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 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1046 visitLoop(Node loop, Node initializer, Expression condition, NodeList updates, | 1046 visitLoop(Node loop, Node initializer, Expression condition, NodeList updates, |
| 1047 Node body) { | 1047 Node body) { |
| 1048 // Generate: | 1048 // Generate: |
| 1049 // <initializer> | 1049 // <initializer> |
| 1050 // loop-entry: | 1050 // loop-entry: |
| 1051 // if (!<condition>) goto loop-exit; | 1051 // if (!<condition>) goto loop-exit; |
| 1052 // <body> | 1052 // <body> |
| 1053 // <updates> | 1053 // <updates> |
| 1054 // goto loop-entry; | 1054 // goto loop-entry; |
| 1055 // loop-exit: | 1055 // loop-exit: |
| 1056 if (condition === null || body === null) { | 1056 if (body === null) { |
| 1057 compiler.unimplemented( | 1057 compiler.unimplemented( |
| 1058 'SsaBuilder.visitLoop with empty condition or body', | 1058 'SsaBuilder.visitLoop with empty body', |
| 1059 node: loop); | 1059 node: loop); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 localsHandler.startLoop(loop); | 1062 localsHandler.startLoop(loop); |
| 1063 | 1063 |
| 1064 // The initializer. | 1064 // The initializer. |
| 1065 if (initializer !== null) { | 1065 if (initializer !== null) { |
| 1066 visit(initializer); | 1066 visit(initializer); |
| 1067 // We don't care about the value of the initialization. | 1067 // We don't care about the value of the initialization. |
| 1068 if (initializer.asExpression() !== null) pop(); | 1068 if (initializer.asExpression() !== null) pop(); |
| 1069 } | 1069 } |
| 1070 assert(!isAborted()); | 1070 assert(!isAborted()); |
| 1071 | 1071 |
| 1072 BreakHandler breakHandler = beginLoopHeader(loop); | 1072 BreakHandler breakHandler = beginLoopHeader(loop); |
| 1073 HBasicBlock conditionBlock = current; | 1073 HBasicBlock conditionBlock = current; |
| 1074 | 1074 |
| 1075 // The condition. | 1075 HBasicBlock conditionExitBlock; |
| 1076 visit(condition); | 1076 if (condition != null) { |
| 1077 HBasicBlock conditionExitBlock = close(new HLoopBranch(popBoolified())); | 1077 visit(condition); |
| 1078 conditionExitBlock = close(new HLoopBranch(popBoolified())); | |
| 1079 } else { | |
| 1080 conditionExitBlock = close(new HLoopBranch(graph.addConstantBool(true))); | |
|
Lasse Reichstein Nielsen
2012/03/09 07:16:46
This could be one line with a conditional expressi
ngeoffray
2012/03/09 09:16:45
Done.
| |
| 1081 } | |
| 1078 | 1082 |
| 1079 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler); | 1083 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler); |
| 1080 | 1084 |
| 1081 // The body. | 1085 // The body. |
| 1082 HBasicBlock bodyBlock = addNewBlock(); | 1086 HBasicBlock bodyBlock = addNewBlock(); |
| 1083 conditionExitBlock.addSuccessor(bodyBlock); | 1087 conditionExitBlock.addSuccessor(bodyBlock); |
| 1084 open(bodyBlock); | 1088 open(bodyBlock); |
| 1085 | 1089 |
| 1086 localsHandler.enterLoopBody(loop); | 1090 localsHandler.enterLoopBody(loop); |
| 1087 visit(body); | 1091 visit(body); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1112 updateBlock = close(new HGoto()); | 1116 updateBlock = close(new HGoto()); |
| 1113 // The back-edge completing the cycle. | 1117 // The back-edge completing the cycle. |
| 1114 updateBlock.addSuccessor(conditionBlock); | 1118 updateBlock.addSuccessor(conditionBlock); |
| 1115 conditionBlock.postProcessLoopHeader(); | 1119 conditionBlock.postProcessLoopHeader(); |
| 1116 | 1120 |
| 1117 endLoop(conditionBlock, conditionExitBlock, breakHandler); | 1121 endLoop(conditionBlock, conditionExitBlock, breakHandler); |
| 1118 localsHandler = savedLocals; | 1122 localsHandler = savedLocals; |
| 1119 } | 1123 } |
| 1120 | 1124 |
| 1121 visitFor(For node) { | 1125 visitFor(For node) { |
| 1122 if (node.condition === null) { | |
| 1123 compiler.unimplemented("SsaBuilder for loop without condition"); | |
| 1124 } | |
| 1125 assert(node.body !== null); | 1126 assert(node.body !== null); |
| 1126 visitLoop(node, node.initializer, node.condition, node.update, node.body); | 1127 visitLoop(node, node.initializer, node.condition, node.update, node.body); |
| 1127 } | 1128 } |
| 1128 | 1129 |
| 1129 visitWhile(While node) { | 1130 visitWhile(While node) { |
| 1130 visitLoop(node, null, node.condition, null, node.body); | 1131 visitLoop(node, null, node.condition, null, node.body); |
| 1131 } | 1132 } |
| 1132 | 1133 |
| 1133 visitDoWhile(DoWhile node) { | 1134 visitDoWhile(DoWhile node) { |
| 1134 localsHandler.startLoop(node); | 1135 localsHandler.startLoop(node); |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2484 // Normally, we would call [close] here. However, then we hit | 2485 // Normally, we would call [close] here. However, then we hit |
| 2485 // another unimplemented feature: aborting loop body. Simply | 2486 // another unimplemented feature: aborting loop body. Simply |
| 2486 // calling [add] does not work as it asserts that the instruction | 2487 // calling [add] does not work as it asserts that the instruction |
| 2487 // isn't a control flow instruction. So we inline parts of [add]. | 2488 // isn't a control flow instruction. So we inline parts of [add]. |
| 2488 current.addAfter(current.last, new HThrow(message)); | 2489 current.addAfter(current.last, new HThrow(message)); |
| 2489 if (isExpression) { | 2490 if (isExpression) { |
| 2490 stack.add(graph.addConstantNull()); | 2491 stack.add(graph.addConstantNull()); |
| 2491 } | 2492 } |
| 2492 } | 2493 } |
| 2493 } | 2494 } |
| OLD | NEW |