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

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

Issue 11348316: Move the handling of operator[] into the new interceptors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 2689
2690 visitOperatorSend(node) { 2690 visitOperatorSend(node) {
2691 assert(node.selector is Operator); 2691 assert(node.selector is Operator);
2692 if (!methodInterceptionEnabled) { 2692 if (!methodInterceptionEnabled) {
2693 visitDynamicSend(node); 2693 visitDynamicSend(node);
2694 return; 2694 return;
2695 } 2695 }
2696 2696
2697 Operator op = node.selector; 2697 Operator op = node.selector;
2698 if (const SourceString("[]") == op.source) { 2698 if (const SourceString("[]") == op.source) {
2699 HStatic target = new HStatic(interceptors.getIndexInterceptor()); 2699 visitDynamicSend(node);
2700 add(target);
2701 visit(node.receiver);
2702 HInstruction receiver = pop();
2703 visit(node.argumentsNode);
2704 HInstruction index = pop();
2705 push(new HIndex(target, receiver, index));
2706 } else if (const SourceString("&&") == op.source || 2700 } else if (const SourceString("&&") == op.source ||
2707 const SourceString("||") == op.source) { 2701 const SourceString("||") == op.source) {
2708 visitLogicalAndOr(node, op); 2702 visitLogicalAndOr(node, op);
2709 } else if (const SourceString("!") == op.source) { 2703 } else if (const SourceString("!") == op.source) {
2710 visitLogicalNot(node); 2704 visitLogicalNot(node);
2711 } else if (node.argumentsNode is Prefix) { 2705 } else if (node.argumentsNode is Prefix) {
2712 visitUnary(node, op); 2706 visitUnary(node, op);
2713 } else if (const SourceString("is") == op.source) { 2707 } else if (const SourceString("is") == op.source) {
2714 visit(node.receiver); 2708 visit(node.receiver);
2715 HInstruction expression = pop(); 2709 HInstruction expression = pop();
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
3544 String reasons = fetchReasonsFromMalformedType(type); 3538 String reasons = fetchReasonsFromMalformedType(type);
3545 // TODO(johnniwinther): Change to resemble type errors from bounds check 3539 // TODO(johnniwinther): Change to resemble type errors from bounds check
3546 // on type arguments. 3540 // on type arguments.
3547 generateRuntimeError(node, '$type is malformed: $reasons'); 3541 generateRuntimeError(node, '$type is malformed: $reasons');
3548 } else { 3542 } else {
3549 visitNewSend(node.send, type); 3543 visitNewSend(node.send, type);
3550 } 3544 }
3551 } 3545 }
3552 } 3546 }
3553 3547
3548 HInvokeDynamicMethod buildInvokeDynamicWithOneArgument(
3549 Node node, Selector selector, HInstruction receiver, HInstruction arg0) {
3550 Set<ClassElement> interceptedClasses =
3551 getInterceptedClassesOn(node, selector);
3552 List<HInstruction> inputs = <HInstruction>[];
3553 if (interceptedClasses != null) {
3554 inputs.add(invokeInterceptor(interceptedClasses, receiver, node));
3555 }
3556 inputs.add(receiver);
3557 inputs.add(arg0);
3558 return new HInvokeDynamicMethod(selector, inputs);
3559 }
3560
3554 visitSendSet(SendSet node) { 3561 visitSendSet(SendSet node) {
3555 Element element = elements[node]; 3562 Element element = elements[node];
3556 if (!Elements.isUnresolved(element) && element.impliesType()) { 3563 if (!Elements.isUnresolved(element) && element.impliesType()) {
3557 Identifier selector = node.selector; 3564 Identifier selector = node.selector;
3558 generateThrowNoSuchMethod(node, selector.source.slowToString(), 3565 generateThrowNoSuchMethod(node, selector.source.slowToString(),
3559 argumentNodes: node.arguments); 3566 argumentNodes: node.arguments);
3560 return; 3567 return;
3561 } 3568 }
3562 Operator op = node.assignmentOperator; 3569 Operator op = node.assignmentOperator;
3563 if (node.isSuperCall) { 3570 if (node.isSuperCall) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3595 // Compound assignments are considered as being prefix. 3602 // Compound assignments are considered as being prefix.
3596 bool isPrefix = !node.isPostfix; 3603 bool isPrefix = !node.isPostfix;
3597 Element getter = elements[node.selector]; 3604 Element getter = elements[node.selector];
3598 if (isCompoundAssignment) { 3605 if (isCompoundAssignment) {
3599 value = pop(); 3606 value = pop();
3600 index = pop(); 3607 index = pop();
3601 } else { 3608 } else {
3602 index = pop(); 3609 index = pop();
3603 value = graph.addConstantInt(1, constantSystem); 3610 value = graph.addConstantInt(1, constantSystem);
3604 } 3611 }
3605 HStatic indexMethod = new HStatic(interceptors.getIndexInterceptor()); 3612
3606 add(indexMethod); 3613 HInvokeDynamicMethod left = buildInvokeDynamicWithOneArgument(
3607 HInstruction left = new HIndex(indexMethod, receiver, index); 3614 node, new Selector.index(), receiver, index);
3608 add(left); 3615 add(left);
3609 Element opElement = elements[op]; 3616 Element opElement = elements[op];
3610 visitBinary(left, op, value); 3617 visitBinary(left, op, value);
3611 value = pop(); 3618 value = pop();
3612 HInstruction assign = new HIndexAssign( 3619 HInstruction assign = new HIndexAssign(
3613 target, receiver, index, value); 3620 target, receiver, index, value);
3614 add(assign); 3621 add(assign);
3615 if (isPrefix) { 3622 if (isPrefix) {
3616 stack.add(value); 3623 stack.add(value);
3617 } else { 3624 } else {
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
4991 new HSubGraphBlockInformation(elseBranch.graph)); 4998 new HSubGraphBlockInformation(elseBranch.graph));
4992 4999
4993 HBasicBlock conditionStartBlock = conditionBranch.block; 5000 HBasicBlock conditionStartBlock = conditionBranch.block;
4994 conditionStartBlock.setBlockFlow(info, joinBlock); 5001 conditionStartBlock.setBlockFlow(info, joinBlock);
4995 SubGraph conditionGraph = conditionBranch.graph; 5002 SubGraph conditionGraph = conditionBranch.graph;
4996 HIf branch = conditionGraph.end.last; 5003 HIf branch = conditionGraph.end.last;
4997 assert(branch is HIf); 5004 assert(branch is HIf);
4998 branch.blockInformation = conditionStartBlock.blockFlow; 5005 branch.blockInformation = conditionStartBlock.blockFlow;
4999 } 5006 }
5000 } 5007 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698