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

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

Issue 10119010: Start propagating non-primitive types in the backend, and fold instructions that know about the typ… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 Element getTraceFromException() { 101 Element getTraceFromException() {
102 return compiler.findHelper(const SourceString('getTraceFromException')); 102 return compiler.findHelper(const SourceString('getTraceFromException'));
103 } 103 }
104 104
105 Element getEqualsInterceptor() { 105 Element getEqualsInterceptor() {
106 return compiler.findHelper(const SourceString('eq')); 106 return compiler.findHelper(const SourceString('eq'));
107 } 107 }
108 108
109 Element getTripleEqualsInterceptor() {
110 return compiler.findHelper(const SourceString('eqq'));
111 }
112
109 Element getMapMaker() { 113 Element getMapMaker() {
110 return compiler.findHelper(const SourceString('makeLiteralMap')); 114 return compiler.findHelper(const SourceString('makeLiteralMap'));
111 } 115 }
112 } 116 }
113 117
114 class SsaBuilderTask extends CompilerTask { 118 class SsaBuilderTask extends CompilerTask {
115 final Interceptors interceptors; 119 final Interceptors interceptors;
116 final Map<Node, ClosureData> closureDataCache; 120 final Map<Node, ClosureData> closureDataCache;
117 121
118 String get name() => 'SSA builder'; 122 String get name() => 'SSA builder';
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 inputs.add(target); 2144 inputs.add(target);
2141 if (element.kind == ElementKind.FUNCTION || 2145 if (element.kind == ElementKind.FUNCTION ||
2142 element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { 2146 element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) {
2143 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, 2147 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
2144 element, inputs); 2148 element, inputs);
2145 if (!succeeded) { 2149 if (!succeeded) {
2146 // TODO(ngeoffray): Match the VM behavior and throw an 2150 // TODO(ngeoffray): Match the VM behavior and throw an
2147 // exception at runtime. 2151 // exception at runtime.
2148 compiler.cancel('Unimplemented non-matching static call', node: node); 2152 compiler.cancel('Unimplemented non-matching static call', node: node);
2149 } 2153 }
2150 push(new HInvokeStatic(selector, inputs)); 2154 HType type = HType.UNKNOWN;
2155 if (element.isGenerativeConstructor()) {
2156 ClassElement cls = element.enclosingElement;
2157 type = new HNonPrimitiveType(cls.type);
2158 } else if (element.isFactoryConstructor()
2159 && element === compiler.listClass) {
2160 type = HType.MUTABLE_ARRAY;
2161 }
2162 push(new HInvokeStatic(selector, inputs, type));
2151 } else { 2163 } else {
2152 if (element.kind == ElementKind.GETTER) { 2164 if (element.kind == ElementKind.GETTER) {
2153 target = new HInvokeStatic(Selector.GETTER, inputs); 2165 target = new HInvokeStatic(Selector.GETTER, inputs);
2154 add(target); 2166 add(target);
2155 inputs = <HInstruction>[target]; 2167 inputs = <HInstruction>[target];
2156 } 2168 }
2157 addDynamicSendArgumentsToList(node, inputs); 2169 addDynamicSendArgumentsToList(node, inputs);
2158 push(new HInvokeClosure(selector, inputs)); 2170 push(new HInvokeClosure(selector, inputs));
2159 } 2171 }
2160 } 2172 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 link = link.tail) { 2661 link = link.tail) {
2650 visit(link.head); 2662 visit(link.head);
2651 inputs.addLast(pop()); 2663 inputs.addLast(pop());
2652 inputs.addLast(pop()); 2664 inputs.addLast(pop());
2653 } 2665 }
2654 HLiteralList keyValuePairs = new HLiteralList(inputs); 2666 HLiteralList keyValuePairs = new HLiteralList(inputs);
2655 HStatic mapMaker = new HStatic(interceptors.getMapMaker()); 2667 HStatic mapMaker = new HStatic(interceptors.getMapMaker());
2656 add(keyValuePairs); 2668 add(keyValuePairs);
2657 add(mapMaker); 2669 add(mapMaker);
2658 inputs = <HInstruction>[mapMaker, keyValuePairs]; 2670 inputs = <HInstruction>[mapMaker, keyValuePairs];
2659 push(new HInvokeStatic(Selector.INVOCATION_1, inputs)); 2671 // TODO(ngeoffray): give the concrete type of our map literal.
2672 push(new HInvokeStatic(Selector.INVOCATION_1, inputs, HType.UNKNOWN));
2660 } 2673 }
2661 2674
2662 visitLiteralMapEntry(LiteralMapEntry node) { 2675 visitLiteralMapEntry(LiteralMapEntry node) {
2663 visit(node.value); 2676 visit(node.value);
2664 visit(node.key); 2677 visit(node.key);
2665 } 2678 }
2666 2679
2667 visitNamedArgument(NamedArgument node) { 2680 visitNamedArgument(NamedArgument node) {
2668 visit(node.expression); 2681 visit(node.expression);
2669 } 2682 }
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 false, 3107 false,
3095 <HInstruction>[target, input])); 3108 <HInstruction>[target, input]));
3096 return builder.pop(); 3109 return builder.pop();
3097 } 3110 }
3098 3111
3099 HInstruction result() { 3112 HInstruction result() {
3100 flushLiterals(); 3113 flushLiterals();
3101 return prefix; 3114 return prefix;
3102 } 3115 }
3103 } 3116 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/operations.dart ('k') | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698