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

Side by Side Diff: lib/compiler/implementation/world.dart

Issue 11017006: Create and use new change/depends flags for the GVN analysis. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/ssa/nodes.dart ('k') | tests/language/language_dart2js.status » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class World { 5 class World {
6 final Compiler compiler; 6 final Compiler compiler;
7 final Map<ClassElement, Set<ClassElement>> subtypes; 7 final Map<ClassElement, Set<ClassElement>> subtypes;
8 final Set<ClassElement> classesNeedingRti; 8 final Set<ClassElement> classesNeedingRti;
9 final Map<ClassElement, Set<ClassElement>> rtiDependencies; 9 final Map<ClassElement, Set<ClassElement>> rtiDependencies;
10 final FunctionSet userDefinedGetters; 10 final FunctionSet userDefinedGetters;
11 final FunctionSet userDefinedSetters;
11 12
12 World(Compiler compiler) 13 World(Compiler compiler)
13 : subtypes = new Map<ClassElement, Set<ClassElement>>(), 14 : subtypes = new Map<ClassElement, Set<ClassElement>>(),
14 userDefinedGetters = new FunctionSet(compiler), 15 userDefinedGetters = new FunctionSet(compiler),
16 userDefinedSetters = new FunctionSet(compiler),
15 classesNeedingRti = new Set<ClassElement>(), 17 classesNeedingRti = new Set<ClassElement>(),
16 rtiDependencies = new Map<ClassElement, Set<ClassElement>>(), 18 rtiDependencies = new Map<ClassElement, Set<ClassElement>>(),
17 this.compiler = compiler; 19 this.compiler = compiler;
18 20
19 void populate() { 21 void populate() {
20 void addSubtypes(ClassElement cls) { 22 void addSubtypes(ClassElement cls) {
21 if (cls.resolutionState != STATE_DONE) { 23 if (cls.resolutionState != STATE_DONE) {
22 compiler.internalErrorOnElement( 24 compiler.internalErrorOnElement(
23 cls, 'Class "${cls.name.slowToString()}" is not resolved.'); 25 cls, 'Class "${cls.name.slowToString()}" is not resolved.');
24 } 26 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 Set<ClassElement> classes = 84 Set<ClassElement> classes =
83 rtiDependencies.putIfAbsent(element, () => new Set<ClassElement>()); 85 rtiDependencies.putIfAbsent(element, () => new Set<ClassElement>());
84 classes.add(dependency); 86 classes.add(dependency);
85 } 87 }
86 88
87 void recordUserDefinedGetter(Element element) { 89 void recordUserDefinedGetter(Element element) {
88 assert(element.isGetter()); 90 assert(element.isGetter());
89 userDefinedGetters.add(element); 91 userDefinedGetters.add(element);
90 } 92 }
91 93
94 void recordUserDefinedSetter(Element element) {
95 assert(element.isSetter());
96 userDefinedSetters.add(element);
97 }
98
92 bool hasAnyUserDefinedGetter(Selector selector) { 99 bool hasAnyUserDefinedGetter(Selector selector) {
93 return userDefinedGetters.hasAnyElementMatchingSelector(selector); 100 return userDefinedGetters.hasAnyElementMatchingSelector(selector);
94 } 101 }
95 102
103 bool hasAnyUserDefinedSetter(Selector selector) {
104 return userDefinedSetters.hasAnyElementMatchingSelector(selector);
105 }
106
96 void registerUsedElement(Element element) { 107 void registerUsedElement(Element element) {
97 if (element.isMember() && element.isGetter()) { 108 if (element.isMember()) {
98 // We're collecting user-defined getters to let the codegen know which 109 if (element.isGetter()) {
99 // field accesses might have side effects. 110 // We're collecting user-defined getters to let the codegen know which
100 userDefinedGetters.add(element); 111 // field accesses might have side effects.
112 recordUserDefinedGetter(element);
113 } else if (element.isSetter()) {
114 recordUserDefinedSetter(element);
115 }
101 } 116 }
102 } 117 }
103 118
104 /** 119 /**
105 * Returns a [MemberSet] that contains the possible targets of the given 120 * Returns a [MemberSet] that contains the possible targets of the given
106 * [selector] on a receiver with the given [type]. This includes all sub 121 * [selector] on a receiver with the given [type]. This includes all sub
107 * types. 122 * types.
108 */ 123 */
109 MemberSet _memberSetFor(DartType type, Selector selector) { 124 MemberSet _memberSetFor(DartType type, Selector selector) {
110 assert(compiler !== null); 125 assert(compiler !== null);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 final SourceString name; 184 final SourceString name;
170 185
171 MemberSet(SourceString this.name) : elements = new Set<Element>(); 186 MemberSet(SourceString this.name) : elements = new Set<Element>();
172 187
173 void add(Element element) { 188 void add(Element element) {
174 elements.add(element); 189 elements.add(element);
175 } 190 }
176 191
177 bool isEmpty() => elements.isEmpty(); 192 bool isEmpty() => elements.isEmpty();
178 } 193 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/nodes.dart ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698