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 SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
6 final JavaScriptBackend backend; | 6 final JavaScriptBackend backend; |
7 SsaCodeGeneratorTask(JavaScriptBackend backend) | 7 SsaCodeGeneratorTask(JavaScriptBackend backend) |
8 : this.backend = backend, | 8 : this.backend = backend, |
9 super(backend.compiler); | 9 super(backend.compiler); |
10 String get name() => 'SSA code generator'; | 10 String get name() => 'SSA code generator'; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 HBasicBlock currentBlock; | 183 HBasicBlock currentBlock; |
184 | 184 |
185 // Records a block-information that is being handled specially. | 185 // Records a block-information that is being handled specially. |
186 // Used to break bad recursion. | 186 // Used to break bad recursion. |
187 HBlockInformation currentBlockInformation; | 187 HBlockInformation currentBlockInformation; |
188 // The subgraph is used to delimit traversal for some constructions, e.g., | 188 // The subgraph is used to delimit traversal for some constructions, e.g., |
189 // if branches. | 189 // if branches. |
190 SubGraph subGraph; | 190 SubGraph subGraph; |
191 | 191 |
192 LibraryElement get currentLibrary() => work.element.getLibrary(); | 192 LibraryElement get currentLibrary() => work.element.getLibrary(); |
| 193 ClassElement get currentClass() => work.element.getEnclosingClass(); |
193 Compiler get compiler() => backend.compiler; | 194 Compiler get compiler() => backend.compiler; |
194 NativeEmitter get nativeEmitter() => backend.emitter.nativeEmitter; | 195 NativeEmitter get nativeEmitter() => backend.emitter.nativeEmitter; |
195 Enqueuer get world() => backend.compiler.enqueuer.codegen; | 196 Enqueuer get world() => backend.compiler.enqueuer.codegen; |
196 | 197 |
197 bool isGenerateAtUseSite(HInstruction instruction) { | 198 bool isGenerateAtUseSite(HInstruction instruction) { |
198 return generateAtUseSite.contains(instruction); | 199 return generateAtUseSite.contains(instruction); |
199 } | 200 } |
200 | 201 |
201 SsaCodeGenerator(this.backend, | 202 SsaCodeGenerator(this.backend, |
202 this.work, | 203 this.work, |
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 buffer.add('$className.prototype.$methodName.call'); | 1457 buffer.add('$className.prototype.$methodName.call'); |
1457 visitArguments(node.inputs); | 1458 visitArguments(node.inputs); |
1458 } | 1459 } |
1459 endExpression(JSPrecedence.CALL_PRECEDENCE); | 1460 endExpression(JSPrecedence.CALL_PRECEDENCE); |
1460 world.registerStaticUse(superMethod); | 1461 world.registerStaticUse(superMethod); |
1461 } | 1462 } |
1462 | 1463 |
1463 visitFieldGet(HFieldGet node) { | 1464 visitFieldGet(HFieldGet node) { |
1464 if (!node.isFromActivation()) { | 1465 if (!node.isFromActivation()) { |
1465 String name = | 1466 String name = |
1466 compiler.namer.instanceFieldName(currentLibrary, node.name); | 1467 compiler.namer.instanceFieldName(currentClass, node.name); |
1467 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 1468 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
1468 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1469 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
1469 buffer.add('.'); | 1470 buffer.add('.'); |
1470 buffer.add(name); | 1471 buffer.add(name); |
1471 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 1472 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
1472 } else { | 1473 } else { |
1473 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); | 1474 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); |
1474 } | 1475 } |
1475 } | 1476 } |
1476 | 1477 |
1477 visitFieldSet(HFieldSet node) { | 1478 visitFieldSet(HFieldSet node) { |
1478 String name; | 1479 String name; |
1479 if (!node.isFromActivation()) { | 1480 if (!node.isFromActivation()) { |
1480 name = | 1481 name = |
1481 compiler.namer.instanceFieldName(currentLibrary, node.name); | 1482 compiler.namer.instanceFieldName(currentClass, node.name); |
1482 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1483 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
1483 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1484 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
1484 buffer.add('.'); | 1485 buffer.add('.'); |
1485 buffer.add(name); | 1486 buffer.add(name); |
1486 } else { | 1487 } else { |
1487 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); | 1488 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); |
1488 } | 1489 } |
1489 buffer.add(' = '); | 1490 buffer.add(' = '); |
1490 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1491 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
1491 if (node.receiver !== null) { | 1492 if (node.receiver !== null) { |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 startBailoutSwitch(); | 2506 startBailoutSwitch(); |
2506 } | 2507 } |
2507 } | 2508 } |
2508 | 2509 |
2509 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2510 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
2510 if (labeledBlockInfo.body.start.hasGuards()) { | 2511 if (labeledBlockInfo.body.start.hasGuards()) { |
2511 endBailoutSwitch(); | 2512 endBailoutSwitch(); |
2512 } | 2513 } |
2513 } | 2514 } |
2514 } | 2515 } |
OLD | NEW |