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

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

Issue 1229563005: dart2js cps: Rewrite iterator/moveNext/current into JS array accesses. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Run redundant phi elimination before type propagation Created 5 years, 5 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 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 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 cps_ir.cps_fragment; 5 library cps_ir.cps_fragment;
6 6
7 import 'cps_ir_nodes.dart'; 7 import 'cps_ir_nodes.dart';
8 import '../constants/values.dart'; 8 import '../constants/values.dart';
9 import '../universe/universe.dart' show Selector; 9 import '../universe/universe.dart' show Selector;
10 import '../types/types.dart' show TypeMask; 10 import '../types/types.dart' show TypeMask;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 Expression root; 53 Expression root;
54 54
55 /// Node whose body is the hole in this CPS fragment. May be null. 55 /// Node whose body is the hole in this CPS fragment. May be null.
56 InteriorNode context; 56 InteriorNode context;
57 57
58 /// Source information to attach to every IR node created in the fragment. 58 /// Source information to attach to every IR node created in the fragment.
59 SourceInformation sourceInformation; 59 SourceInformation sourceInformation;
60 60
61 CpsFragment([this.sourceInformation, this.context]); 61 CpsFragment([this.sourceInformation, this.context]);
62 62
63 /// Asserts that the fragment is closed and returns the IR that was built. 63 bool get isOpen => root == null || context != null;
64 bool get isClosed => !isOpen;
65 bool get isEmpty => root == null;
66
67 /// Asserts that the fragment is non-empty and closed and returns the IR that
68 /// was built.
64 Expression get result { 69 Expression get result {
65 assert(context == null); 70 assert(!isEmpty);
66 assert(root != null); 71 assert(isClosed);
67 return root; 72 return root;
68 } 73 }
69 74
70 /// Put the given expression into the fragment's hole. 75 /// Put the given expression into the fragment's hole.
71 /// 76 ///
72 /// Afterwards the fragment is closed and cannot be extended until a new 77 /// Afterwards the fragment is closed and cannot be extended until a new
73 /// [context] is set. 78 /// [context] is set.
74 void put(Expression node) { 79 void put(Expression node) {
75 assert(root == null || context != null); // We must put the node somewhere. 80 assert(root == null || context != null); // We must put the node somewhere.
76 if (root == null) { 81 if (root == null) {
(...skipping 15 matching lines...) Expand all
92 } 97 }
93 98
94 /// Bind a constant value. 99 /// Bind a constant value.
95 Primitive makeConstant(ConstantValue constant) { 100 Primitive makeConstant(ConstantValue constant) {
96 return letPrim(new Constant(constant)); 101 return letPrim(new Constant(constant));
97 } 102 }
98 103
99 Primitive makeZero() => makeConstant(new IntConstantValue(0)); 104 Primitive makeZero() => makeConstant(new IntConstantValue(0));
100 Primitive makeOne() => makeConstant(new IntConstantValue(1)); 105 Primitive makeOne() => makeConstant(new IntConstantValue(1));
101 Primitive makeNull() => makeConstant(new NullConstantValue()); 106 Primitive makeNull() => makeConstant(new NullConstantValue());
107 Primitive makeTrue() => makeConstant(new TrueConstantValue());
108 Primitive makeFalse() => makeConstant(new FalseConstantValue());
102 109
103 /// Invoke a built-in operator. 110 /// Invoke a built-in operator.
104 Primitive applyBuiltin(BuiltinOperator op, List<Primitive> args) { 111 Primitive applyBuiltin(BuiltinOperator op, List<Primitive> args) {
105 return letPrim(new ApplyBuiltinOperator(op, args)); 112 return letPrim(new ApplyBuiltinOperator(op, args));
106 } 113 }
107 114
108 /// Inserts an invocation. binds its continuation, and returns the 115 /// Inserts an invocation. binds its continuation, and returns the
109 /// continuation parameter (i.e. the return value of the invocation). 116 /// continuation parameter (i.e. the return value of the invocation).
110 /// 117 ///
111 /// The continuation body becomes the new hole. 118 /// The continuation body becomes the new hole.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 /// in this fragment. 263 /// in this fragment.
257 /// 264 ///
258 /// [other] is reset to an empty fragment after this. 265 /// [other] is reset to an empty fragment after this.
259 void append(CpsFragment other) { 266 void append(CpsFragment other) {
260 if (other.root == null) return; 267 if (other.root == null) return;
261 put(other.root); 268 put(other.root);
262 context = other.context; 269 context = other.context;
263 other.context = null; 270 other.context = null;
264 other.root = null; 271 other.root = null;
265 } 272 }
273
274 /// Reads the value of the given mutable variable.
275 Primitive getMutable(MutableVariable variable) {
276 return letPrim(new GetMutableVariable(variable));
277 }
278
279 /// Sets the value of the given mutable variable.
280 void setMutable(MutableVariable variable, Primitive value) {
281 SetMutableVariable setter = new SetMutableVariable(variable, value);
282 put(setter);
283 context = setter;
284 }
285
286 /// Declare a new mutable variable.
287 void letMutable(MutableVariable variable, Primitive initialValue) {
288 LetMutable let = new LetMutable(variable, initialValue);
289 put(let);
290 context = let;
291 }
266 } 292 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698