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

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

Issue 1896843002: Store and serialize NativeBehavior in TreeElements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 months 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
OLDNEW
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 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 4018 matching lines...) Expand 10 before | Expand all | Expand 10 after
4029 4029
4030 void handleForeignJs(ast.Send node) { 4030 void handleForeignJs(ast.Send node) {
4031 Link<ast.Node> link = node.arguments; 4031 Link<ast.Node> link = node.arguments;
4032 // Don't visit the first argument, which is the type, and the second 4032 // Don't visit the first argument, which is the type, and the second
4033 // argument, which is the foreign code. 4033 // argument, which is the foreign code.
4034 if (link.isEmpty || link.tail.isEmpty) { 4034 if (link.isEmpty || link.tail.isEmpty) {
4035 // We should not get here because the call should be compiled to NSM. 4035 // We should not get here because the call should be compiled to NSM.
4036 reporter.internalError( 4036 reporter.internalError(
4037 node.argumentsNode, 'At least two arguments expected.'); 4037 node.argumentsNode, 'At least two arguments expected.');
4038 } 4038 }
4039 native.NativeBehavior nativeBehavior = 4039 native.NativeBehavior nativeBehavior = elements.getNativeData(node);
4040 compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node); 4040 assert(invariant(node, nativeBehavior != null,
4041 message: "No NativeBehavior for $node"));
4041 4042
4042 List<HInstruction> inputs = <HInstruction>[]; 4043 List<HInstruction> inputs = <HInstruction>[];
4043 addGenericSendArgumentsToList(link.tail.tail, inputs); 4044 addGenericSendArgumentsToList(link.tail.tail, inputs);
4044 4045
4045 if (nativeBehavior.codeTemplate.positionalArgumentCount != inputs.length) { 4046 if (nativeBehavior.codeTemplate.positionalArgumentCount != inputs.length) {
4046 reporter.reportErrorMessage(node, MessageKind.GENERIC, { 4047 reporter.reportErrorMessage(node, MessageKind.GENERIC, {
4047 'text': 'Mismatch between number of placeholders' 4048 'text': 'Mismatch between number of placeholders'
4048 ' and number of arguments.' 4049 ' and number of arguments.'
4049 }); 4050 });
4050 stack.add(graph.addConstantNull(compiler)); // Result expected on stack. 4051 stack.add(graph.addConstantNull(compiler)); // Result expected on stack.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
4197 4198
4198 js.Template template = 4199 js.Template template =
4199 backend.emitter.builtinTemplateFor(JsBuiltin.values[index]); 4200 backend.emitter.builtinTemplateFor(JsBuiltin.values[index]);
4200 4201
4201 List<HInstruction> compiledArguments = <HInstruction>[]; 4202 List<HInstruction> compiledArguments = <HInstruction>[];
4202 for (int i = 2; i < arguments.length; i++) { 4203 for (int i = 2; i < arguments.length; i++) {
4203 visit(arguments[i]); 4204 visit(arguments[i]);
4204 compiledArguments.add(pop()); 4205 compiledArguments.add(pop());
4205 } 4206 }
4206 4207
4207 native.NativeBehavior nativeBehavior = 4208 native.NativeBehavior nativeBehavior = elements.getNativeData(node);
4208 compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node); 4209 assert(invariant(node, nativeBehavior != null,
4210 message: "No NativeBehavior for $node"));
4209 4211
4210 TypeMask ssaType = 4212 TypeMask ssaType =
4211 TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler); 4213 TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler);
4212 4214
4213 push(new HForeignCode(template, ssaType, compiledArguments, 4215 push(new HForeignCode(template, ssaType, compiledArguments,
4214 nativeBehavior: nativeBehavior)); 4216 nativeBehavior: nativeBehavior));
4215 } 4217 }
4216 4218
4217 void handleForeignJsEmbeddedGlobal(ast.Send node) { 4219 void handleForeignJsEmbeddedGlobal(ast.Send node) {
4218 List<ast.Node> arguments = node.arguments.toList(); 4220 List<ast.Node> arguments = node.arguments.toList();
(...skipping 23 matching lines...) Expand all
4242 'text': 'Error: Expected String as second argument ' 4244 'text': 'Error: Expected String as second argument '
4243 'to JS_EMBEDDED_GLOBAL.' 4245 'to JS_EMBEDDED_GLOBAL.'
4244 }); 4246 });
4245 return; 4247 return;
4246 } 4248 }
4247 HConstant hConstant = globalNameHNode; 4249 HConstant hConstant = globalNameHNode;
4248 StringConstantValue constant = hConstant.constant; 4250 StringConstantValue constant = hConstant.constant;
4249 String globalName = constant.primitiveValue.slowToString(); 4251 String globalName = constant.primitiveValue.slowToString();
4250 js.Template expr = js.js.expressionTemplateYielding( 4252 js.Template expr = js.js.expressionTemplateYielding(
4251 backend.emitter.generateEmbeddedGlobalAccess(globalName)); 4253 backend.emitter.generateEmbeddedGlobalAccess(globalName));
4252 native.NativeBehavior nativeBehavior = 4254 native.NativeBehavior nativeBehavior = elements.getNativeData(node);
4253 compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node); 4255 assert(invariant(node, nativeBehavior != null,
4256 message: "No NativeBehavior for $node"));
4254 TypeMask ssaType = 4257 TypeMask ssaType =
4255 TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler); 4258 TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler);
4256 push(new HForeignCode(expr, ssaType, const [], 4259 push(new HForeignCode(expr, ssaType, const [],
4257 nativeBehavior: nativeBehavior)); 4260 nativeBehavior: nativeBehavior));
4258 } 4261 }
4259 4262
4260 void handleJsInterceptorConstant(ast.Send node) { 4263 void handleJsInterceptorConstant(ast.Send node) {
4261 // Single argument must be a TypeConstant which is converted into a 4264 // Single argument must be a TypeConstant which is converted into a
4262 // InterceptorConstant. 4265 // InterceptorConstant.
4263 if (!node.arguments.isEmpty && node.arguments.tail.isEmpty) { 4266 if (!node.arguments.isEmpty && node.arguments.tail.isEmpty) {
(...skipping 4309 matching lines...) Expand 10 before | Expand all | Expand 10 after
8573 const _LoopTypeVisitor(); 8576 const _LoopTypeVisitor();
8574 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; 8577 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP;
8575 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; 8578 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP;
8576 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; 8579 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP;
8577 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; 8580 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP;
8578 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 8581 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
8579 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 8582 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
8580 int visitSwitchStatement(ast.SwitchStatement node) => 8583 int visitSwitchStatement(ast.SwitchStatement node) =>
8581 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; 8584 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
8582 } 8585 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/serialization.dart ('k') | pkg/compiler/lib/src/universe/side_effects.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698