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

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

Issue 10310037: Fix regression on constant folding an interceptor into a dynamic invocation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 | lib/compiler/implementation/ssa/nodes.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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 SourceString getterName = send.selector.asIdentifier().source; 1750 SourceString getterName = send.selector.asIdentifier().source;
1751 Selector selector = elements.getSelector(send); 1751 Selector selector = elements.getSelector(send);
1752 Element staticInterceptor = null; 1752 Element staticInterceptor = null;
1753 if (methodInterceptionEnabled) { 1753 if (methodInterceptionEnabled) {
1754 staticInterceptor = interceptors.getStaticGetInterceptor(getterName); 1754 staticInterceptor = interceptors.getStaticGetInterceptor(getterName);
1755 } 1755 }
1756 if (staticInterceptor != null) { 1756 if (staticInterceptor != null) {
1757 HStatic target = new HStatic(staticInterceptor); 1757 HStatic target = new HStatic(staticInterceptor);
1758 add(target); 1758 add(target);
1759 List<HInstruction> inputs = <HInstruction>[target, receiver]; 1759 List<HInstruction> inputs = <HInstruction>[target, receiver];
1760 push(new HInvokeInterceptor(selector, getterName, true, inputs)); 1760 push(new HInvokeInterceptor(selector, getterName, inputs, getter: true));
1761 } else { 1761 } else {
1762 push(new HInvokeDynamicGetter(selector, null, getterName, receiver)); 1762 push(new HInvokeDynamicGetter(selector, null, getterName, receiver));
1763 } 1763 }
1764 } 1764 }
1765 1765
1766 void generateGetter(Send send, Element element) { 1766 void generateGetter(Send send, Element element) {
1767 if (Elements.isStaticOrTopLevelField(element)) { 1767 if (Elements.isStaticOrTopLevelField(element)) {
1768 if (element.kind == ElementKind.FIELD && !element.isAssignable()) { 1768 if (element.kind == ElementKind.FIELD && !element.isAssignable()) {
1769 // A static final. Get its constant value and inline it. 1769 // A static final. Get its constant value and inline it.
1770 Constant value = compiler.constantHandler.compileVariable(element); 1770 Constant value = compiler.constantHandler.compileVariable(element);
(...skipping 23 matching lines...) Expand all
1794 SourceString dartSetterName = send.selector.asIdentifier().source; 1794 SourceString dartSetterName = send.selector.asIdentifier().source;
1795 Selector selector = elements.getSelector(send); 1795 Selector selector = elements.getSelector(send);
1796 Element staticInterceptor = null; 1796 Element staticInterceptor = null;
1797 if (methodInterceptionEnabled) { 1797 if (methodInterceptionEnabled) {
1798 staticInterceptor = interceptors.getStaticSetInterceptor(dartSetterName); 1798 staticInterceptor = interceptors.getStaticSetInterceptor(dartSetterName);
1799 } 1799 }
1800 if (staticInterceptor != null) { 1800 if (staticInterceptor != null) {
1801 HStatic target = new HStatic(staticInterceptor); 1801 HStatic target = new HStatic(staticInterceptor);
1802 add(target); 1802 add(target);
1803 List<HInstruction> inputs = <HInstruction>[target, receiver, value]; 1803 List<HInstruction> inputs = <HInstruction>[target, receiver, value];
1804 add(new HInvokeInterceptor(selector, dartSetterName, false, inputs)); 1804 add(new HInvokeInterceptor(
1805 selector, dartSetterName, inputs, setter: true));
1805 } else { 1806 } else {
1806 add(new HInvokeDynamicSetter(selector, null, dartSetterName, 1807 add(new HInvokeDynamicSetter(selector, null, dartSetterName,
1807 receiver, value)); 1808 receiver, value));
1808 } 1809 }
1809 stack.add(value); 1810 stack.add(value);
1810 } 1811 }
1811 1812
1812 void generateSetter(SendSet send, Element element, HInstruction value) { 1813 void generateSetter(SendSet send, Element element, HInstruction value) {
1813 if (Elements.isStaticOrTopLevelField(element)) { 1814 if (Elements.isStaticOrTopLevelField(element)) {
1814 Selector selector = elements.getSelector(send); 1815 Selector selector = elements.getSelector(send);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 interceptor = interceptors.getStaticInterceptor(dartMethodName, 2002 interceptor = interceptors.getStaticInterceptor(dartMethodName,
2002 node.argumentCount()); 2003 node.argumentCount());
2003 } 2004 }
2004 if (interceptor != null) { 2005 if (interceptor != null) {
2005 HStatic target = new HStatic(interceptor); 2006 HStatic target = new HStatic(interceptor);
2006 add(target); 2007 add(target);
2007 inputs.add(target); 2008 inputs.add(target);
2008 visit(node.receiver); 2009 visit(node.receiver);
2009 inputs.add(pop()); 2010 inputs.add(pop());
2010 addGenericSendArgumentsToList(node.arguments, inputs); 2011 addGenericSendArgumentsToList(node.arguments, inputs);
2011 push(new HInvokeInterceptor(selector, dartMethodName, false, inputs)); 2012 push(new HInvokeInterceptor(selector, dartMethodName, inputs));
2012 return; 2013 return;
2013 } 2014 }
2014 2015
2015 if (node.receiver === null) { 2016 if (node.receiver === null) {
2016 inputs.add(localsHandler.readThis()); 2017 inputs.add(localsHandler.readThis());
2017 } else { 2018 } else {
2018 visit(node.receiver); 2019 visit(node.receiver);
2019 inputs.add(pop()); 2020 inputs.add(pop());
2020 } 2021 }
2021 2022
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 // The iterator is shared between initializer, condition and body. 2747 // The iterator is shared between initializer, condition and body.
2747 HInstruction iterator; 2748 HInstruction iterator;
2748 void buildInitializer() { 2749 void buildInitializer() {
2749 SourceString iteratorName = const SourceString("iterator"); 2750 SourceString iteratorName = const SourceString("iterator");
2750 Element interceptor = interceptors.getStaticInterceptor(iteratorName, 0); 2751 Element interceptor = interceptors.getStaticInterceptor(iteratorName, 0);
2751 assert(interceptor != null); 2752 assert(interceptor != null);
2752 HStatic target = new HStatic(interceptor); 2753 HStatic target = new HStatic(interceptor);
2753 add(target); 2754 add(target);
2754 visit(node.expression); 2755 visit(node.expression);
2755 List<HInstruction> inputs = <HInstruction>[target, pop()]; 2756 List<HInstruction> inputs = <HInstruction>[target, pop()];
2756 iterator = new HInvokeInterceptor(selector, iteratorName, false, inputs); 2757 iterator = new HInvokeInterceptor(selector, iteratorName, inputs);
2757 add(iterator); 2758 add(iterator);
2758 } 2759 }
2759 HInstruction buildCondition() { 2760 HInstruction buildCondition() {
2760 push(new HInvokeDynamicMethod( 2761 push(new HInvokeDynamicMethod(
2761 selector, const SourceString('hasNext'), <HInstruction>[iterator])); 2762 selector, const SourceString('hasNext'), <HInstruction>[iterator]));
2762 return popBoolified(); 2763 return popBoolified();
2763 } 2764 }
2764 void buildBody() { 2765 void buildBody() {
2765 push(new HInvokeDynamicMethod( 2766 push(new HInvokeDynamicMethod(
2766 selector, const SourceString('next'), <HInstruction>[iterator])); 2767 selector, const SourceString('next'), <HInstruction>[iterator]));
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 <HInstruction>[target, input], 3279 <HInstruction>[target, input],
3279 HType.STRING)); 3280 HType.STRING));
3280 return builder.pop(); 3281 return builder.pop();
3281 } 3282 }
3282 3283
3283 HInstruction result() { 3284 HInstruction result() {
3284 flushLiterals(); 3285 flushLiterals();
3285 return prefix; 3286 return prefix;
3286 } 3287 }
3287 } 3288 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698