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 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
8 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
(...skipping 4046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4057 } | 4057 } |
4058 | 4058 |
4059 void handleForeignJsCurrentIsolateContext(ast.Send node) { | 4059 void handleForeignJsCurrentIsolateContext(ast.Send node) { |
4060 if (!node.arguments.isEmpty) { | 4060 if (!node.arguments.isEmpty) { |
4061 compiler.internalError(node, | 4061 compiler.internalError(node, |
4062 'Too many arguments to JS_CURRENT_ISOLATE_CONTEXT.'); | 4062 'Too many arguments to JS_CURRENT_ISOLATE_CONTEXT.'); |
4063 } | 4063 } |
4064 | 4064 |
4065 if (!compiler.hasIsolateSupport) { | 4065 if (!compiler.hasIsolateSupport) { |
4066 // If the isolate library is not used, we just generate code | 4066 // If the isolate library is not used, we just generate code |
4067 // to fetch the current isolate. | 4067 // to fetch the static state. |
4068 String name = backend.namer.currentIsolate; | 4068 String name = backend.namer.staticStateHolder; |
4069 push(new HForeignCode(js.js.parseForeignJS(name), | 4069 push(new HForeignCode(js.js.parseForeignJS(name), |
4070 backend.dynamicType, | 4070 backend.dynamicType, |
4071 <HInstruction>[])); | 4071 <HInstruction>[])); |
4072 } else { | 4072 } else { |
4073 // Call a helper method from the isolate library. The isolate | 4073 // Call a helper method from the isolate library. The isolate |
4074 // library uses its own isolate structure, that encapsulates | 4074 // library uses its own isolate structure, that encapsulates |
4075 // Leg's isolate. | 4075 // Leg's isolate. |
4076 Element element = backend.isolateHelperLibrary.find('_currentIsolate'); | 4076 Element element = backend.isolateHelperLibrary.find('_currentIsolate'); |
4077 if (element == null) { | 4077 if (element == null) { |
4078 compiler.internalError(node, | 4078 compiler.internalError(node, |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4324 return params; | 4324 return params; |
4325 } | 4325 } |
4326 | 4326 |
4327 void handleForeignDartClosureToJs(ast.Send node, String name) { | 4327 void handleForeignDartClosureToJs(ast.Send node, String name) { |
4328 // TODO(ahe): This implements DART_CLOSURE_TO_JS and should probably take | 4328 // TODO(ahe): This implements DART_CLOSURE_TO_JS and should probably take |
4329 // care to wrap the closure in another closure that saves the current | 4329 // care to wrap the closure in another closure that saves the current |
4330 // isolate. | 4330 // isolate. |
4331 handleForeignRawFunctionRef(node, name); | 4331 handleForeignRawFunctionRef(node, name); |
4332 } | 4332 } |
4333 | 4333 |
4334 void handleForeignSetCurrentIsolate(ast.Send node) { | 4334 void handleForeignSetStaticState(ast.Send node) { |
herhut
2015/07/10 13:56:21
While you're at it: This should probably be
handl
floitsch
2015/09/16 15:24:23
Done.
| |
4335 if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) { | 4335 if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) { |
4336 compiler.internalError(node.argumentsNode, | 4336 compiler.internalError(node.argumentsNode, |
4337 'Exactly one argument required.'); | 4337 'Exactly one argument required.'); |
4338 } | 4338 } |
4339 visit(node.arguments.head); | 4339 visit(node.arguments.head); |
4340 String isolateName = backend.namer.currentIsolate; | 4340 String isolateName = backend.namer.staticStateHolder; |
4341 SideEffects sideEffects = new SideEffects.empty(); | 4341 SideEffects sideEffects = new SideEffects.empty(); |
4342 sideEffects.setAllSideEffects(); | 4342 sideEffects.setAllSideEffects(); |
4343 push(new HForeignCode( | 4343 push(new HForeignCode( |
4344 js.js.parseForeignJS("$isolateName = #"), | 4344 js.js.parseForeignJS("$isolateName = #"), |
4345 backend.dynamicType, | 4345 backend.dynamicType, |
4346 <HInstruction>[pop()], | 4346 <HInstruction>[pop()], |
4347 nativeBehavior: native.NativeBehavior.PURE, | 4347 nativeBehavior: native.NativeBehavior.PURE, |
4348 effects: sideEffects)); | 4348 effects: sideEffects)); |
4349 } | 4349 } |
4350 | 4350 |
4351 void handleForeignJsCurrentIsolate(ast.Send node) { | 4351 void handleForeignJsStaticState(ast.Send node) { |
herhut
2015/07/10 13:56:20
I would prefer making this JsGetStaticState...
floitsch
2015/09/16 15:24:23
Done.
| |
4352 if (!node.arguments.isEmpty) { | 4352 if (!node.arguments.isEmpty) { |
4353 compiler.internalError(node.argumentsNode, 'Too many arguments.'); | 4353 compiler.internalError(node.argumentsNode, 'Too many arguments.'); |
4354 } | 4354 } |
4355 push(new HForeignCode(js.js.parseForeignJS(backend.namer.currentIsolate), | 4355 push(new HForeignCode(js.js.parseForeignJS(backend.namer.staticStateHolder), |
4356 backend.dynamicType, | 4356 backend.dynamicType, |
4357 <HInstruction>[])); | 4357 <HInstruction>[])); |
4358 } | 4358 } |
4359 | 4359 |
4360 void handleForeignSend(ast.Send node, FunctionElement element) { | 4360 void handleForeignSend(ast.Send node, FunctionElement element) { |
4361 String name = element.name; | 4361 String name = element.name; |
4362 if (name == 'JS') { | 4362 if (name == 'JS') { |
4363 handleForeignJs(node); | 4363 handleForeignJs(node); |
4364 } else if (name == 'JS_CURRENT_ISOLATE_CONTEXT') { | 4364 } else if (name == 'JS_CURRENT_ISOLATE_CONTEXT') { |
4365 handleForeignJsCurrentIsolateContext(node); | 4365 handleForeignJsCurrentIsolateContext(node); |
4366 } else if (name == 'JS_CALL_IN_ISOLATE') { | 4366 } else if (name == 'JS_CALL_IN_ISOLATE') { |
4367 handleForeignJsCallInIsolate(node); | 4367 handleForeignJsCallInIsolate(node); |
4368 } else if (name == 'DART_CLOSURE_TO_JS') { | 4368 } else if (name == 'DART_CLOSURE_TO_JS') { |
4369 handleForeignDartClosureToJs(node, 'DART_CLOSURE_TO_JS'); | 4369 handleForeignDartClosureToJs(node, 'DART_CLOSURE_TO_JS'); |
4370 } else if (name == 'RAW_DART_FUNCTION_REF') { | 4370 } else if (name == 'RAW_DART_FUNCTION_REF') { |
4371 handleForeignRawFunctionRef(node, 'RAW_DART_FUNCTION_REF'); | 4371 handleForeignRawFunctionRef(node, 'RAW_DART_FUNCTION_REF'); |
4372 } else if (name == 'JS_SET_CURRENT_ISOLATE') { | 4372 } else if (name == 'JS_SET_STATIC_STATE') { |
4373 handleForeignSetCurrentIsolate(node); | 4373 handleForeignSetStaticState(node); |
4374 } else if (name == 'JS_CURRENT_ISOLATE') { | 4374 } else if (name == 'JS_STATIC_STATE') { |
herhut
2015/07/10 13:56:20
Maybe use JS_GET_STATIC_STATE?
floitsch
2015/09/16 15:24:23
Done.
| |
4375 handleForeignJsCurrentIsolate(node); | 4375 handleForeignJsStaticState(node); |
4376 } else if (name == 'JS_GET_NAME') { | 4376 } else if (name == 'JS_GET_NAME') { |
4377 handleForeignJsGetName(node); | 4377 handleForeignJsGetName(node); |
4378 } else if (name == 'JS_EMBEDDED_GLOBAL') { | 4378 } else if (name == 'JS_EMBEDDED_GLOBAL') { |
4379 handleForeignJsEmbeddedGlobal(node); | 4379 handleForeignJsEmbeddedGlobal(node); |
4380 } else if (name == 'JS_BUILTIN') { | 4380 } else if (name == 'JS_BUILTIN') { |
4381 handleForeignJsBuiltin(node); | 4381 handleForeignJsBuiltin(node); |
4382 } else if (name == 'JS_GET_FLAG') { | 4382 } else if (name == 'JS_GET_FLAG') { |
4383 handleForeignJsGetFlag(node); | 4383 handleForeignJsGetFlag(node); |
4384 } else if (name == 'JS_EFFECT') { | 4384 } else if (name == 'JS_EFFECT') { |
4385 stack.add(graph.addConstantNull(compiler)); | 4385 stack.add(graph.addConstantNull(compiler)); |
(...skipping 4471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8857 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8857 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
8858 unaliased.accept(this, builder); | 8858 unaliased.accept(this, builder); |
8859 } | 8859 } |
8860 | 8860 |
8861 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8861 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
8862 JavaScriptBackend backend = builder.compiler.backend; | 8862 JavaScriptBackend backend = builder.compiler.backend; |
8863 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8863 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
8864 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8864 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
8865 } | 8865 } |
8866 } | 8866 } |
OLD | NEW |