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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/universe/side_effects.dart

Issue 694353007: Move dart2js from sdk/lib/_internal/compiler to pkg/compiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of universe;
6
7 class SideEffects {
8 // Changes flags.
9 static const int FLAG_CHANGES_INDEX = 0;
10 static const int FLAG_CHANGES_INSTANCE_PROPERTY = FLAG_CHANGES_INDEX + 1;
11 static const int FLAG_CHANGES_STATIC_PROPERTY
12 = FLAG_CHANGES_INSTANCE_PROPERTY + 1;
13 static const int FLAG_CHANGES_COUNT = FLAG_CHANGES_STATIC_PROPERTY + 1;
14
15 // Depends flags (one for each changes flag).
16 static const int FLAG_DEPENDS_ON_INDEX_STORE = FLAG_CHANGES_COUNT;
17 static const int FLAG_DEPENDS_ON_INSTANCE_PROPERTY_STORE =
18 FLAG_DEPENDS_ON_INDEX_STORE + 1;
19 static const int FLAG_DEPENDS_ON_STATIC_PROPERTY_STORE =
20 FLAG_DEPENDS_ON_INSTANCE_PROPERTY_STORE + 1;
21 static const int FLAG_DEPENDS_ON_COUNT =
22 FLAG_DEPENDS_ON_STATIC_PROPERTY_STORE + 1;
23
24 int flags = 0;
25
26 SideEffects() {
27 setAllSideEffects();
28 setDependsOnSomething();
29 }
30
31 SideEffects.empty();
32
33 bool operator==(other) => flags == other.flags;
34
35 int get hashCode => throw new UnsupportedError('SideEffects.hashCode');
36
37 bool getFlag(int position) => (flags & (1 << position)) != 0;
38 void setFlag(int position) { flags |= (1 << position); }
39
40 int getChangesFlags() => flags & ((1 << FLAG_CHANGES_COUNT) - 1);
41 int getDependsOnFlags() {
42 return (flags & ((1 << FLAG_DEPENDS_ON_COUNT) - 1)) >> FLAG_CHANGES_COUNT;
43 }
44
45 bool hasSideEffects() => getChangesFlags() != 0;
46 bool dependsOnSomething() => getDependsOnFlags() != 0;
47
48 void setAllSideEffects() { flags |= ((1 << FLAG_CHANGES_COUNT) - 1); }
49
50 void clearAllSideEffects() { flags &= ~((1 << FLAG_CHANGES_COUNT) - 1); }
51
52 void setDependsOnSomething() {
53 int count = FLAG_DEPENDS_ON_COUNT - FLAG_CHANGES_COUNT;
54 flags |= (((1 << count) - 1) << FLAG_CHANGES_COUNT);
55 }
56 void clearAllDependencies() {
57 int count = FLAG_DEPENDS_ON_COUNT - FLAG_CHANGES_COUNT;
58 flags &= ~(((1 << count) - 1) << FLAG_CHANGES_COUNT);
59 }
60
61 bool dependsOnStaticPropertyStore() {
62 return getFlag(FLAG_DEPENDS_ON_STATIC_PROPERTY_STORE);
63 }
64 void setDependsOnStaticPropertyStore() {
65 setFlag(FLAG_DEPENDS_ON_STATIC_PROPERTY_STORE);
66 }
67 void setChangesStaticProperty() { setFlag(FLAG_CHANGES_STATIC_PROPERTY); }
68 bool changesStaticProperty() => getFlag(FLAG_CHANGES_STATIC_PROPERTY);
69
70 bool dependsOnIndexStore() => getFlag(FLAG_DEPENDS_ON_INDEX_STORE);
71 void setDependsOnIndexStore() { setFlag(FLAG_DEPENDS_ON_INDEX_STORE); }
72 void setChangesIndex() { setFlag(FLAG_CHANGES_INDEX); }
73 bool changesIndex() => getFlag(FLAG_CHANGES_INDEX);
74
75 bool dependsOnInstancePropertyStore() {
76 return getFlag(FLAG_DEPENDS_ON_INSTANCE_PROPERTY_STORE);
77 }
78 void setDependsOnInstancePropertyStore() {
79 setFlag(FLAG_DEPENDS_ON_INSTANCE_PROPERTY_STORE);
80 }
81 void setChangesInstanceProperty() { setFlag(FLAG_CHANGES_INSTANCE_PROPERTY); }
82 bool changesInstanceProperty() => getFlag(FLAG_CHANGES_INSTANCE_PROPERTY);
83
84 static int computeDependsOnFlags(int flags) => flags << FLAG_CHANGES_COUNT;
85
86 bool dependsOn(int dependsFlags) => (flags & dependsFlags) != 0;
87
88 void add(SideEffects other) {
89 flags |= other.flags;
90 }
91
92 String toString() {
93 StringBuffer buffer = new StringBuffer();
94 buffer.write('Depends on');
95 if (dependsOnIndexStore()) buffer.write(' []');
96 if (dependsOnInstancePropertyStore()) buffer.write(' field store');
97 if (dependsOnStaticPropertyStore()) buffer.write(' static store');
98 if (!dependsOnSomething()) buffer.write(' nothing');
99 buffer.write(', Changes');
100 if (changesIndex()) buffer.write(' []');
101 if (changesInstanceProperty()) buffer.write(' field');
102 if (changesStaticProperty()) buffer.write(' static');
103 if (!hasSideEffects()) buffer.write(' nothing');
104 buffer.write('.');
105 return buffer.toString();
106 }
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698