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

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

Issue 10035059: Special case mangling for a variable named 't'. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « no previous file | no next file » | 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 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 * It is generated as either statements (indented and ';'-terminated), 86 * It is generated as either statements (indented and ';'-terminated),
87 * expressions (comma separated) or declarations (also comma separated, 87 * expressions (comma separated) or declarations (also comma separated,
88 * but expected to be preceeded by a 'var' so it declares its variables); 88 * but expected to be preceeded by a 'var' so it declares its variables);
89 */ 89 */
90 static final int STATE_STATEMENT = 0; 90 static final int STATE_STATEMENT = 0;
91 static final int STATE_FIRST_EXPRESSION = 1; 91 static final int STATE_FIRST_EXPRESSION = 1;
92 static final int STATE_FIRST_DECLARATION = 2; 92 static final int STATE_FIRST_DECLARATION = 2;
93 static final int STATE_EXPRESSION = 3; 93 static final int STATE_EXPRESSION = 3;
94 static final int STATE_DECLARATION = 4; 94 static final int STATE_DECLARATION = 4;
95 95
96 static final String TEMPORARY_PREFIX = 't';
97
96 final Compiler compiler; 98 final Compiler compiler;
97 final WorkItem work; 99 final WorkItem work;
98 final StringBuffer buffer; 100 final StringBuffer buffer;
99 final String parameters; 101 final String parameters;
100 102
101 final Map<Element, String> parameterNames; 103 final Map<Element, String> parameterNames;
102 final Map<int, String> names; 104 final Map<int, String> names;
103 final Set<String> usedNames; 105 final Set<String> usedNames;
104 final Map<String, int> prefixes; 106 final Map<String, int> prefixes;
105 final Set<HInstruction> generateAtUseSite; 107 final Set<HInstruction> generateAtUseSite;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 logicalOperations = new Map<HPhi, String>(), 151 logicalOperations = new Map<HPhi, String>(),
150 breakAction = new Map<Element, ElementAction>(), 152 breakAction = new Map<Element, ElementAction>(),
151 continueAction = new Map<Element, ElementAction>(), 153 continueAction = new Map<Element, ElementAction>(),
152 phiEquivalence = new Equivalence<HPhi>() { 154 phiEquivalence = new Equivalence<HPhi>() {
153 155
154 for (final name in parameterNames.getValues()) { 156 for (final name in parameterNames.getValues()) {
155 prefixes[name] = 0; 157 prefixes[name] = 0;
156 } 158 }
157 159
158 // Create a namespace for temporaries. 160 // Create a namespace for temporaries.
159 prefixes['t'] = 0; 161 prefixes[TEMPORARY_PREFIX] = 0;
160 162
161 equalsNullElement = 163 equalsNullElement =
162 compiler.builder.interceptors.getEqualsNullInterceptor(); 164 compiler.builder.interceptors.getEqualsNullInterceptor();
163 } 165 }
164 166
165 abstract visitTypeGuard(HTypeGuard node); 167 abstract visitTypeGuard(HTypeGuard node);
166 168
167 abstract beginGraph(HGraph graph); 169 abstract beginGraph(HGraph graph);
168 abstract endGraph(HGraph graph); 170 abstract endGraph(HGraph graph);
169 171
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 272
271 void visitConditionGraph(SubGraph conditionSubGraph) { 273 void visitConditionGraph(SubGraph conditionSubGraph) {
272 visitExpressionGraph(conditionSubGraph); 274 visitExpressionGraph(conditionSubGraph);
273 } 275 }
274 276
275 String temporary(HInstruction instruction) { 277 String temporary(HInstruction instruction) {
276 int id = instruction.id; 278 int id = instruction.id;
277 String name = names[id]; 279 String name = names[id];
278 if (name !== null) return name; 280 if (name !== null) return name;
279 281
280 String prefix = 't'; 282 String prefix = TEMPORARY_PREFIX;
281 if (instruction.sourceElement !== null) { 283 if (instruction.sourceElement !== null) {
282 Element element = instruction.sourceElement; 284 Element element = instruction.sourceElement;
283 if (element !== null && !element.name.isEmpty()) { 285 if (element !== null && !element.name.isEmpty()) {
284 prefix = element.name.slowToString(); 286 prefix = element.name.slowToString();
287 // Special case the variable named [TEMPORARY_PREFIX] to allow keeping i ts
floitsch 2012/04/20 10:36:37 80 chars.
288 // name.
289 if (prefix == TEMPORARY_PREFIX && !usedNames.contains(prefix)) {
290 return newName(id, prefix);
291 }
285 // If we've never seen that prefix before, try to use it 292 // If we've never seen that prefix before, try to use it
286 // directly. 293 // directly.
287 if (!prefixes.containsKey(prefix)) { 294 if (!prefixes.containsKey(prefix)) {
288 // Make sure the variable name does not conflict with our mangling. 295 // Make sure the variable name does not conflict with our mangling.
289 while (usedNames.contains(prefix)) { 296 while (usedNames.contains(prefix)) {
290 prefix = '${prefix}_'; 297 prefix = '${prefix}_';
291 } 298 }
292 prefixes[prefix] = 0; 299 prefixes[prefix] = 0;
293 return newName(id, prefix); 300 return newName(id, prefix);
294 } 301 }
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 startBailoutSwitch(); 1935 startBailoutSwitch();
1929 } 1936 }
1930 } 1937 }
1931 1938
1932 void endElse(HIf node) { 1939 void endElse(HIf node) {
1933 if (node.elseBlock.hasGuards()) { 1940 if (node.elseBlock.hasGuards()) {
1934 endBailoutSwitch(); 1941 endBailoutSwitch();
1935 } 1942 }
1936 } 1943 }
1937 } 1944 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698