Commit ace81fd7 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Hide some more heap allocators.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/252213002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21069 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8ecbf17d
......@@ -4294,18 +4294,6 @@ MaybeObject* Heap::AllocateEmptyConstantPoolArray() {
}
MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) {
Object* result;
{ MaybeObject* maybe_result = AllocateFixedArray(length, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(
hash_table_map());
ASSERT(result->IsHashTable());
return result;
}
MaybeObject* Heap::AllocateSymbol() {
// Statically ensure that it is safe to allocate symbols in paged spaces.
STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize);
......
......@@ -698,72 +698,13 @@ class Heap {
// For use during bootup.
void RepairFreeListsAfterBoot();
// Allocates an internalized string 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.
MUST_USE_RESULT inline MaybeObject* AllocateInternalizedStringFromUtf8(
Vector<const char> str,
int chars,
uint32_t hash_field);
MUST_USE_RESULT inline MaybeObject* AllocateOneByteInternalizedString(
Vector<const uint8_t> str,
uint32_t hash_field);
MUST_USE_RESULT inline MaybeObject* AllocateTwoByteInternalizedString(
Vector<const uc16> str,
uint32_t hash_field);
template<typename T>
static inline bool IsOneByte(T t, int chars);
template<typename T>
MUST_USE_RESULT inline MaybeObject* AllocateInternalizedStringImpl(
T t, int chars, uint32_t hash_field);
// 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.
MUST_USE_RESULT MaybeObject* AllocateFixedArray(
int length,
PretenureFlag pretenure = NOT_TENURED);
// Allocates an uninitialized fixed array. It must be filled by the caller.
//
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length);
// Move len elements within a given array from src_index index to dst_index
// index.
void MoveElements(FixedArray* array, int dst_index, int src_index, int len);
// Make a copy of src and return it. Returns
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
MUST_USE_RESULT inline MaybeObject* CopyFixedArray(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);
// Make a copy of src and return it. Returns
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
MUST_USE_RESULT inline MaybeObject* CopyFixedDoubleArray(
FixedDoubleArray* src);
// 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);
// 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);
// Sloppy mode arguments object size.
static const int kSloppyArgumentsObjectSize =
JSObject::kHeaderSize + 2 * kPointerSize;
......@@ -798,7 +739,6 @@ class Heap {
void AdjustLiveBytes(Address address, int by, InvocationMode mode);
bool InternalizeStringIfExists(String* str, String** result);
bool InternalizeTwoCharsStringIfExists(String* str, String** result);
// Converts the given boolean condition to JavaScript boolean value.
inline Object* ToBoolean(bool condition);
......@@ -1542,6 +1482,11 @@ class Heap {
MUST_USE_RESULT MaybeObject* CopyCode(Code* code);
// Allocates a fixed array initialized with undefined values
MUST_USE_RESULT MaybeObject* AllocateFixedArray(
int length,
PretenureFlag pretenure = NOT_TENURED);
private:
Heap();
......@@ -1866,10 +1811,51 @@ class Heap {
bool CreateInitialMaps();
void CreateInitialObjects();
// Allocates an internalized string in old space based on the character
// stream.
MUST_USE_RESULT inline MaybeObject* AllocateInternalizedStringFromUtf8(
Vector<const char> str,
int chars,
uint32_t hash_field);
MUST_USE_RESULT inline MaybeObject* AllocateOneByteInternalizedString(
Vector<const uint8_t> str,
uint32_t hash_field);
MUST_USE_RESULT inline MaybeObject* AllocateTwoByteInternalizedString(
Vector<const uc16> str,
uint32_t hash_field);
template<bool is_one_byte, typename T>
MUST_USE_RESULT MaybeObject* AllocateInternalizedStringImpl(
T t, int chars, uint32_t hash_field);
template<typename T>
MUST_USE_RESULT inline MaybeObject* AllocateInternalizedStringImpl(
T t, int chars, uint32_t hash_field);
// Allocates an uninitialized fixed array. It must be filled by the caller.
MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length);
// Make a copy of src and return it. Returns
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
MUST_USE_RESULT inline MaybeObject* CopyFixedArray(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);
// Make a copy of src and return it. Returns
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
MUST_USE_RESULT inline MaybeObject* CopyFixedDoubleArray(
FixedDoubleArray* src);
// 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);
// Computes a single character string where the character has code.
// A cache is used for ASCII codes.
MUST_USE_RESULT MaybeObject* LookupSingleCharacterStringFromCode(
......
......@@ -83,12 +83,13 @@ typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags;
// Use this to expose protected methods in i::Heap.
class TestHeap : public i::Heap {
public:
using i::Heap::AllocateArgumentsObject;
using i::Heap::AllocateByteArray;
using i::Heap::AllocateFixedArray;
using i::Heap::AllocateHeapNumber;
using i::Heap::AllocateMap;
using i::Heap::AllocateJSObject;
using i::Heap::AllocateJSObjectFromMap;
using i::Heap::AllocateByteArray;
using i::Heap::AllocateArgumentsObject;
using i::Heap::AllocateMap;
using i::Heap::CopyCode;
};
......
......@@ -1624,7 +1624,7 @@ TEST(TestSizeOfObjects) {
AlwaysAllocateScope always_allocate(CcTest::i_isolate());
int filler_size = static_cast<int>(FixedArray::SizeFor(8192));
for (int i = 1; i <= 100; i++) {
CcTest::heap()->AllocateFixedArray(8192, TENURED)->ToObjectChecked();
CcTest::test_heap()->AllocateFixedArray(8192, TENURED)->ToObjectChecked();
CHECK_EQ(initial_size + i * filler_size,
static_cast<int>(CcTest::heap()->SizeOfObjects()));
}
......
......@@ -76,7 +76,7 @@ TEST(MarkingDeque) {
TEST(Promotion) {
CcTest::InitializeVM();
Heap* heap = CcTest::heap();
TestHeap* heap = CcTest::test_heap();
heap->ConfigureHeap(2*256*KB, 1*MB, 1*MB, 0);
v8::HandleScope sc(CcTest::isolate());
......@@ -101,7 +101,7 @@ TEST(Promotion) {
TEST(NoPromotion) {
CcTest::InitializeVM();
Heap* heap = CcTest::heap();
TestHeap* heap = CcTest::test_heap();
heap->ConfigureHeap(2*256*KB, 1*MB, 1*MB, 0);
v8::HandleScope sc(CcTest::isolate());
......@@ -253,7 +253,7 @@ TEST(ObjectGroups) {
FLAG_incremental_marking = false;
CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
Heap* heap = CcTest::heap();
TestHeap* heap = CcTest::test_heap();
NumberOfWeakCalls = 0;
v8::HandleScope handle_scope(CcTest::isolate());
......@@ -392,7 +392,7 @@ TEST(EmptyObjectGroups) {
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> object = global_handles->Create(
CcTest::heap()->AllocateFixedArray(1)->ToObjectChecked());
CcTest::test_heap()->AllocateFixedArray(1)->ToObjectChecked());
TestRetainedObjectInfo info;
global_handles->AddObjectGroup(NULL, 0, &info);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment