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

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

Issue 13094013: Fix bug 9239 by always evaluating the receiver before the value in an instance SendSet. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/getter_setter_order_test.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) 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 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 instruction.inputs.add(value); 2433 instruction.inputs.add(value);
2434 addWithPosition(instruction, send); 2434 addWithPosition(instruction, send);
2435 } else { 2435 } else {
2436 addWithPosition( 2436 addWithPosition(
2437 new HInvokeDynamicSetter(selector, null, receiver, value, !hasSetter), 2437 new HInvokeDynamicSetter(selector, null, receiver, value, !hasSetter),
2438 send); 2438 send);
2439 } 2439 }
2440 stack.add(value); 2440 stack.add(value);
2441 } 2441 }
2442 2442
2443 void generateSetter(SendSet send, Element element, HInstruction value) { 2443 void generateNonInstanceSetter(SendSet send,
2444 Element element,
2445 HInstruction value) {
2446 assert(!Elements.isInstanceSend(send, elements));
2444 if (Elements.isStaticOrTopLevelField(element)) { 2447 if (Elements.isStaticOrTopLevelField(element)) {
2445 if (element.isSetter()) { 2448 if (element.isSetter()) {
2446 HStatic target = new HStatic(element); 2449 HStatic target = new HStatic(element);
2447 add(target); 2450 add(target);
2448 addWithPosition( 2451 addWithPosition(
2449 new HInvokeStatic(<HInstruction>[target, value], HType.UNKNOWN), 2452 new HInvokeStatic(<HInstruction>[target, value], HType.UNKNOWN),
2450 send); 2453 send);
2451 } else { 2454 } else {
2452 value = potentiallyCheckType(value, element.computeType(compiler)); 2455 value = potentiallyCheckType(value, element.computeType(compiler));
2453 addWithPosition(new HStaticStore(element, value), send); 2456 addWithPosition(new HStaticStore(element, value), send);
2454 } 2457 }
2455 stack.add(value); 2458 stack.add(value);
2456 } else if (element == null || Elements.isInstanceField(element)) {
2457 HInstruction receiver = generateInstanceSendReceiver(send);
2458 generateInstanceSetterWithCompiledReceiver(send, receiver, value);
2459 } else if (Elements.isErroneousElement(element)) { 2459 } else if (Elements.isErroneousElement(element)) {
2460 // An erroneous element indicates an unresolved static setter. 2460 // An erroneous element indicates an unresolved static setter.
2461 generateThrowNoSuchMethod(send, 2461 generateThrowNoSuchMethod(send,
2462 getTargetName(element, 'set'), 2462 getTargetName(element, 'set'),
2463 argumentNodes: send.arguments); 2463 argumentNodes: send.arguments);
2464 } else { 2464 } else {
2465 stack.add(value); 2465 stack.add(value);
2466 // If the value does not already have a name, give it here. 2466 // If the value does not already have a name, give it here.
2467 if (value.sourceElement == null) { 2467 if (value.sourceElement == null) {
2468 value.sourceElement = element; 2468 value.sourceElement = element;
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 3708
3709 if (node.isPostfix) { 3709 if (node.isPostfix) {
3710 stack.add(getterInstruction); 3710 stack.add(getterInstruction);
3711 } else { 3711 } else {
3712 stack.add(value); 3712 stack.add(value);
3713 } 3713 }
3714 } 3714 }
3715 } else if (const SourceString("=") == op.source) { 3715 } else if (const SourceString("=") == op.source) {
3716 Link<Node> link = node.arguments; 3716 Link<Node> link = node.arguments;
3717 assert(!link.isEmpty && link.tail.isEmpty); 3717 assert(!link.isEmpty && link.tail.isEmpty);
3718 visit(link.head); 3718 if (Elements.isInstanceSend(node, elements)) {
3719 HInstruction value = pop(); 3719 HInstruction receiver = generateInstanceSendReceiver(node);
3720 generateSetter(node, element, value); 3720 visit(link.head);
3721 generateInstanceSetterWithCompiledReceiver(node, receiver, pop());
3722 } else {
3723 visit(link.head);
3724 generateNonInstanceSetter(node, element, pop());
3725 }
3721 } else if (identical(op.source.stringValue, "is")) { 3726 } else if (identical(op.source.stringValue, "is")) {
3722 compiler.internalError("is-operator as SendSet", node: op); 3727 compiler.internalError("is-operator as SendSet", node: op);
3723 } else { 3728 } else {
3724 assert(const SourceString("++") == op.source || 3729 assert(const SourceString("++") == op.source ||
3725 const SourceString("--") == op.source || 3730 const SourceString("--") == op.source ||
3726 node.assignmentOperator.source.stringValue.endsWith("=")); 3731 node.assignmentOperator.source.stringValue.endsWith("="));
3727 3732
3728 // [receiver] is only used if the node is an instance send. 3733 // [receiver] is only used if the node is an instance send.
3729 HInstruction receiver = null; 3734 HInstruction receiver = null;
3730 if (Elements.isInstanceSend(node, elements)) { 3735 if (Elements.isInstanceSend(node, elements)) {
3731 receiver = generateInstanceSendReceiver(node); 3736 receiver = generateInstanceSendReceiver(node);
3732 generateInstanceGetterWithCompiledReceiver( 3737 generateInstanceGetterWithCompiledReceiver(
3733 node, elements.getGetterSelectorInComplexSendSet(node), receiver); 3738 node, elements.getGetterSelectorInComplexSendSet(node), receiver);
3734 } else { 3739 } else {
3735 generateGetter(node, elements[node.selector]); 3740 generateGetter(node, elements[node.selector]);
3736 } 3741 }
3737 HInstruction getterInstruction = pop(); 3742 HInstruction getterInstruction = pop();
3738 handleComplexOperatorSend(node, getterInstruction, node.arguments); 3743 handleComplexOperatorSend(node, getterInstruction, node.arguments);
3739 HInstruction value = pop(); 3744 HInstruction value = pop();
3740 assert(value != null); 3745 assert(value != null);
3741 if (Elements.isInstanceSend(node, elements)) { 3746 if (Elements.isInstanceSend(node, elements)) {
3742 assert(receiver != null); 3747 assert(receiver != null);
3743 generateInstanceSetterWithCompiledReceiver(node, receiver, value); 3748 generateInstanceSetterWithCompiledReceiver(node, receiver, value);
3744 } else { 3749 } else {
3745 assert(receiver == null); 3750 assert(receiver == null);
3746 generateSetter(node, element, value); 3751 generateNonInstanceSetter(node, element, value);
3747 } 3752 }
3748 if (node.isPostfix) { 3753 if (node.isPostfix) {
3749 pop(); 3754 pop();
3750 stack.add(getterInstruction); 3755 stack.add(getterInstruction);
3751 } 3756 }
3752 } 3757 }
3753 } 3758 }
3754 3759
3755 void visitLiteralInt(LiteralInt node) { 3760 void visitLiteralInt(LiteralInt node) {
3756 stack.add(graph.addConstantInt(node.value, constantSystem)); 3761 stack.add(graph.addConstantInt(node.value, constantSystem));
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
5097 new HSubGraphBlockInformation(elseBranch.graph)); 5102 new HSubGraphBlockInformation(elseBranch.graph));
5098 5103
5099 HBasicBlock conditionStartBlock = conditionBranch.block; 5104 HBasicBlock conditionStartBlock = conditionBranch.block;
5100 conditionStartBlock.setBlockFlow(info, joinBlock); 5105 conditionStartBlock.setBlockFlow(info, joinBlock);
5101 SubGraph conditionGraph = conditionBranch.graph; 5106 SubGraph conditionGraph = conditionBranch.graph;
5102 HIf branch = conditionGraph.end.last; 5107 HIf branch = conditionGraph.end.last;
5103 assert(branch is HIf); 5108 assert(branch is HIf);
5104 branch.blockInformation = conditionStartBlock.blockFlow; 5109 branch.blockInformation = conditionStartBlock.blockFlow;
5105 } 5110 }
5106 } 5111 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/getter_setter_order_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698