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

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

Issue 10221014: 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: Changes. 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 } 890 }
888 } 891 }
889 892
890 visitEquals(HEquals node) { 893 visitEquals(HEquals node) {
891 if (node.builtin) { 894 if (node.builtin) {
892 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); 895 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
893 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE); 896 use(node.left, JSPrecedence.EQUALITY_PRECEDENCE);
894 buffer.add(' === '); 897 buffer.add(' === ');
895 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE); 898 use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE);
896 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); 899 endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
897 } else if (node.element === equalsNullElement) { 900 } else if (node.element === equalsNullElement ||
901 node.element === boolifiedEqualsNullElement) {
898 beginExpression(JSPrecedence.CALL_PRECEDENCE); 902 beginExpression(JSPrecedence.CALL_PRECEDENCE);
899 use(node.target, JSPrecedence.CALL_PRECEDENCE); 903 use(node.target, JSPrecedence.CALL_PRECEDENCE);
900 buffer.add('('); 904 buffer.add('(');
901 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE); 905 use(node.left, JSPrecedence.ASSIGNMENT_PRECEDENCE);
902 buffer.add(')'); 906 buffer.add(')');
903 endExpression(JSPrecedence.CALL_PRECEDENCE); 907 endExpression(JSPrecedence.CALL_PRECEDENCE);
904 } else { 908 } else {
905 visitInvokeStatic(node); 909 visitInvokeStatic(node);
906 } 910 }
907 } 911 }
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 startBailoutSwitch(); 2141 startBailoutSwitch();
2138 } 2142 }
2139 } 2143 }
2140 2144
2141 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2145 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2142 if (labeledBlockInfo.body.start.hasGuards()) { 2146 if (labeledBlockInfo.body.start.hasGuards()) {
2143 endBailoutSwitch(); 2147 endBailoutSwitch();
2144 } 2148 }
2145 } 2149 }
2146 } 2150 }
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