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

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

Issue 10377166: Prepare to have more than one universe. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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 | « dart/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 int nextFreeClassId = 0;
7 Map<Element, String> generatedCode; 6 Map<Element, String> generatedCode;
8 Map<Element, String> generatedBailoutCode; 7 Map<Element, String> generatedBailoutCode;
9 final Set<ClassElement> instantiatedClasses; 8 final Set<ClassElement> instantiatedClasses;
10 final Set<SourceString> instantiatedClassInstanceFields; 9 final Set<SourceString> instantiatedClassInstanceFields;
11 final Set<FunctionElement> staticFunctionsNeedingGetter; 10 final Set<FunctionElement> staticFunctionsNeedingGetter;
12 final Map<SourceString, Set<Selector>> invokedNames; 11 final Map<SourceString, Set<Selector>> invokedNames;
13 final Map<SourceString, Set<Selector>> invokedGetters; 12 final Map<SourceString, Set<Selector>> invokedGetters;
14 final Map<SourceString, Set<Selector>> invokedSetters; 13 final Map<SourceString, Set<Selector>> invokedSetters;
15 final Map<String, LibraryElement> libraries;
16 // TODO(ngeoffray): This should be a Set<Type>. 14 // TODO(ngeoffray): This should be a Set<Type>.
17 final Set<Element> isChecks; 15 final Set<Element> isChecks;
18 final RuntimeTypeInformation rti; 16 final RuntimeTypeInformation rti;
19 17
20 Universe() : generatedCode = new Map<Element, String>(), 18 Universe() : generatedCode = new Map<Element, String>(),
21 generatedBailoutCode = new Map<Element, String>(), 19 generatedBailoutCode = new Map<Element, String>(),
22 libraries = new Map<String, LibraryElement>(),
23 instantiatedClasses = new Set<ClassElement>(), 20 instantiatedClasses = new Set<ClassElement>(),
24 instantiatedClassInstanceFields = new Set<SourceString>(), 21 instantiatedClassInstanceFields = new Set<SourceString>(),
25 staticFunctionsNeedingGetter = new Set<FunctionElement>(), 22 staticFunctionsNeedingGetter = new Set<FunctionElement>(),
26 invokedNames = new Map<SourceString, Set<Selector>>(), 23 invokedNames = new Map<SourceString, Set<Selector>>(),
27 invokedGetters = new Map<SourceString, Set<Selector>>(), 24 invokedGetters = new Map<SourceString, Set<Selector>>(),
28 invokedSetters = new Map<SourceString, Set<Selector>>(), 25 invokedSetters = new Map<SourceString, Set<Selector>>(),
29 isChecks = new Set<Element>(), 26 isChecks = new Set<Element>(),
30 rti = new RuntimeTypeInformation(); 27 rti = new RuntimeTypeInformation();
31 28
32 int getNextFreeClassId() => nextFreeClassId++;
33
34 void addGeneratedCode(WorkItem work, String code) { 29 void addGeneratedCode(WorkItem work, String code) {
35 generatedCode[work.element] = code; 30 generatedCode[work.element] = code;
36 } 31 }
37 32
38 void addBailoutCode(WorkItem work, String code) { 33 void addBailoutCode(WorkItem work, String code) {
39 generatedBailoutCode[work.element] = code; 34 generatedBailoutCode[work.element] = code;
40 } 35 }
41 36
42 bool hasMatchingSelector(Set<Selector> selectors, 37 bool hasMatchingSelector(Set<Selector> selectors,
43 Element member, 38 Element member,
44 Compiler compiler) { 39 Compiler compiler) {
45 if (selectors === null) return false; 40 if (selectors === null) return false;
46 for (Selector selector in selectors) { 41 for (Selector selector in selectors) {
47 if (selector.applies(member, compiler)) return true; 42 if (selector.applies(member, compiler)) return true;
48 } 43 }
49 return false; 44 return false;
50 } 45 }
51 46
52 bool hasInvocation(Element member, Compiler compiler) { 47 bool hasInvocation(Element member, Compiler compiler) {
53 return hasMatchingSelector( 48 return hasMatchingSelector(invokedNames[member.name], member, compiler);
54 compiler.universe.invokedNames[member.name], member, compiler);
55 } 49 }
56 50
57 bool hasGetter(Element member, Compiler compiler) { 51 bool hasGetter(Element member, Compiler compiler) {
58 return hasMatchingSelector( 52 return hasMatchingSelector(invokedGetters[member.name], member, compiler);
59 compiler.universe.invokedGetters[member.name], member, compiler);
60 } 53 }
61 54
62 bool hasSetter(Element member, Compiler compiler) { 55 bool hasSetter(Element member, Compiler compiler) {
63 return hasMatchingSelector( 56 return hasMatchingSelector(invokedSetters[member.name], member, compiler);
64 compiler.universe.invokedSetters[member.name], member, compiler);
65 } 57 }
66 } 58 }
67 59
68 class SelectorKind { 60 class SelectorKind {
69 final String name; 61 final String name;
70 const SelectorKind(this.name); 62 const SelectorKind(this.name);
71 63
72 static final SelectorKind GETTER = const SelectorKind('getter'); 64 static final SelectorKind GETTER = const SelectorKind('getter');
73 static final SelectorKind SETTER = const SelectorKind('setter'); 65 static final SelectorKind SETTER = const SelectorKind('setter');
74 static final SelectorKind INVOCATION = const SelectorKind('invocation'); 66 static final SelectorKind INVOCATION = const SelectorKind('invocation');
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 333
342 return false; 334 return false;
343 } 335 }
344 336
345 bool operator ==(other) { 337 bool operator ==(other) {
346 if (other is !TypedSelector) return false; 338 if (other is !TypedSelector) return false;
347 if (other.receiverType !== receiverType) return false; 339 if (other.receiverType !== receiverType) return false;
348 return super == other; 340 return super == other;
349 } 341 }
350 } 342 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/ssa/optimize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698