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

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

Issue 2186423002: Only reload libraries when they may have been modified. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review Created 4 years, 4 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
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/isolate_reload.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) 2016, the Dart project authors. Please see the AUTHORS file 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 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_ISOLATE_RELOAD_H_ 5 #ifndef VM_ISOLATE_RELOAD_H_
6 #define VM_ISOLATE_RELOAD_H_ 6 #define VM_ISOLATE_RELOAD_H_
7 7
8 #include "include/dart_tools_api.h"
9
8 #include "vm/globals.h" 10 #include "vm/globals.h"
9 #include "vm/growable_array.h" 11 #include "vm/growable_array.h"
10 #include "vm/log.h" 12 #include "vm/log.h"
11 13
12 DECLARE_FLAG(bool, trace_reload); 14 DECLARE_FLAG(bool, trace_reload);
13 DECLARE_FLAG(bool, trace_reload_verbose); 15 DECLARE_FLAG(bool, trace_reload_verbose);
14 16
15 // 'Trace Isolate Reload' TIR_Print 17 // 'Trace Isolate Reload' TIR_Print
16 #if defined(_MSC_VER) 18 #if defined(_MSC_VER)
17 #define TIR_Print(format, ...) \ 19 #define TIR_Print(format, ...) \
18 if (FLAG_trace_reload) Log::Current()->Print(format, __VA_ARGS__) 20 if (FLAG_trace_reload) Log::Current()->Print(format, __VA_ARGS__)
19 #else 21 #else
20 #define TIR_Print(format, ...) \ 22 #define TIR_Print(format, ...) \
21 if (FLAG_trace_reload) Log::Current()->Print(format, ##__VA_ARGS__) 23 if (FLAG_trace_reload) Log::Current()->Print(format, ##__VA_ARGS__)
22 #endif 24 #endif
23 25
24 // 'Verbose Trace Isolate Reload' VTIR_Print 26 // 'Verbose Trace Isolate Reload' VTIR_Print
25 #if defined(_MSC_VER) 27 #if defined(_MSC_VER)
26 #define VTIR_Print(format, ...) \ 28 #define VTIR_Print(format, ...) \
27 if (FLAG_trace_reload_verbose) Log::Current()->Print(format, __VA_ARGS__) 29 if (FLAG_trace_reload_verbose) Log::Current()->Print(format, __VA_ARGS__)
28 #else 30 #else
29 #define VTIR_Print(format, ...) \ 31 #define VTIR_Print(format, ...) \
30 if (FLAG_trace_reload_verbose) Log::Current()->Print(format, ##__VA_ARGS__) 32 if (FLAG_trace_reload_verbose) Log::Current()->Print(format, ##__VA_ARGS__)
31 #endif 33 #endif
32 34
33 namespace dart { 35 namespace dart {
34 36
37 class BitVector;
35 class GrowableObjectArray; 38 class GrowableObjectArray;
36 class Isolate; 39 class Isolate;
37 class Library; 40 class Library;
41 class ObjectPointerVisitor;
42 class ObjectStore;
38 class RawError; 43 class RawError;
39 class RawGrowableObjectArray; 44 class RawGrowableObjectArray;
40 class RawLibrary; 45 class RawLibrary;
41 class RawObject; 46 class RawObject;
42 class RawString; 47 class RawString;
43 class ObjectPointerVisitor; 48 class Script;
44 class ObjectStore;
45 class UpdateClassesVisitor; 49 class UpdateClassesVisitor;
46 50
47 class IsolateReloadContext { 51 class IsolateReloadContext {
48 public: 52 public:
49 explicit IsolateReloadContext(Isolate* isolate); 53 explicit IsolateReloadContext(Isolate* isolate);
50 ~IsolateReloadContext(); 54 ~IsolateReloadContext();
51 55
52 void StartReload(); 56 void StartReload(bool force_reload);
53 void FinishReload(); 57 void FinishReload();
54 void AbortReload(const Error& error); 58 void AbortReload(const Error& error);
55 59
56 RawLibrary* saved_root_library() const; 60 RawLibrary* saved_root_library() const;
57 61
58 RawGrowableObjectArray* saved_libraries() const; 62 RawGrowableObjectArray* saved_libraries() const;
59 63
60 void ReportError(const Error& error); 64 void ReportError(const Error& error);
61 void ReportError(const String& error_msg); 65 void ReportError(const String& error_msg);
62 void ReportSuccess(); 66 void ReportSuccess();
63 67
68 bool reload_skipped() const { return reload_skipped_; }
69
64 bool has_error() const { return has_error_; } 70 bool has_error() const { return has_error_; }
65 RawError* error() const { return error_; } 71 RawError* error() const { return error_; }
66 72
73 int64_t reload_timestamp() const { return reload_timestamp_; }
74
67 static bool IsSameField(const Field& a, const Field& b); 75 static bool IsSameField(const Field& a, const Field& b);
68 static bool IsSameLibrary(const Library& a_lib, const Library& b_lib); 76 static bool IsSameLibrary(const Library& a_lib, const Library& b_lib);
69 static bool IsSameClass(const Class& a, const Class& b); 77 static bool IsSameClass(const Class& a, const Class& b);
70 78
71 RawClass* FindOriginalClass(const Class& cls); 79 RawClass* FindOriginalClass(const Class& cls);
72 80
73 bool IsDirty(const Library& lib); 81 bool IsDirty(const Library& lib);
74 82
75 // Prefers old classes when we are in the middle of a reload. 83 // Prefers old classes when we are in the middle of a reload.
76 RawClass* GetClassForHeapWalkAt(intptr_t cid); 84 RawClass* GetClassForHeapWalkAt(intptr_t cid);
77 85
78 void RegisterClass(const Class& new_cls); 86 void RegisterClass(const Class& new_cls);
79 87
80 // Finds the library private key for |replacement_or_new| or return null 88 // Finds the library private key for |replacement_or_new| or return null
81 // if |replacement_or_new| is new. 89 // if |replacement_or_new| is new.
82 RawString* FindLibraryPrivateKey(const Library& replacement_or_new); 90 RawString* FindLibraryPrivateKey(const Library& replacement_or_new);
83 91
84 int64_t start_time_micros() const { return start_time_micros_; } 92 int64_t start_time_micros() const { return start_time_micros_; }
85 93
94 static Dart_FileModifiedCallback file_modified_callback() {
95 return file_modified_callback_;
96 }
97 static void SetFileModifiedCallback(Dart_FileModifiedCallback callback) {
98 file_modified_callback_ = callback;
99 }
100
86 private: 101 private:
87 void set_saved_root_library(const Library& value); 102 void set_saved_root_library(const Library& value);
88 103
89 void set_saved_libraries(const GrowableObjectArray& value); 104 void set_saved_libraries(const GrowableObjectArray& value);
90 105
91 void VisitObjectPointers(ObjectPointerVisitor* visitor); 106 void VisitObjectPointers(ObjectPointerVisitor* visitor);
92 107
93 Isolate* isolate() { return isolate_; } 108 Isolate* isolate() { return isolate_; }
94 ObjectStore* object_store(); 109 ObjectStore* object_store();
95 110
96 void EnsuredUnoptimizedCodeForStack(); 111 void EnsuredUnoptimizedCodeForStack();
97 void DeoptimizeDependentCode(); 112 void DeoptimizeDependentCode();
98 113
99 void Checkpoint(); 114 void Checkpoint();
100 115
101 void CheckpointClasses(); 116 void CheckpointClasses();
102 117
103 // Is |lib| a library whose sources have not changed? 118 bool ScriptModifiedSince(const Script& script, int64_t since);
104 bool IsCleanLibrary(const Library& lib); 119 BitVector* FindModifiedLibraries(bool force_reload);
120
105 void CheckpointLibraries(); 121 void CheckpointLibraries();
106 122
107 bool ValidateReload(); 123 bool ValidateReload();
108 124
109 void Rollback(); 125 void Rollback();
110 126
111 void RollbackClasses(); 127 void RollbackClasses();
112 void RollbackLibraries(); 128 void RollbackLibraries();
113 129
114 #ifdef DEBUG 130 #ifdef DEBUG
115 void VerifyMaps(); 131 void VerifyMaps();
116 #endif 132 #endif
117 133
118 void Commit(); 134 void Commit();
119 135
120 void PostCommit(); 136 void PostCommit();
121 137
122 void ClearReplacedObjectBits(); 138 void ClearReplacedObjectBits();
123 139
124 // atomic_install: 140 // atomic_install:
125 void MarkAllFunctionsForRecompilation(); 141 void MarkAllFunctionsForRecompilation();
126 void ResetUnoptimizedICsOnStack(); 142 void ResetUnoptimizedICsOnStack();
127 void ResetMegamorphicCaches(); 143 void ResetMegamorphicCaches();
128 void InvalidateWorld(); 144 void InvalidateWorld();
129 145
130 int64_t start_time_micros_; 146 int64_t start_time_micros_;
147 int64_t reload_timestamp_;
131 Isolate* isolate_; 148 Isolate* isolate_;
149 bool reload_skipped_;
132 bool has_error_; 150 bool has_error_;
133 151
134 intptr_t saved_num_cids_; 152 intptr_t saved_num_cids_;
135 RawClass** saved_class_table_; 153 RawClass** saved_class_table_;
136 154
137 intptr_t num_saved_libs_; 155 intptr_t num_saved_libs_;
138 struct LibraryInfo { 156 struct LibraryInfo {
139 bool dirty; 157 bool dirty;
140 }; 158 };
141 MallocGrowableArray<LibraryInfo> library_infos_; 159 MallocGrowableArray<LibraryInfo> library_infos_;
142 160
161 // A bit vector indicating which of the original libraries were modified.
162 BitVector* modified_libs_;
163
143 RawClass* OldClassOrNull(const Class& replacement_or_new); 164 RawClass* OldClassOrNull(const Class& replacement_or_new);
144 165
145 RawLibrary* OldLibraryOrNull(const Library& replacement_or_new); 166 RawLibrary* OldLibraryOrNull(const Library& replacement_or_new);
146 void BuildLibraryMapping(); 167 void BuildLibraryMapping();
147 168
148 void AddClassMapping(const Class& replacement_or_new, 169 void AddClassMapping(const Class& replacement_or_new,
149 const Class& original); 170 const Class& original);
150 171
151 void AddLibraryMapping(const Library& replacement_or_new, 172 void AddLibraryMapping(const Library& replacement_or_new,
152 const Library& original); 173 const Library& original);
(...skipping 16 matching lines...) Expand all
169 RawArray* old_libraries_set_storage_; 190 RawArray* old_libraries_set_storage_;
170 RawArray* library_map_storage_; 191 RawArray* library_map_storage_;
171 RawArray* become_map_storage_; 192 RawArray* become_map_storage_;
172 RawGrowableObjectArray* become_enum_mappings_; 193 RawGrowableObjectArray* become_enum_mappings_;
173 RawLibrary* saved_root_library_; 194 RawLibrary* saved_root_library_;
174 RawGrowableObjectArray* saved_libraries_; 195 RawGrowableObjectArray* saved_libraries_;
175 RawObject** to() { return reinterpret_cast<RawObject**>(&saved_libraries_); } 196 RawObject** to() { return reinterpret_cast<RawObject**>(&saved_libraries_); }
176 197
177 friend class Isolate; 198 friend class Isolate;
178 friend class Class; // AddStaticFieldMapping, AddEnumBecomeMapping. 199 friend class Class; // AddStaticFieldMapping, AddEnumBecomeMapping.
200
201 static Dart_FileModifiedCallback file_modified_callback_;
179 }; 202 };
180 203
181 } // namespace dart 204 } // namespace dart
182 205
183 #endif // VM_ISOLATE_RELOAD_H_ 206 #endif // VM_ISOLATE_RELOAD_H_
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/isolate_reload.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698