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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 45143003: Implement JS_INTERCEPTOR_CONSTANT (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 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 3183 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 argument, MessageKind.GENERIC, 3194 argument, MessageKind.GENERIC,
3195 {'text': 'Error: Expected a literal string.'}); 3195 {'text': 'Error: Expected a literal string.'});
3196 } 3196 }
3197 stack.add( 3197 stack.add(
3198 addConstantString( 3198 addConstantString(
3199 argument, 3199 argument,
3200 backend.namer.getNameForJsGetName( 3200 backend.namer.getNameForJsGetName(
3201 argument, string.dartString.slowToString()))); 3201 argument, string.dartString.slowToString())));
3202 } 3202 }
3203 3203
3204 void handleJsInterceptorConstant(Send node) {
3205 void bad(Node node) {
3206 compiler.reportError(node,
3207 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
3208 stack.add(graph.addConstantNull(compiler));
3209 }
3210 if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) {
3211 return bad(node.arguments);
3212 }
3213 Node argument = node.arguments.head;
3214 // argument must be a TypeConstant.
3215 visit(argument);
3216 HInstruction argumentInstruction = pop();
3217 if (argumentInstruction is! HConstant) {
3218 return bad(argument);
3219 }
3220 Constant argumentConstant = argumentInstruction.constant;
3221 if (argumentConstant is! TypeConstant) {
3222 return bad(argument);
3223 }
3224
3225 Constant constant =
3226 new InterceptorConstant(argumentConstant.representedType);
3227 HInstruction instruction = graph.addConstant(constant, compiler);
3228 stack.add(instruction);
3229 }
3230
3204 void handleForeignJsCallInIsolate(Send node) { 3231 void handleForeignJsCallInIsolate(Send node) {
3205 Link<Node> link = node.arguments; 3232 Link<Node> link = node.arguments;
3206 if (!compiler.hasIsolateSupport()) { 3233 if (!compiler.hasIsolateSupport()) {
3207 // If the isolate library is not used, we just invoke the 3234 // If the isolate library is not used, we just invoke the
3208 // closure. 3235 // closure.
3209 visit(link.tail.head); 3236 visit(link.tail.head);
3210 Selector selector = new Selector.callClosure(0); 3237 Selector selector = new Selector.callClosure(0);
3211 push(new HInvokeClosure(selector, 3238 push(new HInvokeClosure(selector,
3212 <HInstruction>[pop()], 3239 <HInstruction>[pop()],
3213 backend.dynamicType)); 3240 backend.dynamicType));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3363 } else if (name == 'JS_IS_INDEXABLE_FIELD_NAME') { 3390 } else if (name == 'JS_IS_INDEXABLE_FIELD_NAME') {
3364 Element element = compiler.findHelper( 3391 Element element = compiler.findHelper(
3365 'JavaScriptIndexingBehavior'); 3392 'JavaScriptIndexingBehavior');
3366 stack.add(addConstantString(node, backend.namer.operatorIs(element))); 3393 stack.add(addConstantString(node, backend.namer.operatorIs(element)));
3367 } else if (name == 'JS_CURRENT_ISOLATE') { 3394 } else if (name == 'JS_CURRENT_ISOLATE') {
3368 handleForeignJsCurrentIsolate(node); 3395 handleForeignJsCurrentIsolate(node);
3369 } else if (name == 'JS_GET_NAME') { 3396 } else if (name == 'JS_GET_NAME') {
3370 handleForeignJsGetName(node); 3397 handleForeignJsGetName(node);
3371 } else if (name == 'JS_EFFECT') { 3398 } else if (name == 'JS_EFFECT') {
3372 stack.add(graph.addConstantNull(compiler)); 3399 stack.add(graph.addConstantNull(compiler));
3400 } else if (name == 'JS_INTERCEPTOR_CONSTANT') {
3401 handleJsInterceptorConstant(node);
3373 } else { 3402 } else {
3374 throw "Unknown foreign: ${selector}"; 3403 throw "Unknown foreign: ${selector}";
3375 } 3404 }
3376 } 3405 }
3377 3406
3378 generateSuperNoSuchMethodSend(Send node, 3407 generateSuperNoSuchMethodSend(Send node,
3379 Selector selector, 3408 Selector selector,
3380 List<HInstruction> arguments) { 3409 List<HInstruction> arguments) {
3381 String name = selector.name; 3410 String name = selector.name;
3382 3411
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after
5619 new HSubGraphBlockInformation(elseBranch.graph)); 5648 new HSubGraphBlockInformation(elseBranch.graph));
5620 5649
5621 HBasicBlock conditionStartBlock = conditionBranch.block; 5650 HBasicBlock conditionStartBlock = conditionBranch.block;
5622 conditionStartBlock.setBlockFlow(info, joinBlock); 5651 conditionStartBlock.setBlockFlow(info, joinBlock);
5623 SubGraph conditionGraph = conditionBranch.graph; 5652 SubGraph conditionGraph = conditionBranch.graph;
5624 HIf branch = conditionGraph.end.last; 5653 HIf branch = conditionGraph.end.last;
5625 assert(branch is HIf); 5654 assert(branch is HIf);
5626 branch.blockInformation = conditionStartBlock.blockFlow; 5655 branch.blockInformation = conditionStartBlock.blockFlow;
5627 } 5656 }
5628 } 5657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698