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

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

Issue 10539156: Track fields which are known to be always set to integer constants (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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>> fieldIntegerSetters;
16 // TODO(ngeoffray): This should be a Set<Type>. 17 // TODO(ngeoffray): This should be a Set<Type>.
17 final Set<Element> isChecks; 18 final Set<Element> isChecks;
18 final RuntimeTypeInformation rti; 19 final RuntimeTypeInformation rti;
19 20
20 Universe() : generatedCode = new Map<Element, String>(), 21 Universe() : generatedCode = new Map<Element, String>(),
21 generatedBailoutCode = new Map<Element, String>(), 22 generatedBailoutCode = new Map<Element, String>(),
22 instantiatedClasses = new Set<ClassElement>(), 23 instantiatedClasses = new Set<ClassElement>(),
23 instantiatedClassInstanceFields = new Set<SourceString>(), 24 instantiatedClassInstanceFields = new Set<SourceString>(),
24 staticFunctionsNeedingGetter = new Set<FunctionElement>(), 25 staticFunctionsNeedingGetter = new Set<FunctionElement>(),
25 invokedNames = new Map<SourceString, Set<Selector>>(), 26 invokedNames = new Map<SourceString, Set<Selector>>(),
26 invokedGetters = new Map<SourceString, Set<Selector>>(), 27 invokedGetters = new Map<SourceString, Set<Selector>>(),
27 invokedSetters = new Map<SourceString, Set<Selector>>(), 28 invokedSetters = new Map<SourceString, Set<Selector>>(),
28 fieldGetters = new Map<SourceString, Set<Selector>>(), 29 fieldGetters = new Map<SourceString, Set<Selector>>(),
29 fieldSetters = new Map<SourceString, Set<Selector>>(), 30 fieldSetters = new Map<SourceString, Set<Selector>>(),
31 fieldIntegerSetters =
32 new Map<Element, Map<SourceString, bool>>(),
30 isChecks = new Set<Element>(), 33 isChecks = new Set<Element>(),
31 rti = new RuntimeTypeInformation(); 34 rti = new RuntimeTypeInformation();
32 35
33 void addGeneratedCode(WorkItem work, String code) { 36 void addGeneratedCode(WorkItem work, String code) {
34 generatedCode[work.element] = code; 37 generatedCode[work.element] = code;
35 } 38 }
36 39
37 void addBailoutCode(WorkItem work, String code) { 40 void addBailoutCode(WorkItem work, String code) {
38 generatedBailoutCode[work.element] = code; 41 generatedBailoutCode[work.element] = code;
39 } 42 }
(...skipping 20 matching lines...) Expand all
60 return hasMatchingSelector(invokedSetters[member.name], member, compiler); 63 return hasMatchingSelector(invokedSetters[member.name], member, compiler);
61 } 64 }
62 65
63 bool hasFieldGetter(Element member, Compiler compiler) { 66 bool hasFieldGetter(Element member, Compiler compiler) {
64 return hasMatchingSelector(fieldGetters[member.name], member, compiler); 67 return hasMatchingSelector(fieldGetters[member.name], member, compiler);
65 } 68 }
66 69
67 bool hasFieldSetter(Element member, Compiler compiler) { 70 bool hasFieldSetter(Element member, Compiler compiler) {
68 return hasMatchingSelector(fieldSetters[member.name], member, compiler); 71 return hasMatchingSelector(fieldSetters[member.name], member, compiler);
69 } 72 }
73
74 void updateFieldIntegerSetters(
75 Type type, SourceString name, bool isInteger) {
76 Map<SourceString, bool> fields =
77 fieldIntegerSetters.putIfAbsent(type.element, () => new Map<SourceString , bool>());
ngeoffray 2012/06/14 13:01:21 line too long
Søren Gjesse 2012/06/15 13:19:59 Done.
78 if (!fields.containsKey(name)) {
79 fields[name] = isInteger;
80 } else {
81 fields[name] = fields[name] && isInteger;
82 }
83 }
84
85 bool hasFieldOnlyIntegerSetters(Type type, SourceString name) {
86 if (type == null) return false;
87 if (!fieldIntegerSetters.containsKey(type.element)) return false;
88 Map<SourceString, bool> fields = fieldIntegerSetters[type.element];
89 if (!fields.containsKey(name)) return false;
90 return fields[name];
91 }
70 } 92 }
71 93
72 class SelectorKind { 94 class SelectorKind {
73 final String name; 95 final String name;
74 const SelectorKind(this.name); 96 const SelectorKind(this.name);
75 97
76 static final SelectorKind GETTER = const SelectorKind('getter'); 98 static final SelectorKind GETTER = const SelectorKind('getter');
77 static final SelectorKind SETTER = const SelectorKind('setter'); 99 static final SelectorKind SETTER = const SelectorKind('setter');
78 static final SelectorKind INVOCATION = const SelectorKind('invocation'); 100 static final SelectorKind INVOCATION = const SelectorKind('invocation');
79 static final SelectorKind OPERATOR = const SelectorKind('operator'); 101 static final SelectorKind OPERATOR = const SelectorKind('operator');
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 367
346 return false; 368 return false;
347 } 369 }
348 370
349 bool operator ==(other) { 371 bool operator ==(other) {
350 if (other is !TypedSelector) return false; 372 if (other is !TypedSelector) return false;
351 if (other.receiverType !== receiverType) return false; 373 if (other.receiverType !== receiverType) return false;
352 return super == other; 374 return super == other;
353 } 375 }
354 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698