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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_nodes.dart

Issue 417043003: Implement shrinking reductions in CPS IR (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments, fixed several bugs exposed by later commits Created 6 years, 4 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../dart2jslib.dart' as dart2js show Constant, ConstructedConstant, 9 import '../dart2jslib.dart' as dart2js show Constant, ConstructedConstant,
10 StringConstant, ListConstant, MapConstant; 10 StringConstant, ListConstant, MapConstant;
11 import '../elements/elements.dart'; 11 import '../elements/elements.dart';
12 import '../universe/universe.dart' show Selector, SelectorKind; 12 import '../universe/universe.dart' show Selector, SelectorKind;
13 import '../dart_types.dart' show DartType, GenericType; 13 import '../dart_types.dart' show DartType, GenericType;
14 import 'const_expression.dart'; 14 import 'const_expression.dart';
15 import '../helpers/helpers.dart'; 15 import '../helpers/helpers.dart';
16 16
17 abstract class Node { 17 abstract class Node {
18 static int hashCount = 0; 18 static int hashCount = 0;
19 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff; 19 final int hashCode = hashCount = (hashCount + 1) & 0x3fffffff;
20 20
21 /// A pointer to the parent node. Is null until set by optimization passes.
22 Node parent;
23
21 accept(Visitor visitor); 24 accept(Visitor visitor);
22 } 25 }
23 26
24 abstract class Expression extends Node { 27 abstract class Expression extends Node {
25 Expression plug(Expression expr) => throw 'impossible'; 28 Expression plug(Expression expr) => throw 'impossible';
26 } 29 }
27 30
28 /// The base class of things that variables can refer to: primitives, 31 /// The base class of things that variables can refer to: primitives,
29 /// continuations, function and continuation parameters, etc. 32 /// continuations, function and continuation parameters, etc.
30 abstract class Definition extends Node { 33 abstract class Definition extends Node {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 79 }
77 } 80 }
78 81
79 /// Operands to invocations and primitives are always variables. They point to 82 /// Operands to invocations and primitives are always variables. They point to
80 /// their definition and are doubly-linked into a list of occurrences. 83 /// their definition and are doubly-linked into a list of occurrences.
81 class Reference { 84 class Reference {
82 Definition definition; 85 Definition definition;
83 Reference previous = null; 86 Reference previous = null;
84 Reference next = null; 87 Reference next = null;
85 88
89 /// A pointer to the parent node. Is null until set by optimization passes.
90 Node parent;
91
86 Reference(this.definition) { 92 Reference(this.definition) {
87 next = definition.firstRef; 93 next = definition.firstRef;
88 if (next != null) next.previous = this; 94 if (next != null) next.previous = this;
89 definition.firstRef = this; 95 definition.firstRef = this;
90 } 96 }
91 97
92 /// Unlinks this reference from the list of occurrences. 98 /// Unlinks this reference from the list of occurrences.
93 void unlink() { 99 void unlink() {
94 if (previous == null) { 100 if (previous == null) {
95 assert(definition.firstRef == this); 101 assert(definition.firstRef == this);
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 release(node.parameters[i]); 903 release(node.parameters[i]);
898 } 904 }
899 } 905 }
900 906
901 void visitIsTrue(IsTrue node) { 907 void visitIsTrue(IsTrue node) {
902 visitReference(node.value); 908 visitReference(node.value);
903 } 909 }
904 910
905 } 911 }
906 912
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698