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

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

Issue 10537118: Reapply "Collect field getters and setters in the universe"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes to original patch Created 8 years, 6 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 | « lib/compiler/implementation/enqueue.dart ('k') | lib/compiler/implementation/universe.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 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 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 } 1312 }
1313 } 1313 }
1314 1314
1315 visitTry(HTry node) { 1315 visitTry(HTry node) {
1316 // We should never get here. Try/catch/finally is always handled using block 1316 // We should never get here. Try/catch/finally is always handled using block
1317 // information in [visitTryInfo], or not at all, in the case of the bailout 1317 // information in [visitTryInfo], or not at all, in the case of the bailout
1318 // generator. 1318 // generator.
1319 compiler.internalError('visitTry should not be called', instruction: node); 1319 compiler.internalError('visitTry should not be called', instruction: node);
1320 } 1320 }
1321 1321
1322 /** 1322 /**
1323 * Analyzes the given [graph] to know whether it is empty, or 1323 * Analyzes the given [graph] to know whether it is empty, or
1324 * contains one statement, one expression, or multiple statements. 1324 * contains one statement, one expression, or multiple statements.
1325 */ 1325 */
1326 int analyzeGraphForCodegen(HStatementInformation graph) { 1326 int analyzeGraphForCodegen(HStatementInformation graph) {
1327 HBasicBlock start = graph.start; 1327 HBasicBlock start = graph.start;
1328 HBasicBlock end = graph.end; 1328 HBasicBlock end = graph.end;
1329 // Only deal with single blocks for now. TODO(ngeoffray): analyze 1329 // Only deal with single blocks for now. TODO(ngeoffray): analyze
1330 // all blocks. 1330 // all blocks.
1331 if (start !== end) return MULTIPLE_STATEMENTS; 1331 if (start !== end) return MULTIPLE_STATEMENTS;
1332 1332
1333 int kind = EMPTY; 1333 int kind = EMPTY;
1334 bool updateKind(int newKind) { 1334 bool updateKind(int newKind) {
1335 if (kind != EMPTY) return false; 1335 if (kind != EMPTY) return false;
1336 kind = newKind; 1336 kind = newKind;
1337 return true; 1337 return true;
1338 } 1338 }
1339 1339
1340 for (HInstruction instruction = start.first; 1340 for (HInstruction instruction = start.first;
1341 instruction != start.last; 1341 instruction != start.last;
1342 instruction = instruction.next) { 1342 instruction = instruction.next) {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 } 1681 }
1682 1682
1683 visitFieldGet(HFieldGet node) { 1683 visitFieldGet(HFieldGet node) {
1684 if (!node.isFromActivation()) { 1684 if (!node.isFromActivation()) {
1685 String name = compiler.namer.getName(node.element); 1685 String name = compiler.namer.getName(node.element);
1686 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1686 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1687 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1687 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1688 buffer.add('.'); 1688 buffer.add('.');
1689 buffer.add(name); 1689 buffer.add(name);
1690 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); 1690 beginExpression(JSPrecedence.MEMBER_PRECEDENCE);
1691 if (node.receiver != null) {
ngeoffray 2012/06/12 08:23:07 I don't think this can happen, see line 1687
Søren Gjesse 2012/06/12 10:09:17 Removed check.
1692 Type type = node.receiver.propagatedType.computeType(compiler);
1693 if (type != null) {
ngeoffray 2012/06/12 08:23:07 I'm surprised that we have a null type here. A HIn
Søren Gjesse 2012/06/12 10:09:17 As discussed offline there are HFieldGet instructi
1694 world.registerFieldGetter(node.element.name, type);
1695 }
1696 }
1691 } else { 1697 } else {
1692 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE); 1698 use(node.receiver, JSPrecedence.EXPRESSION_PRECEDENCE);
1693 } 1699 }
1694 } 1700 }
1695 1701
1696 visitFieldSet(HFieldSet node) { 1702 visitFieldSet(HFieldSet node) {
1697 String name; 1703 String name;
1698 if (!node.isFromActivation()) { 1704 if (!node.isFromActivation()) {
1699 name = compiler.namer.getName(node.element); 1705 name = compiler.namer.getName(node.element);
1700 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1706 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1701 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1707 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1702 buffer.add('.'); 1708 buffer.add('.');
1703 buffer.add(name); 1709 buffer.add(name);
1710 if (node.receiver != null) {
1711 Type type = node.receiver.propagatedType.computeType(compiler);
1712 if (type != null) {
1713 world.registerFieldSetter(node.element.name, type);
1714 }
1715 }
1704 } else { 1716 } else {
1705 declareInstruction(node.receiver); 1717 declareInstruction(node.receiver);
1706 } 1718 }
1707 buffer.add(' = '); 1719 buffer.add(' = ');
1708 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); 1720 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE);
1709 if (node.receiver !== null) { 1721 if (node.receiver !== null) {
1710 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 1722 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
1711 } 1723 }
1712 } 1724 }
1713 1725
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 bool visitAndOrInfo(HAndOrBlockInformation info) => false; 2628 bool visitAndOrInfo(HAndOrBlockInformation info) => false;
2617 bool visitIfInfo(HIfBlockInformation info) => false; 2629 bool visitIfInfo(HIfBlockInformation info) => false;
2618 bool visitLoopInfo(HLoopBlockInformation info) => false; 2630 bool visitLoopInfo(HLoopBlockInformation info) => false;
2619 bool visitTryInfo(HTryBlockInformation info) => false; 2631 bool visitTryInfo(HTryBlockInformation info) => false;
2620 bool visitSequenceInfo(HStatementSequenceInformation info) => false; 2632 bool visitSequenceInfo(HStatementSequenceInformation info) => false;
2621 2633
2622 // If argument is a [HCheck] and it does not have a name, we try to 2634 // If argument is a [HCheck] and it does not have a name, we try to
2623 // find the name of its checked input. Note that there must be a 2635 // find the name of its checked input. Note that there must be a
2624 // name, otherwise the instruction would not be in the live 2636 // name, otherwise the instruction would not be in the live
2625 // environment. 2637 // environment.
2626 HInstruction unwrap(argument) {» 2638 HInstruction unwrap(argument) {
2627 while (argument is HCheck && !variableNames.hasName(argument)) { 2639 while (argument is HCheck && !variableNames.hasName(argument)) {
2628 argument = argument.checkedInput; 2640 argument = argument.checkedInput;
2629 } 2641 }
2630 assert(variableNames.hasName(argument)); 2642 assert(variableNames.hasName(argument));
2631 return argument;» 2643 return argument;
2632 } 2644 }
2633 2645
2634 void visitTypeGuard(HTypeGuard node) { 2646 void visitTypeGuard(HTypeGuard node) {
2635 indent--; 2647 indent--;
2636 addIndented('case ${node.state}:\n'); 2648 addIndented('case ${node.state}:\n');
2637 indent++; 2649 indent++;
2638 addIndented('state = 0;\n'); 2650 addIndented('state = 0;\n');
2639 2651
2640 setup.add(' case ${node.state}:\n'); 2652 setup.add(' case ${node.state}:\n');
2641 int i = 0; 2653 int i = 0;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 startBailoutSwitch(); 2790 startBailoutSwitch();
2779 } 2791 }
2780 } 2792 }
2781 2793
2782 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2794 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2783 if (labeledBlockInfo.body.start.hasGuards()) { 2795 if (labeledBlockInfo.body.start.hasGuards()) {
2784 endBailoutSwitch(); 2796 endBailoutSwitch();
2785 } 2797 }
2786 } 2798 }
2787 } 2799 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/enqueue.dart ('k') | lib/compiler/implementation/universe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698