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

Side by Side Diff: src/global-handles.h

Issue 2801073006: Decouple root visitors from object visitors. (Closed)
Patch Set: rebase Created 3 years, 8 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 | « src/frames.cc ('k') | src/global-handles.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_GLOBAL_HANDLES_H_ 5 #ifndef V8_GLOBAL_HANDLES_H_
6 #define V8_GLOBAL_HANDLES_H_ 6 #define V8_GLOBAL_HANDLES_H_
7 7
8 #include <type_traits> 8 #include <type_traits>
9 9
10 #include "include/v8.h" 10 #include "include/v8.h"
11 #include "include/v8-profiler.h" 11 #include "include/v8-profiler.h"
12 12
13 #include "src/handles.h" 13 #include "src/handles.h"
14 #include "src/list.h" 14 #include "src/list.h"
15 #include "src/utils.h" 15 #include "src/utils.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20 class HeapStats; 20 class HeapStats;
21 class ObjectVisitor; 21 class RootVisitor;
22 22
23 // Structure for tracking global handles. 23 // Structure for tracking global handles.
24 // A single list keeps all the allocated global handles. 24 // A single list keeps all the allocated global handles.
25 // Destroyed handles stay in the list but is added to the free list. 25 // Destroyed handles stay in the list but is added to the free list.
26 // At GC the destroyed global handles are removed from the free list 26 // At GC the destroyed global handles are removed from the free list
27 // and deallocated. 27 // and deallocated.
28 28
29 enum WeaknessType { 29 enum WeaknessType {
30 // Embedder gets a handle to the dying object. 30 // Embedder gets a handle to the dying object.
31 FINALIZER_WEAK, 31 FINALIZER_WEAK,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 // Tells whether global handle is weak. 119 // Tells whether global handle is weak.
120 static bool IsWeak(Object** location); 120 static bool IsWeak(Object** location);
121 121
122 // Process pending weak handles. 122 // Process pending weak handles.
123 // Returns the number of freed nodes. 123 // Returns the number of freed nodes.
124 int PostGarbageCollectionProcessing( 124 int PostGarbageCollectionProcessing(
125 GarbageCollector collector, const v8::GCCallbackFlags gc_callback_flags); 125 GarbageCollector collector, const v8::GCCallbackFlags gc_callback_flags);
126 126
127 // Iterates over all strong handles. 127 // Iterates over all strong handles.
128 void IterateStrongRoots(ObjectVisitor* v); 128 void IterateStrongRoots(RootVisitor* v);
129 129
130 // Iterates over all handles. 130 // Iterates over all handles.
131 void IterateAllRoots(ObjectVisitor* v); 131 void IterateAllRoots(RootVisitor* v);
132 132
133 // Iterates over all handles that have embedder-assigned class ID. 133 // Iterates over all handles that have embedder-assigned class ID.
134 void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v); 134 void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v);
135 135
136 // Iterates over all handles in the new space that have embedder-assigned 136 // Iterates over all handles in the new space that have embedder-assigned
137 // class ID. 137 // class ID.
138 void IterateAllRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v); 138 void IterateAllRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v);
139 139
140 // Iterate over all handles in the new space that are weak, unmodified 140 // Iterate over all handles in the new space that are weak, unmodified
141 // and have class IDs 141 // and have class IDs
142 void IterateWeakRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v); 142 void IterateWeakRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v);
143 143
144 // Iterates over all weak roots in heap. 144 // Iterates over all weak roots in heap.
145 void IterateWeakRoots(ObjectVisitor* v); 145 void IterateWeakRoots(RootVisitor* v);
146 146
147 // Find all weak handles satisfying the callback predicate, mark 147 // Find all weak handles satisfying the callback predicate, mark
148 // them as pending. 148 // them as pending.
149 void IdentifyWeakHandles(WeakSlotCallback f); 149 void IdentifyWeakHandles(WeakSlotCallback f);
150 150
151 // NOTE: Five ...NewSpace... functions below are used during 151 // NOTE: Five ...NewSpace... functions below are used during
152 // scavenge collections and iterate over sets of handles that are 152 // scavenge collections and iterate over sets of handles that are
153 // guaranteed to contain all handles holding new space objects (but 153 // guaranteed to contain all handles holding new space objects (but
154 // may also include old space objects). 154 // may also include old space objects).
155 155
156 // Iterates over strong and dependent handles. See the node above. 156 // Iterates over strong and dependent handles. See the node above.
157 void IterateNewSpaceStrongAndDependentRoots(ObjectVisitor* v); 157 void IterateNewSpaceStrongAndDependentRoots(RootVisitor* v);
158 158
159 // Finds weak independent or partially independent handles satisfying 159 // Finds weak independent or partially independent handles satisfying
160 // the callback predicate and marks them as pending. See the note above. 160 // the callback predicate and marks them as pending. See the note above.
161 void IdentifyNewSpaceWeakIndependentHandles(WeakSlotCallbackWithHeap f); 161 void IdentifyNewSpaceWeakIndependentHandles(WeakSlotCallbackWithHeap f);
162 162
163 // Iterates over weak independent or partially independent handles. 163 // Iterates over weak independent or partially independent handles.
164 // See the note above. 164 // See the note above.
165 void IterateNewSpaceWeakIndependentRoots(ObjectVisitor* v); 165 void IterateNewSpaceWeakIndependentRoots(RootVisitor* v);
166 166
167 // Finds weak independent or unmodified handles satisfying 167 // Finds weak independent or unmodified handles satisfying
168 // the callback predicate and marks them as pending. See the note above. 168 // the callback predicate and marks them as pending. See the note above.
169 void MarkNewSpaceWeakUnmodifiedObjectsPending( 169 void MarkNewSpaceWeakUnmodifiedObjectsPending(
170 WeakSlotCallbackWithHeap is_unscavenged); 170 WeakSlotCallbackWithHeap is_unscavenged);
171 171
172 // Iterates over weak independent or unmodified handles. 172 // Iterates over weak independent or unmodified handles.
173 // See the note above. 173 // See the note above.
174 template <IterationMode mode> 174 template <IterationMode mode>
175 void IterateNewSpaceWeakUnmodifiedRoots(ObjectVisitor* v); 175 void IterateNewSpaceWeakUnmodifiedRoots(RootVisitor* v);
176 176
177 // Identify unmodified objects that are in weak state and marks them 177 // Identify unmodified objects that are in weak state and marks them
178 // unmodified 178 // unmodified
179 void IdentifyWeakUnmodifiedObjects(WeakSlotCallback is_unmodified); 179 void IdentifyWeakUnmodifiedObjects(WeakSlotCallback is_unmodified);
180 180
181 // Tear down the global handle structure. 181 // Tear down the global handle structure.
182 void TearDown(); 182 void TearDown();
183 183
184 Isolate* isolate() { return isolate_; } 184 Isolate* isolate() { return isolate_; }
185 185
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 // Assign a SingletonHandle to an empty slot and returns the handle. 298 // Assign a SingletonHandle to an empty slot and returns the handle.
299 Handle<Object> CreateSingleton(Isolate* isolate, 299 Handle<Object> CreateSingleton(Isolate* isolate,
300 Object* object, 300 Object* object,
301 SingletonHandle singleton) { 301 SingletonHandle singleton) {
302 Create(isolate, object, &singleton_handles_[singleton]); 302 Create(isolate, object, &singleton_handles_[singleton]);
303 return Get(singleton_handles_[singleton]); 303 return Get(singleton_handles_[singleton]);
304 } 304 }
305 305
306 // Iterates over all handles. 306 // Iterates over all handles.
307 void IterateAllRoots(ObjectVisitor* visitor); 307 void IterateAllRoots(RootVisitor* visitor);
308 // Iterates over all handles which might be in new space. 308 // Iterates over all handles which might be in new space.
309 void IterateNewSpaceRoots(ObjectVisitor* visitor); 309 void IterateNewSpaceRoots(RootVisitor* visitor);
310 // Rebuilds new space list. 310 // Rebuilds new space list.
311 void PostGarbageCollectionProcessing(Heap* heap); 311 void PostGarbageCollectionProcessing(Heap* heap);
312 312
313 private: 313 private:
314 static const int kInvalidIndex = -1; 314 static const int kInvalidIndex = -1;
315 static const int kShift = 8; 315 static const int kShift = 8;
316 static const int kSize = 1 << kShift; 316 static const int kSize = 1 << kShift;
317 static const int kMask = 0xff; 317 static const int kMask = 0xff;
318 318
319 // Gets the slot for an index 319 // Gets the slot for an index
320 inline Object** GetLocation(int index) { 320 inline Object** GetLocation(int index) {
321 DCHECK(index >= 0 && index < size_); 321 DCHECK(index >= 0 && index < size_);
322 return &blocks_[index >> kShift][index & kMask]; 322 return &blocks_[index >> kShift][index & kMask];
323 } 323 }
324 324
325 int size_; 325 int size_;
326 List<Object**> blocks_; 326 List<Object**> blocks_;
327 List<int> new_space_indices_; 327 List<int> new_space_indices_;
328 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; 328 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES];
329 329
330 DISALLOW_COPY_AND_ASSIGN(EternalHandles); 330 DISALLOW_COPY_AND_ASSIGN(EternalHandles);
331 }; 331 };
332 332
333 333
334 } // namespace internal 334 } // namespace internal
335 } // namespace v8 335 } // namespace v8
336 336
337 #endif // V8_GLOBAL_HANDLES_H_ 337 #endif // V8_GLOBAL_HANDLES_H_
OLDNEW
« no previous file with comments | « src/frames.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698