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: pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart

Issue 898463002: Rename ClosureVariable, use separate IR forms for declaration and assignment. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 5 years, 10 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library dart2js.ir_tracer; 5 library dart2js.ir_tracer;
6 6
7 import 'dart:async' show EventSink; 7 import 'dart:async' show EventSink;
8 8
9 import 'cps_ir_nodes.dart' as cps_ir hide Function; 9 import 'cps_ir_nodes.dart' as cps_ir hide Function;
10 import '../tracer.dart'; 10 import '../tracer.dart';
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (IR_TRACE_LET_CONT) { 113 if (IR_TRACE_LET_CONT) {
114 String dummy = names.name(node); 114 String dummy = names.name(node);
115 for (cps_ir.Continuation continuation in node.continuations) { 115 for (cps_ir.Continuation continuation in node.continuations) {
116 String id = names.name(continuation); 116 String id = names.name(continuation);
117 printStmt(dummy, "LetCont $id = <$id>"); 117 printStmt(dummy, "LetCont $id = <$id>");
118 } 118 }
119 } 119 }
120 visit(node.body); 120 visit(node.body);
121 } 121 }
122 122
123 visitLetMutable(cps_ir.LetMutable node) {
124 String id = names.name(node.variable);
125 printStmt(id, "${node.runtimeType} $id = ${formatReference(node.value)}");
126 visit(node.body);
127 }
128
123 visitInvokeStatic(cps_ir.InvokeStatic node) { 129 visitInvokeStatic(cps_ir.InvokeStatic node) {
124 String dummy = names.name(node); 130 String dummy = names.name(node);
125 String callName = node.selector.name; 131 String callName = node.selector.name;
126 String args = node.arguments.map(formatReference).join(', '); 132 String args = node.arguments.map(formatReference).join(', ');
127 String kont = formatReference(node.continuation); 133 String kont = formatReference(node.continuation);
128 printStmt(dummy, "InvokeStatic $callName ($args) $kont"); 134 printStmt(dummy, "InvokeStatic $callName ($args) $kont");
129 } 135 }
130 136
131 visitInvokeMethod(cps_ir.InvokeMethod node) { 137 visitInvokeMethod(cps_ir.InvokeMethod node) {
132 String dummy = names.name(node); 138 String dummy = names.name(node);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 207 }
202 208
203 visitBranch(cps_ir.Branch node) { 209 visitBranch(cps_ir.Branch node) {
204 String dummy = names.name(node); 210 String dummy = names.name(node);
205 String condition = visit(node.condition); 211 String condition = visit(node.condition);
206 String trueCont = formatReference(node.trueContinuation); 212 String trueCont = formatReference(node.trueContinuation);
207 String falseCont = formatReference(node.falseContinuation); 213 String falseCont = formatReference(node.falseContinuation);
208 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)"); 214 printStmt(dummy, "Branch $condition ($trueCont, $falseCont)");
209 } 215 }
210 216
211 visitSetClosureVariable(cps_ir.SetClosureVariable node) { 217 visitSetMutableVariable(cps_ir.SetMutableVariable node) {
212 String dummy = names.name(node); 218 String dummy = names.name(node);
213 String variable = names.name(node.variable.definition); 219 String variable = names.name(node.variable.definition);
214 String value = formatReference(node.value); 220 String value = formatReference(node.value);
215 printStmt(dummy, 'SetClosureVariable $variable = $value'); 221 printStmt(dummy, '${node.runtimeType} $variable := $value');
216 visit(node.body); 222 visit(node.body);
217 } 223 }
218 224
219 visitDeclareFunction(cps_ir.DeclareFunction node) { 225 visitDeclareFunction(cps_ir.DeclareFunction node) {
220 String dummy = names.name(node); 226 String dummy = names.name(node);
221 String variable = names.name(node.variable.definition); 227 String variable = names.name(node.variable);
222 printStmt(dummy, 'DeclareFunction $variable'); 228 printStmt(dummy, 'DeclareFunction $variable');
223 visit(node.body); 229 visit(node.body);
224 } 230 }
225 231
226 String formatReference(cps_ir.Reference ref) { 232 String formatReference(cps_ir.Reference ref) {
227 cps_ir.Definition target = ref.definition; 233 cps_ir.Definition target = ref.definition;
228 if (target is cps_ir.Continuation && target.isReturnContinuation) { 234 if (target is cps_ir.Continuation && target.isReturnContinuation) {
229 return "return"; // Do not generate a name for the return continuation 235 return "return"; // Do not generate a name for the return continuation
230 } else { 236 } else {
231 return names.name(ref.definition); 237 return names.name(ref.definition);
232 } 238 }
233 } 239 }
234 240
235 String formatPrimitive(cps_ir.Primitive p) => visit(p); 241 String formatPrimitive(cps_ir.Primitive p) => visit(p);
236 242
237 visitConstant(cps_ir.Constant node) { 243 visitConstant(cps_ir.Constant node) {
238 return "Constant ${node.expression.value.toStructuredString()}"; 244 return "Constant ${node.expression.value.toStructuredString()}";
239 } 245 }
240 246
241 visitParameter(cps_ir.Parameter node) { 247 visitParameter(cps_ir.Parameter node) {
242 return "Parameter ${names.name(node)}"; 248 return "Parameter ${names.name(node)}";
243 } 249 }
244 250
245 visitClosureVariable(cps_ir.ClosureVariable node) { 251 visitMutableVariable(cps_ir.MutableVariable node) {
246 return "ClosureVariable ${names.name(node)}"; 252 return "${node.runtimeType} ${names.name(node)}";
247 } 253 }
248 254
249 visitContinuation(cps_ir.Continuation node) { 255 visitContinuation(cps_ir.Continuation node) {
250 return "Continuation ${names.name(node)}"; 256 return "Continuation ${names.name(node)}";
251 } 257 }
252 258
253 visitIsTrue(cps_ir.IsTrue node) { 259 visitIsTrue(cps_ir.IsTrue node) {
254 return "IsTrue(${names.name(node.value.definition)})"; 260 return "IsTrue(${names.name(node.value.definition)})";
255 } 261 }
256 262
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 300 }
295 301
296 visitReifyTypeVar(cps_ir.ReifyTypeVar node) { 302 visitReifyTypeVar(cps_ir.ReifyTypeVar node) {
297 return "ReifyTypeVar ${node.typeVariable.name}"; 303 return "ReifyTypeVar ${node.typeVariable.name}";
298 } 304 }
299 305
300 visitCreateFunction(cps_ir.CreateFunction node) { 306 visitCreateFunction(cps_ir.CreateFunction node) {
301 return "CreateFunction ${node.definition.element.name}"; 307 return "CreateFunction ${node.definition.element.name}";
302 } 308 }
303 309
304 visitGetClosureVariable(cps_ir.GetClosureVariable node) { 310 visitGetMutableVariable(cps_ir.GetMutableVariable node) {
305 String variable = names.name(node.variable.definition); 311 String variable = names.name(node.variable.definition);
306 return 'GetClosureVariable $variable'; 312 return '${node.runtimeType} $variable';
307 } 313 }
308 314
309 visitRunnableBody(cps_ir.RunnableBody node) {} 315 visitRunnableBody(cps_ir.RunnableBody node) {}
310 visitFieldInitializer(cps_ir.FieldInitializer node) {} 316 visitFieldInitializer(cps_ir.FieldInitializer node) {}
311 visitSuperInitializer(cps_ir.SuperInitializer node) {} 317 visitSuperInitializer(cps_ir.SuperInitializer node) {}
312 visitCondition(cps_ir.Condition c) {} 318 visitCondition(cps_ir.Condition c) {}
313 visitExpression(cps_ir.Expression e) {} 319 visitExpression(cps_ir.Expression e) {}
314 visitPrimitive(cps_ir.Primitive p) {} 320 visitPrimitive(cps_ir.Primitive p) {}
315 visitDefinition(cps_ir.Definition d) {} 321 visitDefinition(cps_ir.Definition d) {}
316 visitInitializer(cps_ir.Initializer i) {} 322 visitInitializer(cps_ir.Initializer i) {}
(...skipping 13 matching lines...) Expand all
330 'B': 0, 336 'B': 0,
331 'v': 0, 337 'v': 0,
332 'x': 0, 338 'x': 0,
333 'c': 0 339 'c': 0
334 }; 340 };
335 341
336 String prefix(x) { 342 String prefix(x) {
337 if (x is cps_ir.Parameter) return 'r'; 343 if (x is cps_ir.Parameter) return 'r';
338 if (x is cps_ir.Continuation || x is cps_ir.FunctionDefinition) return 'B'; 344 if (x is cps_ir.Continuation || x is cps_ir.FunctionDefinition) return 'B';
339 if (x is cps_ir.Primitive) return 'v'; 345 if (x is cps_ir.Primitive) return 'v';
340 if (x is cps_ir.ClosureVariable) return 'c'; 346 if (x is cps_ir.MutableVariable) return 'c';
341 return 'x'; 347 return 'x';
342 } 348 }
343 349
344 String name(x) { 350 String name(x) {
345 String nam = names[x]; 351 String nam = names[x];
346 if (nam == null) { 352 if (nam == null) {
347 String pref = prefix(x); 353 String pref = prefix(x);
348 int id = counters[pref]++; 354 int id = counters[pref]++;
349 nam = names[x] = '${pref}${id}'; 355 nam = names[x] = '${pref}${id}';
350 } 356 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 455 }
450 456
451 visitConcatenateStrings(cps_ir.ConcatenateStrings exp) { 457 visitConcatenateStrings(cps_ir.ConcatenateStrings exp) {
452 addEdgeToContinuation(exp.continuation); 458 addEdgeToContinuation(exp.continuation);
453 } 459 }
454 460
455 visitInvokeContinuation(cps_ir.InvokeContinuation exp) { 461 visitInvokeContinuation(cps_ir.InvokeContinuation exp) {
456 addEdgeToContinuation(exp.continuation); 462 addEdgeToContinuation(exp.continuation);
457 } 463 }
458 464
459 visitSetClosureVariable(cps_ir.SetClosureVariable exp) { 465 visitSetMutableVariable(cps_ir.SetMutableVariable exp) {
460 visit(exp.body); 466 visit(exp.body);
461 } 467 }
462 468
463 visitSetField(cps_ir.SetField exp) { 469 visitSetField(cps_ir.SetField exp) {
464 visit(exp.body); 470 visit(exp.body);
465 } 471 }
466 472
467 visitDeclareFunction(cps_ir.DeclareFunction exp) { 473 visitDeclareFunction(cps_ir.DeclareFunction exp) {
468 visit(exp.body); 474 visit(exp.body);
469 } 475 }
470 476
471 visitBranch(cps_ir.Branch exp) { 477 visitBranch(cps_ir.Branch exp) {
472 cps_ir.Continuation trueTarget = exp.trueContinuation.definition; 478 cps_ir.Continuation trueTarget = exp.trueContinuation.definition;
473 if (!trueTarget.isReturnContinuation) { 479 if (!trueTarget.isReturnContinuation) {
474 current_block.addEdgeTo(getBlock(trueTarget)); 480 current_block.addEdgeTo(getBlock(trueTarget));
475 } 481 }
476 cps_ir.Continuation falseTarget = exp.falseContinuation.definition; 482 cps_ir.Continuation falseTarget = exp.falseContinuation.definition;
477 if (!falseTarget.isReturnContinuation) { 483 if (!falseTarget.isReturnContinuation) {
478 current_block.addEdgeTo(getBlock(falseTarget)); 484 current_block.addEdgeTo(getBlock(falseTarget));
479 } 485 }
480 } 486 }
481 487
482 visitContinuation(cps_ir.Continuation c) { 488 visitContinuation(cps_ir.Continuation c) {
483 var old_node = current_block; 489 var old_node = current_block;
484 current_block = getBlock(c); 490 current_block = getBlock(c);
485 visit(c.body); 491 visit(c.body);
486 current_block = old_node; 492 current_block = old_node;
487 } 493 }
488 } 494 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart ('k') | pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698