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