| Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| ===================================================================
|
| --- sdk/lib/_internal/compiler/implementation/ssa/builder.dart (revision 22409)
|
| +++ sdk/lib/_internal/compiler/implementation/ssa/builder.dart (working copy)
|
| @@ -2515,14 +2515,12 @@
|
| return;
|
| }
|
| }
|
| - // TODO(5346): Try to avoid the need for calling [declaration] before
|
| - // creating an [HStatic].
|
| - HInstruction instruction = new HStatic(element.declaration);
|
| if (element.isGetter()) {
|
| - add(instruction);
|
| - instruction = buildInvokeStatic(<HInstruction>[instruction]);
|
| - push(instruction);
|
| + push(buildInvokeStatic(element, <HInstruction>[]));
|
| } else {
|
| + // TODO(5346): Try to avoid the need for calling [declaration] before
|
| + // creating an [HStatic].
|
| + HInstruction instruction = new HStatic(element.declaration);
|
| instruction.instructionType =
|
| new HType.inferredTypeForElement(element, compiler);
|
| push(instruction);
|
| @@ -2580,10 +2578,8 @@
|
| }
|
| if (Elements.isStaticOrTopLevelField(element)) {
|
| if (element.isSetter()) {
|
| - HStatic target = new HStatic(element);
|
| - add(target);
|
| - var instruction = buildInvokeStatic(
|
| - <HInstruction>[target, value], HType.UNKNOWN);
|
| + var instruction = buildInvokeStatic(element,
|
| + <HInstruction>[value], HType.UNKNOWN);
|
| addWithPosition(instruction, location);
|
| } else {
|
| value = potentiallyCheckType(value, element.computeType(compiler));
|
| @@ -2620,27 +2616,21 @@
|
| }
|
|
|
| void pushInvokeHelper0(Element helper, HType type) {
|
| - HInstruction reference = new HStatic(helper);
|
| - add(reference);
|
| - List<HInstruction> inputs = <HInstruction>[reference];
|
| - push(buildInvokeStatic(inputs, type));
|
| + List<HInstruction> inputs = <HInstruction>[];
|
| + push(buildInvokeStatic(helper, inputs, type));
|
| }
|
|
|
| void pushInvokeHelper1(Element helper, HInstruction a0, HType type) {
|
| - HInstruction reference = new HStatic(helper);
|
| - add(reference);
|
| - List<HInstruction> inputs = <HInstruction>[reference, a0];
|
| - push(buildInvokeStatic(inputs, type));
|
| + List<HInstruction> inputs = <HInstruction>[a0];
|
| + push(buildInvokeStatic(helper, inputs, type));
|
| }
|
|
|
| void pushInvokeHelper2(Element helper,
|
| HInstruction a0,
|
| HInstruction a1,
|
| HType type) {
|
| - HInstruction reference = new HStatic(helper);
|
| - add(reference);
|
| - List<HInstruction> inputs = <HInstruction>[reference, a0, a1];
|
| - push(buildInvokeStatic(inputs, type));
|
| + List<HInstruction> inputs = <HInstruction>[a0, a1];
|
| + push(buildInvokeStatic(helper, inputs, type));
|
| }
|
|
|
| void pushInvokeHelper3(Element helper,
|
| @@ -2648,10 +2638,8 @@
|
| HInstruction a1,
|
| HInstruction a2,
|
| HType type) {
|
| - HInstruction reference = new HStatic(helper);
|
| - add(reference);
|
| - List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2];
|
| - push(buildInvokeStatic(inputs, type));
|
| + List<HInstruction> inputs = <HInstruction>[a0, a1, a2];
|
| + push(buildInvokeStatic(helper, inputs, type));
|
| }
|
|
|
| void pushInvokeHelper4(Element helper,
|
| @@ -2660,10 +2648,8 @@
|
| HInstruction a2,
|
| HInstruction a3,
|
| HType type) {
|
| - HInstruction reference = new HStatic(helper);
|
| - add(reference);
|
| - List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2, a3];
|
| - push(buildInvokeStatic(inputs, type));
|
| + List<HInstruction> inputs = <HInstruction>[a0, a1, a2, a3];
|
| + push(buildInvokeStatic(helper, inputs, type));
|
| }
|
|
|
| void pushInvokeHelper5(Element helper,
|
| @@ -2673,10 +2659,8 @@
|
| HInstruction a3,
|
| HInstruction a4,
|
| HType type) {
|
| - HInstruction reference = new HStatic(helper);
|
| - add(reference);
|
| - List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2, a3, a4];
|
| - push(buildInvokeStatic(inputs, type));
|
| + List<HInstruction> inputs = <HInstruction>[a0, a1, a2, a3, a4];
|
| + push(buildInvokeStatic(helper, inputs, type));
|
| }
|
|
|
| HForeign createForeign(String code,
|
| @@ -2775,19 +2759,14 @@
|
| if (type.kind == TypeKind.TYPE_VARIABLE) {
|
| HInstruction runtimeType = addTypeVariableReference(type);
|
| Element helper = backend.getGetObjectIsSubtype();
|
| - HInstruction helperCall = new HStatic(helper);
|
| - add(helperCall);
|
| - List<HInstruction> inputs = <HInstruction>[helperCall, expression,
|
| - runtimeType];
|
| - HInstruction call = buildInvokeStatic(inputs, HType.BOOLEAN);
|
| + List<HInstruction> inputs = <HInstruction>[expression, runtimeType];
|
| + HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN);
|
| add(call);
|
| instruction = new HIs(type, <HInstruction>[expression, call],
|
| HIs.VARIABLE_CHECK);
|
| } else if (RuntimeTypes.hasTypeArguments(type)) {
|
| Element element = type.element;
|
| Element helper = backend.getCheckSubtype();
|
| - HInstruction helperCall = new HStatic(helper);
|
| - add(helperCall);
|
| HInstruction representations =
|
| buildTypeArgumentRepresentations(type);
|
| add(representations);
|
| @@ -2798,12 +2777,11 @@
|
| // have a subclass.
|
| HInstruction asFieldName =
|
| addConstantString(node, backend.namer.substitutionName(element));
|
| - List<HInstruction> inputs = <HInstruction>[helperCall,
|
| - expression,
|
| + List<HInstruction> inputs = <HInstruction>[expression,
|
| isFieldName,
|
| representations,
|
| asFieldName];
|
| - HInstruction call = buildInvokeStatic(inputs, HType.BOOLEAN);
|
| + HInstruction call = buildInvokeStatic(helper, inputs, HType.BOOLEAN);
|
| add(call);
|
| instruction = new HIs(type, <HInstruction>[expression, call],
|
| HIs.COMPOUND_CHECK);
|
| @@ -3041,11 +3019,9 @@
|
| compiler.cancel(
|
| 'Isolate library and compiler mismatch', node: node);
|
| }
|
| - HStatic target = new HStatic(element);
|
| - add(target);
|
| - List<HInstruction> inputs = <HInstruction>[target];
|
| + List<HInstruction> inputs = <HInstruction>[];
|
| addGenericSendArgumentsToList(link, inputs);
|
| - push(buildInvokeStatic(inputs, HType.UNKNOWN));
|
| + push(buildInvokeStatic(element, inputs, HType.UNKNOWN));
|
| }
|
| }
|
|
|
| @@ -3344,10 +3320,8 @@
|
|
|
| // Set the runtime type information on the object.
|
| Element typeInfoSetterElement = backend.getSetRuntimeTypeInfo();
|
| - HInstruction typeInfoSetter = new HStatic(typeInfoSetterElement);
|
| - add(typeInfoSetter);
|
| - add(buildInvokeStatic(
|
| - <HInstruction>[typeInfoSetter, newObject, typeInfo], HType.UNKNOWN));
|
| + add(buildInvokeStatic(typeInfoSetterElement,
|
| + <HInstruction>[newObject, typeInfo], HType.UNKNOWN));
|
| }
|
|
|
| /**
|
| @@ -3401,12 +3375,7 @@
|
| message: 'Constructor Symbol.validated is missing'));
|
| }
|
|
|
| - // TODO(5346): Try to avoid the need for calling [declaration] before
|
| - // creating an [HStatic].
|
| - HInstruction target = new HStatic(constructor.declaration);
|
| - add(target);
|
| var inputs = <HInstruction>[];
|
| - inputs.add(target);
|
| // TODO(5347): Try to avoid the need for calling [implementation] before
|
| // calling [addStaticSendArgumentsToList].
|
| bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
|
| @@ -3440,7 +3409,8 @@
|
| compiler.enqueuer.codegen.registerFactoryWithTypeArguments(elements);
|
| }
|
| HType elementType = computeType(constructor);
|
| - HInstruction newInstance = buildInvokeStatic(inputs, elementType);
|
| + HInstruction newInstance =
|
| + buildInvokeStatic(constructor, inputs, elementType);
|
| pushWithPosition(newInstance, node);
|
|
|
| // The List constructor forwards to a Dart static method that does
|
| @@ -3479,9 +3449,7 @@
|
| return;
|
| }
|
|
|
| - HInstruction target = new HStatic(element);
|
| - add(target);
|
| - var inputs = <HInstruction>[target];
|
| + var inputs = <HInstruction>[];
|
| // TODO(5347): Try to avoid the need for calling [implementation] before
|
| // calling [addStaticSendArgumentsToList].
|
| bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
|
| @@ -3493,11 +3461,12 @@
|
| }
|
|
|
| if (isIdenticalFunction) {
|
| - pushWithPosition(new HIdentity(inputs[1], inputs[2]), node);
|
| + pushWithPosition(new HIdentity(inputs[0], inputs[1]), node);
|
| return;
|
| }
|
|
|
| - HInvokeStatic instruction = buildInvokeStatic(inputs, HType.UNKNOWN);
|
| + HInvokeStatic instruction =
|
| + buildInvokeStatic(element, inputs, HType.UNKNOWN);
|
| HType returnType =
|
| new HType.inferredReturnTypeForElement(element, compiler);
|
| if (returnType.isUnknown()) {
|
| @@ -3714,14 +3683,16 @@
|
| }
|
| }
|
|
|
| - HInstruction buildInvokeStatic(List<HInstruction> inputs,
|
| + HInstruction buildInvokeStatic(Element element,
|
| + List<HInstruction> inputs,
|
| [HType type = null]) {
|
| - HStatic staticInstruction = inputs[0];
|
| - Element element = staticInstruction.element;
|
| if (type == null) {
|
| type = new HType.inferredReturnTypeForElement(element, compiler);
|
| }
|
| - HInstruction instruction = new HInvokeStatic(inputs, type);
|
| + // TODO(5346): Try to avoid the need for calling [declaration] before
|
| + // creating an [HInvokeStatic].
|
| + HInstruction instruction =
|
| + new HInvokeStatic(element.declaration, inputs, type);
|
| instruction.sideEffects = compiler.world.getSideEffectsOfElement(element);
|
| return instruction;
|
| }
|
| @@ -3732,9 +3703,7 @@
|
| HInstruction receiver = localsHandler.readThis();
|
| // TODO(5346): Try to avoid the need for calling [declaration] before
|
| // creating an [HStatic].
|
| - HInstruction target = new HStatic(element.declaration);
|
| - add(target);
|
| - List<HInstruction> inputs = <HInstruction>[target];
|
| + List<HInstruction> inputs = <HInstruction>[];
|
| Set<ClassElement> interceptedClasses =
|
| backend.getInterceptedClassesOn(selector.name);
|
| if (interceptedClasses != null) {
|
| @@ -3743,6 +3712,7 @@
|
| inputs.add(receiver);
|
| inputs.addAll(arguments);
|
| HInstruction instruction = new HInvokeSuper(
|
| + element,
|
| currentNonClosureClass,
|
| inputs,
|
| isSetter: selector.isSetter() || selector.isIndexSet());
|
|
|