📄 heap.h.svn-base
字号:
// Please note this function does not perform a garbage collection. static Object* Allocate(Map* map, AllocationSpace space); // Allocates a JS Map in the heap. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this function does not perform a garbage collection. static Object* AllocateMap(InstanceType instance_type, int instance_size); // Allocates a partial map for bootstrapping. static Object* AllocatePartialMap(InstanceType instance_type, int instance_size); // Allocate a map for the specified function static Object* AllocateInitialMap(JSFunction* fun); // Allocates and fully initializes a String. There are two String // encodings: ASCII and two byte. One should choose between the three string // allocation functions based on the encoding of the string buffer used to // initialized the string. // - ...FromAscii initializes the string from a buffer that is ASCII // encoded (it does not check that the buffer is ASCII encoded) and the // result will be ASCII encoded. // - ...FromUTF8 initializes the string from a buffer that is UTF-8 // encoded. If the characters are all single-byte characters, the // result will be ASCII encoded, otherwise it will converted to two // byte. // - ...FromTwoByte initializes the string from a buffer that is two-byte // encoded. If the characters are all single-byte characters, the // result will be converted to ASCII, otherwise it will be left as // two-byte. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateStringFromAscii( Vector<const char> str, PretenureFlag pretenure = NOT_TENURED); static Object* AllocateStringFromUtf8( Vector<const char> str, PretenureFlag pretenure = NOT_TENURED); static Object* AllocateStringFromTwoByte( Vector<const uc16> str, PretenureFlag pretenure = NOT_TENURED); // Allocates a symbol in old space based on the character stream. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this function does not perform a garbage collection. static Object* AllocateSymbol(unibrow::CharacterStream* buffer, int chars, int hash); // Allocates and partially initializes a String. There are two String // encodings: ASCII and two byte. These functions allocate a string of the // given length and set its map and length fields. The characters of the // string are uninitialized. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateRawAsciiString( int length, PretenureFlag pretenure = NOT_TENURED); static Object* AllocateRawTwoByteString( int length, PretenureFlag pretenure = NOT_TENURED); // Computes a single character string where the character has code. // A cache is used for ascii codes. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. Please note this does not perform a garbage collection. static Object* LookupSingleCharacterStringFromCode(uint16_t code); // Allocate a byte array of the specified length // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please not this does not perform a garbage collection. static Object* AllocateByteArray(int length); // Allocates a fixed array initialized with undefined values // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateFixedArray(int length, PretenureFlag pretenure = NOT_TENURED); // Allocates a fixed array initialized with the hole values. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateFixedArrayWithHoles(int length); // AllocateHashTable is identical to AllocateFixedArray except // that the resulting object has hash_table_map as map. static Object* AllocateHashTable(int length); // Allocate a global (but otherwise uninitialized) context. static Object* AllocateGlobalContext(); // Allocate a function context. static Object* AllocateFunctionContext(int length, JSFunction* closure); // Allocate a 'with' context. static Object* AllocateWithContext(Context* previous, JSObject* extension); // Allocates a new utility object in the old generation. static Object* AllocateStruct(InstanceType type); // Initializes a function with a shared part and prototype. // Returns the function. // Note: this code was factored out of AllocateFunction such that // other parts of the VM could use it. Specifically, a function that creates // instances of type JS_FUNCTION_TYPE benefit from the use of this function. // Please note this does not perform a garbage collection. static Object* InitializeFunction(JSFunction* function, SharedFunctionInfo* shared, Object* prototype); // Allocates a function initialized with a shared part. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateFunction(Map* function_map, SharedFunctionInfo* shared, Object* prototype); // Indicies for direct access into argument objects. static const int arguments_callee_index = 0; static const int arguments_length_index = 1; // Allocates an arguments object - optionally with an elements array. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateArgumentsObject(Object* callee, int length); // Converts a double into either a Smi or a HeapNumber object. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* NewNumberFromDouble(double value, PretenureFlag pretenure = NOT_TENURED); // Same as NewNumberFromDouble, but may return a preallocated/immutable // number object (e.g., minus_zero_value_, nan_value_) static Object* NumberFromDouble(double value, PretenureFlag pretenure = NOT_TENURED); // Allocated a HeapNumber from value. static Object* AllocateHeapNumber(double value, PretenureFlag pretenure); static Object* AllocateHeapNumber(double value); // pretenure = NOT_TENURED // Converts an int into either a Smi or a HeapNumber object. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static inline Object* NumberFromInt32(int32_t value); // Converts an int into either a Smi or a HeapNumber object. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static inline Object* NumberFromUint32(uint32_t value); // Allocates a new proxy object. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateProxy(Address proxy, PretenureFlag pretenure = NOT_TENURED); // Allocates a new SharedFunctionInfo object. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateSharedFunctionInfo(Object* name); // Allocates a new cons string object. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateConsString(String* first, String* second); // Allocates a new sliced string object which is a slice of an underlying // string buffer stretching from the index start (inclusive) to the index // end (exclusive). // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateSlicedString(String* buffer, int start, int end); // Allocates a new sub string object which is a substring of an underlying // string buffer stretching from the index start (inclusive) to the index // end (exclusive). // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateSubString(String* buffer, int start, int end); // Allocate a new external string object, which is backed by a string // resource that resides outside the V8 heap. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this does not perform a garbage collection. static Object* AllocateExternalStringFromAscii( ExternalAsciiString::Resource* resource); static Object* AllocateExternalStringFromTwoByte( ExternalTwoByteString::Resource* resource); // Allocates an uninitialized object. The memory is non-executable if the // hardware and OS allow. // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this function does not perform a garbage collection. static inline Object* AllocateRaw(int size_in_bytes, AllocationSpace space); // Makes a new native code object // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation // failed. // Please note this function does not perform a garbage collection. static Object* CreateCode(const CodeDesc& desc, ScopeInfo<>* sinfo, Code::Flags flags); static Object* CopyCode(Code* code); // Finds the symbol for string in the symbol table. // If not found, a new symbol is added to the table and returned. // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation // failed. // Please note this function does not perform a garbage collection. static Object* LookupSymbol(Vector<const char> str); static Object* LookupAsciiSymbol(const char* str) { return LookupSymbol(CStrVector(str)); } static Object* LookupSymbol(String* str); // Compute the matching symbol map for a string if possible. // NULL is returned if string is in new space or not flattened. static Map* SymbolMapForString(String* str); // Converts the given boolean condition to JavaScript boolean value. static Object* ToBoolean(bool condition) { return condition ? true_value() : false_value(); } // Code that should be run before and after each GC. Includes some // reporting/verification activities when compiled with DEBUG set. static void GarbageCollectionPrologue(); static void GarbageCollectionEpilogue(); // Performs garbage collection operation. // Returns whether required_space bytes are available after the collection. static bool CollectGarbage(int required_space, AllocationSpace space); // Performs a full garbage collection. static void CollectAllGarbage(); // Utility to invoke the scavenger. This is needed in test code to // ensure correct callback for weak global handles. static void PerformScavenge(); static void SetGlobalGCPrologueCallback(GCCallback callback) { global_gc_prologue_callback_ = callback; } static void SetGlobalGCEpilogueCallback(GCCallback callback) { global_gc_epilogue_callback_ = callback; } // Heap roots#define ROOT_ACCESSOR(type, name) static type* name() { return name##_; } ROOT_LIST(ROOT_ACCESSOR)#undef ROOT_ACCESSOR// Utility type maps#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ static Map* name##_map() { return name##_map_; } STRUCT_LIST(STRUCT_MAP_ACCESSOR)#undef STRUCT_MAP_ACCESSOR#define SYMBOL_ACCESSOR(name, str) static String* name() { return name##_; } SYMBOL_LIST(SYMBOL_ACCESSOR)#undef SYMBOL_ACCESSOR // Iterates over all roots in the heap. static void IterateRoots(ObjectVisitor* v); // Iterates over all strong roots in the heap. static void IterateStrongRoots(ObjectVisitor* v); // Iterates remembered set of an old space. static void IterateRSet(PagedSpace* space, ObjectSlotCallback callback); // Iterates a range of remembered set addresses starting with rset_start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -