Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2227 return; | 2227 return; |
| 2228 } | 2228 } |
| 2229 LocalsHandler beforeLocals = new LocalsHandler.from(localsHandler); | 2229 LocalsHandler beforeLocals = new LocalsHandler.from(localsHandler); |
| 2230 assert(targetElement.isBreakTarget); | 2230 assert(targetElement.isBreakTarget); |
| 2231 BreakHandler handler = new BreakHandler(this, targetElement); | 2231 BreakHandler handler = new BreakHandler(this, targetElement); |
| 2232 // Introduce a new basic block. | 2232 // Introduce a new basic block. |
| 2233 HBasicBlock entryBlock = graph.addNewBlock(); | 2233 HBasicBlock entryBlock = graph.addNewBlock(); |
| 2234 goto(current, entryBlock); | 2234 goto(current, entryBlock); |
| 2235 open(entryBlock); | 2235 open(entryBlock); |
| 2236 visit(body); | 2236 visit(body); |
| 2237 SubGraph bodyGraph = new SubGraph(entryBlock, lastOpenedBlock); | |
| 2237 if (isAborted()) { | 2238 if (isAborted()) { |
| 2238 compiler.unimplemented( | 2239 compiler.unimplemented( |
| 2239 "SsaBuilder for labeled statement with aborting body", node: node); | 2240 "SsaBuilder for labeled statement with aborting body", node: node); |
| 2240 } | 2241 } |
| 2241 | 2242 |
| 2242 HBasicBlock joinBlock = graph.addNewBlock(); | 2243 HBasicBlock joinBlock = graph.addNewBlock(); |
| 2243 List<LocalsHandler> breakLocals = <LocalsHandler>[]; | 2244 List<LocalsHandler> breakLocals = <LocalsHandler>[]; |
| 2244 handler.forEachBreak((HBreak breakInstruction, LocalsHandler locals) { | 2245 handler.forEachBreak((HBreak breakInstruction, LocalsHandler locals) { |
| 2245 breakInstruction.block.addSuccessor(joinBlock); | 2246 breakInstruction.block.addSuccessor(joinBlock); |
| 2246 breakLocals.add(locals); | 2247 breakLocals.add(locals); |
| 2247 }); | 2248 }); |
| 2248 bool hasBreak = breakLocals.length > 0; | 2249 bool hasBreak = breakLocals.length > 0; |
| 2249 if (!isAborted()) { | 2250 if (!isAborted()) { |
| 2250 goto(current, joinBlock); | 2251 goto(current, joinBlock); |
| 2251 breakLocals.add(localsHandler); | 2252 breakLocals.add(localsHandler); |
| 2252 } | 2253 } |
| 2253 open(joinBlock); | 2254 open(joinBlock); |
| 2254 localsHandler = beforeLocals.mergeMultiple(breakLocals, joinBlock); | 2255 localsHandler = beforeLocals.mergeMultiple(breakLocals, joinBlock); |
| 2255 | 2256 |
| 2256 if (hasBreak) { | 2257 if (hasBreak) { |
| 2257 // There was at least one reachable break, so the label is needed. | 2258 // There was at least one reachable break, so the label is needed. |
| 2258 HLabeledBlockInformation blockInfo = | 2259 HLabeledBlockInformation blockInfo = |
| 2259 new HLabeledBlockInformation(entryBlock, current, | 2260 new HLabeledBlockInformation(bodyGraph, joinBlock, handler.labels()); |
| 2260 handler.labels()); | |
| 2261 handler.close(); | 2261 handler.close(); |
|
ngeoffray
2012/03/06 11:17:37
Move the close around?
Lasse Reichstein Nielsen
2012/03/08 09:02:02
I did. On another computer. Bad sync!
| |
| 2262 // Mark both entry and exit with the information. You can | |
| 2263 // tell which one is which by comparing with blockInfo.start/end. | |
| 2264 // It doesn't matter which merge block we use, they won't be generating | |
| 2265 // any code, so put the end-marker on the last join block. | |
| 2266 entryBlock.labeledBlockInformation = blockInfo; | 2262 entryBlock.labeledBlockInformation = blockInfo; |
| 2267 current.labeledBlockInformation = blockInfo; | |
| 2268 } | 2263 } |
| 2269 } | 2264 } |
| 2270 | 2265 |
| 2271 visitLiteralMap(LiteralMap node) { | 2266 visitLiteralMap(LiteralMap node) { |
| 2272 generateUnimplemented('literal map not implemented', isExpression: true); | 2267 generateUnimplemented('literal map not implemented', isExpression: true); |
| 2273 } | 2268 } |
| 2274 | 2269 |
| 2275 visitLiteralMapEntry(LiteralMapEntry node) { | 2270 visitLiteralMapEntry(LiteralMapEntry node) { |
| 2276 compiler.unimplemented('SsaBuilder.visitLiteralMapEntry', node: node); | 2271 compiler.unimplemented('SsaBuilder.visitLiteralMapEntry', node: node); |
| 2277 } | 2272 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2399 // Normally, we would call [close] here. However, then we hit | 2394 // Normally, we would call [close] here. However, then we hit |
| 2400 // another unimplemented feature: aborting loop body. Simply | 2395 // another unimplemented feature: aborting loop body. Simply |
| 2401 // calling [add] does not work as it asserts that the instruction | 2396 // calling [add] does not work as it asserts that the instruction |
| 2402 // isn't a control flow instruction. So we inline parts of [add]. | 2397 // isn't a control flow instruction. So we inline parts of [add]. |
| 2403 current.addAfter(current.last, new HThrow(message)); | 2398 current.addAfter(current.last, new HThrow(message)); |
| 2404 if (isExpression) { | 2399 if (isExpression) { |
| 2405 stack.add(graph.addNewLiteralNull()); | 2400 stack.add(graph.addNewLiteralNull()); |
| 2406 } | 2401 } |
| 2407 } | 2402 } |
| 2408 } | 2403 } |
| OLD | NEW |