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

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 3166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 argument, MessageKind.GENERIC, 3177 argument, MessageKind.GENERIC,
3178 {'text': 'Error: Expected a literal string.'}); 3178 {'text': 'Error: Expected a literal string.'});
3179 } 3179 }
3180 stack.add( 3180 stack.add(
3181 addConstantString( 3181 addConstantString(
3182 argument, 3182 argument,
3183 backend.namer.getNameForJsGetName( 3183 backend.namer.getNameForJsGetName(
3184 argument, string.dartString.slowToString()))); 3184 argument, string.dartString.slowToString())));
3185 } 3185 }
3186 3186
3187 void handleJsInterceptorConstant(Send node) {
3188 void bad(Node node) {
3189 compiler.reportError(node,
ahe 2013/10/29 15:23:07 You can use reportFatalError to abort immediately.
3190 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
ahe 2013/10/29 15:23:07 I'd just use MessageKind.GENERIC for this. Users s
3191 stack.add(graph.addConstantNull(compiler));
3192 }
3193 if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) {
3194 return bad(node.arguments);
3195 }
3196 Node argument = node.arguments.head;
3197 // argument must be a TypeConstant.
3198 visit(argument);
3199 HInstruction argumentInstruction = pop();
3200 if (argumentInstruction is! HConstant) {
3201 return bad(argument);
3202 }
3203 Constant argumentConstant = argumentInstruction.constant;
3204 if (argumentConstant is! TypeConstant) {
3205 return bad(argument);
3206 }
3207
3208 Constant constant =
3209 new InterceptorConstant(argumentConstant.representedType);
3210 HInstruction instruction = graph.addConstant(constant, compiler);
3211 stack.add(instruction);
3212 }
3213
3187 void handleForeignJsCallInIsolate(Send node) { 3214 void handleForeignJsCallInIsolate(Send node) {
3188 Link<Node> link = node.arguments; 3215 Link<Node> link = node.arguments;
3189 if (!compiler.hasIsolateSupport()) { 3216 if (!compiler.hasIsolateSupport()) {
3190 // If the isolate library is not used, we just invoke the 3217 // If the isolate library is not used, we just invoke the
3191 // closure. 3218 // closure.
3192 visit(link.tail.head); 3219 visit(link.tail.head);
3193 Selector selector = new Selector.callClosure(0); 3220 Selector selector = new Selector.callClosure(0);
3194 push(new HInvokeClosure(selector, <HInstruction>[pop()])); 3221 push(new HInvokeClosure(selector, <HInstruction>[pop()]));
3195 } else { 3222 } else {
3196 // Call a helper method from the isolate library. 3223 // Call a helper method from the isolate library.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3344 } else if (name == 'JS_IS_INDEXABLE_FIELD_NAME') { 3371 } else if (name == 'JS_IS_INDEXABLE_FIELD_NAME') {
3345 Element element = compiler.findHelper( 3372 Element element = compiler.findHelper(
3346 'JavaScriptIndexingBehavior'); 3373 'JavaScriptIndexingBehavior');
3347 stack.add(addConstantString(node, backend.namer.operatorIs(element))); 3374 stack.add(addConstantString(node, backend.namer.operatorIs(element)));
3348 } else if (name == 'JS_CURRENT_ISOLATE') { 3375 } else if (name == 'JS_CURRENT_ISOLATE') {
3349 handleForeignJsCurrentIsolate(node); 3376 handleForeignJsCurrentIsolate(node);
3350 } else if (name == 'JS_GET_NAME') { 3377 } else if (name == 'JS_GET_NAME') {
3351 handleForeignJsGetName(node); 3378 handleForeignJsGetName(node);
3352 } else if (name == 'JS_EFFECT') { 3379 } else if (name == 'JS_EFFECT') {
3353 stack.add(graph.addConstantNull(compiler)); 3380 stack.add(graph.addConstantNull(compiler));
3381 } else if (name == 'JS_INTERCEPTOR_CONSTANT') {
3382 handleJsInterceptorConstant(node);
3354 } else { 3383 } else {
3355 throw "Unknown foreign: ${selector}"; 3384 throw "Unknown foreign: ${selector}";
3356 } 3385 }
3357 } 3386 }
3358 3387
3359 generateSuperNoSuchMethodSend(Send node, 3388 generateSuperNoSuchMethodSend(Send node,
3360 Selector selector, 3389 Selector selector,
3361 List<HInstruction> arguments) { 3390 List<HInstruction> arguments) {
3362 String name = selector.name; 3391 String name = selector.name;
3363 3392
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5588 new HSubGraphBlockInformation(elseBranch.graph)); 5617 new HSubGraphBlockInformation(elseBranch.graph));
5589 5618
5590 HBasicBlock conditionStartBlock = conditionBranch.block; 5619 HBasicBlock conditionStartBlock = conditionBranch.block;
5591 conditionStartBlock.setBlockFlow(info, joinBlock); 5620 conditionStartBlock.setBlockFlow(info, joinBlock);
5592 SubGraph conditionGraph = conditionBranch.graph; 5621 SubGraph conditionGraph = conditionBranch.graph;
5593 HIf branch = conditionGraph.end.last; 5622 HIf branch = conditionGraph.end.last;
5594 assert(branch is HIf); 5623 assert(branch is HIf);
5595 branch.blockInformation = conditionStartBlock.blockFlow; 5624 branch.blockInformation = conditionStartBlock.blockFlow;
5596 } 5625 }
5597 } 5626 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698