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

Side by Side Diff: vm/class_finalizer.h

Issue 9594028: Add a first class GrowableObjectArray type in the VM and use it internally in the VM at all spots w… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | « no previous file | vm/class_finalizer.cc » ('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 #ifndef VM_CLASS_FINALIZER_H_ 5 #ifndef VM_CLASS_FINALIZER_H_
6 #define VM_CLASS_FINALIZER_H_ 6 #define VM_CLASS_FINALIZER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 class AbstractType; 13 class AbstractType;
14 class AbstractTypeArguments; 14 class AbstractTypeArguments;
15 class Class; 15 class Class;
16 class Error; 16 class Error;
17 class Function; 17 class Function;
18 class GrowableObjectArray;
18 class RawAbstractType; 19 class RawAbstractType;
19 class RawClass; 20 class RawClass;
20 class RawType; 21 class RawType;
21 class Script; 22 class Script;
22 class Type; 23 class Type;
23 class UnresolvedClass; 24 class UnresolvedClass;
24 25
25 // Traverses all pending, unfinalized classes, validates and marks them as 26 // Traverses all pending, unfinalized classes, validates and marks them as
26 // finalized. 27 // finalized.
27 class ClassFinalizer : public AllStatic { 28 class ClassFinalizer : public AllStatic {
28 public: 29 public:
29 enum { 30 enum {
30 kGeneratingSnapshot = true, 31 kGeneratingSnapshot = true,
31 kNotGeneratingSnapshot = false 32 kNotGeneratingSnapshot = false
32 }; 33 };
33 34
34 // Add 'interface' to 'interface_list' if it is not already in the list and 35 // Add 'interface' to 'interface_list' if it is not already in the list and
35 // return true. Also return true if 'interface' is not added, because it is 36 // return true. Also return true if 'interface' is not added, because it is
36 // not unique, i.e. it is already in the list. 37 // not unique, i.e. it is already in the list.
37 // Return false if 'interface' conflicts with an interface already in the list 38 // Return false if 'interface' conflicts with an interface already in the list
38 // with the same class, but different type arguments. 39 // with the same class, but different type arguments.
39 // In the case of a conflict, set 'conflicting' to the existing interface. 40 // In the case of a conflict, set 'conflicting' to the existing interface.
40 static bool AddInterfaceIfUnique(GrowableArray<AbstractType*>* interface_list, 41 static bool AddInterfaceIfUnique(const GrowableObjectArray& interface_list,
41 AbstractType* interface, 42 const AbstractType& interface,
42 AbstractType* conflicting); 43 AbstractType* conflicting);
43 44
44 // Modes for type resolution and finalization. The ordering is relevant. 45 // Modes for type resolution and finalization. The ordering is relevant.
45 enum FinalizationKind { 46 enum FinalizationKind {
46 kIgnore, // Parsed type is ignored and replaced by Dynamic. 47 kIgnore, // Parsed type is ignored and replaced by Dynamic.
47 kDoNotResolve, // Type resolution is postponed. 48 kDoNotResolve, // Type resolution is postponed.
48 kTryResolve, // Type resolution is attempted, but not required. 49 kTryResolve, // Type resolution is attempted, but not required.
49 kFinalize, // Type resolution and type finalization are required. 50 kFinalize, // Type resolution and type finalization are required.
50 // A malformed type is tolerated. 51 // A malformed type is tolerated.
51 kFinalizeWellFormed // Error-free resolution and finalization are required. 52 kFinalizeWellFormed // Error-free resolution and finalization are required.
52 // A malformed type is not tolerated. 53 // A malformed type is not tolerated.
53 }; 54 };
54 55
55 // Finalize given type while parsing class cls. 56 // Finalize given type while parsing class cls.
56 // Also canonicalize type if applicable. 57 // Also canonicalize type if applicable.
57 static RawAbstractType* FinalizeType(const Class& cls, 58 static RawAbstractType* FinalizeType(const Class& cls,
58 const AbstractType& type, 59 const AbstractType& type,
59 FinalizationKind finalization); 60 FinalizationKind finalization);
60 61
61 // Replace the malformed type with Dynamic and, depending on the given type 62 // Replace the malformed type with Dynamic and, depending on the given type
62 // finalization mode and execution mode, mark the type as malformed or report 63 // finalization mode and execution mode, mark the type as malformed or report
63 // a compile time error. 64 // a compile time error.
64 static void FinalizeMalformedType(const Class& cls, 65 static void FinalizeMalformedType(const Class& cls,
65 const Type& type, 66 const Type& type,
66 FinalizationKind finalization, 67 FinalizationKind finalization,
67 const char* format, ...); 68 const char* format, ...);
68 69
69 // Pending classes are classes that need to be finalized.
70 static void AddPendingClasses(const GrowableArray<const Class*>& classes);
71
72 // Return false if we still have classes pending to be finalized. 70 // Return false if we still have classes pending to be finalized.
73 static bool AllClassesFinalized(); 71 static bool AllClassesFinalized();
74 72
75 // Return whether class finalization failed. 73 // Return whether class finalization failed.
76 // The function returns true if the finalization was successful. 74 // The function returns true if the finalization was successful.
77 // If finalization fails, an error message is set in the sticky error field 75 // If finalization fails, an error message is set in the sticky error field
78 // in the object store. 76 // in the object store.
79 static bool FinalizePendingClasses() { 77 static bool FinalizePendingClasses() {
80 return FinalizePendingClasses(kNotGeneratingSnapshot); 78 return FinalizePendingClasses(kNotGeneratingSnapshot);
81 } 79 }
82 static bool FinalizePendingClassesForSnapshotCreation() { 80 static bool FinalizePendingClassesForSnapshotCreation() {
83 return FinalizePendingClasses(kGeneratingSnapshot); 81 return FinalizePendingClasses(kGeneratingSnapshot);
84 } 82 }
85 83
86 // Verify that the pending classes have been properly prefinalized. This is 84 // Verify that the pending classes have been properly prefinalized. This is
87 // needed during bootstrapping where the classes have been preloaded. 85 // needed during bootstrapping where the classes have been preloaded.
88 static void VerifyBootstrapClasses(); 86 static void VerifyBootstrapClasses();
89 87
90 private: 88 private:
91 static bool FinalizePendingClasses(bool generating_snapshot); 89 static bool FinalizePendingClasses(bool generating_snapshot);
92 static void FinalizeClass(const Class& cls, bool generating_snapshot); 90 static void FinalizeClass(const Class& cls, bool generating_snapshot);
93 static bool IsSuperCycleFree(const Class& cls); 91 static bool IsSuperCycleFree(const Class& cls);
94 static void CheckForLegalConstClass(const Class& cls); 92 static void CheckForLegalConstClass(const Class& cls);
95 static RawClass* ResolveClass(const Class& cls, 93 static RawClass* ResolveClass(const Class& cls,
96 const UnresolvedClass& unresolved_class); 94 const UnresolvedClass& unresolved_class);
97 static void ResolveSuperType(const Class& cls); 95 static void ResolveSuperType(const Class& cls);
98 static void ResolveDefaultClass(const Class& cls); 96 static void ResolveDefaultClass(const Class& cls);
99 static void ResolveInterfaces(const Class& cls, 97 static void ResolveInterfaces(const Class& cls,
100 GrowableArray<const Class*>* visited); 98 const GrowableObjectArray& visited);
101 static void FinalizeTypeArguments(const Class& cls, 99 static void FinalizeTypeArguments(const Class& cls,
102 const AbstractTypeArguments& arguments, 100 const AbstractTypeArguments& arguments,
103 FinalizationKind finalization); 101 FinalizationKind finalization);
104 static void ResolveType(const Class& cls, 102 static void ResolveType(const Class& cls,
105 const AbstractType& type, 103 const AbstractType& type,
106 FinalizationKind finalization); 104 FinalizationKind finalization);
107 static void ResolveAndFinalizeUpperBounds(const Class& cls); 105 static void ResolveAndFinalizeUpperBounds(const Class& cls);
108 static void ResolveAndFinalizeSignature(const Class& cls, 106 static void ResolveAndFinalizeSignature(const Class& cls,
109 const Function& function); 107 const Function& function);
110 static void ResolveAndFinalizeMemberTypes(const Class& cls); 108 static void ResolveAndFinalizeMemberTypes(const Class& cls);
111 static void PrintClassInformation(const Class& cls); 109 static void PrintClassInformation(const Class& cls);
112 static void VerifyClassImplements(const Class& cls); 110 static void VerifyClassImplements(const Class& cls);
113 static void CollectInterfaces(const Class& cls, 111 static void CollectInterfaces(const Class& cls,
114 GrowableArray<const Class*>* interfaces); 112 const GrowableObjectArray& interfaces);
115 static void ReportError(const Error& error); 113 static void ReportError(const Error& error);
116 static void ReportError(const Script& script, 114 static void ReportError(const Script& script,
117 intptr_t token_index, 115 intptr_t token_index,
118 const char* format, ...); 116 const char* format, ...);
119 static void ReportError(const char* format, ...); 117 static void ReportError(const char* format, ...);
120 }; 118 };
121 119
122 } // namespace dart 120 } // namespace dart
123 121
124 #endif // VM_CLASS_FINALIZER_H_ 122 #endif // VM_CLASS_FINALIZER_H_
OLDNEW
« no previous file with comments | « no previous file | vm/class_finalizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698