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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart

Issue 759193005: Add support for fields to the new dart backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 6 years 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';
11 11
12 /** 12 /**
13 * If true, show LetCont expressions in output. 13 * If true, show LetCont expressions in output.
14 */ 14 */
15 const bool IR_TRACE_LET_CONT = false; 15 const bool IR_TRACE_LET_CONT = false;
16 16
17 class IRTracer extends TracerUtil implements cps_ir.Visitor { 17 class IRTracer extends TracerUtil implements cps_ir.Visitor {
18 EventSink<String> output; 18 EventSink<String> output;
19 19
20 IRTracer(this.output); 20 IRTracer(this.output);
21 21
22 visit(cps_ir.Node node) => node.accept(this); 22 visit(cps_ir.Node node) => node.accept(this);
23 23
24 void traceGraph(String name, cps_ir.FunctionDefinition graph) { 24 void traceGraph(String name, cps_ir.ExecutableDefinition graph) {
25 tag("cfg", () { 25 tag("cfg", () {
26 printProperty("name", name); 26 printProperty("name", name);
27 visitFunctionDefinition(graph); 27 visit(graph);
28 }); 28 });
29 } 29 }
30 30
31 // Temporary field used during tree walk 31 // Temporary field used during tree walk
32 Names names; 32 Names names;
33 33
34 visitFunctionDefinition(cps_ir.FunctionDefinition f) { 34 visitExecutableDefinition(cps_ir.ExecutableDefinition node) {
35 names = new Names(); 35 names = new Names();
36 BlockCollector builder = new BlockCollector(names); 36 BlockCollector builder = new BlockCollector(names);
37 builder.visit(f); 37 builder.visit(node);
38 38
39 printNode(builder.entry); 39 printNode(builder.entry);
40 for (Block block in builder.cont2block.values) { 40 for (Block block in builder.cont2block.values) {
41 printNode(block); 41 printNode(block);
42 } 42 }
43 names = null; 43 names = null;
44 } 44 }
45 45
46 visitFieldDefinition(cps_ir.FieldDefinition node) {
47 visitExecutableDefinition(node);
48 }
49
50 visitFunctionDefinition(cps_ir.FunctionDefinition node) {
51 visitExecutableDefinition(node);
52 }
53
46 int countUses(cps_ir.Definition definition) { 54 int countUses(cps_ir.Definition definition) {
47 int count = 0; 55 int count = 0;
48 cps_ir.Reference ref = definition.firstRef; 56 cps_ir.Reference ref = definition.firstRef;
49 while (ref != null) { 57 while (ref != null) {
50 ++count; 58 ++count;
51 ref = ref.next; 59 ref = ref.next;
52 } 60 }
53 return count; 61 return count;
54 } 62 }
55 63
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 330
323 Block getBlock(cps_ir.Continuation c) { 331 Block getBlock(cps_ir.Continuation c) {
324 Block block = cont2block[c]; 332 Block block = cont2block[c];
325 if (block == null) { 333 if (block == null) {
326 block = new Block(names.name(c), c.parameters, c.body); 334 block = new Block(names.name(c), c.parameters, c.body);
327 cont2block[c] = block; 335 cont2block[c] = block;
328 } 336 }
329 return block; 337 return block;
330 } 338 }
331 339
332 visitFunctionDefinition(cps_ir.FunctionDefinition f) { 340 visitExecutableDefinition(cps_ir.ExecutableDefinition node) {
333 entry = current_block = new Block(names.name(f), [], f.body); 341 entry = current_block = new Block(names.name(node), [], node.body);
334 visit(f.body); 342 visit(node.body);
343 }
344
345 visitFieldDefinition(cps_ir.FieldDefinition node) {
346 visitExecutableDefinition(node);
347 }
348
349 visitFunctionDefinition(cps_ir.FunctionDefinition node) {
350 visitExecutableDefinition(node);
335 } 351 }
336 352
337 visitLetPrim(cps_ir.LetPrim exp) { 353 visitLetPrim(cps_ir.LetPrim exp) {
338 visit(exp.body); 354 visit(exp.body);
339 } 355 }
340 356
341 visitLetCont(cps_ir.LetCont exp) { 357 visitLetCont(cps_ir.LetCont exp) {
342 visit(exp.continuation); 358 visit(exp.continuation);
343 visit(exp.body); 359 visit(exp.body);
344 } 360 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 405 }
390 } 406 }
391 407
392 visitContinuation(cps_ir.Continuation c) { 408 visitContinuation(cps_ir.Continuation c) {
393 var old_node = current_block; 409 var old_node = current_block;
394 current_block = getBlock(c); 410 current_block = getBlock(c);
395 visit(c.body); 411 visit(c.body);
396 current_block = old_node; 412 current_block = old_node;
397 } 413 }
398 } 414 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart ('k') | pkg/compiler/lib/src/cps_ir/optimizers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698