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 3075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3086 } | 3086 } |
3087 visit(closure); | 3087 visit(closure); |
3088 List<HInstruction> inputs = <HInstruction>[pop()]; | 3088 List<HInstruction> inputs = <HInstruction>[pop()]; |
3089 String invocationName = backend.namer.closureInvocationName( | 3089 String invocationName = backend.namer.closureInvocationName( |
3090 new Selector.callClosure(params.requiredParameterCount)); | 3090 new Selector.callClosure(params.requiredParameterCount)); |
3091 push(new HForeign(new DartString.literal('#.$invocationName'), | 3091 push(new HForeign(new DartString.literal('#.$invocationName'), |
3092 const LiteralDartString('var'), | 3092 const LiteralDartString('var'), |
3093 inputs)); | 3093 inputs)); |
3094 } | 3094 } |
3095 | 3095 |
| 3096 void handleForeignSetCurrentIsolate(Send node) { |
| 3097 if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) { |
| 3098 compiler.cancel('Exactly one argument required', |
| 3099 node: node.argumentsNode); |
| 3100 } |
| 3101 visit(node.arguments.head); |
| 3102 String isolateName = backend.namer.CURRENT_ISOLATE; |
| 3103 push(new HForeign(new DartString.literal("$isolateName = #"), |
| 3104 const LiteralDartString('void'), |
| 3105 <HInstruction>[pop()])); |
| 3106 } |
| 3107 |
| 3108 void handleForeignCreateIsolate(Send node) { |
| 3109 if (!node.arguments.isEmpty) { |
| 3110 compiler.cancel('Too many arguments', |
| 3111 node: node.argumentsNode); |
| 3112 } |
| 3113 String constructorName = backend.namer.isolateName; |
| 3114 push(new HForeign(new DartString.literal("new $constructorName"), |
| 3115 const LiteralDartString('var'), |
| 3116 <HInstruction>[])); |
| 3117 } |
| 3118 |
3096 visitForeignSend(Send node) { | 3119 visitForeignSend(Send node) { |
3097 Selector selector = elements.getSelector(node); | 3120 Selector selector = elements.getSelector(node); |
3098 SourceString name = selector.name; | 3121 SourceString name = selector.name; |
3099 if (name == const SourceString('JS')) { | 3122 if (name == const SourceString('JS')) { |
3100 handleForeignJs(node); | 3123 handleForeignJs(node); |
3101 } else if (name == const SourceString('UNINTERCEPTED')) { | 3124 } else if (name == const SourceString('UNINTERCEPTED')) { |
3102 handleForeignUnintercepted(node); | 3125 handleForeignUnintercepted(node); |
3103 } else if (name == const SourceString('JS_HAS_EQUALS')) { | 3126 } else if (name == const SourceString('JS_HAS_EQUALS')) { |
3104 handleForeignJsHasEquals(node); | 3127 handleForeignJsHasEquals(node); |
3105 } else if (name == const SourceString('JS_CURRENT_ISOLATE')) { | 3128 } else if (name == const SourceString('JS_CURRENT_ISOLATE')) { |
3106 handleForeignJsCurrentIsolate(node); | 3129 handleForeignJsCurrentIsolate(node); |
3107 } else if (name == const SourceString('JS_CALL_IN_ISOLATE')) { | 3130 } else if (name == const SourceString('JS_CALL_IN_ISOLATE')) { |
3108 handleForeignJsCallInIsolate(node); | 3131 handleForeignJsCallInIsolate(node); |
3109 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) { | 3132 } else if (name == const SourceString('DART_CLOSURE_TO_JS')) { |
3110 handleForeignDartClosureToJs(node); | 3133 handleForeignDartClosureToJs(node); |
| 3134 } else if (name == const SourceString('JS_SET_CURRENT_ISOLATE')) { |
| 3135 handleForeignSetCurrentIsolate(node); |
| 3136 } else if (name == const SourceString('JS_CREATE_ISOLATE')) { |
| 3137 handleForeignCreateIsolate(node); |
3111 } else { | 3138 } else { |
3112 throw "Unknown foreign: ${selector}"; | 3139 throw "Unknown foreign: ${selector}"; |
3113 } | 3140 } |
3114 } | 3141 } |
3115 | 3142 |
3116 generateSuperNoSuchMethodSend(Send node) { | 3143 generateSuperNoSuchMethodSend(Send node) { |
3117 Selector selector = elements.getSelector(node); | 3144 Selector selector = elements.getSelector(node); |
3118 SourceString name = selector.name; | 3145 SourceString name = selector.name; |
3119 | 3146 |
3120 ClassElement cls = work.element.getEnclosingClass(); | 3147 ClassElement cls = work.element.getEnclosingClass(); |
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5032 new HSubGraphBlockInformation(elseBranch.graph)); | 5059 new HSubGraphBlockInformation(elseBranch.graph)); |
5033 | 5060 |
5034 HBasicBlock conditionStartBlock = conditionBranch.block; | 5061 HBasicBlock conditionStartBlock = conditionBranch.block; |
5035 conditionStartBlock.setBlockFlow(info, joinBlock); | 5062 conditionStartBlock.setBlockFlow(info, joinBlock); |
5036 SubGraph conditionGraph = conditionBranch.graph; | 5063 SubGraph conditionGraph = conditionBranch.graph; |
5037 HIf branch = conditionGraph.end.last; | 5064 HIf branch = conditionGraph.end.last; |
5038 assert(branch is HIf); | 5065 assert(branch is HIf); |
5039 branch.blockInformation = conditionStartBlock.blockFlow; | 5066 branch.blockInformation = conditionStartBlock.blockFlow; |
5040 } | 5067 } |
5041 } | 5068 } |
OLD | NEW |