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

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

Issue 10584009: Refactor the collection of initializer list types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed last round of comments Created 8 years, 6 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/optimize.dart ('k') | no next file » | 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 Universe { 5 class Universe {
6 Map<Element, String> generatedCode; 6 Map<Element, String> generatedCode;
7 Map<Element, String> generatedBailoutCode; 7 Map<Element, String> generatedBailoutCode;
8 final Set<ClassElement> instantiatedClasses; 8 final Set<ClassElement> instantiatedClasses;
9 final Set<SourceString> instantiatedClassInstanceFields; 9 final Set<SourceString> instantiatedClassInstanceFields;
10 final Set<FunctionElement> staticFunctionsNeedingGetter; 10 final Set<FunctionElement> staticFunctionsNeedingGetter;
11 final Map<SourceString, Set<Selector>> invokedNames; 11 final Map<SourceString, Set<Selector>> invokedNames;
12 final Map<SourceString, Set<Selector>> invokedGetters; 12 final Map<SourceString, Set<Selector>> invokedGetters;
13 final Map<SourceString, Set<Selector>> invokedSetters; 13 final Map<SourceString, Set<Selector>> invokedSetters;
14 final Map<SourceString, Set<Selector>> fieldGetters; 14 final Map<SourceString, Set<Selector>> fieldGetters;
15 final Map<SourceString, Set<Selector>> fieldSetters; 15 final Map<SourceString, Set<Selector>> fieldSetters;
16 final Map<Element, Map<SourceString, bool>> fieldIntegerInitializers;
17 final Map<Element, Map<SourceString, bool>> fieldIntegerSetters;
18 // TODO(ngeoffray): This should be a Set<Type>. 16 // TODO(ngeoffray): This should be a Set<Type>.
19 final Set<Element> isChecks; 17 final Set<Element> isChecks;
20 final RuntimeTypeInformation rti; 18 final RuntimeTypeInformation rti;
21 19
22 Universe() : generatedCode = new Map<Element, String>(), 20 Universe() : generatedCode = new Map<Element, String>(),
23 generatedBailoutCode = new Map<Element, String>(), 21 generatedBailoutCode = new Map<Element, String>(),
24 instantiatedClasses = new Set<ClassElement>(), 22 instantiatedClasses = new Set<ClassElement>(),
25 instantiatedClassInstanceFields = new Set<SourceString>(), 23 instantiatedClassInstanceFields = new Set<SourceString>(),
26 staticFunctionsNeedingGetter = new Set<FunctionElement>(), 24 staticFunctionsNeedingGetter = new Set<FunctionElement>(),
27 invokedNames = new Map<SourceString, Set<Selector>>(), 25 invokedNames = new Map<SourceString, Set<Selector>>(),
28 invokedGetters = new Map<SourceString, Set<Selector>>(), 26 invokedGetters = new Map<SourceString, Set<Selector>>(),
29 invokedSetters = new Map<SourceString, Set<Selector>>(), 27 invokedSetters = new Map<SourceString, Set<Selector>>(),
30 fieldGetters = new Map<SourceString, Set<Selector>>(), 28 fieldGetters = new Map<SourceString, Set<Selector>>(),
31 fieldSetters = new Map<SourceString, Set<Selector>>(), 29 fieldSetters = new Map<SourceString, Set<Selector>>(),
32 fieldIntegerInitializers =
33 new Map<Element, Map<SourceString, bool>>(),
34 fieldIntegerSetters =
35 new Map<Element, Map<SourceString, bool>>(),
36 isChecks = new Set<Element>(), 30 isChecks = new Set<Element>(),
37 rti = new RuntimeTypeInformation(); 31 rti = new RuntimeTypeInformation();
38 32
39 void addGeneratedCode(WorkItem work, String code) { 33 void addGeneratedCode(WorkItem work, String code) {
40 generatedCode[work.element] = code; 34 generatedCode[work.element] = code;
41 } 35 }
42 36
43 void addBailoutCode(WorkItem work, String code) { 37 void addBailoutCode(WorkItem work, String code) {
44 generatedBailoutCode[work.element] = code; 38 generatedBailoutCode[work.element] = code;
45 } 39 }
(...skipping 20 matching lines...) Expand all
66 return hasMatchingSelector(invokedSetters[member.name], member, compiler); 60 return hasMatchingSelector(invokedSetters[member.name], member, compiler);
67 } 61 }
68 62
69 bool hasFieldGetter(Element member, Compiler compiler) { 63 bool hasFieldGetter(Element member, Compiler compiler) {
70 return hasMatchingSelector(fieldGetters[member.name], member, compiler); 64 return hasMatchingSelector(fieldGetters[member.name], member, compiler);
71 } 65 }
72 66
73 bool hasFieldSetter(Element member, Compiler compiler) { 67 bool hasFieldSetter(Element member, Compiler compiler) {
74 return hasMatchingSelector(fieldSetters[member.name], member, compiler); 68 return hasMatchingSelector(fieldSetters[member.name], member, compiler);
75 } 69 }
76
77 void updateFieldIntegerInitializers(Type type,
78 SourceString name,
79 bool isInteger) {
80 Map<SourceString, bool> fields =
81 fieldIntegerInitializers.putIfAbsent(
82 type.element, () => new Map<SourceString, bool>());
83 if (!fields.containsKey(name)) {
84 fields[name] = isInteger;
85 } else {
86 fields[name] = fields[name] && isInteger;
87 }
88 }
89
90 bool hasFieldOnlyIntegerInitializers(Type type, SourceString name) {
91 if (type == null) return false;
92 if (!fieldIntegerInitializers.containsKey(type.element)) return true;
93 Map<SourceString, bool> fields = fieldIntegerInitializers[type.element];
94 if (!fields.containsKey(name)) return false;
95 return fields[name];
96 }
97
98 void updateFieldIntegerSetters(Type type, SourceString name, bool isInteger) {
99 Map<SourceString, bool> fields =
100 fieldIntegerSetters.putIfAbsent(
101 type.element, () => new Map<SourceString, bool>());
102 if (!fields.containsKey(name)) {
103 fields[name] = isInteger;
104 } else {
105 fields[name] = fields[name] && isInteger;
106 }
107 }
108
109 bool couldHaveFieldOnlyIntegerSetters(Type type, SourceString name) {
110 if (type == null) return false;
111 if (!fieldIntegerSetters.containsKey(type.element)) return true;
112 Map<SourceString, bool> fields = fieldIntegerSetters[type.element];
113 if (!fields.containsKey(name)) return false;
114 return fields[name];
115 }
116
117 bool hasFieldOnlyIntegerSetters(Type type, SourceString name) {
118 if (type == null) return false;
119 if (!fieldIntegerSetters.containsKey(type.element)) return true;
120 Map<SourceString, bool> fields = fieldIntegerSetters[type.element];
121 if (!fields.containsKey(name)) return false;
122 return fields[name];
123 }
124 } 70 }
125 71
126 class SelectorKind { 72 class SelectorKind {
127 final String name; 73 final String name;
128 const SelectorKind(this.name); 74 const SelectorKind(this.name);
129 75
130 static final SelectorKind GETTER = const SelectorKind('getter'); 76 static final SelectorKind GETTER = const SelectorKind('getter');
131 static final SelectorKind SETTER = const SelectorKind('setter'); 77 static final SelectorKind SETTER = const SelectorKind('setter');
132 static final SelectorKind INVOCATION = const SelectorKind('invocation'); 78 static final SelectorKind INVOCATION = const SelectorKind('invocation');
133 static final SelectorKind OPERATOR = const SelectorKind('operator'); 79 static final SelectorKind OPERATOR = const SelectorKind('operator');
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 345
400 return false; 346 return false;
401 } 347 }
402 348
403 bool operator ==(other) { 349 bool operator ==(other) {
404 if (other is !TypedSelector) return false; 350 if (other is !TypedSelector) return false;
405 if (other.receiverType !== receiverType) return false; 351 if (other.receiverType !== receiverType) return false;
406 return super == other; 352 return super == other;
407 } 353 }
408 } 354 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698