Make Heap::AllocateRawFixedArray methods private.

R=hpayer@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16959 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6245d34b
......@@ -5340,25 +5340,10 @@ MaybeObject* Heap::AllocateEmptyExternalArray(ExternalArrayType array_type) {
}
MaybeObject* Heap::AllocateRawFixedArray(int length) {
if (length < 0 || length > FixedArray::kMaxLength) {
return Failure::OutOfMemoryException(0xd);
}
ASSERT(length > 0);
// Use the general function if we're forced to always allocate.
if (always_allocate()) return AllocateFixedArray(length, TENURED);
// Allocate the raw data for a fixed array.
int size = FixedArray::SizeFor(length);
return size <= Page::kMaxNonCodeHeapObjectSize
? new_space_.AllocateRaw(size)
: lo_space_->AllocateRaw(size, NOT_EXECUTABLE);
}
MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) {
int len = src->length();
Object* obj;
{ MaybeObject* maybe_obj = AllocateRawFixedArray(len);
{ MaybeObject* maybe_obj = AllocateRawFixedArray(len, NOT_TENURED);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
if (InNewSpace(obj)) {
......@@ -5409,22 +5394,20 @@ MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) {
}
MUST_USE_RESULT static MaybeObject* AllocateFixedArrayWithFiller(
Heap* heap,
int length,
PretenureFlag pretenure,
Object* filler) {
MaybeObject* Heap::AllocateFixedArrayWithFiller(int length,
PretenureFlag pretenure,
Object* filler) {
ASSERT(length >= 0);
ASSERT(heap->empty_fixed_array()->IsFixedArray());
if (length == 0) return heap->empty_fixed_array();
ASSERT(empty_fixed_array()->IsFixedArray());
if (length == 0) return empty_fixed_array();
ASSERT(!heap->InNewSpace(filler));
ASSERT(!InNewSpace(filler));
Object* result;
{ MaybeObject* maybe_result = heap->AllocateRawFixedArray(length, pretenure);
{ MaybeObject* maybe_result = AllocateRawFixedArray(length, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
HeapObject::cast(result)->set_map_no_write_barrier(heap->fixed_array_map());
HeapObject::cast(result)->set_map_no_write_barrier(fixed_array_map());
FixedArray* array = FixedArray::cast(result);
array->set_length(length);
MemsetPointer(array->data_start(), filler, length);
......@@ -5433,19 +5416,13 @@ MUST_USE_RESULT static MaybeObject* AllocateFixedArrayWithFiller(
MaybeObject* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) {
return AllocateFixedArrayWithFiller(this,
length,
pretenure,
undefined_value());
return AllocateFixedArrayWithFiller(length, pretenure, undefined_value());
}
MaybeObject* Heap::AllocateFixedArrayWithHoles(int length,
PretenureFlag pretenure) {
return AllocateFixedArrayWithFiller(this,
length,
pretenure,
the_hole_value());
return AllocateFixedArrayWithFiller(length, pretenure, the_hole_value());
}
......@@ -5453,7 +5430,7 @@ MaybeObject* Heap::AllocateUninitializedFixedArray(int length) {
if (length == 0) return empty_fixed_array();
Object* obj;
{ MaybeObject* maybe_obj = AllocateRawFixedArray(length);
{ MaybeObject* maybe_obj = AllocateRawFixedArray(length, NOT_TENURED);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
......
......@@ -951,10 +951,6 @@ class Heap {
int length,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT MaybeObject* AllocateRawFixedDoubleArray(
int length,
PretenureFlag pretenure);
// 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.
......@@ -1505,11 +1501,6 @@ class Heap {
inline intptr_t AdjustAmountOfExternalAllocatedMemory(
intptr_t change_in_bytes);
// Allocate uninitialized fixed array.
MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length);
MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length,
PretenureFlag pretenure);
// This is only needed for testing high promotion mode.
void SetNewSpaceHighPromotionModeActive(bool mode) {
new_space_high_promotion_mode_active_ = mode;
......@@ -2083,6 +2074,18 @@ class Heap {
// Allocate an uninitialized object in the global property cell space.
MUST_USE_RESULT inline MaybeObject* AllocateRawPropertyCell();
// Allocate an uninitialized fixed array.
MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(
int length, PretenureFlag pretenure);
// Allocate an uninitialized fixed double array.
MUST_USE_RESULT MaybeObject* AllocateRawFixedDoubleArray(
int length, PretenureFlag pretenure);
// Allocate an initialized fixed array with the given filler value.
MUST_USE_RESULT MaybeObject* AllocateFixedArrayWithFiller(
int length, PretenureFlag pretenure, Object* filler);
// Initializes a JSObject based on its map.
void InitializeJSObjectFromMap(JSObject* obj,
FixedArray* properties,
......
......@@ -7952,21 +7952,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStrictArgumentsFast) {
// Allocate the elements if needed.
if (length > 0) {
// Allocate the fixed array.
Object* obj;
{ MaybeObject* maybe_obj = isolate->heap()->AllocateRawFixedArray(length);
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
FixedArray* array;
{ MaybeObject* maybe_obj =
isolate->heap()->AllocateUninitializedFixedArray(length);
if (!maybe_obj->To(&array)) return maybe_obj;
}
DisallowHeapAllocation no_gc;
FixedArray* array = reinterpret_cast<FixedArray*>(obj);
array->set_map_no_write_barrier(isolate->heap()->fixed_array_map());
array->set_length(length);
WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
for (int i = 0; i < length; i++) {
array->set(i, *--parameters, mode);
}
JSObject::cast(result)->set_elements(FixedArray::cast(obj));
JSObject::cast(result)->set_elements(array);
}
return result;
}
......
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