OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library dart2js.cps_ir.effects; | 4 library dart2js.cps_ir.effects; |
5 | 5 |
6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
7 import '../universe/side_effects.dart' show SideEffects; | 7 import '../universe/side_effects.dart' show SideEffects; |
8 | 8 |
9 /// Bitmasks for tracking non-local side effects and dependencies. | 9 /// Bitmasks for tracking non-local side effects and dependencies. |
10 /// | 10 /// |
(...skipping 12 matching lines...) Expand all Loading... |
23 static const int numberOfEffectAreas = 5; | 23 static const int numberOfEffectAreas = 5; |
24 | 24 |
25 // Bitmasks for computation that modifies state in a given area. | 25 // Bitmasks for computation that modifies state in a given area. |
26 static const int _changes = 1; | 26 static const int _changes = 1; |
27 static const int changesStaticField = _changes << _staticField; | 27 static const int changesStaticField = _changes << _staticField; |
28 static const int changesInstanceField = _changes << _instanceField; | 28 static const int changesInstanceField = _changes << _instanceField; |
29 static const int changesIndexableContent = _changes << _indexableContent; | 29 static const int changesIndexableContent = _changes << _indexableContent; |
30 static const int changesIndexableLength = _changes << _indexableLength; | 30 static const int changesIndexableLength = _changes << _indexableLength; |
31 static const int changesOther = _changes << _other; | 31 static const int changesOther = _changes << _other; |
32 | 32 |
33 static const int changesAll = | 33 static const int changesAll = changesStaticField | |
34 changesStaticField | | |
35 changesInstanceField | | 34 changesInstanceField | |
36 changesIndexableContent | | 35 changesIndexableContent | |
37 changesIndexableLength | | 36 changesIndexableLength | |
38 changesOther; | 37 changesOther; |
39 | 38 |
40 // Bitmasks for computation that depends on state in a given area. | 39 // Bitmasks for computation that depends on state in a given area. |
41 static const int _depends = 1 << numberOfEffectAreas; | 40 static const int _depends = 1 << numberOfEffectAreas; |
42 static const int dependsOnStaticField = _depends << _staticField; | 41 static const int dependsOnStaticField = _depends << _staticField; |
43 static const int dependsOnInstanceField = _depends << _instanceField; | 42 static const int dependsOnInstanceField = _depends << _instanceField; |
44 static const int dependsOnIndexableContent = _depends << _indexableContent; | 43 static const int dependsOnIndexableContent = _depends << _indexableContent; |
45 static const int dependsOnIndexableLength = _depends << _indexableLength; | 44 static const int dependsOnIndexableLength = _depends << _indexableLength; |
46 static const int dependsOnOther = _depends << _other; | 45 static const int dependsOnOther = _depends << _other; |
47 | 46 |
48 static const int dependsOnAll = | 47 static const int dependsOnAll = dependsOnStaticField | |
49 dependsOnStaticField | | |
50 dependsOnInstanceField | | 48 dependsOnInstanceField | |
51 dependsOnIndexableContent | | 49 dependsOnIndexableContent | |
52 dependsOnIndexableLength | | 50 dependsOnIndexableLength | |
53 dependsOnOther; | 51 dependsOnOther; |
54 | 52 |
55 static const int all = changesAll | dependsOnAll; | 53 static const int all = changesAll | dependsOnAll; |
56 static const int none = 0; | 54 static const int none = 0; |
57 | 55 |
58 static int _changesArea(int effectArea) => _changes << effectArea; | 56 static int _changesArea(int effectArea) => _changes << effectArea; |
59 | 57 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 EffectNumbers._zero(); | 122 EffectNumbers._zero(); |
125 | 123 |
126 EffectNumbers.fresh(EffectNumberer numberer) { | 124 EffectNumbers.fresh(EffectNumberer numberer) { |
127 reset(numberer); | 125 reset(numberer); |
128 } | 126 } |
129 | 127 |
130 EffectNumbers copy() { | 128 EffectNumbers copy() { |
131 return new EffectNumbers._zero().._effectNumbers.setAll(0, _effectNumbers); | 129 return new EffectNumbers._zero().._effectNumbers.setAll(0, _effectNumbers); |
132 } | 130 } |
133 | 131 |
134 int operator[](int i) => _effectNumbers[i]; | 132 int operator [](int i) => _effectNumbers[i]; |
135 | 133 |
136 void operator[]=(int i, int value) { | 134 void operator []=(int i, int value) { |
137 _effectNumbers[i] = value; | 135 _effectNumbers[i] = value; |
138 } | 136 } |
139 | 137 |
140 int get staticField => _effectNumbers[Effects._staticField]; | 138 int get staticField => _effectNumbers[Effects._staticField]; |
141 int get instanceField => _effectNumbers[Effects._instanceField]; | 139 int get instanceField => _effectNumbers[Effects._instanceField]; |
142 int get indexableContent => _effectNumbers[Effects._indexableContent]; | 140 int get indexableContent => _effectNumbers[Effects._indexableContent]; |
143 int get indexableLength => _effectNumbers[Effects._indexableLength]; | 141 int get indexableLength => _effectNumbers[Effects._indexableLength]; |
144 int get other => _effectNumbers[Effects._other]; | 142 int get other => _effectNumbers[Effects._other]; |
145 | 143 |
146 void set staticField(int n) { | 144 void set staticField(int n) { |
147 _effectNumbers[Effects._staticField] = n; | 145 _effectNumbers[Effects._staticField] = n; |
148 } | 146 } |
| 147 |
149 void set instanceField(int n) { | 148 void set instanceField(int n) { |
150 _effectNumbers[Effects._instanceField] = n; | 149 _effectNumbers[Effects._instanceField] = n; |
151 } | 150 } |
| 151 |
152 void set indexableContent(int n) { | 152 void set indexableContent(int n) { |
153 _effectNumbers[Effects._indexableContent] = n; | 153 _effectNumbers[Effects._indexableContent] = n; |
154 } | 154 } |
| 155 |
155 void set indexableLength(int n) { | 156 void set indexableLength(int n) { |
156 _effectNumbers[Effects._indexableLength] = n; | 157 _effectNumbers[Effects._indexableLength] = n; |
157 } | 158 } |
| 159 |
158 void set other(int n) { | 160 void set other(int n) { |
159 _effectNumbers[Effects._other] = n; | 161 _effectNumbers[Effects._other] = n; |
160 } | 162 } |
161 | 163 |
162 void reset(EffectNumberer numberer) { | 164 void reset(EffectNumberer numberer) { |
163 for (int i = 0; i < Effects.numberOfEffectAreas; ++i) { | 165 for (int i = 0; i < Effects.numberOfEffectAreas; ++i) { |
164 _effectNumbers[i] = numberer.next(); | 166 _effectNumbers[i] = numberer.next(); |
165 } | 167 } |
166 } | 168 } |
167 | 169 |
(...skipping 20 matching lines...) Expand all Loading... |
188 List<int> getDependencies(int dependsFlags) { | 190 List<int> getDependencies(int dependsFlags) { |
189 Int32List copy = new Int32List.fromList(_effectNumbers); | 191 Int32List copy = new Int32List.fromList(_effectNumbers); |
190 for (int i = 0; i < Effects.numberOfEffectAreas; ++i) { | 192 for (int i = 0; i < Effects.numberOfEffectAreas; ++i) { |
191 if (dependsFlags & Effects._dependsOnArea(i) == 0) { | 193 if (dependsFlags & Effects._dependsOnArea(i) == 0) { |
192 copy[i] = EffectNumberer.none; | 194 copy[i] = EffectNumberer.none; |
193 } | 195 } |
194 } | 196 } |
195 return copy; | 197 return copy; |
196 } | 198 } |
197 } | 199 } |
OLD | NEW |