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

Side by Side Diff: dart/frog/leg/ssa/builder.dart

Issue 9558005: Implement literal maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 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 | « dart/frog/leg/resolver.dart ('k') | dart/frog/leg/ssa/closure.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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return compiler.findHelper(const SourceString('indexSet')); 86 return compiler.findHelper(const SourceString('indexSet'));
87 } 87 }
88 88
89 Element getEqualsNullInterceptor() { 89 Element getEqualsNullInterceptor() {
90 return compiler.findHelper(const SourceString('eqNull')); 90 return compiler.findHelper(const SourceString('eqNull'));
91 } 91 }
92 92
93 Element getExceptionUnwrapper() { 93 Element getExceptionUnwrapper() {
94 return compiler.findHelper(const SourceString('unwrapException')); 94 return compiler.findHelper(const SourceString('unwrapException'));
95 } 95 }
96
97 Element getMapMaker() {
98 return compiler.findHelper(const SourceString('makeLiteralMap'));
99 }
96 } 100 }
97 101
98 class SsaBuilderTask extends CompilerTask { 102 class SsaBuilderTask extends CompilerTask {
99 SsaBuilderTask(Compiler compiler) 103 SsaBuilderTask(Compiler compiler)
100 : super(compiler), interceptors = new Interceptors(compiler); 104 : super(compiler), interceptors = new Interceptors(compiler);
101 String get name() => 'SSA builder'; 105 String get name() => 'SSA builder';
102 Interceptors interceptors; 106 Interceptors interceptors;
103 107
104 HGraph build(WorkItem work) { 108 HGraph build(WorkItem work) {
105 return measure(() { 109 return measure(() {
(...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 // Mark both entry and exit with the information. You can 2233 // Mark both entry and exit with the information. You can
2230 // tell which one is which by comparing with blockInfo.start/end. 2234 // tell which one is which by comparing with blockInfo.start/end.
2231 // It doesn't matter which merge block we use, they won't be generating 2235 // It doesn't matter which merge block we use, they won't be generating
2232 // any code, so put the end-marker on the last join block. 2236 // any code, so put the end-marker on the last join block.
2233 entryBlock.labeledBlockInformation = blockInfo; 2237 entryBlock.labeledBlockInformation = blockInfo;
2234 current.labeledBlockInformation = blockInfo; 2238 current.labeledBlockInformation = blockInfo;
2235 } 2239 }
2236 } 2240 }
2237 2241
2238 visitLiteralMap(LiteralMap node) { 2242 visitLiteralMap(LiteralMap node) {
2239 generateUnimplemented('literal map not implemented', isExpression: true); 2243 List<HInstruction> inputs = <HInstruction>[];
2244 for (Link<Node> link = node.entries.nodes;
2245 !link.isEmpty();
2246 link = link.tail) {
2247 visit(link.head);
2248 inputs.addLast(pop());
2249 inputs.addLast(pop());
2250 }
2251 HLiteralList keyValuePairs = new HLiteralList(inputs, node.isConst());
2252 HStatic mapMaker = new HStatic(interceptors.getMapMaker());
2253 add(keyValuePairs);
2254 add(mapMaker);
2255 inputs = <HInstruction>[mapMaker, keyValuePairs];
2256 push(new HInvokeStatic(Selector.INVOCATION_1, inputs));
2240 } 2257 }
2241 2258
2242 visitLiteralMapEntry(LiteralMapEntry node) { 2259 visitLiteralMapEntry(LiteralMapEntry node) {
2243 compiler.unimplemented('SsaBuilder.visitLiteralMapEntry', node: node); 2260 visit(node.value);
2261 visit(node.key);
2244 } 2262 }
2245 2263
2246 visitNamedArgument(NamedArgument node) { 2264 visitNamedArgument(NamedArgument node) {
2247 visit(node.expression); 2265 visit(node.expression);
2248 } 2266 }
2249 2267
2250 visitSwitchStatement(SwitchStatement node) { 2268 visitSwitchStatement(SwitchStatement node) {
2251 generateUnimplemented('switch statement not implemented'); 2269 generateUnimplemented('switch statement not implemented');
2252 } 2270 }
2253 2271
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 // Normally, we would call [close] here. However, then we hit 2384 // Normally, we would call [close] here. However, then we hit
2367 // another unimplemented feature: aborting loop body. Simply 2385 // another unimplemented feature: aborting loop body. Simply
2368 // calling [add] does not work as it asserts that the instruction 2386 // calling [add] does not work as it asserts that the instruction
2369 // isn't a control flow instruction. So we inline parts of [add]. 2387 // isn't a control flow instruction. So we inline parts of [add].
2370 current.addAfter(current.last, new HThrow(message)); 2388 current.addAfter(current.last, new HThrow(message));
2371 if (isExpression) { 2389 if (isExpression) {
2372 stack.add(graph.addNewLiteralNull()); 2390 stack.add(graph.addNewLiteralNull());
2373 } 2391 }
2374 } 2392 }
2375 } 2393 }
OLDNEW
« no previous file with comments | « dart/frog/leg/resolver.dart ('k') | dart/frog/leg/ssa/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698