⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 heap.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
  // corresponding to the range of allocated pointers  // [object_start, object_end).  static void IterateRSetRange(Address object_start,                               Address object_end,                               Address rset_start,                               ObjectSlotCallback copy_object_func);  // Returns whether the object resides in new space.  static inline bool InNewSpace(Object* object);  static inline bool InFromSpace(Object* object);  static inline bool InToSpace(Object* object);  // Checks whether an address/object in the heap (including auxiliary  // area and unused area).  static bool Contains(Address addr);  static bool Contains(HeapObject* value);  // Checks whether an address/object in a space.  // Currently used by tests and heap verification only.  static bool InSpace(Address addr, AllocationSpace space);  static bool InSpace(HeapObject* value, AllocationSpace space);  // Finds out which space an object should get promoted to based on its type.  static inline OldSpace* TargetSpace(HeapObject* object);  // Sets the stub_cache_ (only used when expanding the dictionary).  static void set_code_stubs(Dictionary* value) { code_stubs_ = value; }  // Sets the non_monomorphic_cache_ (only used when expanding the dictionary).  static void set_non_monomorphic_cache(Dictionary* value) {    non_monomorphic_cache_ = value;  }#ifdef DEBUG  static void Print();  static void PrintHandles();  // Verify the heap is in its normal state before or after a GC.  static void Verify();  // Report heap statistics.  static void ReportHeapStatistics(const char* title);  static void ReportCodeStatistics(const char* title);  // Fill in bogus values in from space  static void ZapFromSpace();#endif  // Makes a new symbol object  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation  // failed.  // Please note this function does not perform a garbage collection.  static Object* CreateSymbol(const char* str, int length, int hash);  static Object* CreateSymbol(String* str);  // Write barrier support for address[offset] = o.  inline static void RecordWrite(Address address, int offset);  // Given an address occupied by a live code object, return that object.  static Object* FindCodeObject(Address a);  // Invoke Shrink on shrinkable spaces.  static void Shrink();  enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };  static inline HeapState gc_state() { return gc_state_; }#ifdef DEBUG  static bool IsAllocationAllowed() { return allocation_allowed_; }  static inline bool allow_allocation(bool enable);  static bool disallow_allocation_failure() {    return disallow_allocation_failure_;  }  static void TracePathToObject();  static void TracePathToGlobal();#endif  // Callback function pased to Heap::Iterate etc.  Copies an object if  // necessary, the object might be promoted to an old space.  The caller must  // ensure the precondition that the object is (a) a heap object and (b) in  // the heap's from space.  static void CopyObject(HeapObject** p);  // Clear a range of remembered set addresses corresponding to the object  // area address 'start' with size 'size_in_bytes', eg, when adding blocks  // to the free list.  static void ClearRSetRange(Address start, int size_in_bytes);  // Rebuild remembered set in old and map spaces.  static void RebuildRSets();  //  // Support for the API.  //  static bool CreateApiObjects();  // Attempt to find the number in a small cache.  If we finds it, return  // the string representation of the number.  Otherwise return undefined.  static Object* GetNumberStringCache(Object* number);  // Update the cache with a new number-string pair.  static void SetNumberStringCache(Object* number, String* str);  // Entries in the cache.  Must be a power of 2.  static const int kNumberStringCacheSize = 64;  // Adjusts the amount of registered external memory.  // Returns the adjusted value.  static int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes) {    int amount = amount_of_external_allocated_memory_ + change_in_bytes;    if (change_in_bytes >= 0) {      // Avoid overflow.      if (amount > amount_of_external_allocated_memory_) {        amount_of_external_allocated_memory_ = amount;      }    } else {      // Avoid underflow.      if (amount >= 0) {        amount_of_external_allocated_memory_ = amount;      }    }    ASSERT(amount_of_external_allocated_memory_ >= 0);    return amount_of_external_allocated_memory_;  } private:  static int semispace_size_;  static int initial_semispace_size_;  static int young_generation_size_;  static int old_generation_size_;  static int new_space_growth_limit_;  static int scavenge_count_;  static const int kMaxMapSpaceSize = 8*MB;  static NewSpace* new_space_;  static OldSpace* old_pointer_space_;  static OldSpace* old_data_space_;  static OldSpace* code_space_;  static MapSpace* map_space_;  static LargeObjectSpace* lo_space_;  static HeapState gc_state_;  // Returns the size of object residing in non new spaces.  static int PromotedSpaceSize();  // Returns the amount of external memory registered since last global gc.  static int PromotedExternalMemorySize();  static int mc_count_;  // how many mark-compact collections happened  static int gc_count_;  // how many gc happened#ifdef DEBUG  static bool allocation_allowed_;  // If the --gc-interval flag is set to a positive value, this  // variable holds the value indicating the number of allocations  // remain until the next failure and garbage collection.  static int allocation_timeout_;  // Do we expect to be able to handle allocation failure at this  // time?  static bool disallow_allocation_failure_;#endif  // DEBUG  // Promotion limit that trigger a global GC  static int promoted_space_limit_;  // The amount of external memory registered through the API kept alive  // by global handles  static int amount_of_external_allocated_memory_;  // Caches the amount of external memory registered at the last global gc.  static int amount_of_external_allocated_memory_at_last_global_gc_;  // Indicates that an allocation has failed in the old generation since the  // last GC.  static int old_gen_exhausted_;  // Declare all the roots#define ROOT_DECLARATION(type, name) static type* name##_;  ROOT_LIST(ROOT_DECLARATION)#undef ROOT_DECLARATION// Utility type maps#define DECLARE_STRUCT_MAP(NAME, Name, name) static Map* name##_map_;  STRUCT_LIST(DECLARE_STRUCT_MAP)#undef DECLARE_STRUCT_MAP#define SYMBOL_DECLARATION(name, str) static String* name##_;  SYMBOL_LIST(SYMBOL_DECLARATION)#undef SYMBOL_DECLARATION  // GC callback function, called before and after mark-compact GC.  // Allocations in the callback function are disallowed.  static GCCallback global_gc_prologue_callback_;  static GCCallback global_gc_epilogue_callback_;  // Checks whether a global GC is necessary  static GarbageCollector SelectGarbageCollector(AllocationSpace space);  // Performs garbage collection  static void PerformGarbageCollection(AllocationSpace space,                                       GarbageCollector collector,                                       GCTracer* tracer);  // Returns either a Smi or a Number object from 'value'. If 'new_object'  // is false, it may return a preallocated immutable object.  static Object* SmiOrNumberFromDouble(double value,                                       bool new_object,                                       PretenureFlag pretenure = NOT_TENURED);  // Allocate an uninitialized object in map space.  The behavior is identical  // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't  // have to test the allocation space argument and (b) can reduce code size  // (since both AllocateRaw and AllocateRawMap are inlined).  static inline Object* AllocateRawMap(int size_in_bytes);  // Initializes a JSObject based on its map.  static void InitializeJSObjectFromMap(JSObject* obj,                                        FixedArray* properties,                                        Map* map);  static bool CreateInitialMaps();  static bool CreateInitialObjects();  static void CreateFixedStubs();  static Object* CreateOddball(Map* map,                               const char* to_string,                               Object* to_number);  // Allocate empty fixed array.  static Object* AllocateEmptyFixedArray();  // Performs a minor collection in new generation.  static void Scavenge();  // Performs a major collection in the whole heap.  static void MarkCompact(GCTracer* tracer);  // Code to be run before and after mark-compact.  static void MarkCompactPrologue();  static void MarkCompactEpilogue();  // Helper function used by CopyObject to copy a source object to an  // allocated target object and update the forwarding pointer in the source  // object.  Returns the target object.  static HeapObject* MigrateObject(HeapObject** source_p,                                   HeapObject* target,                                   int size);  // Helper function that governs the promotion policy from new space to  // old.  If the object's old address lies below the new space's age  // mark or if we've already filled the bottom 1/16th of the to space,  // we try to promote this object.  static inline bool ShouldBePromoted(Address old_address, int object_size);#if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)  // Record the copy of an object in the NewSpace's statistics.  static void RecordCopiedObject(HeapObject* obj);  // Record statistics before and after garbage collection.  static void ReportStatisticsBeforeGC();  static void ReportStatisticsAfterGC();#endif  // Update an old object's remembered set  static int UpdateRSet(HeapObject* obj);  // Rebuild remembered set in an old space.  static void RebuildRSets(PagedSpace* space);  // Rebuild remembered set in the large object space.  static void RebuildRSets(LargeObjectSpace* space);  static const int kInitialSymbolTableSize = 2048;  static const int kInitialEvalCacheSize = 64;  friend class Factory;  friend class DisallowAllocationFailure;};#ifdef DEBUG// Visitor class to verify interior pointers that do not have remembered set// bits.  All heap object pointers have to point into the heap to a location// that has a map pointer at its first word.  Caveat: Heap::Contains is an// approximation because it can return true for objects in a heap space but// above the allocation pointer.class VerifyPointersVisitor: public ObjectVisitor { public:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -