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

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

Issue 1375213003: dart2js cps: Maintain parent pointers instead of recomputing them. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase Created 5 years, 2 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
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 library cps_ir.parent_visitor;
6
7 import 'cps_ir_nodes.dart';
8
9 /// Traverses the CPS term and sets node.parent for each visited node.
10 class ParentVisitor extends DeepRecursiveVisitor {
11 static void setParents(Node node) {
12 ParentVisitor visitor = new ParentVisitor._make();
13 visitor._worklist.add(node);
14 visitor.trampoline();
15 }
16
17 /// Private to avoid accidental `new ParentVisitor().visit(node)` calls.
18 ParentVisitor._make();
19
20 Node _parent;
21 final List<Node> _worklist = <Node>[];
22
23 void trampoline() {
24 while (_worklist.isNotEmpty) {
25 _parent = _worklist.removeLast();
26 _parent.accept(this);
27 }
28 }
29
30 @override
31 visit(Node node) {
32 _worklist.add(node);
33 assert(_parent != node);
34 assert(_parent != null);
35 node.parent = _parent;
36 }
37
38 @override
39 processReference(Reference node) {
40 node.parent = _parent;
41 }
42 }
43
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/optimizers.dart ('k') | pkg/compiler/lib/src/cps_ir/redundant_join.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698