OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 class MemoryAllocator; | 330 class MemoryAllocator; |
331 class MemoryReducer; | 331 class MemoryReducer; |
332 class ObjectIterator; | 332 class ObjectIterator; |
333 class ObjectStats; | 333 class ObjectStats; |
334 class Page; | 334 class Page; |
335 class PagedSpace; | 335 class PagedSpace; |
336 class Scavenger; | 336 class Scavenger; |
337 class ScavengeJob; | 337 class ScavengeJob; |
338 class Space; | 338 class Space; |
339 class StoreBuffer; | 339 class StoreBuffer; |
| 340 class TracePossibleWrapperReporter; |
340 class WeakObjectRetainer; | 341 class WeakObjectRetainer; |
341 | 342 |
342 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); | 343 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); |
343 | 344 |
344 enum PromotionMode { PROMOTE_MARKED, DEFAULT_PROMOTION }; | 345 enum PromotionMode { PROMOTE_MARKED, DEFAULT_PROMOTION }; |
345 | 346 |
346 enum ArrayStorageAllocationMode { | 347 enum ArrayStorageAllocationMode { |
347 DONT_INITIALIZE_ARRAY_ELEMENTS, | 348 DONT_INITIALIZE_ARRAY_ELEMENTS, |
348 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE | 349 INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE |
349 }; | 350 }; |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 void RegisterReservationsForBlackAllocation(Reservation* reservations); | 1198 void RegisterReservationsForBlackAllocation(Reservation* reservations); |
1198 | 1199 |
1199 IncrementalMarking* incremental_marking() { return incremental_marking_; } | 1200 IncrementalMarking* incremental_marking() { return incremental_marking_; } |
1200 | 1201 |
1201 // =========================================================================== | 1202 // =========================================================================== |
1202 // Embedder heap tracer support. ============================================= | 1203 // Embedder heap tracer support. ============================================= |
1203 // =========================================================================== | 1204 // =========================================================================== |
1204 | 1205 |
1205 void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer); | 1206 void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer); |
1206 | 1207 |
1207 bool UsingEmbedderHeapTracer(); | 1208 bool UsingEmbedderHeapTracer() { return embedder_heap_tracer() != nullptr; } |
1208 | 1209 |
1209 void TracePossibleWrapper(JSObject* js_object); | 1210 void TracePossibleWrapper(JSObject* js_object); |
1210 | 1211 |
1211 void RegisterExternallyReferencedObject(Object** object); | 1212 void RegisterExternallyReferencedObject(Object** object); |
1212 | 1213 |
| 1214 void RegisterWrappersWithEmbedderHeapTracer(); |
| 1215 |
| 1216 // In order to avoid running out of memory we force tracing wrappers if there |
| 1217 // are too many of them. |
| 1218 bool RequiresImmediateWrapperProcessing(); |
| 1219 |
| 1220 EmbedderHeapTracer* embedder_heap_tracer() { return embedder_heap_tracer_; } |
| 1221 |
| 1222 EmbedderReachableReferenceReporter* embedder_reachable_reference_reporter() { |
| 1223 return embedder_reference_reporter_; |
| 1224 } |
| 1225 |
| 1226 size_t wrappers_to_trace() { return wrappers_to_trace_.size(); } |
| 1227 |
1213 // =========================================================================== | 1228 // =========================================================================== |
1214 // External string table API. ================================================ | 1229 // External string table API. ================================================ |
1215 // =========================================================================== | 1230 // =========================================================================== |
1216 | 1231 |
1217 // Registers an external string. | 1232 // Registers an external string. |
1218 inline void RegisterExternalString(String* string); | 1233 inline void RegisterExternalString(String* string); |
1219 | 1234 |
1220 // Finalizes an external string by deleting the associated external | 1235 // Finalizes an external string by deleting the associated external |
1221 // data and clearing the resource pointer. | 1236 // data and clearing the resource pointer. |
1222 inline void FinalizeExternalString(String* string); | 1237 inline void FinalizeExternalString(String* string); |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2314 | 2329 |
2315 int gc_callbacks_depth_; | 2330 int gc_callbacks_depth_; |
2316 | 2331 |
2317 bool deserialization_complete_; | 2332 bool deserialization_complete_; |
2318 | 2333 |
2319 StrongRootsList* strong_roots_list_; | 2334 StrongRootsList* strong_roots_list_; |
2320 | 2335 |
2321 // The depth of HeapIterator nestings. | 2336 // The depth of HeapIterator nestings. |
2322 int heap_iterator_depth_; | 2337 int heap_iterator_depth_; |
2323 | 2338 |
| 2339 EmbedderHeapTracer* embedder_heap_tracer_; |
| 2340 EmbedderReachableReferenceReporter* embedder_reference_reporter_; |
| 2341 std::vector<std::pair<void*, void*>> wrappers_to_trace_; |
| 2342 |
2324 // Used for testing purposes. | 2343 // Used for testing purposes. |
2325 bool force_oom_; | 2344 bool force_oom_; |
2326 | 2345 |
2327 // Classes in "heap" can be friends. | 2346 // Classes in "heap" can be friends. |
2328 friend class AlwaysAllocateScope; | 2347 friend class AlwaysAllocateScope; |
2329 friend class GCCallbacksScope; | 2348 friend class GCCallbacksScope; |
2330 friend class GCTracer; | 2349 friend class GCTracer; |
2331 friend class HeapIterator; | 2350 friend class HeapIterator; |
2332 friend class IdleScavengeObserver; | 2351 friend class IdleScavengeObserver; |
2333 friend class IncrementalMarking; | 2352 friend class IncrementalMarking; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2637 intptr_t step_size_; | 2656 intptr_t step_size_; |
2638 intptr_t bytes_to_next_step_; | 2657 intptr_t bytes_to_next_step_; |
2639 | 2658 |
2640 private: | 2659 private: |
2641 friend class LargeObjectSpace; | 2660 friend class LargeObjectSpace; |
2642 friend class NewSpace; | 2661 friend class NewSpace; |
2643 friend class PagedSpace; | 2662 friend class PagedSpace; |
2644 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2663 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
2645 }; | 2664 }; |
2646 | 2665 |
| 2666 class TracePossibleWrapperReporter : public EmbedderReachableReferenceReporter { |
| 2667 public: |
| 2668 explicit TracePossibleWrapperReporter(Heap* heap) : heap_(heap) {} |
| 2669 void ReportExternalReference(Value* object) override { |
| 2670 heap_->RegisterExternallyReferencedObject( |
| 2671 reinterpret_cast<Object**>(object)); |
| 2672 } |
| 2673 |
| 2674 private: |
| 2675 Heap* heap_; |
| 2676 }; |
| 2677 |
2647 } // namespace internal | 2678 } // namespace internal |
2648 } // namespace v8 | 2679 } // namespace v8 |
2649 | 2680 |
2650 #endif // V8_HEAP_HEAP_H_ | 2681 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |