Chromium Code Reviews| Index: src/heap.h |
| diff --git a/src/heap.h b/src/heap.h |
| index c44d99edbf0c00cef1287c65d5a1b481ec5bfb5c..0b3e21cf11ab5aa922b9df398a17a44fdf9b9420 100644 |
| --- a/src/heap.h |
| +++ b/src/heap.h |
| @@ -705,18 +705,6 @@ class Heap { |
| return old_data_space_->allocation_limit_address(); |
| } |
| - // Allocates and initializes a new JavaScript object based on a |
| - // constructor. |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // If allocation_site is non-null, then a memento is emitted after the object |
| - // that points to the site. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateJSObject( |
| - JSFunction* constructor, |
| - PretenureFlag pretenure = NOT_TENURED, |
| - AllocationSite* allocation_site = NULL); |
| - |
| // Returns a deep copy of the JavaScript object. |
| // Properties and elements are copied too. |
| // Returns failure if allocation failed. |
| @@ -724,47 +712,6 @@ class Heap { |
| MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source, |
| AllocationSite* site = NULL); |
| - // Allocates and initializes a new JavaScript object based on a map. |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // Passing an allocation site means that a memento will be created that |
| - // points to the site. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateJSObjectFromMap( |
| - Map* map, |
| - PretenureFlag pretenure = NOT_TENURED, |
| - bool alloc_props = true, |
| - AllocationSite* allocation_site = NULL); |
| - |
| - // Allocates a heap object based on the map. |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // Please note this function does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* Allocate(Map* map, AllocationSpace space, |
| - AllocationSite* allocation_site = NULL); |
| - |
| - // 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. |
| - MUST_USE_RESULT MaybeObject* AllocateMap( |
| - InstanceType instance_type, |
| - int instance_size, |
| - ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
| - |
| - // Allocates a partial map for bootstrapping. |
| - MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType instance_type, |
| - int instance_size); |
| - |
| - // Allocate a block of memory in the given space (filled with a filler). |
| - // Used as a fall-back for generated code when the space is full. |
| - MUST_USE_RESULT MaybeObject* AllocateFillerObject(int size, |
| - bool double_align, |
| - AllocationSpace space); |
| - |
| - // Allocates an empty PolymorphicCodeCache. |
| - MUST_USE_RESULT MaybeObject* AllocatePolymorphicCodeCache(); |
| - |
| // Clear the Instanceof cache (used when a prototype changes). |
| inline void ClearInstanceofCache(); |
| @@ -774,32 +721,6 @@ class Heap { |
| // For use during bootup. |
| void RepairFreeListsAfterBoot(); |
| - // 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. |
| - MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow( |
| - Vector<const char> str, |
| - int non_ascii_start, |
| - PretenureFlag pretenure = NOT_TENURED); |
| - MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte( |
| - Vector<const uc16> str, |
| - PretenureFlag pretenure = NOT_TENURED); |
| - |
| // Allocates an internalized string in old space based on the character |
| // stream. Returns Failure::RetryAfterGC(requested_bytes, space) if the |
| // allocation failed. |
| @@ -824,51 +745,6 @@ class Heap { |
| MUST_USE_RESULT inline MaybeObject* AllocateInternalizedStringImpl( |
| T t, int chars, uint32_t hash_field); |
| - template<bool is_one_byte, typename T> |
| - MUST_USE_RESULT MaybeObject* AllocateInternalizedStringImpl( |
| - T t, int chars, uint32_t hash_field); |
| - |
| - // 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. |
| - MUST_USE_RESULT MaybeObject* LookupSingleCharacterStringFromCode( |
| - uint16_t code); |
| - |
| - // Allocate a byte array of the specified length |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateByteArray( |
| - int length, |
| - PretenureFlag pretenure = NOT_TENURED); |
| - |
| - // Allocates an external array of the specified length and type. |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateExternalArray( |
| - int length, |
| - ExternalArrayType array_type, |
| - void* external_pointer, |
| - PretenureFlag pretenure); |
| - |
| - // Allocates a fixed typed array of the specified length and type. |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateFixedTypedArray( |
| - int length, |
| - ExternalArrayType array_type, |
| - PretenureFlag pretenure); |
| - |
| - // Allocate a symbol in old space. |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateSymbol(); |
| - MUST_USE_RESULT MaybeObject* AllocatePrivateSymbol(); |
| - |
| // Allocates a fixed array initialized with undefined values |
| // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| // failed. |
| @@ -892,10 +768,6 @@ class Heap { |
| // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| MUST_USE_RESULT inline MaybeObject* CopyFixedArray(FixedArray* src); |
| - // Make a copy of src and return it. Returns |
| - // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| - MUST_USE_RESULT MaybeObject* CopyAndTenureFixedCOWArray(FixedArray* src); |
| - |
| // Make a copy of src, set the map, and return the copy. Returns |
| // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| MUST_USE_RESULT MaybeObject* CopyFixedArrayWithMap(FixedArray* src, Map* map); |
| @@ -905,42 +777,16 @@ class Heap { |
| MUST_USE_RESULT inline MaybeObject* CopyFixedDoubleArray( |
| FixedDoubleArray* src); |
| - // Make a copy of src, set the map, and return the copy. Returns |
| - // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| - MUST_USE_RESULT MaybeObject* CopyFixedDoubleArrayWithMap( |
| - FixedDoubleArray* src, Map* map); |
| - |
| // Make a copy of src and return it. Returns |
| // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| MUST_USE_RESULT inline MaybeObject* CopyConstantPoolArray( |
| ConstantPoolArray* src); |
| - // Make a copy of src, set the map, and return the copy. Returns |
| - // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| - MUST_USE_RESULT MaybeObject* CopyConstantPoolArrayWithMap( |
| - ConstantPoolArray* src, Map* map); |
| - |
| - MUST_USE_RESULT MaybeObject* AllocateConstantPoolArray( |
| - int number_of_int64_entries, |
| - int number_of_code_ptr_entries, |
| - int number_of_heap_ptr_entries, |
| - int number_of_int32_entries); |
| - |
| - // Allocates a fixed double array with uninitialized values. Returns |
| - // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedDoubleArray( |
| - int length, |
| - PretenureFlag pretenure = NOT_TENURED); |
| - |
| // AllocateHashTable is identical to AllocateFixedArray except |
| // that the resulting object has hash_table_map as map. |
| MUST_USE_RESULT MaybeObject* AllocateHashTable( |
| int length, PretenureFlag pretenure = NOT_TENURED); |
| - // Allocates a new utility object in the old generation. |
| - MUST_USE_RESULT MaybeObject* AllocateStruct(InstanceType type); |
| - |
| // Sloppy mode arguments object size. |
| static const int kSloppyArgumentsObjectSize = |
| JSObject::kHeaderSize + 2 * kPointerSize; |
| @@ -952,17 +798,6 @@ class Heap { |
| // callee is only valid in sloppy mode. |
| static const int kArgumentsCalleeIndex = 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. |
| - MUST_USE_RESULT MaybeObject* AllocateArgumentsObject( |
| - Object* callee, int length); |
| - |
| - // Allocated a HeapNumber from value. |
| - MUST_USE_RESULT MaybeObject* AllocateHeapNumber( |
| - double value, PretenureFlag pretenure = NOT_TENURED); |
| - |
| // Converts an int into either a Smi or a HeapNumber object. |
| // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| // failed. |
| @@ -970,13 +805,6 @@ class Heap { |
| MUST_USE_RESULT inline MaybeObject* NumberFromUint32( |
| uint32_t value, PretenureFlag pretenure = NOT_TENURED); |
| - // Allocates a new foreign object. |
| - // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| - // failed. |
| - // Please note this does not perform a garbage collection. |
| - MUST_USE_RESULT MaybeObject* AllocateForeign( |
| - Address address, PretenureFlag pretenure = NOT_TENURED); |
| - |
| // Finalizes an external string by deleting the associated external |
| // data and clearing the resource pointer. |
| inline void FinalizeExternalString(String* string); |
| @@ -992,27 +820,6 @@ class Heap { |
| // Maintain marking consistency for IncrementalMarking. |
| void AdjustLiveBytes(Address address, int by, InvocationMode mode); |
| - MUST_USE_RESULT MaybeObject* AllocateCode(int object_size, bool immovable); |
| - |
| - MUST_USE_RESULT MaybeObject* CopyCode(Code* code); |
| - |
| - // Copy the code and scope info part of the code object, but insert |
| - // the provided data as the relocation information. |
| - MUST_USE_RESULT MaybeObject* CopyCode(Code* code, Vector<byte> reloc_info); |
| - |
| - // Finds the internalized copy for string in the string table. |
| - // If not found, a new string 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. |
| - MUST_USE_RESULT MaybeObject* InternalizeUtf8String(const char* str) { |
| - return InternalizeUtf8String(CStrVector(str)); |
| - } |
| - MUST_USE_RESULT MaybeObject* InternalizeUtf8String(Vector<const char> str); |
| - |
| - MUST_USE_RESULT MaybeObject* InternalizeString(String* str); |
| - MUST_USE_RESULT MaybeObject* InternalizeStringWithKey(HashTableKey* key); |
| - |
| bool InternalizeStringIfExists(String* str, String** result); |
| bool InternalizeTwoCharsStringIfExists(String* str, String** result); |
| @@ -1729,6 +1536,69 @@ class Heap { |
| static void FatalProcessOutOfMemory(const char* location, |
| bool take_snapshot = false); |
| + protected: |
| + // Methods made available to tests. |
| + |
| + // 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. |
|
Michael Starzinger
2014/04/29 13:15:09
nit: I never was sure of the value of duplicating
Yang
2014/04/29 13:55:13
Done.
|
| + MUST_USE_RESULT MaybeObject* AllocateMap( |
| + InstanceType instance_type, |
| + int instance_size, |
| + ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND); |
| + |
| + // Allocates and initializes a new JavaScript object based on a |
| + // constructor. |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // If allocation_site is non-null, then a memento is emitted after the object |
| + // that points to the site. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateJSObject( |
| + JSFunction* constructor, |
| + PretenureFlag pretenure = NOT_TENURED, |
| + AllocationSite* allocation_site = NULL); |
| + |
| + // Allocates and initializes a new JavaScript object based on a map. |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // Passing an allocation site means that a memento will be created that |
| + // points to the site. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateJSObjectFromMap( |
| + Map* map, |
| + PretenureFlag pretenure = NOT_TENURED, |
| + bool alloc_props = true, |
| + AllocationSite* allocation_site = NULL); |
| + |
| + // Allocated a HeapNumber from value. |
| + MUST_USE_RESULT MaybeObject* AllocateHeapNumber( |
| + double value, PretenureFlag pretenure = NOT_TENURED); |
| + |
| + // Allocate a byte array of the specified length |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateByteArray( |
| + int length, |
| + PretenureFlag pretenure = NOT_TENURED); |
| + |
| + // 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. |
| + MUST_USE_RESULT MaybeObject* AllocateArgumentsObject( |
| + Object* callee, int length); |
| + |
| + // Copy the code and scope info part of the code object, but insert |
| + // the provided data as the relocation information. |
| + MUST_USE_RESULT MaybeObject* CopyCode(Code* code, Vector<byte> reloc_info); |
| + |
| + MUST_USE_RESULT MaybeObject* CopyCode(Code* code); |
| + |
| + MUST_USE_RESULT MaybeObject* InternalizeString(String* str); |
| + |
| private: |
| Heap(); |
| @@ -1985,6 +1855,33 @@ class Heap { |
| AllocationSpace space, |
| AllocationSpace retry_space); |
| + // Allocates a heap object based on the map. |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // Please note this function does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* Allocate(Map* map, AllocationSpace space, |
| + AllocationSite* allocation_site = NULL); |
| + |
| + // Allocates a partial map for bootstrapping. |
| + MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType instance_type, |
| + int instance_size); |
| + |
| + // Initializes a JSObject based on its map. |
| + void InitializeJSObjectFromMap(JSObject* obj, |
| + FixedArray* properties, |
| + Map* map); |
| + void InitializeAllocationMemento(AllocationMemento* memento, |
| + AllocationSite* allocation_site); |
| + |
| + bool CreateInitialMaps(); |
| + bool CreateInitialObjects(); |
| + |
| + // Allocate a block of memory in the given space (filled with a filler). |
| + // Used as a fall-back for generated code when the space is full. |
| + MUST_USE_RESULT MaybeObject* AllocateFillerObject(int size, |
| + bool double_align, |
| + AllocationSpace space); |
| + |
| // Allocate an uninitialized fixed array. |
| MUST_USE_RESULT MaybeObject* AllocateRawFixedArray( |
| int length, PretenureFlag pretenure); |
| @@ -2006,15 +1903,98 @@ class Heap { |
| MUST_USE_RESULT MaybeObject* AllocateRawTwoByteString( |
| int length, PretenureFlag pretenure); |
| - // Initializes a JSObject based on its map. |
| - void InitializeJSObjectFromMap(JSObject* obj, |
| - FixedArray* properties, |
| - Map* map); |
| - void InitializeAllocationMemento(AllocationMemento* memento, |
| - AllocationSite* allocation_site); |
| + // 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. |
| + MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow( |
| + Vector<const char> str, |
| + int non_ascii_start, |
| + PretenureFlag pretenure = NOT_TENURED); |
| + MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte( |
| + Vector<const uc16> str, |
| + PretenureFlag pretenure = NOT_TENURED); |
| - bool CreateInitialMaps(); |
| - bool CreateInitialObjects(); |
| + template<bool is_one_byte, typename T> |
| + MUST_USE_RESULT MaybeObject* AllocateInternalizedStringImpl( |
| + T t, int chars, uint32_t hash_field); |
| + |
| + // 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. |
| + MUST_USE_RESULT MaybeObject* LookupSingleCharacterStringFromCode( |
| + uint16_t code); |
| + |
| + // Allocate a symbol in old space. |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateSymbol(); |
| + MUST_USE_RESULT MaybeObject* AllocatePrivateSymbol(); |
| + |
| + // Allocates an empty PolymorphicCodeCache. |
| + MUST_USE_RESULT MaybeObject* AllocatePolymorphicCodeCache(); |
| + |
| + // Make a copy of src, set the map, and return the copy. Returns |
| + // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| + MUST_USE_RESULT MaybeObject* CopyConstantPoolArrayWithMap( |
| + ConstantPoolArray* src, Map* map); |
| + |
| + MUST_USE_RESULT MaybeObject* AllocateConstantPoolArray( |
| + int number_of_int64_entries, |
| + int number_of_code_ptr_entries, |
| + int number_of_heap_ptr_entries, |
| + int number_of_int32_entries); |
| + |
| + // Allocates an external array of the specified length and type. |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateExternalArray( |
| + int length, |
| + ExternalArrayType array_type, |
| + void* external_pointer, |
| + PretenureFlag pretenure); |
| + |
| + // Allocates a fixed typed array of the specified length and type. |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateFixedTypedArray( |
| + int length, |
| + ExternalArrayType array_type, |
| + PretenureFlag pretenure); |
| + |
| + // Make a copy of src and return it. Returns |
| + // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| + MUST_USE_RESULT MaybeObject* CopyAndTenureFixedCOWArray(FixedArray* src); |
| + |
| + // Make a copy of src, set the map, and return the copy. Returns |
| + // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| + MUST_USE_RESULT MaybeObject* CopyFixedDoubleArrayWithMap( |
| + FixedDoubleArray* src, Map* map); |
| + |
| + // Allocates a fixed double array with uninitialized values. Returns |
| + // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedDoubleArray( |
| + int length, |
| + PretenureFlag pretenure = NOT_TENURED); |
| // These five Create*EntryStub functions are here and forced to not be inlined |
| // because of a gcc-4.4 bug that assigns wrong vtable entries. |
| @@ -2043,6 +2023,20 @@ class Heap { |
| // Allocate a tenured JS global property cell initialized with the hole. |
| MUST_USE_RESULT MaybeObject* AllocatePropertyCell(); |
| + // Allocates a new utility object in the old generation. |
| + MUST_USE_RESULT MaybeObject* AllocateStruct(InstanceType type); |
| + |
| + // Allocates a new foreign object. |
| + // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| + // failed. |
| + // Please note this does not perform a garbage collection. |
| + MUST_USE_RESULT MaybeObject* AllocateForeign( |
| + Address address, PretenureFlag pretenure = NOT_TENURED); |
| + |
| + MUST_USE_RESULT MaybeObject* AllocateCode(int object_size, bool immovable); |
| + |
| + MUST_USE_RESULT MaybeObject* InternalizeStringWithKey(HashTableKey* key); |
| + |
| // Performs a minor collection in new generation. |
| void Scavenge(); |