Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1458)

Side by Side Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2551713002: dart2js-kernel: Implement JS_CALL_IN_ISOLATE (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 '../common.dart'; 7 import '../common.dart';
8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
9 import '../common/names.dart'; 9 import '../common/names.dart';
10 import '../common/tasks.dart' show CompilerTask; 10 import '../common/tasks.dart' show CompilerTask;
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 "to '$methodName'." 1205 "to '$methodName'."
1206 }); 1206 });
1207 return null; 1207 return null;
1208 } 1208 }
1209 1209
1210 HConstant hConstant = instruction; 1210 HConstant hConstant = instruction;
1211 StringConstantValue stringConstant = hConstant.constant; 1211 StringConstantValue stringConstant = hConstant.constant;
1212 return stringConstant.primitiveValue.slowToString(); 1212 return stringConstant.primitiveValue.slowToString();
1213 } 1213 }
1214 1214
1215 // TODO(sra): Remove when handleInvokeStaticForeign fully implemented.
1216 void unhandledForeign(ir.StaticInvocation invocation) {
1217 ir.Procedure target = invocation.target;
1218 TypeMask typeMask = astAdapter.returnTypeOf(target);
1219 List<HInstruction> arguments = _visitArguments(invocation.arguments);
1220 _pushStaticInvocation(target, arguments, typeMask);
1221 }
1222
1223 void handleForeignJsCurrentIsolateContext(ir.StaticInvocation invocation) { 1215 void handleForeignJsCurrentIsolateContext(ir.StaticInvocation invocation) {
1224 if (_unexpectedForeignArguments(invocation, 0, 0)) { 1216 if (_unexpectedForeignArguments(invocation, 0, 0)) {
1225 stack.add(graph.addConstantNull(compiler)); // Result expected on stack. 1217 stack.add(graph.addConstantNull(compiler)); // Result expected on stack.
1226 return; 1218 return;
1227 } 1219 }
1228 1220
1229 if (!compiler.hasIsolateSupport) { 1221 if (!compiler.hasIsolateSupport) {
1230 // If the isolate library is not used, we just generate code 1222 // If the isolate library is not used, we just generate code
1231 // to fetch the static state. 1223 // to fetch the static state.
1232 String name = backend.namer.staticStateHolder; 1224 String name = backend.namer.staticStateHolder;
1233 push(new HForeignCode( 1225 push(new HForeignCode(
1234 js.js.parseForeignJS(name), backend.dynamicType, <HInstruction>[], 1226 js.js.parseForeignJS(name), backend.dynamicType, <HInstruction>[],
1235 nativeBehavior: native.NativeBehavior.DEPENDS_OTHER)); 1227 nativeBehavior: native.NativeBehavior.DEPENDS_OTHER));
1236 } else { 1228 } else {
1237 // Call a helper method from the isolate library. The isolate library uses 1229 // Call a helper method from the isolate library. The isolate library uses
1238 // its own isolate structure that encapsulates the isolate structure used 1230 // its own isolate structure that encapsulates the isolate structure used
1239 // for binding to methods. 1231 // for binding to methods.
1240 ir.Procedure target = astAdapter.currentIsolate; 1232 ir.Procedure target = astAdapter.currentIsolate;
1241 if (target == null) { 1233 if (target == null) {
1242 compiler.reporter.internalError(astAdapter.getNode(invocation), 1234 compiler.reporter.internalError(astAdapter.getNode(invocation),
1243 'Isolate library and compiler mismatch.'); 1235 'Isolate library and compiler mismatch.');
1244 } 1236 }
1245 _pushStaticInvocation(target, <HInstruction>[], backend.dynamicType); 1237 _pushStaticInvocation(target, <HInstruction>[], backend.dynamicType);
1246 } 1238 }
1247 } 1239 }
1248 1240
1249 void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) { 1241 void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) {
1250 unhandledForeign(invocation); 1242 if (_unexpectedForeignArguments(invocation, 2, 2)) {
Siggi Cherem (dart-lang) 2016/12/04 05:02:41 woo hoo!
1243 stack.add(graph.addConstantNull(compiler)); // Result expected on stack.
1244 return;
1245 }
1246
1247 List<HInstruction> inputs = _visitArguments(invocation.arguments);
1248
1249 if (!compiler.hasIsolateSupport) {
1250 // If the isolate library is not used, we ignore the isolate argument and
1251 // just invoke the closure.
1252 push(new HInvokeClosure(new Selector.callClosure(0),
1253 <HInstruction>[inputs[1]], backend.dynamicType));
1254 } else {
1255 // Call a helper method from the isolate library.
1256 ir.Procedure callInIsolate = astAdapter.callInIsolate;
1257 if (callInIsolate == null) {
1258 compiler.reporter.internalError(astAdapter.getNode(invocation),
1259 'Isolate library and compiler mismatch.');
1260 }
1261 _pushStaticInvocation(callInIsolate, inputs, backend.dynamicType);
1262 }
1251 } 1263 }
1252 1264
1253 void handleForeignDartClosureToJs( 1265 void handleForeignDartClosureToJs(
1254 ir.StaticInvocation invocation, String name) { 1266 ir.StaticInvocation invocation, String name) {
1255 // TODO(sra): Do we need to wrap the closure in something that saves the 1267 // TODO(sra): Do we need to wrap the closure in something that saves the
1256 // current isolate? 1268 // current isolate?
1257 handleForeignRawFunctionRef(invocation, name); 1269 handleForeignRawFunctionRef(invocation, name);
1258 } 1270 }
1259 1271
1260 void handleForeignRawFunctionRef( 1272 void handleForeignRawFunctionRef(
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 push(new HNot(popBoolified(), backend.boolType)); 1723 push(new HNot(popBoolified(), backend.boolType));
1712 } 1724 }
1713 1725
1714 @override 1726 @override
1715 void visitStringConcatenation(ir.StringConcatenation stringConcat) { 1727 void visitStringConcatenation(ir.StringConcatenation stringConcat) {
1716 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); 1728 KernelStringBuilder stringBuilder = new KernelStringBuilder(this);
1717 stringConcat.accept(stringBuilder); 1729 stringConcat.accept(stringBuilder);
1718 stack.add(stringBuilder.result); 1730 stack.add(stringBuilder.result);
1719 } 1731 }
1720 } 1732 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698