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

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

Issue 11412105: - Move length getter and setter interceptors to the new interceptor scheme. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 add(target); 2447 add(target);
2448 instruction = new HInvokeStatic(<HInstruction>[target, receiver]); 2448 instruction = new HInvokeStatic(<HInstruction>[target, receiver]);
2449 add(instruction); 2449 add(instruction);
2450 } 2450 }
2451 instruction = new HInvokeDynamicGetter( 2451 instruction = new HInvokeDynamicGetter(
2452 selector, null, instruction, !hasGetter); 2452 selector, null, instruction, !hasGetter);
2453 // Add the receiver as an argument to the getter call on the 2453 // Add the receiver as an argument to the getter call on the
2454 // interceptor. 2454 // interceptor.
2455 instruction.inputs.add(receiver); 2455 instruction.inputs.add(receiver);
2456 pushWithPosition(instruction, send); 2456 pushWithPosition(instruction, send);
2457 } else if (elements[send] == null && interceptor != null) {
2458 // Use the old, deprecated interceptor mechanism.
2459 HStatic target = new HStatic(interceptor);
2460 add(target);
2461 List<HInstruction> inputs = <HInstruction>[target, receiver];
2462 pushWithPosition(new HInvokeInterceptor(selector, inputs, !hasGetter),
2463 send);
2464 } else { 2457 } else {
2465 pushWithPosition( 2458 pushWithPosition(
2466 new HInvokeDynamicGetter(selector, null, receiver, !hasGetter), send); 2459 new HInvokeDynamicGetter(selector, null, receiver, !hasGetter), send);
2467 } 2460 }
2468 } 2461 }
2469 2462
2470 void generateGetter(Send send, Element element) { 2463 void generateGetter(Send send, Element element) {
2471 if (Elements.isStaticOrTopLevelField(element)) { 2464 if (Elements.isStaticOrTopLevelField(element)) {
2472 Constant value; 2465 Constant value;
2473 if (element.isField() && !element.isAssignable()) { 2466 if (element.isField() && !element.isAssignable()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 void generateInstanceSetterWithCompiledReceiver(Send send, 2502 void generateInstanceSetterWithCompiledReceiver(Send send,
2510 HInstruction receiver, 2503 HInstruction receiver,
2511 HInstruction value) { 2504 HInstruction value) {
2512 assert(Elements.isInstanceSend(send, elements)); 2505 assert(Elements.isInstanceSend(send, elements));
2513 Selector selector = elements.getSelector(send); 2506 Selector selector = elements.getSelector(send);
2514 assert(selector.isSetter()); 2507 assert(selector.isSetter());
2515 SourceString setterName = selector.name; 2508 SourceString setterName = selector.name;
2516 Element interceptor = getInterceptor(send, selector); 2509 Element interceptor = getInterceptor(send, selector);
2517 bool hasSetter = compiler.world.hasAnyUserDefinedSetter(selector); 2510 bool hasSetter = compiler.world.hasAnyUserDefinedSetter(selector);
2518 if (interceptor != null && interceptor == backend.getInterceptorMethod) { 2511 if (interceptor != null && interceptor == backend.getInterceptorMethod) {
2519 compiler.internalError( 2512 // If we're using an interceptor class, emit a call to the
2520 'Unimplemented intercepted setter call with interceptor classes'); 2513 // interceptor method and then the actual dynamic call on the
2521 } else if (interceptor != null && elements[send] == null) { 2514 // interceptor object.
2522 HStatic target = new HStatic(interceptor); 2515 HInstruction instruction;
2523 add(target); 2516 if (backend.isInterceptorClass(currentElement.getEnclosingClass())
2524 List<HInstruction> inputs = <HInstruction>[target, receiver, value]; 2517 && send.receiver == null) {
2525 addWithPosition(new HInvokeInterceptor(selector, inputs), send); 2518 instruction = thisInstruction;
2519 } else {
2520 HStatic target = new HStatic(interceptor);
2521 add(target);
2522 instruction = new HInvokeStatic(<HInstruction>[target, receiver]);
2523 add(instruction);
2524 }
2525 instruction = new HInvokeDynamicSetter(
2526 selector, null, instruction, receiver, !hasSetter);
2527 // Add the value as an argument to the setter call on the
2528 // interceptor.
2529 instruction.inputs.add(value);
2530 addWithPosition(instruction, send);
2526 } else { 2531 } else {
2527 addWithPosition( 2532 addWithPosition(
2528 new HInvokeDynamicSetter(selector, null, receiver, value, !hasSetter), 2533 new HInvokeDynamicSetter(selector, null, receiver, value, !hasSetter),
2529 send); 2534 send);
2530 } 2535 }
2531 stack.add(value); 2536 stack.add(value);
2532 } 2537 }
2533 2538
2534 void generateSetter(SendSet send, Element element, HInstruction value) { 2539 void generateSetter(SendSet send, Element element, HInstruction value) {
2535 if (Elements.isStaticOrTopLevelField(element)) { 2540 if (Elements.isStaticOrTopLevelField(element)) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 add(instruction); 2806 add(instruction);
2802 inputs.add(instruction); 2807 inputs.add(instruction);
2803 inputs.add(receiver); 2808 inputs.add(receiver);
2804 } 2809 }
2805 addDynamicSendArgumentsToList(node, inputs); 2810 addDynamicSendArgumentsToList(node, inputs);
2806 // The first entry in the inputs list is the interceptor. The 2811 // The first entry in the inputs list is the interceptor. The
2807 // second is the receiver, and the others are the arguments. 2812 // second is the receiver, and the others are the arguments.
2808 HInstruction instruction = new HInvokeDynamicMethod(selector, inputs); 2813 HInstruction instruction = new HInvokeDynamicMethod(selector, inputs);
2809 pushWithPosition(instruction, node); 2814 pushWithPosition(instruction, node);
2810 return; 2815 return;
2811 } else if (elements[node] == null) {
2812 HStatic target = new HStatic(interceptor);
2813 add(target);
2814 inputs.add(target);
2815 visit(node.receiver);
2816 inputs.add(pop());
2817 addGenericSendArgumentsToList(node.arguments, inputs);
2818 pushWithPosition(new HInvokeInterceptor(selector, inputs), node);
2819 return;
2820 } 2816 }
2821 } 2817 }
2822 2818
2823 Element element = elements[node]; 2819 Element element = elements[node];
2824 if (element != null && compiler.world.hasNoOverridingMember(element)) { 2820 if (element != null && compiler.world.hasNoOverridingMember(element)) {
2825 if (tryInlineMethod(element, selector, node.arguments)) { 2821 if (tryInlineMethod(element, selector, node.arguments)) {
2826 return; 2822 return;
2827 } 2823 }
2828 } 2824 }
2829 2825
(...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after
4961 new HSubGraphBlockInformation(elseBranch.graph)); 4957 new HSubGraphBlockInformation(elseBranch.graph));
4962 4958
4963 HBasicBlock conditionStartBlock = conditionBranch.block; 4959 HBasicBlock conditionStartBlock = conditionBranch.block;
4964 conditionStartBlock.setBlockFlow(info, joinBlock); 4960 conditionStartBlock.setBlockFlow(info, joinBlock);
4965 SubGraph conditionGraph = conditionBranch.graph; 4961 SubGraph conditionGraph = conditionBranch.graph;
4966 HIf branch = conditionGraph.end.last; 4962 HIf branch = conditionGraph.end.last;
4967 assert(branch is HIf); 4963 assert(branch is HIf);
4968 branch.blockInformation = conditionStartBlock.blockFlow; 4964 branch.blockInformation = conditionStartBlock.blockFlow;
4969 } 4965 }
4970 } 4966 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698