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

Side by Side Diff: runtime/vm/isolate_reload.h

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 #ifndef VM_ISOLATE_RELOAD_H_
6 #define VM_ISOLATE_RELOAD_H_
7
8 #include "vm/globals.h"
9 #include "vm/growable_array.h"
10 #include "vm/log.h"
11
12 DECLARE_FLAG(bool, trace_reload);
13
14 // 'Trace Isolate Reload' TIR_Print
15 #if defined(_MSC_VER)
16 #define TIR_Print(format, ...) \
17 if (FLAG_trace_reload) Log::Current()->Print(format, __VA_ARGS__)
18 #else
19 #define TIR_Print(format, ...) \
20 if (FLAG_trace_reload) Log::Current()->Print(format, ##__VA_ARGS__)
21 #endif
22
23 namespace dart {
24
25 class GrowableObjectArray;
26 class Isolate;
27 class Library;
28 class RawError;
29 class RawGrowableObjectArray;
30 class RawLibrary;
31 class RawObject;
32 class RawString;
33 class ObjectPointerVisitor;
34 class ObjectStore;
35 class UpdateClassesVisitor;
36
37 class IsolateReloadContext {
38 public:
39 explicit IsolateReloadContext(Isolate* isolate, bool test_mode = false);
40 ~IsolateReloadContext();
41
42 void StartReload();
43 void FinishReload();
44 void AbortReload(const Error& error);
45
46 RawLibrary* saved_root_library() const;
47
48 RawGrowableObjectArray* saved_libraries() const;
49
50 void ReportError(const Error& error);
51 void ReportError(const String& error_msg);
52 void ReportSuccess();
53
54 bool has_error() const { return has_error_; }
55 RawError* error() const { return error_; }
56 bool test_mode() const { return test_mode_; }
57
58 static bool IsSameField(const Field& a, const Field& b);
59 static bool IsSameLibrary(const Library& a_lib, const Library& b_lib);
60 static bool IsSameClass(const Class& a, const Class& b);
61
62 RawClass* FindOriginalClass(const Class& cls);
63
64 bool IsDirty(const Library& lib);
65
66 // Prefers old classes when we are in the middle of a reload.
67 RawClass* GetClassForHeapWalkAt(intptr_t cid);
68
69 void RegisterClass(const Class& new_cls);
70
71 int64_t start_time_micros() const { return start_time_micros_; }
72
73 private:
74 void set_saved_root_library(const Library& value);
75
76 void set_saved_libraries(const GrowableObjectArray& value);
77
78 void VisitObjectPointers(ObjectPointerVisitor* visitor);
79
80 Isolate* isolate() { return isolate_; }
81 ObjectStore* object_store();
82
83 void EnsuredUnoptimizedCodeForStack();
84 void DeoptimizeDependentCode();
85
86 void Checkpoint();
87
88 void CheckpointClasses();
89
90 // Is |lib| a library whose sources have not changed?
91 bool IsCleanLibrary(const Library& lib);
92 void CheckpointLibraries();
93
94 bool ValidateReload();
95
96 void Rollback();
97
98 void RollbackClasses();
99 void RollbackLibraries();
100
101 #ifdef DEBUG
102 void VerifyMaps();
103 void VerifyCanonicalTypeArguments();
104 #endif
105
106 void Commit();
107
108 void PostCommit();
109
110 void ClearReplacedObjectBits();
111
112 void BuildCleanScriptSet();
113 void FilterCompileTimeConstants();
114
115 // atomic_install:
116 void MarkAllFunctionsForRecompilation();
117 void ResetUnoptimizedICsOnStack();
118 void ResetMegamorphicCaches();
119 void InvalidateWorld();
120
121 int64_t start_time_micros_;
122 Isolate* isolate_;
123 bool test_mode_;
124 bool has_error_;
125
126 intptr_t saved_num_cids_;
127 RawClass** saved_class_table_;
128
129 intptr_t num_saved_libs_;
130 struct LibraryInfo {
131 bool dirty;
132 };
133 MallocGrowableArray<LibraryInfo> library_infos_;
134
135 RawClass* OldClassOrNull(const Class& replacement_or_new);
136
137 RawLibrary* OldLibraryOrNull(const Library& replacement_or_new);
138 void BuildLibraryMapping();
139
140 void AddClassMapping(const Class& replacement_or_new,
141 const Class& original);
142
143 void AddLibraryMapping(const Library& replacement_or_new,
144 const Library& original);
145
146 void AddStaticFieldMapping(const Field& old_field, const Field& new_field);
147
148 void AddBecomeMapping(const Object& old, const Object& nue);
149
150 void RebuildDirectSubclasses();
151
152 RawClass* MappedClass(const Class& replacement_or_new);
153 RawLibrary* MappedLibrary(const Library& replacement_or_new);
154
155 RawObject** from() { return reinterpret_cast<RawObject**>(&script_uri_); }
156 RawString* script_uri_;
157 RawError* error_;
158 RawArray* clean_scripts_set_storage_;
159 RawArray* compile_time_constants_;
160 RawArray* old_classes_set_storage_;
161 RawArray* class_map_storage_;
162 RawArray* old_libraries_set_storage_;
163 RawArray* library_map_storage_;
164 RawArray* become_map_storage_;
165 RawLibrary* saved_root_library_;
166 RawGrowableObjectArray* saved_libraries_;
167 RawObject** to() { return reinterpret_cast<RawObject**>(&saved_libraries_); }
168
169 friend class Isolate;
170 friend class Class; // AddStaticFieldMapping.
171 };
172
173 } // namespace dart
174
175 #endif // VM_ISOLATE_RELOAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698