Skip to content

Commit

Permalink
Cleanup in bootstrap sequence.
Browse files Browse the repository at this point in the history
- Renamed JCHSU to Runtime
- Call Runtime.bootstrap instead of JCHSU.modernizeBrowser inline,
  this allows to add JS bootstrap code like modernizeBrowser easily.
- Simplified immortal types generation.

Change-Id: Ib864cdf9dd98700717f54e113d06cb9220a410e7
  • Loading branch information
rluble authored and Gerrit Code Review committed Oct 15, 2015
1 parent 8d47a83 commit c305414
Show file tree
Hide file tree
Showing 31 changed files with 248 additions and 142 deletions.
2 changes: 1 addition & 1 deletion dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
Expand Up @@ -146,7 +146,7 @@ public boolean visit(JNode x, Context ctx) {
*/ */
public static final Set<String> IMMORTAL_CODEGEN_TYPES_SET = Sets.newLinkedHashSet(Arrays.asList( public static final Set<String> IMMORTAL_CODEGEN_TYPES_SET = Sets.newLinkedHashSet(Arrays.asList(
"com.google.gwt.lang.CollapsedPropertyHolder", "com.google.gwt.lang.CollapsedPropertyHolder",
"com.google.gwt.lang.JavaClassHierarchySetupUtil", "com.google.gwt.lang.Runtime",
"com.google.gwt.lang.ModuleUtils")); "com.google.gwt.lang.ModuleUtils"));


public static final String JAVASCRIPTOBJECT = "com.google.gwt.core.client.JavaScriptObject"; public static final String JAVASCRIPTOBJECT = "com.google.gwt.core.client.JavaScriptObject";
Expand Down
91 changes: 91 additions & 0 deletions dev/core/src/com/google/gwt/dev/jjs/ast/RuntimeConstants.java
@@ -0,0 +1,91 @@
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.dev.jjs.ast;

/**
* Provides access to known types, methods and fields.
*/
public class RuntimeConstants {
public static final String ASYNC_FRAGMENT_LOADER_BROWSER_LOADER =
"AsyncFragmentLoader.BROWSER_LOADER";
public static final String ASYNC_FRAGMENT_LOADER_ON_LOAD = "AsyncFragmentLoader.onLoad";
public static final String ASYNC_FRAGMENT_LOADER_RUN_ASYNC = "AsyncFragmentLoader.runAsync";

public static final String ARRAY_GET_CLASS_LITERAL_FOR_ARRAY = "Array.getClassLiteralForArray";
public static final String ARRAY_INIT_DIM = "Array.initDim";
public static final String ARRAY_INIT_DIMS = "Array.initDims";
public static final String ARRAY_INIT_VALUES = "Array.initValues";
public static final String ARRAY_SET_CHECK = "Array.setCheck";

public static final String CAST_CHAR_TO_STRING = "Cast.charToString";
public static final String CAST_HAS_JAVA_OBJECT_VIRTUAL_DISPATCH =
"Cast.hasJavaObjectVirtualDispatch";
public static final String CAST_IS_JAVA_ARRAY = "Cast.isJavaArray";
public static final String CAST_THROW_CLASS_CAST_EXCEPTION_UNLESS_NULL
= "Cast.throwClassCastExceptionUnlessNull";

public static final String CLASS_CREATE_FOR_CLASS = "Class.createForClass";
public static final String CLASS_CREATE_FOR_PRIMITIVE = "Class.createForPrimitive";
public static final String CLASS_CREATE_FOR_INTERFACE = "Class.createForInterface";

public static final String COLLAPSED_PROPERTY_HOLDER_GET_PERMUTATION_ID
= "CollapsedPropertyHolder.getPermutationId";

public static final String COVERAGE_UTIL_COVERAGE = "CoverageUtil.coverage";

public static final String ENUM_CREATE_VALUE_OF_MAP = "Enum.createValueOfMap";
public static final String ENUM_ENUM = "Enum.Enum";
public static final String ENUM_NAME = "Enum.name";
public static final String ENUM_ORDINAL = "Enum.ordinal";
public static final String ENUM_TO_STRING = "Enum.toString";

public static final String EXCEPTIONS_CHECK_NOT_NULL = "Exceptions.checkNotNull";
public static final String EXCEPTIONS_MAKE_ASSERTION_ERROR_ = "Exceptions.makeAssertionError";
public static final String EXCEPTIONS_UNWRAP = "Exceptions.unwrap";
public static final String EXCEPTIONS_WRAP = "Exceptions.wrap";

public static final String GWT_IS_SCRIPT = "GWT.isScript";

public static final String LONG_LIB_FROM_DOUBLE = "LongLib.fromDouble";
public static final String LONG_LIB_FROM_INT = "LongLib.fromInt";
public static final String LONG_LIB_TO_DOUBLE = "LongLib.toDouble";
public static final String LONG_LIB_TO_INT = "LongLib.toInt";
public static final String LONG_LIB_TO_STRING = "LongLib.toString";

public static final String OBJECT_CASTABLE_TYPE_MAP = "Object.castableTypeMap";
public static final String OBJECT_CLAZZ = "Object.___clazz";
public static final String OBJECT_GET_CLASS = "Object.getClass";
public static final String OBJECT_TO_STRING = "Object.toString";
public static final String OBJECT_TYPEMARKER = "Object.typeMarker";

public static final String RUN_ASYNC_CALLBACK_ON_SUCCESS = "RunAsyncCallback.onSuccess";
public static final String RUN_ASYNC_CODE_FOR_SPLIT_POINT_NUMBER
= "RunAsyncCode.forSplitPointNumber";

public static final String RUNTIME = "Runtime";
public static final String RUNTIME_BOOTSTRAP = "Runtime.bootstrap";
public static final String RUNTIME_COPY_OBJECT_PROPERTIES = "Runtime.copyObjectProperties";
public static final String RUNTIME_DEFINE_CLASS = "Runtime.defineClass";
public static final String RUNTIME_DEFINE_PROPERTIES = "Runtime.defineProperties";
public static final String RUNTIME_EMPTY_METHOD = "Runtime.emptyMethod";
public static final String RUNTIME_GET_CLASS_PROTOTYPE = "Runtime.getClassPrototype";
public static final String RUNTIME_MAKE_LAMBDA_FUNCTION = "Runtime.makeLambdaFunction";
public static final String RUNTIME_PROVIDE = "Runtime.provide";
public static final String RUNTIME_TYPE_MARKER_FN = "Runtime.typeMarkerFn";
public static final String RUNTIME_UNIQUE_ID = "Runtime.uniqueId";

public static final String UTIL_MAKE_ENUM_NAME = "Util.makeEnumName";
}
9 changes: 5 additions & 4 deletions dev/core/src/com/google/gwt/dev/jjs/impl/ArrayNormalizer.java
Expand Up @@ -34,6 +34,7 @@
import com.google.gwt.dev.jjs.ast.JReferenceType; import com.google.gwt.dev.jjs.ast.JReferenceType;
import com.google.gwt.dev.jjs.ast.JRuntimeTypeReference; import com.google.gwt.dev.jjs.ast.JRuntimeTypeReference;
import com.google.gwt.dev.jjs.ast.JType; import com.google.gwt.dev.jjs.ast.JType;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.dev.jjs.ast.js.JsonArray; import com.google.gwt.dev.jjs.ast.js.JsonArray;


import java.util.Collections; import java.util.Collections;
Expand Down Expand Up @@ -213,10 +214,10 @@ public static void exec(JProgram program) {


private ArrayNormalizer(JProgram program) { private ArrayNormalizer(JProgram program) {
this.program = program; this.program = program;
setCheckMethod = program.getIndexedMethod("Array.setCheck"); setCheckMethod = program.getIndexedMethod(RuntimeConstants.ARRAY_SET_CHECK);
initDim = program.getIndexedMethod("Array.initDim"); initDim = program.getIndexedMethod(RuntimeConstants.ARRAY_INIT_DIM);
initDims = program.getIndexedMethod("Array.initDims"); initDims = program.getIndexedMethod(RuntimeConstants.ARRAY_INIT_DIMS);
initValues = program.getIndexedMethod("Array.initValues"); initValues = program.getIndexedMethod(RuntimeConstants.ARRAY_INIT_VALUES);
} }


private void execImpl() { private void execImpl() {
Expand Down
Expand Up @@ -31,6 +31,7 @@
import com.google.gwt.dev.jjs.ast.JType; import com.google.gwt.dev.jjs.ast.JType;
import com.google.gwt.dev.jjs.ast.JUnaryOperation; import com.google.gwt.dev.jjs.ast.JUnaryOperation;
import com.google.gwt.dev.jjs.ast.JUnaryOperator; import com.google.gwt.dev.jjs.ast.JUnaryOperator;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.dev.jjs.ast.js.JDebuggerStatement; import com.google.gwt.dev.jjs.ast.js.JDebuggerStatement;
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType; import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger; import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
Expand Down Expand Up @@ -63,7 +64,8 @@ public void endVisit(JAssertStatement x, Context ctx) {


then.addStmt(new JDebuggerStatement(x.getSourceInfo())); then.addStmt(new JDebuggerStatement(x.getSourceInfo()));


String methodName = "Exceptions.makeAssertionError" + getAssertMethodSuffix(x.getArg()); String methodName =
RuntimeConstants.EXCEPTIONS_MAKE_ASSERTION_ERROR_ + getAssertMethodSuffix(x.getArg());
JMethod method = program.getIndexedMethod(methodName); JMethod method = program.getIndexedMethod(methodName);
JMethodCall call = new JMethodCall(x.getSourceInfo(), null, method); JMethodCall call = new JMethodCall(x.getSourceInfo(), null, method);
if (x.getArg() != null) { if (x.getArg() != null) {
Expand Down
Expand Up @@ -39,6 +39,7 @@
import com.google.gwt.dev.jjs.ast.JThrowStatement; import com.google.gwt.dev.jjs.ast.JThrowStatement;
import com.google.gwt.dev.jjs.ast.JTryStatement; import com.google.gwt.dev.jjs.ast.JTryStatement;
import com.google.gwt.dev.jjs.ast.JType; import com.google.gwt.dev.jjs.ast.JType;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;


import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
Expand All @@ -53,7 +54,7 @@ public class CatchBlockNormalizer {
* Collapses all multi-catch blocks into a single catch block. * Collapses all multi-catch blocks into a single catch block.
*/ */
private class CollapseCatchBlocks extends JModVisitor { private class CollapseCatchBlocks extends JModVisitor {
JMethod wrapMethod = program.getIndexedMethod("Exceptions.wrap"); JMethod wrapMethod = program.getIndexedMethod(RuntimeConstants.EXCEPTIONS_WRAP);


@Override @Override
public void endVisit(JMethodBody x, Context ctx) { public void endVisit(JMethodBody x, Context ctx) {
Expand Down Expand Up @@ -144,7 +145,7 @@ public boolean visit(JMethodBody x, Context ctx) {
private class UnwrapJavaScriptExceptionVisitor extends JModVisitor { private class UnwrapJavaScriptExceptionVisitor extends JModVisitor {
JDeclaredType jseType = JDeclaredType jseType =
program.getFromTypeMap("com.google.gwt.core.client.JavaScriptException"); program.getFromTypeMap("com.google.gwt.core.client.JavaScriptException");
JMethod unwrapMethod = program.getIndexedMethod("Exceptions.unwrap"); JMethod unwrapMethod = program.getIndexedMethod(RuntimeConstants.EXCEPTIONS_UNWRAP);


@Override @Override
public void endVisit(JThrowStatement x, Context ctx) { public void endVisit(JThrowStatement x, Context ctx) {
Expand Down
Expand Up @@ -50,6 +50,7 @@
import com.google.gwt.dev.jjs.ast.JVariable; import com.google.gwt.dev.jjs.ast.JVariable;
import com.google.gwt.dev.jjs.ast.JVariableRef; import com.google.gwt.dev.jjs.ast.JVariableRef;
import com.google.gwt.dev.jjs.ast.JVisitor; import com.google.gwt.dev.jjs.ast.JVisitor;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.dev.jjs.ast.js.JsniFieldRef; import com.google.gwt.dev.jjs.ast.js.JsniFieldRef;
import com.google.gwt.dev.jjs.ast.js.JsniMethodBody; import com.google.gwt.dev.jjs.ast.js.JsniMethodBody;
import com.google.gwt.dev.jjs.ast.js.JsniMethodRef; import com.google.gwt.dev.jjs.ast.js.JsniMethodRef;
Expand Down Expand Up @@ -795,7 +796,7 @@ private void rescueByConcat(JType type) {
* TODO: can we narrow the focus by walking up the type hierarchy or * TODO: can we narrow the focus by walking up the type hierarchy or
* doing explicit toString calls? * doing explicit toString calls?
*/ */
JMethod toStringMethod = program.getIndexedMethod("Object.toString"); JMethod toStringMethod = program.getIndexedMethod(RuntimeConstants.OBJECT_TO_STRING);
rescue(toStringMethod); rescue(toStringMethod);
} else if (type == charType) { } else if (type == charType) {
/* /*
Expand Down Expand Up @@ -916,6 +917,8 @@ public ControlFlowAnalyzer(ControlFlowAnalyzer cfa) {
program = cfa.program; program = cfa.program;
asyncFragmentOnLoad = cfa.asyncFragmentOnLoad; asyncFragmentOnLoad = cfa.asyncFragmentOnLoad;
runAsyncOnSuccess = cfa.runAsyncOnSuccess; runAsyncOnSuccess = cfa.runAsyncOnSuccess;
getClassField = cfa.getClassField;
getClassMethod = cfa.getClassMethod;
fieldsWritten = Sets.newHashSet(cfa.fieldsWritten); fieldsWritten = Sets.newHashSet(cfa.fieldsWritten);
instantiatedTypes = Sets.newHashSet(cfa.instantiatedTypes); instantiatedTypes = Sets.newHashSet(cfa.instantiatedTypes);
liveFieldsAndMethods = Sets.newHashSet(cfa.liveFieldsAndMethods); liveFieldsAndMethods = Sets.newHashSet(cfa.liveFieldsAndMethods);
Expand All @@ -928,17 +931,15 @@ public ControlFlowAnalyzer(ControlFlowAnalyzer cfa) {
argsToRescueIfParameterRead = argsToRescueIfParameterRead =
ArrayListMultimap.create(cfa.argsToRescueIfParameterRead); ArrayListMultimap.create(cfa.argsToRescueIfParameterRead);
} }
getClassField = program.getIndexedField("Object.___clazz");
getClassMethod = program.getIndexedMethod("Object.getClass");
rescuer = new RescueVisitor(); rescuer = new RescueVisitor();
} }


public ControlFlowAnalyzer(JProgram program) { public ControlFlowAnalyzer(JProgram program) {
this.program = program; this.program = program;
asyncFragmentOnLoad = program.getIndexedMethod("AsyncFragmentLoader.onLoad"); asyncFragmentOnLoad = program.getIndexedMethod(RuntimeConstants.ASYNC_FRAGMENT_LOADER_ON_LOAD);
runAsyncOnSuccess = program.getIndexedMethod("RunAsyncCallback.onSuccess"); runAsyncOnSuccess = program.getIndexedMethod(RuntimeConstants.RUN_ASYNC_CALLBACK_ON_SUCCESS);
getClassField = program.getIndexedField("Object.___clazz"); getClassField = program.getIndexedField(RuntimeConstants.OBJECT_CLAZZ);
getClassMethod = program.getIndexedMethod("Object.getClass"); getClassMethod = program.getIndexedMethod(RuntimeConstants.OBJECT_GET_CLASS);
rescuer = new RescueVisitor(); rescuer = new RescueVisitor();
} }


Expand Down
Expand Up @@ -65,6 +65,7 @@
import com.google.gwt.dev.jjs.ast.JVariableRef; import com.google.gwt.dev.jjs.ast.JVariableRef;
import com.google.gwt.dev.jjs.ast.JVisitor; import com.google.gwt.dev.jjs.ast.JVisitor;
import com.google.gwt.dev.jjs.ast.JWhileStatement; import com.google.gwt.dev.jjs.ast.JWhileStatement;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.dev.jjs.ast.js.JMultiExpression; import com.google.gwt.dev.jjs.ast.js.JMultiExpression;
import com.google.gwt.dev.util.Ieee754_64_Arithmetic; import com.google.gwt.dev.util.Ieee754_64_Arithmetic;
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType; import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
Expand Down Expand Up @@ -93,6 +94,7 @@
* other passes will feed into this, however. * other passes will feed into this, however.
*/ */
public class DeadCodeElimination { public class DeadCodeElimination {

/** /**
* Eliminates dead or unreachable code when possible, and makes local * Eliminates dead or unreachable code when possible, and makes local
* simplifications like changing "<code>x || true</code>" to "<code>x</code>". * simplifications like changing "<code>x || true</code>" to "<code>x</code>".
Expand Down Expand Up @@ -139,9 +141,11 @@ public DeadCodeVisitor(OptimizerContext optimizerCtx) {


private final Set<JBlock> switchBlocks = Sets.newHashSet(); private final Set<JBlock> switchBlocks = Sets.newHashSet();


private final JMethod isScriptMethod = program.getIndexedMethod("GWT.isScript"); private final JMethod isScriptMethod = program.getIndexedMethod(RuntimeConstants.GWT_IS_SCRIPT);
private final JMethod enumOrdinalMethod = program.getIndexedMethod("Enum.ordinal"); private final JMethod enumOrdinalMethod =
private final JField enumOrdinalField = program.getIndexedField("Enum.ordinal"); program.getIndexedMethod(RuntimeConstants.ENUM_ORDINAL);
private final JField enumOrdinalField =
program.getIndexedField(RuntimeConstants.ENUM_ORDINAL);


/** /**
* Short circuit binary operations. * Short circuit binary operations.
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.google.gwt.dev.jjs.ast.JConstructor; import com.google.gwt.dev.jjs.ast.JConstructor;
import com.google.gwt.dev.jjs.ast.JDeclaredType; import com.google.gwt.dev.jjs.ast.JDeclaredType;
import com.google.gwt.dev.jjs.ast.JMember; import com.google.gwt.dev.jjs.ast.JMember;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.dev.js.ast.JsExpression; import com.google.gwt.dev.js.ast.JsExpression;
import com.google.gwt.dev.js.ast.JsFunction; import com.google.gwt.dev.js.ast.JsFunction;
import com.google.gwt.dev.js.ast.JsInvocation; import com.google.gwt.dev.js.ast.JsInvocation;
Expand Down Expand Up @@ -51,7 +52,7 @@ public DefaultJsInteropExportsGenerator(List<JsStatement> exportStmts, JsName gl
Map<String, JsFunction> indexedFunctions) { Map<String, JsFunction> indexedFunctions) {
this.exportStmts = exportStmts; this.exportStmts = exportStmts;
this.globalTemp = globalTemp; this.globalTemp = globalTemp;
this.provideFunc = indexedFunctions.get("JavaClassHierarchySetupUtil.provide").getName(); this.provideFunc = indexedFunctions.get(RuntimeConstants.RUNTIME_PROVIDE).getName();
} }


@Override @Override
Expand Down
5 changes: 3 additions & 2 deletions dev/core/src/com/google/gwt/dev/jjs/impl/Devirtualizer.java
Expand Up @@ -36,6 +36,7 @@
import com.google.gwt.dev.jjs.ast.JType; import com.google.gwt.dev.jjs.ast.JType;
import com.google.gwt.dev.jjs.ast.JTypeOracle; import com.google.gwt.dev.jjs.ast.JTypeOracle;
import com.google.gwt.dev.jjs.ast.JVariableRef; import com.google.gwt.dev.jjs.ast.JVariableRef;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.dev.jjs.impl.MakeCallsStatic.CreateStaticImplsVisitor; import com.google.gwt.dev.jjs.impl.MakeCallsStatic.CreateStaticImplsVisitor;
import com.google.gwt.dev.jjs.impl.MakeCallsStatic.StaticCallConverter; import com.google.gwt.dev.jjs.impl.MakeCallsStatic.StaticCallConverter;
import com.google.gwt.thirdparty.guava.common.collect.Lists; import com.google.gwt.thirdparty.guava.common.collect.Lists;
Expand Down Expand Up @@ -289,8 +290,8 @@ private Devirtualizer(JProgram program) {
this.program = program; this.program = program;


this.hasJavaObjectVirtualDispatch = this.hasJavaObjectVirtualDispatch =
program.getIndexedMethod("Cast.hasJavaObjectVirtualDispatch"); program.getIndexedMethod(RuntimeConstants.CAST_HAS_JAVA_OBJECT_VIRTUAL_DISPATCH);
this.isJavaArray = program.getIndexedMethod("Cast.isJavaArray"); this.isJavaArray = program.getIndexedMethod(RuntimeConstants.CAST_IS_JAVA_ARRAY);
// TODO: consider turning on null checks for "this"? // TODO: consider turning on null checks for "this"?
// However, for JSO's there is existing code that relies on nulls being okay. // However, for JSO's there is existing code that relies on nulls being okay.
this.converter = new StaticCallConverter(program, false); this.converter = new StaticCallConverter(program, false);
Expand Down
13 changes: 7 additions & 6 deletions dev/core/src/com/google/gwt/dev/jjs/impl/EnumNameObfuscator.java
Expand Up @@ -31,6 +31,7 @@
import com.google.gwt.dev.jjs.ast.JParameter; import com.google.gwt.dev.jjs.ast.JParameter;
import com.google.gwt.dev.jjs.ast.JProgram; import com.google.gwt.dev.jjs.ast.JProgram;
import com.google.gwt.dev.jjs.ast.JVisitor; import com.google.gwt.dev.jjs.ast.JVisitor;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.thirdparty.guava.common.collect.Lists; import com.google.gwt.thirdparty.guava.common.collect.Lists;


import java.util.Collection; import java.util.Collection;
Expand Down Expand Up @@ -61,11 +62,11 @@ private EnumNameCallChecker(JProgram jprogram, TreeLogger logger,
List<String> blacklistedEnums) { List<String> blacklistedEnums) {
this.logger = logger; this.logger = logger;
this.blacklistedEnums = blacklistedEnums; this.blacklistedEnums = blacklistedEnums;
this.enumNameMethod = jprogram.getIndexedMethod("Enum.name"); this.enumNameMethod = jprogram.getIndexedMethod(RuntimeConstants.ENUM_NAME);
this.enumToStringMethod = jprogram.getIndexedMethod("Enum.toString"); this.enumToStringMethod = jprogram.getIndexedMethod(RuntimeConstants.ENUM_TO_STRING);
this.classType = jprogram.getIndexedType("Class"); this.classType = jprogram.getFromTypeMap("java.lang.Class");
this.enumType = jprogram.getIndexedType("Enum"); this.enumType = jprogram.getFromTypeMap("java.lang.Enum");
this.stringType = jprogram.getIndexedType("String"); this.stringType = jprogram.getFromTypeMap("java.lang.String");


/* /*
* Find the correct version of enumValueOfMethod. * Find the correct version of enumValueOfMethod.
Expand Down Expand Up @@ -159,7 +160,7 @@ private EnumNameReplacer(JProgram jprogram, TreeLogger logger,
this.jprogram = jprogram; this.jprogram = jprogram;
this.blacklistedEnums = blacklistedEnums; this.blacklistedEnums = blacklistedEnums;
this.closureMode = closureMode; this.closureMode = closureMode;
this.makeEnumName = jprogram.getIndexedMethod("Util.makeEnumName"); this.makeEnumName = jprogram.getIndexedMethod(RuntimeConstants.UTIL_MAKE_ENUM_NAME);
} }


private void exec() { private void exec() {
Expand Down
11 changes: 7 additions & 4 deletions dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
Expand Up @@ -37,6 +37,7 @@
import com.google.gwt.dev.jjs.ast.JPrimitiveType; import com.google.gwt.dev.jjs.ast.JPrimitiveType;
import com.google.gwt.dev.jjs.ast.JProgram; import com.google.gwt.dev.jjs.ast.JProgram;
import com.google.gwt.dev.jjs.ast.JType; import com.google.gwt.dev.jjs.ast.JType;
import com.google.gwt.dev.jjs.ast.RuntimeConstants;
import com.google.gwt.dev.jjs.ast.js.JsniClassLiteral; import com.google.gwt.dev.jjs.ast.js.JsniClassLiteral;
import com.google.gwt.dev.jjs.ast.js.JsniFieldRef; import com.google.gwt.dev.jjs.ast.js.JsniFieldRef;
import com.google.gwt.dev.jjs.ast.js.JsniMethodRef; import com.google.gwt.dev.jjs.ast.js.JsniMethodRef;
Expand Down Expand Up @@ -96,6 +97,7 @@
* {@code ordinal} with the appropriate ordinal value. * {@code ordinal} with the appropriate ordinal value.
*/ */
public class EnumOrdinalizer { public class EnumOrdinalizer {

/** /**
* A simple Tracker class for compiling lists of enum classes processed by * A simple Tracker class for compiling lists of enum classes processed by
* this optimizer. If enabled, the results can be logged as debug output, and * this optimizer. If enabled, the results can be logged as debug output, and
Expand Down Expand Up @@ -749,10 +751,11 @@ public EnumOrdinalizer(JProgram program) {
this.program = program; this.program = program;
this.classLiteralHolderType = program.getTypeClassLiteralHolder(); this.classLiteralHolderType = program.getTypeClassLiteralHolder();
this.javaScriptObjectType = program.getJavaScriptObject(); this.javaScriptObjectType = program.getJavaScriptObject();
this.enumOrdinalField = program.getIndexedField("Enum.ordinal"); this.enumOrdinalField = program.getIndexedField(RuntimeConstants.ENUM_ORDINAL);
this.enumCreateValueOfMapMethod = program.getIndexedMethod("Enum.createValueOfMap"); this.enumCreateValueOfMapMethod =
this.enumOrdinalMethod = program.getIndexedMethod("Enum.ordinal"); program.getIndexedMethod(RuntimeConstants.ENUM_CREATE_VALUE_OF_MAP);
this.enumSuperConstructor = program.getIndexedMethod("Enum.Enum"); this.enumOrdinalMethod = program.getIndexedMethod(RuntimeConstants.ENUM_ORDINAL);
this.enumSuperConstructor = program.getIndexedMethod(RuntimeConstants.ENUM_ENUM);
} }


private OptimizerStats execImpl(OptimizerContext optimizerCtx) { private OptimizerStats execImpl(OptimizerContext optimizerCtx) {
Expand Down

0 comments on commit c305414

Please sign in to comment.