OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of ssa; | 5 part of ssa; |
6 | 6 |
7 /** | 7 /** |
8 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 | 2626 |
2627 void pushInvokeHelper4(Element helper, HInstruction a0, HInstruction a1, | 2627 void pushInvokeHelper4(Element helper, HInstruction a0, HInstruction a1, |
2628 HInstruction a2, HInstruction a3) { | 2628 HInstruction a2, HInstruction a3) { |
2629 HInstruction reference = new HStatic(helper); | 2629 HInstruction reference = new HStatic(helper); |
2630 add(reference); | 2630 add(reference); |
2631 List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2, a3]; | 2631 List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2, a3]; |
2632 HInstruction result = new HInvokeStatic(inputs); | 2632 HInstruction result = new HInvokeStatic(inputs); |
2633 push(result); | 2633 push(result); |
2634 } | 2634 } |
2635 | 2635 |
| 2636 void pushInvokeHelper5(Element helper, HInstruction a0, HInstruction a1, |
| 2637 HInstruction a2, HInstruction a3, HInstruction a4) { |
| 2638 HInstruction reference = new HStatic(helper); |
| 2639 add(reference); |
| 2640 List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2, a3, a4]; |
| 2641 HInstruction result = new HInvokeStatic(inputs); |
| 2642 push(result); |
| 2643 } |
| 2644 |
2636 HForeign createForeign(String code, String type, List<HInstruction> inputs) { | 2645 HForeign createForeign(String code, String type, List<HInstruction> inputs) { |
2637 return new HForeign(new LiteralDartString(code), | 2646 return new HForeign(new LiteralDartString(code), |
2638 new LiteralDartString(type), | 2647 new LiteralDartString(type), |
2639 inputs); | 2648 inputs); |
2640 } | 2649 } |
2641 | 2650 |
2642 HInstruction getRuntimeTypeInfo(HInstruction target) { | 2651 HInstruction getRuntimeTypeInfo(HInstruction target) { |
2643 pushInvokeHelper1(interceptors.getGetRuntimeTypeInfo(), target); | 2652 pushInvokeHelper1(interceptors.getGetRuntimeTypeInfo(), target); |
2644 return pop(); | 2653 return pop(); |
2645 } | 2654 } |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3101 } else if (name == const SourceString('JS_CALL_IN_ISOLATE')) { | 3110 } else if (name == const SourceString('JS_CALL_IN_ISOLATE')) { |
3102 handleForeignJsCallInIsolate(node); | 3111 handleForeignJsCallInIsolate(node); |
3103 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) { | 3112 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) { |
3104 handleForeignDartClosureToJs(node); | 3113 handleForeignDartClosureToJs(node); |
3105 } else { | 3114 } else { |
3106 throw "Unknown foreign: ${selector}"; | 3115 throw "Unknown foreign: ${selector}"; |
3107 } | 3116 } |
3108 } | 3117 } |
3109 | 3118 |
3110 generateSuperNoSuchMethodSend(Send node) { | 3119 generateSuperNoSuchMethodSend(Send node) { |
| 3120 Selector selector = elements.getSelector(node); |
| 3121 SourceString name = selector.name; |
| 3122 |
3111 ClassElement cls = work.element.getEnclosingClass(); | 3123 ClassElement cls = work.element.getEnclosingClass(); |
3112 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); | 3124 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); |
| 3125 if (element.enclosingElement.declaration != compiler.objectClass) { |
| 3126 // Register the call as dynamic if [:noSuchMethod:] on the super class |
| 3127 // is _not_ the default implementation from [:Object:]. |
| 3128 compiler.enqueuer.codegen.registerDynamicInvocation(name, selector); |
| 3129 } |
3113 HStatic target = new HStatic(element); | 3130 HStatic target = new HStatic(element); |
3114 add(target); | 3131 add(target); |
3115 HInstruction self = localsHandler.readThis(); | 3132 HInstruction self = localsHandler.readThis(); |
3116 Identifier identifier = node.selector.asIdentifier(); | 3133 Constant nameConstant = constantSystem.createString( |
3117 String name = identifier.source.slowToString(); | 3134 new DartString.literal(name.slowToString()), node); |
3118 // TODO(ahe): Add the arguments to this list. | 3135 |
3119 push(new HLiteralList([])); | 3136 String internalName = backend.namer.instanceMethodInvocationName( |
3120 Constant nameConstant = | 3137 currentLibrary, name, selector); |
3121 constantSystem.createString(new DartString.literal(name), node); | 3138 Constant internalNameConstant = |
| 3139 constantSystem.createString(new DartString.literal(internalName), node); |
| 3140 |
| 3141 Element createInvocationMirror = |
| 3142 compiler.findHelper(Compiler.CREATE_INVOCATION_MIRROR); |
| 3143 |
| 3144 var arguments = new List<HInstruction>(); |
| 3145 addGenericSendArgumentsToList(node.arguments, arguments); |
| 3146 var argumentsInstruction = new HLiteralList(arguments); |
| 3147 add(argumentsInstruction); |
| 3148 |
| 3149 var argumentNames = new List<HInstruction>(); |
| 3150 for (SourceString argumentName in selector.namedArguments) { |
| 3151 Constant argumentNameConstant = |
| 3152 constantSystem.createString(new DartString.literal( |
| 3153 argumentName.slowToString()), node); |
| 3154 argumentNames.add(graph.addConstant(argumentNameConstant)); |
| 3155 } |
| 3156 var argumentNamesInstruction = new HLiteralList(argumentNames); |
| 3157 add(argumentNamesInstruction); |
| 3158 |
| 3159 Constant kindConstant = |
| 3160 constantSystem.createInt(selector.invocationMirrorKind); |
| 3161 |
| 3162 pushInvokeHelper5(createInvocationMirror, |
| 3163 graph.addConstant(nameConstant), |
| 3164 graph.addConstant(internalNameConstant), |
| 3165 graph.addConstant(kindConstant), |
| 3166 argumentsInstruction, |
| 3167 argumentNamesInstruction); |
| 3168 |
3122 var inputs = <HInstruction>[ | 3169 var inputs = <HInstruction>[ |
3123 target, | 3170 target, |
3124 self, | 3171 self, |
3125 graph.addConstant(nameConstant), | |
3126 pop()]; | 3172 pop()]; |
3127 push(new HInvokeSuper(inputs)); | 3173 push(new HInvokeSuper(inputs)); |
3128 } | 3174 } |
3129 | 3175 |
3130 visitSend(Send node) { | 3176 visitSend(Send node) { |
3131 Element element = elements[node]; | 3177 Element element = elements[node]; |
3132 if (element != null && identical(element, work.element)) { | 3178 if (element != null && identical(element, work.element)) { |
3133 graph.isRecursiveMethod = true; | 3179 graph.isRecursiveMethod = true; |
3134 } | 3180 } |
3135 super.visitSend(node); | 3181 super.visitSend(node); |
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4989 new HSubGraphBlockInformation(elseBranch.graph)); | 5035 new HSubGraphBlockInformation(elseBranch.graph)); |
4990 | 5036 |
4991 HBasicBlock conditionStartBlock = conditionBranch.block; | 5037 HBasicBlock conditionStartBlock = conditionBranch.block; |
4992 conditionStartBlock.setBlockFlow(info, joinBlock); | 5038 conditionStartBlock.setBlockFlow(info, joinBlock); |
4993 SubGraph conditionGraph = conditionBranch.graph; | 5039 SubGraph conditionGraph = conditionBranch.graph; |
4994 HIf branch = conditionGraph.end.last; | 5040 HIf branch = conditionGraph.end.last; |
4995 assert(branch is HIf); | 5041 assert(branch is HIf); |
4996 branch.blockInformation = conditionStartBlock.blockFlow; | 5042 branch.blockInformation = conditionStartBlock.blockFlow; |
4997 } | 5043 } |
4998 } | 5044 } |
OLD | NEW |