| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 return stringConstant.primitiveValue.slowToString(); | 2187 return stringConstant.primitiveValue.slowToString(); |
| 2188 } | 2188 } |
| 2189 | 2189 |
| 2190 void handleForeignJsCurrentIsolateContext(ir.StaticInvocation invocation) { | 2190 void handleForeignJsCurrentIsolateContext(ir.StaticInvocation invocation) { |
| 2191 if (_unexpectedForeignArguments(invocation, 0, 0)) { | 2191 if (_unexpectedForeignArguments(invocation, 0, 0)) { |
| 2192 // Result expected on stack. | 2192 // Result expected on stack. |
| 2193 stack.add(graph.addConstantNull(closedWorld)); | 2193 stack.add(graph.addConstantNull(closedWorld)); |
| 2194 return; | 2194 return; |
| 2195 } | 2195 } |
| 2196 | 2196 |
| 2197 if (!backend.hasIsolateSupport) { | 2197 if (!backend.backendUsage.isIsolateInUse) { |
| 2198 // If the isolate library is not used, we just generate code | 2198 // If the isolate library is not used, we just generate code |
| 2199 // to fetch the static state. | 2199 // to fetch the static state. |
| 2200 String name = backend.namer.staticStateHolder; | 2200 String name = backend.namer.staticStateHolder; |
| 2201 push(new HForeignCode( | 2201 push(new HForeignCode( |
| 2202 js.js.parseForeignJS(name), commonMasks.dynamicType, <HInstruction>[], | 2202 js.js.parseForeignJS(name), commonMasks.dynamicType, <HInstruction>[], |
| 2203 nativeBehavior: native.NativeBehavior.DEPENDS_OTHER)); | 2203 nativeBehavior: native.NativeBehavior.DEPENDS_OTHER)); |
| 2204 } else { | 2204 } else { |
| 2205 // Call a helper method from the isolate library. The isolate library uses | 2205 // Call a helper method from the isolate library. The isolate library uses |
| 2206 // its own isolate structure that encapsulates the isolate structure used | 2206 // its own isolate structure that encapsulates the isolate structure used |
| 2207 // for binding to methods. | 2207 // for binding to methods. |
| 2208 ir.Procedure target = astAdapter.currentIsolate; | 2208 ir.Procedure target = astAdapter.currentIsolate; |
| 2209 if (target == null) { | 2209 if (target == null) { |
| 2210 compiler.reporter.internalError(astAdapter.getNode(invocation), | 2210 compiler.reporter.internalError(astAdapter.getNode(invocation), |
| 2211 'Isolate library and compiler mismatch.'); | 2211 'Isolate library and compiler mismatch.'); |
| 2212 } | 2212 } |
| 2213 _pushStaticInvocation(target, <HInstruction>[], commonMasks.dynamicType); | 2213 _pushStaticInvocation(target, <HInstruction>[], commonMasks.dynamicType); |
| 2214 } | 2214 } |
| 2215 } | 2215 } |
| 2216 | 2216 |
| 2217 void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) { | 2217 void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) { |
| 2218 if (_unexpectedForeignArguments(invocation, 2, 2)) { | 2218 if (_unexpectedForeignArguments(invocation, 2, 2)) { |
| 2219 // Result expected on stack. | 2219 // Result expected on stack. |
| 2220 stack.add(graph.addConstantNull(closedWorld)); | 2220 stack.add(graph.addConstantNull(closedWorld)); |
| 2221 return; | 2221 return; |
| 2222 } | 2222 } |
| 2223 | 2223 |
| 2224 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); | 2224 List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments); |
| 2225 | 2225 |
| 2226 if (!backend.hasIsolateSupport) { | 2226 if (!backend.backendUsage.isIsolateInUse) { |
| 2227 // If the isolate library is not used, we ignore the isolate argument and | 2227 // If the isolate library is not used, we ignore the isolate argument and |
| 2228 // just invoke the closure. | 2228 // just invoke the closure. |
| 2229 push(new HInvokeClosure(new Selector.callClosure(0), | 2229 push(new HInvokeClosure(new Selector.callClosure(0), |
| 2230 <HInstruction>[inputs[1]], commonMasks.dynamicType)); | 2230 <HInstruction>[inputs[1]], commonMasks.dynamicType)); |
| 2231 } else { | 2231 } else { |
| 2232 // Call a helper method from the isolate library. | 2232 // Call a helper method from the isolate library. |
| 2233 ir.Procedure callInIsolate = astAdapter.callInIsolate; | 2233 ir.Procedure callInIsolate = astAdapter.callInIsolate; |
| 2234 if (callInIsolate == null) { | 2234 if (callInIsolate == null) { |
| 2235 compiler.reporter.internalError(astAdapter.getNode(invocation), | 2235 compiler.reporter.internalError(astAdapter.getNode(invocation), |
| 2236 'Isolate library and compiler mismatch.'); | 2236 'Isolate library and compiler mismatch.'); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 assert(noSuchMethod != null); | 2684 assert(noSuchMethod != null); |
| 2685 return noSuchMethod; | 2685 return noSuchMethod; |
| 2686 } | 2686 } |
| 2687 | 2687 |
| 2688 void _generateSuperNoSuchMethod(ir.Expression invocation, String publicName, | 2688 void _generateSuperNoSuchMethod(ir.Expression invocation, String publicName, |
| 2689 List<HInstruction> arguments) { | 2689 List<HInstruction> arguments) { |
| 2690 Selector selector = astAdapter.getSelector(invocation); | 2690 Selector selector = astAdapter.getSelector(invocation); |
| 2691 ir.Class cls = _containingClass(invocation).superclass; | 2691 ir.Class cls = _containingClass(invocation).superclass; |
| 2692 assert(cls != null); | 2692 assert(cls != null); |
| 2693 ir.Procedure noSuchMethod = _findNoSuchMethodInClass(cls); | 2693 ir.Procedure noSuchMethod = _findNoSuchMethodInClass(cls); |
| 2694 if (backend.hasInvokeOnSupport && | 2694 if (backend.backendUsage.isInvokeOnUsed && |
| 2695 _containingClass(noSuchMethod) != astAdapter.objectClass) { | 2695 _containingClass(noSuchMethod) != astAdapter.objectClass) { |
| 2696 // Register the call as dynamic if [noSuchMethod] on the super | 2696 // Register the call as dynamic if [noSuchMethod] on the super |
| 2697 // class is _not_ the default implementation from [Object] (it might be | 2697 // class is _not_ the default implementation from [Object] (it might be |
| 2698 // overridden in the super class, but it might have a different number of | 2698 // overridden in the super class, but it might have a different number of |
| 2699 // arguments), in case the [noSuchMethod] implementation calls | 2699 // arguments), in case the [noSuchMethod] implementation calls |
| 2700 // [JSInvocationMirror._invokeOn]. | 2700 // [JSInvocationMirror._invokeOn]. |
| 2701 // TODO(johnniwinther): Register this more precisely. | 2701 // TODO(johnniwinther): Register this more precisely. |
| 2702 registry?.registerDynamicUse(new DynamicUse(selector, null)); | 2702 registry?.registerDynamicUse(new DynamicUse(selector, null)); |
| 2703 } | 2703 } |
| 2704 | 2704 |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3227 enterBlock.setBlockFlow( | 3227 enterBlock.setBlockFlow( |
| 3228 new HTryBlockInformation( | 3228 new HTryBlockInformation( |
| 3229 kernelBuilder.wrapStatementGraph(bodyGraph), | 3229 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3230 exception, | 3230 exception, |
| 3231 kernelBuilder.wrapStatementGraph(catchGraph), | 3231 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3232 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3232 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3233 exitBlock); | 3233 exitBlock); |
| 3234 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3234 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3235 } | 3235 } |
| 3236 } | 3236 } |
| OLD | NEW |