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

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

Issue 10238003: Reapply "Avoid "=== true" inside code by calling a function that does this for us." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
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 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 9
10 String generateMethod(WorkItem work, HGraph graph) { 10 String generateMethod(WorkItem work, HGraph graph) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 final Map<int, String> names; 120 final Map<int, String> names;
121 final Set<String> usedNames; 121 final Set<String> usedNames;
122 final Map<String, int> prefixes; 122 final Map<String, int> prefixes;
123 final Set<HInstruction> generateAtUseSite; 123 final Set<HInstruction> generateAtUseSite;
124 final Map<HPhi, String> logicalOperations; 124 final Map<HPhi, String> logicalOperations;
125 final Map<Element, ElementAction> breakAction; 125 final Map<Element, ElementAction> breakAction;
126 final Map<Element, ElementAction> continueAction; 126 final Map<Element, ElementAction> continueAction;
127 final Equivalence<HPhi> phiEquivalence; 127 final Equivalence<HPhi> phiEquivalence;
128 128
129 Element equalsNullElement; 129 Element equalsNullElement;
130 Element boolifiedEqualsNullElement;
130 int indent = 0; 131 int indent = 0;
131 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE; 132 int expectedPrecedence = JSPrecedence.STATEMENT_PRECEDENCE;
132 HGraph currentGraph; 133 HGraph currentGraph;
133 /** 134 /**
134 * Whether the code-generation should try to generate an expression 135 * Whether the code-generation should try to generate an expression
135 * instead of a sequence of statements. 136 * instead of a sequence of statements.
136 */ 137 */
137 int generationState = STATE_STATEMENT; 138 int generationState = STATE_STATEMENT;
138 /** 139 /**
139 * While generating expressions, we can't insert variable declarations. 140 * While generating expressions, we can't insert variable declarations.
(...skipping 29 matching lines...) Expand all
169 continueAction = new Map<Element, ElementAction>(), 170 continueAction = new Map<Element, ElementAction>(),
170 phiEquivalence = new Equivalence<HPhi>() { 171 phiEquivalence = new Equivalence<HPhi>() {
171 172
172 for (final name in parameterNames.getValues()) { 173 for (final name in parameterNames.getValues()) {
173 prefixes[name] = 0; 174 prefixes[name] = 0;
174 } 175 }
175 176
176 // Create a namespace for temporaries. 177 // Create a namespace for temporaries.
177 prefixes[TEMPORARY_PREFIX] = 0; 178 prefixes[TEMPORARY_PREFIX] = 0;
178 179
179 equalsNullElement = 180 Interceptors interceptors = compiler.builder.interceptors;
180 compiler.builder.interceptors.getEqualsNullInterceptor(); 181 equalsNullElement = interceptors.getEqualsNullInterceptor();
182 boolifiedEqualsNullElement =
183 interceptors.getBoolifiedVersionOf(equalsNullElement);
181 } 184 }
182 185
183 abstract visitTypeGuard(HTypeGuard node); 186 abstract visitTypeGuard(HTypeGuard node);
184 187
185 abstract beginGraph(HGraph graph); 188 abstract beginGraph(HGraph graph);
186 abstract endGraph(HGraph graph); 189 abstract endGraph(HGraph graph);
187 190
188 abstract beginLoop(HBasicBlock block); 191 abstract beginLoop(HBasicBlock block);
189 abstract endLoop(HBasicBlock block); 192 abstract endLoop(HBasicBlock block);
190 abstract handleLoopCondition(HLoopBranch node); 193 abstract handleLoopCondition(HLoopBranch node);
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 } 845 }
843 } 846 }
844 847
845 visitEquals(HEquals node) { 848 visitEquals(HEquals node) {
846 if (node.builtin) { 849 if (node.builtin) {
847 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); 850 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
848 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); 851 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE);
849 buffer.add(' === '); 852 buffer.add(' === ');
850 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); 853 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE);
851 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); 854 endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
852 } else if (node.element === equalsNullElement) { 855 } else if (node.element === equalsNullElement ||
856 node.element === boolifiedEqualsNullElement) {
853 beginExpression(JSPrecedence.CALL_PRECEDENCE); 857 beginExpression(JSPrecedence.CALL_PRECEDENCE);
854 use(node.target, JSPrecedence.CALL_PRECEDENCE); 858 use(node.target, JSPrecedence.CALL_PRECEDENCE);
855 buffer.add('('); 859 buffer.add('(');
856 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); 860 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE);
857 buffer.add(')'); 861 buffer.add(')');
858 endExpression(JSPrecedence.CALL_PRECEDENCE); 862 endExpression(JSPrecedence.CALL_PRECEDENCE);
859 } else { 863 } else {
860 visitInvokeStatic(node); 864 visitInvokeStatic(node);
861 } 865 }
862 } 866 }
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 startBailoutSwitch(); 2091 startBailoutSwitch();
2088 } 2092 }
2089 } 2093 }
2090 2094
2091 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2095 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2092 if (labeledBlockInfo.body.start.hasGuards()) { 2096 if (labeledBlockInfo.body.start.hasGuards()) {
2093 endBailoutSwitch(); 2097 endBailoutSwitch();
2094 } 2098 }
2095 } 2099 }
2096 } 2100 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698