| 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 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 | 1000 |
| 1001 // Checks whether the given object is allowed to be migrated from it's | 1001 // Checks whether the given object is allowed to be migrated from it's |
| 1002 // current space into the given destination space. Used for debugging. | 1002 // current space into the given destination space. Used for debugging. |
| 1003 inline bool AllowedToBeMigrated(HeapObject* object, AllocationSpace dest); | 1003 inline bool AllowedToBeMigrated(HeapObject* object, AllocationSpace dest); |
| 1004 | 1004 |
| 1005 // Sets the stub_cache_ (only used when expanding the dictionary). | 1005 // Sets the stub_cache_ (only used when expanding the dictionary). |
| 1006 void public_set_code_stubs(UnseededNumberDictionary* value) { | 1006 void public_set_code_stubs(UnseededNumberDictionary* value) { |
| 1007 roots_[kCodeStubsRootIndex] = value; | 1007 roots_[kCodeStubsRootIndex] = value; |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 // Support for computing object sizes for old objects during GCs. Returns | |
| 1011 // a function that is guaranteed to be safe for computing object sizes in | |
| 1012 // the current GC phase. | |
| 1013 HeapObjectCallback GcSafeSizeOfOldObjectFunction() { | |
| 1014 return gc_safe_size_of_old_object_; | |
| 1015 } | |
| 1016 | |
| 1017 // Sets the non_monomorphic_cache_ (only used when expanding the dictionary). | 1010 // Sets the non_monomorphic_cache_ (only used when expanding the dictionary). |
| 1018 void public_set_non_monomorphic_cache(UnseededNumberDictionary* value) { | 1011 void public_set_non_monomorphic_cache(UnseededNumberDictionary* value) { |
| 1019 roots_[kNonMonomorphicCacheRootIndex] = value; | 1012 roots_[kNonMonomorphicCacheRootIndex] = value; |
| 1020 } | 1013 } |
| 1021 | 1014 |
| 1022 void public_set_empty_script(Script* script) { | 1015 void public_set_empty_script(Script* script) { |
| 1023 roots_[kEmptyScriptRootIndex] = script; | 1016 roots_[kEmptyScriptRootIndex] = script; |
| 1024 } | 1017 } |
| 1025 | 1018 |
| 1026 void public_set_store_buffer_top(Address* top) { | 1019 void public_set_store_buffer_top(Address* top) { |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 bool operator==(const GCEpilogueCallbackPair& pair) const { | 1887 bool operator==(const GCEpilogueCallbackPair& pair) const { |
| 1895 return pair.callback == callback; | 1888 return pair.callback == callback; |
| 1896 } | 1889 } |
| 1897 v8::Isolate::GCPrologueCallback callback; | 1890 v8::Isolate::GCPrologueCallback callback; |
| 1898 GCType gc_type; | 1891 GCType gc_type; |
| 1899 // TODO(dcarney): remove variable | 1892 // TODO(dcarney): remove variable |
| 1900 bool pass_isolate_; | 1893 bool pass_isolate_; |
| 1901 }; | 1894 }; |
| 1902 List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; | 1895 List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; |
| 1903 | 1896 |
| 1904 // Support for computing object sizes during GC. | |
| 1905 HeapObjectCallback gc_safe_size_of_old_object_; | |
| 1906 static int GcSafeSizeOfOldObject(HeapObject* object); | |
| 1907 | |
| 1908 // Update the GC state. Called from the mark-compact collector. | |
| 1909 void MarkMapPointersAsEncoded(bool encoded) { | |
| 1910 DCHECK(!encoded); | |
| 1911 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; | |
| 1912 } | |
| 1913 | |
| 1914 // Code that should be run before and after each GC. Includes some | 1897 // Code that should be run before and after each GC. Includes some |
| 1915 // reporting/verification activities when compiled with DEBUG set. | 1898 // reporting/verification activities when compiled with DEBUG set. |
| 1916 void GarbageCollectionPrologue(); | 1899 void GarbageCollectionPrologue(); |
| 1917 void GarbageCollectionEpilogue(); | 1900 void GarbageCollectionEpilogue(); |
| 1918 | 1901 |
| 1919 void PreprocessStackTraces(); | 1902 void PreprocessStackTraces(); |
| 1920 | 1903 |
| 1921 // Pretenuring decisions are made based on feedback collected during new | 1904 // Pretenuring decisions are made based on feedback collected during new |
| 1922 // space evacuation. Note that between feedback collection and calling this | 1905 // space evacuation. Note that between feedback collection and calling this |
| 1923 // method object in old space must not move. | 1906 // method object in old space must not move. |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2742 public: | 2725 public: |
| 2743 virtual ~WeakObjectRetainer() {} | 2726 virtual ~WeakObjectRetainer() {} |
| 2744 | 2727 |
| 2745 // Return whether this object should be retained. If NULL is returned the | 2728 // Return whether this object should be retained. If NULL is returned the |
| 2746 // object has no references. Otherwise the address of the retained object | 2729 // object has no references. Otherwise the address of the retained object |
| 2747 // should be returned as in some GC situations the object has been moved. | 2730 // should be returned as in some GC situations the object has been moved. |
| 2748 virtual Object* RetainAs(Object* object) = 0; | 2731 virtual Object* RetainAs(Object* object) = 0; |
| 2749 }; | 2732 }; |
| 2750 | 2733 |
| 2751 | 2734 |
| 2752 // Intrusive object marking uses least significant bit of | |
| 2753 // heap object's map word to mark objects. | |
| 2754 // Normally all map words have least significant bit set | |
| 2755 // because they contain tagged map pointer. | |
| 2756 // If the bit is not set object is marked. | |
| 2757 // All objects should be unmarked before resuming | |
| 2758 // JavaScript execution. | |
| 2759 class IntrusiveMarking { | |
| 2760 public: | |
| 2761 static bool IsMarked(HeapObject* object) { | |
| 2762 return (object->map_word().ToRawValue() & kNotMarkedBit) == 0; | |
| 2763 } | |
| 2764 | |
| 2765 static void ClearMark(HeapObject* object) { | |
| 2766 uintptr_t map_word = object->map_word().ToRawValue(); | |
| 2767 object->set_map_word(MapWord::FromRawValue(map_word | kNotMarkedBit)); | |
| 2768 DCHECK(!IsMarked(object)); | |
| 2769 } | |
| 2770 | |
| 2771 static void SetMark(HeapObject* object) { | |
| 2772 uintptr_t map_word = object->map_word().ToRawValue(); | |
| 2773 object->set_map_word(MapWord::FromRawValue(map_word & ~kNotMarkedBit)); | |
| 2774 DCHECK(IsMarked(object)); | |
| 2775 } | |
| 2776 | |
| 2777 static Map* MapOfMarkedObject(HeapObject* object) { | |
| 2778 uintptr_t map_word = object->map_word().ToRawValue(); | |
| 2779 return MapWord::FromRawValue(map_word | kNotMarkedBit).ToMap(); | |
| 2780 } | |
| 2781 | |
| 2782 static int SizeOfMarkedObject(HeapObject* object) { | |
| 2783 return object->SizeFromMap(MapOfMarkedObject(object)); | |
| 2784 } | |
| 2785 | |
| 2786 private: | |
| 2787 static const uintptr_t kNotMarkedBit = 0x1; | |
| 2788 STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); // NOLINT | |
| 2789 }; | |
| 2790 | |
| 2791 | |
| 2792 #ifdef DEBUG | 2735 #ifdef DEBUG |
| 2793 // Helper class for tracing paths to a search target Object from all roots. | 2736 // Helper class for tracing paths to a search target Object from all roots. |
| 2794 // The TracePathFrom() method can be used to trace paths from a specific | 2737 // The TracePathFrom() method can be used to trace paths from a specific |
| 2795 // object to the search target object. | 2738 // object to the search target object. |
| 2796 class PathTracer : public ObjectVisitor { | 2739 class PathTracer : public ObjectVisitor { |
| 2797 public: | 2740 public: |
| 2798 enum WhatToFind { | 2741 enum WhatToFind { |
| 2799 FIND_ALL, // Will find all matches. | 2742 FIND_ALL, // Will find all matches. |
| 2800 FIND_FIRST // Will stop the search after first match. | 2743 FIND_FIRST // Will stop the search after first match. |
| 2801 }; | 2744 }; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2843 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2786 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2844 | 2787 |
| 2845 private: | 2788 private: |
| 2846 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2789 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2847 }; | 2790 }; |
| 2848 #endif // DEBUG | 2791 #endif // DEBUG |
| 2849 } | 2792 } |
| 2850 } // namespace v8::internal | 2793 } // namespace v8::internal |
| 2851 | 2794 |
| 2852 #endif // V8_HEAP_HEAP_H_ | 2795 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |