| 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 |
| 11 // Clients of this interface shouldn't depend on lots of heap internals. | 11 // Clients of this interface shouldn't depend on lots of heap internals. |
| 12 // Do not include anything from src/heap here! | 12 // Do not include anything from src/heap here! |
| 13 #include "src/allocation.h" | 13 #include "src/allocation.h" |
| 14 #include "src/assert-scope.h" | 14 #include "src/assert-scope.h" |
| 15 #include "src/atomic-utils.h" | 15 #include "src/atomic-utils.h" |
| 16 #include "src/globals.h" | 16 #include "src/globals.h" |
| 17 // TODO(mstarzinger): Three more includes to kill! | 17 // TODO(mstarzinger): Two more includes to kill! |
| 18 #include "src/heap/incremental-marking.h" | |
| 19 #include "src/heap/spaces.h" | 18 #include "src/heap/spaces.h" |
| 20 #include "src/heap/store-buffer.h" | 19 #include "src/heap/store-buffer.h" |
| 21 #include "src/list.h" | 20 #include "src/list.h" |
| 22 | 21 |
| 23 namespace v8 { | 22 namespace v8 { |
| 24 namespace internal { | 23 namespace internal { |
| 25 | 24 |
| 26 // Defines all the roots in Heap. | 25 // Defines all the roots in Heap. |
| 27 #define STRONG_ROOT_LIST(V) \ | 26 #define STRONG_ROOT_LIST(V) \ |
| 28 V(Map, byte_array_map, ByteArrayMap) \ | 27 V(Map, byte_array_map, ByteArrayMap) \ |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is | 1207 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is |
| 1209 // non-zero, then the slower precise sweeper is used, which leaves the heap | 1208 // non-zero, then the slower precise sweeper is used, which leaves the heap |
| 1210 // in a state where we can iterate over the heap visiting all objects. | 1209 // in a state where we can iterate over the heap visiting all objects. |
| 1211 void CollectAllGarbage( | 1210 void CollectAllGarbage( |
| 1212 int flags = kFinalizeIncrementalMarkingMask, const char* gc_reason = NULL, | 1211 int flags = kFinalizeIncrementalMarkingMask, const char* gc_reason = NULL, |
| 1213 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); | 1212 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 1214 | 1213 |
| 1215 // Last hope GC, should try to squeeze as much as possible. | 1214 // Last hope GC, should try to squeeze as much as possible. |
| 1216 void CollectAllAvailableGarbage(const char* gc_reason = NULL); | 1215 void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
| 1217 | 1216 |
| 1217 // Reports and external memory pressure event, either performs a major GC or |
| 1218 // completes incremental marking in order to free external resources. |
| 1219 void ReportExternalMemoryPressure(const char* gc_reason = NULL); |
| 1220 |
| 1218 // Invoked when GC was requested via the stack guard. | 1221 // Invoked when GC was requested via the stack guard. |
| 1219 void HandleGCRequest(); | 1222 void HandleGCRequest(); |
| 1220 | 1223 |
| 1221 // =========================================================================== | 1224 // =========================================================================== |
| 1222 // Iterators. ================================================================ | 1225 // Iterators. ================================================================ |
| 1223 // =========================================================================== | 1226 // =========================================================================== |
| 1224 | 1227 |
| 1225 // Iterates over all roots in the heap. | 1228 // Iterates over all roots in the heap. |
| 1226 void IterateRoots(ObjectVisitor* v, VisitMode mode); | 1229 void IterateRoots(ObjectVisitor* v, VisitMode mode); |
| 1227 // Iterates over all strong roots in the heap. | 1230 // Iterates over all strong roots in the heap. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 // incremental steps. | 1263 // incremental steps. |
| 1261 void StartIdleIncrementalMarking(); | 1264 void StartIdleIncrementalMarking(); |
| 1262 | 1265 |
| 1263 // Starts incremental marking assuming incremental marking is currently | 1266 // Starts incremental marking assuming incremental marking is currently |
| 1264 // stopped. | 1267 // stopped. |
| 1265 void StartIncrementalMarking(int gc_flags = kNoGCFlags, | 1268 void StartIncrementalMarking(int gc_flags = kNoGCFlags, |
| 1266 const GCCallbackFlags gc_callback_flags = | 1269 const GCCallbackFlags gc_callback_flags = |
| 1267 GCCallbackFlags::kNoGCCallbackFlags, | 1270 GCCallbackFlags::kNoGCCallbackFlags, |
| 1268 const char* reason = nullptr); | 1271 const char* reason = nullptr); |
| 1269 | 1272 |
| 1270 // Performs incremental marking steps of step_size_in_bytes as long as | |
| 1271 // deadline_ins_ms is not reached. step_size_in_bytes can be 0 to compute | |
| 1272 // an estimate increment. Returns the remaining time that cannot be used | |
| 1273 // for incremental marking anymore because a single step would exceed the | |
| 1274 // deadline. | |
| 1275 double AdvanceIncrementalMarking( | |
| 1276 intptr_t step_size_in_bytes, double deadline_in_ms, | |
| 1277 IncrementalMarking::StepActions step_actions); | |
| 1278 | |
| 1279 void FinalizeIncrementalMarkingIfComplete(const char* comment); | 1273 void FinalizeIncrementalMarkingIfComplete(const char* comment); |
| 1280 | 1274 |
| 1281 bool TryFinalizeIdleIncrementalMarking(double idle_time_in_ms); | 1275 bool TryFinalizeIdleIncrementalMarking(double idle_time_in_ms); |
| 1282 | 1276 |
| 1283 IncrementalMarking* incremental_marking() { return &incremental_marking_; } | 1277 IncrementalMarking* incremental_marking() { return incremental_marking_; } |
| 1284 | 1278 |
| 1285 // =========================================================================== | 1279 // =========================================================================== |
| 1286 // External string table API. ================================================ | 1280 // External string table API. ================================================ |
| 1287 // =========================================================================== | 1281 // =========================================================================== |
| 1288 | 1282 |
| 1289 // Registers an external string. | 1283 // Registers an external string. |
| 1290 inline void RegisterExternalString(String* string); | 1284 inline void RegisterExternalString(String* string); |
| 1291 | 1285 |
| 1292 // Finalizes an external string by deleting the associated external | 1286 // Finalizes an external string by deleting the associated external |
| 1293 // data and clearing the resource pointer. | 1287 // data and clearing the resource pointer. |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 | 2257 |
| 2264 // Last time a garbage collection happened. | 2258 // Last time a garbage collection happened. |
| 2265 double last_gc_time_; | 2259 double last_gc_time_; |
| 2266 | 2260 |
| 2267 Scavenger* scavenge_collector_; | 2261 Scavenger* scavenge_collector_; |
| 2268 | 2262 |
| 2269 MarkCompactCollector* mark_compact_collector_; | 2263 MarkCompactCollector* mark_compact_collector_; |
| 2270 | 2264 |
| 2271 StoreBuffer store_buffer_; | 2265 StoreBuffer store_buffer_; |
| 2272 | 2266 |
| 2273 IncrementalMarking incremental_marking_; | 2267 IncrementalMarking* incremental_marking_; |
| 2274 | 2268 |
| 2275 GCIdleTimeHandler* gc_idle_time_handler_; | 2269 GCIdleTimeHandler* gc_idle_time_handler_; |
| 2276 | 2270 |
| 2277 MemoryReducer* memory_reducer_; | 2271 MemoryReducer* memory_reducer_; |
| 2278 | 2272 |
| 2279 ObjectStats* object_stats_; | 2273 ObjectStats* object_stats_; |
| 2280 | 2274 |
| 2281 ScavengeJob* scavenge_job_; | 2275 ScavengeJob* scavenge_job_; |
| 2282 | 2276 |
| 2283 // These two counters are monotomically increasing and never reset. | 2277 // These two counters are monotomically increasing and never reset. |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2715 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2709 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2716 | 2710 |
| 2717 private: | 2711 private: |
| 2718 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2712 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2719 }; | 2713 }; |
| 2720 #endif // DEBUG | 2714 #endif // DEBUG |
| 2721 } | 2715 } |
| 2722 } // namespace v8::internal | 2716 } // namespace v8::internal |
| 2723 | 2717 |
| 2724 #endif // V8_HEAP_HEAP_H_ | 2718 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |