| 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 static const double kMaxHeapGrowingFactor; | 532 static const double kMaxHeapGrowingFactor; |
| 533 static const double kMaxHeapGrowingFactorMemoryConstrained; | 533 static const double kMaxHeapGrowingFactorMemoryConstrained; |
| 534 static const double kMaxHeapGrowingFactorIdle; | 534 static const double kMaxHeapGrowingFactorIdle; |
| 535 static const double kTargetMutatorUtilization; | 535 static const double kTargetMutatorUtilization; |
| 536 | 536 |
| 537 static const int kNoGCFlags = 0; | 537 static const int kNoGCFlags = 0; |
| 538 static const int kReduceMemoryFootprintMask = 1; | 538 static const int kReduceMemoryFootprintMask = 1; |
| 539 static const int kAbortIncrementalMarkingMask = 2; | 539 static const int kAbortIncrementalMarkingMask = 2; |
| 540 static const int kFinalizeIncrementalMarkingMask = 4; | 540 static const int kFinalizeIncrementalMarkingMask = 4; |
| 541 | 541 |
| 542 // Making the heap iterable requires us to abort incremental marking. |
| 543 static const int kMakeHeapIterableMask = kAbortIncrementalMarkingMask; |
| 544 |
| 542 // The roots that have an index less than this are always in old space. | 545 // The roots that have an index less than this are always in old space. |
| 543 static const int kOldSpaceRoots = 0x20; | 546 static const int kOldSpaceRoots = 0x20; |
| 544 | 547 |
| 545 // The minimum size of a HeapObject on the heap. | 548 // The minimum size of a HeapObject on the heap. |
| 546 static const int kMinObjectSizeInWords = 2; | 549 static const int kMinObjectSizeInWords = 2; |
| 547 | 550 |
| 548 STATIC_ASSERT(kUndefinedValueRootIndex == | 551 STATIC_ASSERT(kUndefinedValueRootIndex == |
| 549 Internals::kUndefinedValueRootIndex); | 552 Internals::kUndefinedValueRootIndex); |
| 550 STATIC_ASSERT(kTheHoleValueRootIndex == Internals::kTheHoleValueRootIndex); | 553 STATIC_ASSERT(kTheHoleValueRootIndex == Internals::kTheHoleValueRootIndex); |
| 551 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); | 554 STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // start and hence is only valid if there is only a single reference to it. | 655 // start and hence is only valid if there is only a single reference to it. |
| 653 FixedArrayBase* LeftTrimFixedArray(FixedArrayBase* obj, int elements_to_trim); | 656 FixedArrayBase* LeftTrimFixedArray(FixedArrayBase* obj, int elements_to_trim); |
| 654 | 657 |
| 655 // Trim the given array from the right. | 658 // Trim the given array from the right. |
| 656 template<Heap::InvocationMode mode> | 659 template<Heap::InvocationMode mode> |
| 657 void RightTrimFixedArray(FixedArrayBase* obj, int elements_to_trim); | 660 void RightTrimFixedArray(FixedArrayBase* obj, int elements_to_trim); |
| 658 | 661 |
| 659 // Converts the given boolean condition to JavaScript boolean value. | 662 // Converts the given boolean condition to JavaScript boolean value. |
| 660 inline Oddball* ToBoolean(bool condition); | 663 inline Oddball* ToBoolean(bool condition); |
| 661 | 664 |
| 665 // Check whether the heap is currently iterable. |
| 666 bool IsHeapIterable(); |
| 667 |
| 662 // Notify the heap that a context has been disposed. | 668 // Notify the heap that a context has been disposed. |
| 663 int NotifyContextDisposed(bool dependant_context); | 669 int NotifyContextDisposed(bool dependant_context); |
| 664 | 670 |
| 665 void set_native_contexts_list(Object* object) { | 671 void set_native_contexts_list(Object* object) { |
| 666 native_contexts_list_ = object; | 672 native_contexts_list_ = object; |
| 667 } | 673 } |
| 668 Object* native_contexts_list() const { return native_contexts_list_; } | 674 Object* native_contexts_list() const { return native_contexts_list_; } |
| 669 | 675 |
| 670 void set_allocation_sites_list(Object* object) { | 676 void set_allocation_sites_list(Object* object) { |
| 671 allocation_sites_list_ = object; | 677 allocation_sites_list_ = object; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 // Methods triggering GCs. =================================================== | 1023 // Methods triggering GCs. =================================================== |
| 1018 // =========================================================================== | 1024 // =========================================================================== |
| 1019 | 1025 |
| 1020 // Performs garbage collection operation. | 1026 // Performs garbage collection operation. |
| 1021 // Returns whether there is a chance that another major GC could | 1027 // Returns whether there is a chance that another major GC could |
| 1022 // collect more garbage. | 1028 // collect more garbage. |
| 1023 inline bool CollectGarbage( | 1029 inline bool CollectGarbage( |
| 1024 AllocationSpace space, const char* gc_reason = NULL, | 1030 AllocationSpace space, const char* gc_reason = NULL, |
| 1025 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); | 1031 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 1026 | 1032 |
| 1027 // Performs a full garbage collection. | 1033 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is |
| 1034 // non-zero, then the slower precise sweeper is used, which leaves the heap |
| 1035 // in a state where we can iterate over the heap visiting all objects. |
| 1028 void CollectAllGarbage( | 1036 void CollectAllGarbage( |
| 1029 int flags = kFinalizeIncrementalMarkingMask, const char* gc_reason = NULL, | 1037 int flags = kFinalizeIncrementalMarkingMask, const char* gc_reason = NULL, |
| 1030 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); | 1038 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 1031 | 1039 |
| 1032 // Last hope GC, should try to squeeze as much as possible. | 1040 // Last hope GC, should try to squeeze as much as possible. |
| 1033 void CollectAllAvailableGarbage(const char* gc_reason = NULL); | 1041 void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
| 1034 | 1042 |
| 1035 // Reports and external memory pressure event, either performs a major GC or | 1043 // Reports and external memory pressure event, either performs a major GC or |
| 1036 // completes incremental marking in order to free external resources. | 1044 // completes incremental marking in order to free external resources. |
| 1037 void ReportExternalMemoryPressure(const char* gc_reason = NULL); | 1045 void ReportExternalMemoryPressure(const char* gc_reason = NULL); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1519 // Checks whether a global GC is necessary | 1527 // Checks whether a global GC is necessary |
| 1520 GarbageCollector SelectGarbageCollector(AllocationSpace space, | 1528 GarbageCollector SelectGarbageCollector(AllocationSpace space, |
| 1521 const char** reason); | 1529 const char** reason); |
| 1522 | 1530 |
| 1523 // Make sure there is a filler value behind the top of the new space | 1531 // Make sure there is a filler value behind the top of the new space |
| 1524 // so that the GC does not confuse some unintialized/stale memory | 1532 // so that the GC does not confuse some unintialized/stale memory |
| 1525 // with the allocation memento of the object at the top | 1533 // with the allocation memento of the object at the top |
| 1526 void EnsureFillerObjectAtTop(); | 1534 void EnsureFillerObjectAtTop(); |
| 1527 | 1535 |
| 1528 // Ensure that we have swept all spaces in such a way that we can iterate | 1536 // Ensure that we have swept all spaces in such a way that we can iterate |
| 1529 // over all objects. | 1537 // over all objects. May cause a GC. |
| 1530 void MakeHeapIterable(); | 1538 void MakeHeapIterable(); |
| 1531 | 1539 |
| 1532 // Performs garbage collection operation. | 1540 // Performs garbage collection operation. |
| 1533 // Returns whether there is a chance that another major GC could | 1541 // Returns whether there is a chance that another major GC could |
| 1534 // collect more garbage. | 1542 // collect more garbage. |
| 1535 bool CollectGarbage( | 1543 bool CollectGarbage( |
| 1536 GarbageCollector collector, const char* gc_reason, | 1544 GarbageCollector collector, const char* gc_reason, |
| 1537 const char* collector_reason, | 1545 const char* collector_reason, |
| 1538 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); | 1546 const GCCallbackFlags gc_callback_flags = kNoGCCallbackFlags); |
| 1539 | 1547 |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 friend class LargeObjectSpace; | 2644 friend class LargeObjectSpace; |
| 2637 friend class NewSpace; | 2645 friend class NewSpace; |
| 2638 friend class PagedSpace; | 2646 friend class PagedSpace; |
| 2639 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); | 2647 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); |
| 2640 }; | 2648 }; |
| 2641 | 2649 |
| 2642 } // namespace internal | 2650 } // namespace internal |
| 2643 } // namespace v8 | 2651 } // namespace v8 |
| 2644 | 2652 |
| 2645 #endif // V8_HEAP_HEAP_H_ | 2653 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |