Index: pkg/compiler/lib/src/ssa/builder.dart |
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart |
index e73402f22848ee5a843f09afeb1d28f72ccb9e09..227ece82c0102851b22be06c7641670b8b02ee6b 100644 |
--- a/pkg/compiler/lib/src/ssa/builder.dart |
+++ b/pkg/compiler/lib/src/ssa/builder.dart |
@@ -24,7 +24,7 @@ import '../elements/entities.dart'; |
import '../elements/modelx.dart' show ConstructorBodyElementX; |
import '../io/source_information.dart'; |
import '../js/js.dart' as js; |
-import '../js_backend/backend_helpers.dart' show BackendHelpers; |
+import '../js_backend/backend.dart' show JavaScriptBackend; |
import '../js_backend/js_backend.dart'; |
import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter; |
import '../native/native.dart' as native; |
@@ -223,8 +223,6 @@ class SsaBuilder extends ast.Visitor |
typeBuilder = new TypeBuilder(this); |
} |
- BackendHelpers get helpers => backend.helpers; |
- |
RuntimeTypesEncoder get rtiEncoder => backend.rtiEncoder; |
DiagnosticReporter get reporter => compiler.reporter; |
@@ -722,7 +720,8 @@ class SsaBuilder extends ast.Visitor |
parameters.values.where((p) => p.instructionType.isEmpty); |
if (emptyParameters.length > 0) { |
addComment('${emptyParameters} inferred as [empty]'); |
- pushInvokeStatic(function.body, helpers.assertUnreachableMethod, []); |
+ pushInvokeStatic( |
+ function.body, commonElements.assertUnreachableMethod, []); |
pop(); |
return closeFunction(); |
} |
@@ -1448,24 +1447,24 @@ class SsaBuilder extends ast.Visitor |
insertTraceCall(Element element) { |
if (JavaScriptBackend.TRACE_METHOD == 'console') { |
- if (element == backend.helpers.traceHelper) return; |
+ if (element == commonElements.traceHelper) return; |
n(e) => e == null ? '' : e.name; |
String name = "${n(element.library)}:${n(element.enclosingClass)}." |
"${n(element)}"; |
HConstant nameConstant = addConstantString(name); |
- add(new HInvokeStatic(backend.helpers.traceHelper, |
+ add(new HInvokeStatic(commonElements.traceHelper, |
<HInstruction>[nameConstant], commonMasks.dynamicType)); |
} |
} |
insertCoverageCall(Element element) { |
if (JavaScriptBackend.TRACE_METHOD == 'post') { |
- if (element == backend.helpers.traceHelper) return; |
+ if (element == commonElements.traceHelper) return; |
// TODO(sigmund): create a better uuid for elements. |
HConstant idConstant = |
graph.addConstantInt(element.hashCode, closedWorld); |
HConstant nameConstant = addConstantString(element.name); |
- add(new HInvokeStatic(backend.helpers.traceHelper, |
+ add(new HInvokeStatic(commonElements.traceHelper, |
<HInstruction>[idConstant, nameConstant], commonMasks.dynamicType)); |
} |
} |
@@ -1478,7 +1477,7 @@ class SsaBuilder extends ast.Visitor |
localsHandler.substInContext(supertype), sourceElement); |
HInstruction messageInstruction = graph.addConstantString( |
new ast.DartString.literal(message), closedWorld); |
- MethodElement element = helpers.assertIsSubtype; |
+ MethodElement element = commonElements.assertIsSubtype; |
var inputs = <HInstruction>[ |
subtypeInstruction, |
supertypeInstruction, |
@@ -1543,7 +1542,7 @@ class SsaBuilder extends ast.Visitor |
// assertHelper(condition); |
// |
visit(node.condition); |
- pushInvokeStatic(node, helpers.assertHelper, [pop()]); |
+ pushInvokeStatic(node, commonElements.assertHelper, [pop()]); |
pop(); |
return; |
} |
@@ -1553,12 +1552,12 @@ class SsaBuilder extends ast.Visitor |
// |
void buildCondition() { |
visit(node.condition); |
- pushInvokeStatic(node, helpers.assertTest, [pop()]); |
+ pushInvokeStatic(node, commonElements.assertTest, [pop()]); |
} |
void fail() { |
visit(node.message); |
- pushInvokeStatic(node, helpers.assertThrow, [pop()]); |
+ pushInvokeStatic(node, commonElements.assertThrow, [pop()]); |
pop(); |
} |
@@ -2041,7 +2040,7 @@ class SsaBuilder extends ast.Visitor |
HInstruction loadIdConstant = addConstantString(loadId); |
String uri = prefixElement.deferredImport.uri.toString(); |
HInstruction uriConstant = addConstantString(uri); |
- MethodElement helper = helpers.checkDeferredIsLoaded; |
+ MethodElement helper = commonElements.checkDeferredIsLoaded; |
pushInvokeStatic(location, helper, [loadIdConstant, uriConstant]); |
pop(); |
} |
@@ -2407,21 +2406,21 @@ class SsaBuilder extends ast.Visitor |
expression, |
representation, |
]; |
- pushInvokeStatic(node, helpers.functionTypeTest, inputs, |
+ pushInvokeStatic(node, commonElements.functionTypeTest, inputs, |
typeMask: commonMasks.boolType); |
HInstruction call = pop(); |
return new HIs.compound(type, expression, call, commonMasks.boolType); |
} else if (type.isTypeVariable) { |
HInstruction runtimeType = |
typeBuilder.addTypeVariableReference(type, sourceElement); |
- MethodElement helper = helpers.checkSubtypeOfRuntimeType; |
+ MethodElement helper = commonElements.checkSubtypeOfRuntimeType; |
List<HInstruction> inputs = <HInstruction>[expression, runtimeType]; |
pushInvokeStatic(null, helper, inputs, typeMask: commonMasks.boolType); |
HInstruction call = pop(); |
return new HIs.variable(type, expression, call, commonMasks.boolType); |
} else if (RuntimeTypesSubstitutions.hasTypeArguments(type)) { |
ClassElement element = type.element; |
- MethodElement helper = helpers.checkSubtype; |
+ MethodElement helper = commonElements.checkSubtype; |
HInstruction representations = |
typeBuilder.buildTypeArgumentRepresentations(type, sourceElement); |
add(representations); |
@@ -2685,7 +2684,7 @@ class SsaBuilder extends ast.Visitor |
// Call a helper method from the isolate library. The isolate |
// library uses its own isolate structure, that encapsulates |
// Leg's isolate. |
- MethodElement element = helpers.currentIsolate; |
+ MethodElement element = commonElements.currentIsolate; |
if (element == null) { |
reporter.internalError(node, 'Isolate library and compiler mismatch.'); |
} |
@@ -2753,7 +2752,7 @@ class SsaBuilder extends ast.Visitor |
Element element = elements[argument]; |
if (element == null || |
element is! EnumConstantElement || |
- element.enclosingClass != helpers.jsGetNameEnum) { |
+ element.enclosingClass != commonElements.jsGetNameEnum) { |
reporter.reportErrorMessage(argument, MessageKind.GENERIC, |
{'text': 'Error: Expected a JsGetName enum value.'}); |
} |
@@ -2774,7 +2773,7 @@ class SsaBuilder extends ast.Visitor |
Element builtinElement = elements[arguments[1]]; |
if (builtinElement == null || |
(builtinElement is! EnumConstantElement) || |
- builtinElement.enclosingClass != helpers.jsBuiltinEnum) { |
+ builtinElement.enclosingClass != commonElements.jsBuiltinEnum) { |
reporter.reportErrorMessage(argument, MessageKind.GENERIC, |
{'text': 'Error: Expected a JsBuiltin enum value.'}); |
} |
@@ -2879,7 +2878,7 @@ class SsaBuilder extends ast.Visitor |
<HInstruction>[pop()], commonMasks.dynamicType)); |
} else { |
// Call a helper method from the isolate library. |
- MethodElement element = helpers.callInIsolate; |
+ MethodElement element = commonElements.callInIsolate; |
if (element == null) { |
reporter.internalError(node, 'Isolate library and compiler mismatch.'); |
} |
@@ -2955,7 +2954,7 @@ class SsaBuilder extends ast.Visitor |
void handleForeignSend(ast.Send node, FunctionElement element) { |
String name = element.name; |
- if (name == BackendHelpers.JS) { |
+ if (name == JavaScriptBackend.JS) { |
handleForeignJs(node); |
} else if (name == 'JS_CURRENT_ISOLATE_CONTEXT') { |
handleForeignJsCurrentIsolateContext(node); |
@@ -2971,15 +2970,15 @@ class SsaBuilder extends ast.Visitor |
handleForeignJsGetStaticState(node); |
} else if (name == 'JS_GET_NAME') { |
handleForeignJsGetName(node); |
- } else if (name == BackendHelpers.JS_EMBEDDED_GLOBAL) { |
+ } else if (name == JavaScriptBackend.JS_EMBEDDED_GLOBAL) { |
handleForeignJsEmbeddedGlobal(node); |
- } else if (name == BackendHelpers.JS_BUILTIN) { |
+ } else if (name == JavaScriptBackend.JS_BUILTIN) { |
handleForeignJsBuiltin(node); |
} else if (name == 'JS_GET_FLAG') { |
handleForeignJsGetFlag(node); |
} else if (name == 'JS_EFFECT') { |
stack.add(graph.addConstantNull(closedWorld)); |
- } else if (name == BackendHelpers.JS_INTERCEPTOR_CONSTANT) { |
+ } else if (name == JavaScriptBackend.JS_INTERCEPTOR_CONSTANT) { |
handleJsInterceptorConstant(node); |
} else if (name == 'JS_STRING_CONCAT') { |
handleJsStringConcat(node); |
@@ -2992,7 +2991,7 @@ class SsaBuilder extends ast.Visitor |
SourceInformation sourceInformation) { |
// Until now we only handle these as getters. |
invariant(node, deferredLoader.isDeferredLoaderGetter); |
- FunctionEntity loadFunction = helpers.loadLibraryWrapper; |
+ FunctionEntity loadFunction = commonElements.loadLibraryWrapper; |
PrefixElement prefixElement = deferredLoader.enclosingElement; |
String loadId = |
compiler.deferredLoadTask.getImportDeferName(node, prefixElement); |
@@ -3000,7 +2999,8 @@ class SsaBuilder extends ast.Visitor |
graph.addConstantString(new ast.DartString.literal(loadId), closedWorld) |
]; |
push(new HInvokeStatic(loadFunction, inputs, commonMasks.nonNullType, |
- targetCanThrow: false)..sourceInformation = sourceInformation); |
+ targetCanThrow: false) |
+ ..sourceInformation = sourceInformation); |
} |
generateSuperNoSuchMethodSend( |
@@ -3030,7 +3030,8 @@ class SsaBuilder extends ast.Visitor |
js.Name internalName = backend.namer.invocationName(selector); |
- MethodElement createInvocationMirror = helpers.createInvocationMirror; |
+ MethodElement createInvocationMirror = |
+ commonElements.createInvocationMirror; |
var argumentsInstruction = buildLiteralList(arguments); |
add(argumentsInstruction); |
@@ -3259,7 +3260,7 @@ class SsaBuilder extends ast.Visitor |
HInstruction callSetRuntimeTypeInfo( |
HInstruction typeInfo, HInstruction newObject) { |
// Set the runtime type information on the object. |
- MethodElement typeInfoSetterElement = helpers.setRuntimeTypeInfo; |
+ MethodElement typeInfoSetterElement = commonElements.setRuntimeTypeInfo; |
pushInvokeStatic( |
null, typeInfoSetterElement, <HInstruction>[newObject, typeInfo], |
typeMask: commonMasks.dynamicType, |
@@ -3333,14 +3334,15 @@ class SsaBuilder extends ast.Visitor |
final bool isSymbolConstructor = |
closedWorld.commonElements.isSymbolConstructor(constructorDeclaration); |
- final bool isJSArrayTypedConstructor = |
- constructorDeclaration == helpers.jsArrayTypedConstructor; |
+ final bool isJSArrayTypedConstructor = constructorDeclaration == |
+ closedWorld.commonElements.jsArrayTypedConstructor; |
if (isSymbolConstructor) { |
- constructor = helpers.symbolValidatedConstructor; |
+ constructor = commonElements.symbolValidatedConstructor; |
assert(invariant(send, constructor != null, |
message: 'Constructor Symbol.validated is missing')); |
- callStructure = helpers.symbolValidatedConstructorSelector.callStructure; |
+ callStructure = |
+ commonElements.symbolValidatedConstructorSelector.callStructure; |
assert(invariant(send, callStructure != null, |
message: 'Constructor Symbol.validated is missing')); |
} |
@@ -3767,9 +3769,9 @@ class SsaBuilder extends ast.Visitor |
ResolutionDartType type = localsHandler.substInContext(typeVariable); |
HInstruction value = typeBuilder.analyzeTypeArgument(type, sourceElement, |
sourceInformation: sourceInformationBuilder.buildGet(node)); |
- pushInvokeStatic(node, helpers.runtimeTypeToString, [value], |
+ pushInvokeStatic(node, commonElements.runtimeTypeToString, [value], |
typeMask: commonMasks.stringType); |
- pushInvokeStatic(node, helpers.createRuntimeType, [pop()]); |
+ pushInvokeStatic(node, commonElements.createRuntimeType, [pop()]); |
} |
} |
@@ -3810,17 +3812,17 @@ class SsaBuilder extends ast.Visitor |
} |
void generateRuntimeError(ast.Node node, String message) { |
- MethodElement helper = helpers.throwRuntimeError; |
+ MethodElement helper = commonElements.throwRuntimeError; |
generateError(node, message, helper); |
} |
void generateTypeError(ast.Node node, String message) { |
- MethodElement helper = helpers.throwTypeError; |
+ MethodElement helper = commonElements.throwTypeError; |
generateError(node, message, helper); |
} |
void generateAbstractClassInstantiationError(ast.Node node, String message) { |
- MethodElement helper = helpers.throwAbstractClassInstantiationError; |
+ MethodElement helper = commonElements.throwAbstractClassInstantiationError; |
generateError(node, message, helper); |
} |
@@ -3829,7 +3831,7 @@ class SsaBuilder extends ast.Visitor |
List<HInstruction> argumentValues, |
List<String> existingArguments, |
SourceInformation sourceInformation}) { |
- MethodElement helper = helpers.throwNoSuchMethod; |
+ MethodElement helper = commonElements.throwNoSuchMethod; |
ConstantValue receiverConstant = |
constantSystem.createString(new ast.DartString.empty()); |
HInstruction receiver = graph.addConstant(receiverConstant, closedWorld); |
@@ -3944,10 +3946,10 @@ class SsaBuilder extends ast.Visitor |
bool isLength = selector.isGetter && selector.name == "length"; |
if (isLength || selector.isIndex) { |
return closedWorld.isSubtypeOf( |
- element.enclosingClass, helpers.jsIndexableClass); |
+ element.enclosingClass, commonElements.jsIndexableClass); |
} else if (selector.isIndexSet) { |
return closedWorld.isSubtypeOf( |
- element.enclosingClass, helpers.jsMutableIndexableClass); |
+ element.enclosingClass, commonElements.jsMutableIndexableClass); |
} else { |
return false; |
} |
@@ -3962,9 +3964,9 @@ class SsaBuilder extends ast.Visitor |
if (selector.isSetter) return true; |
if (selector.isIndex) return true; |
if (selector.isIndexSet) return true; |
- if (element == helpers.jsArrayAdd || |
- element == helpers.jsArrayRemoveLast || |
- element == helpers.jsStringSplit) { |
+ if (element == commonElements.jsArrayAdd || |
+ element == commonElements.jsArrayRemoveLast || |
+ element == commonElements.jsStringSplit) { |
return true; |
} |
return false; |
@@ -4085,7 +4087,7 @@ class SsaBuilder extends ast.Visitor |
if (!compiler.options.trustJSInteropTypeAnnotations || |
type.isObject || |
type.isDynamic) { |
- ClassElement cls = backend.helpers.jsJavaScriptObjectClass; |
+ ClassElement cls = commonElements.jsJavaScriptObjectClass; |
nativeBehavior.typesInstantiated.add(cls.thisType); |
} |
@@ -4102,7 +4104,8 @@ class SsaBuilder extends ast.Visitor |
nativeBehavior.codeTemplate = codeTemplate; |
return new HForeignCode(codeTemplate, commonMasks.dynamicType, inputs, |
- nativeBehavior: nativeBehavior)..sourceInformation = sourceInformation; |
+ nativeBehavior: nativeBehavior) |
+ ..sourceInformation = sourceInformation; |
} |
void pushInvokeStatic( |
@@ -5330,7 +5333,7 @@ class SsaBuilder extends ast.Visitor |
visit(node.expression); |
HInstruction expression = pop(); |
- ConstructorElement constructor = helpers.streamIteratorConstructor; |
+ ConstructorElement constructor = commonElements.streamIteratorConstructor; |
pushInvokeStatic( |
node, constructor, [expression, graph.addConstantNull(closedWorld)]); |
streamIterator = pop(); |
@@ -5398,9 +5401,9 @@ class SsaBuilder extends ast.Visitor |
TypeMask mask = elementInferenceResults.typeOfIterator(node); |
if (mask != null && |
- mask.satisfies(helpers.jsIndexableClass, closedWorld) && |
+ mask.satisfies(commonElements.jsIndexableClass, closedWorld) && |
// String is indexable but not iterable. |
- !mask.satisfies(helpers.jsStringClass, closedWorld)) { |
+ !mask.satisfies(commonElements.jsStringClass, closedWorld)) { |
return buildSyncForInIndexable(node, mask); |
} |
buildSyncForInIterator(node); |
@@ -5498,8 +5501,8 @@ class SsaBuilder extends ast.Visitor |
// |
HInstruction length = buildGetLength(); |
push(new HIdentity(length, originalLength, null, boolType)); |
- pushInvokeStatic( |
- node, helpers.checkConcurrentModificationError, [pop(), array]); |
+ pushInvokeStatic(node, commonElements.checkConcurrentModificationError, |
+ [pop(), array]); |
pop(); |
} |
@@ -5627,9 +5630,9 @@ class SsaBuilder extends ast.Visitor |
List<HInstruction> inputs = <HInstruction>[]; |
if (listInputs.isEmpty) { |
- listConstructor = helpers.mapLiteralConstructorEmpty; |
+ listConstructor = commonElements.mapLiteralConstructorEmpty; |
} else { |
- listConstructor = helpers.mapLiteralConstructor; |
+ listConstructor = commonElements.mapLiteralConstructor; |
HLiteralList keyValuePairs = buildLiteralList(listInputs); |
add(keyValuePairs); |
inputs.add(keyValuePairs); |
@@ -5659,9 +5662,9 @@ class SsaBuilder extends ast.Visitor |
// in the output. |
if (typeInputs.every((HInstruction input) => input.isNull())) { |
if (listInputs.isEmpty) { |
- createFunction = helpers.mapLiteralUntypedEmptyMaker; |
+ createFunction = commonElements.mapLiteralUntypedEmptyMaker; |
} else { |
- createFunction = helpers.mapLiteralUntypedMaker; |
+ createFunction = commonElements.mapLiteralUntypedMaker; |
} |
} else { |
inputs.addAll(typeInputs); |
@@ -5677,8 +5680,8 @@ class SsaBuilder extends ast.Visitor |
// The instruction type will always be a subtype of the mapLiteralClass, but |
// type inference might discover a more specific type, or find nothing (in |
// dart2js unit tests). |
- TypeMask mapType = |
- new TypeMask.nonNullSubtype(helpers.mapLiteralClass, closedWorld); |
+ TypeMask mapType = new TypeMask.nonNullSubtype( |
+ commonElements.mapLiteralClass, closedWorld); |
TypeMask returnTypeMask = TypeMaskFactory.inferredReturnTypeForElement( |
createFunction, globalInferenceResults); |
TypeMask instructionType = |
@@ -5985,7 +5988,7 @@ class SsaBuilder extends ast.Visitor |
buildSwitchCase(switchCase); |
if (!isAborted()) { |
if (caseIterator.hasNext && isReachable) { |
- pushInvokeStatic(switchCase, helpers.fallThroughError, []); |
+ pushInvokeStatic(switchCase, commonElements.fallThroughError, []); |
HInstruction error = pop(); |
closeAndGotoExit(new HThrow(error, error.sourceInformation)); |
} else if (!isDefaultCase(switchCase)) { |
@@ -6205,7 +6208,7 @@ class SsaBuilder extends ast.Visitor |
HInstruction oldRethrowableException = rethrowableException; |
rethrowableException = exception; |
- pushInvokeStatic(node, helpers.exceptionUnwrapper, [exception]); |
+ pushInvokeStatic(node, commonElements.exceptionUnwrapper, [exception]); |
HInvokeStatic unwrappedException = pop(); |
tryInstruction.exception = exception; |
Link<ast.Node> link = node.catchBlocks.nodes; |
@@ -6250,7 +6253,8 @@ class SsaBuilder extends ast.Visitor |
} |
ast.Node trace = catchBlock.trace; |
if (trace != null) { |
- pushInvokeStatic(trace, helpers.traceFromException, [exception]); |
+ pushInvokeStatic( |
+ trace, commonElements.traceFromException, [exception]); |
HInstruction traceInstruction = pop(); |
LocalVariableElement traceVariable = elements[trace]; |
localsHandler.updateLocal(traceVariable, traceInstruction); |