Allocate filler objects in the factory.
R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/240393003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20845 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
14010d37c6
commit
c918ccd392
@ -32,6 +32,16 @@ Handle<T> Factory::New(Handle<Map> map,
|
||||
}
|
||||
|
||||
|
||||
Handle<HeapObject> Factory::NewFillerObject(int size,
|
||||
bool double_align,
|
||||
AllocationSpace space) {
|
||||
CALL_HEAP_FUNCTION(
|
||||
isolate(),
|
||||
isolate()->heap()->AllocateFillerObject(size, double_align, space),
|
||||
HeapObject);
|
||||
}
|
||||
|
||||
|
||||
Handle<Box> Factory::NewBox(Handle<Object> value) {
|
||||
Handle<Box> result = Handle<Box>::cast(NewStruct(BOX_TYPE));
|
||||
result->set_value(*value);
|
||||
|
@ -269,6 +269,10 @@ class Factory V8_FINAL {
|
||||
int instance_size,
|
||||
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND);
|
||||
|
||||
Handle<HeapObject> NewFillerObject(int size,
|
||||
bool double_align,
|
||||
AllocationSpace space);
|
||||
|
||||
Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
|
||||
|
||||
Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
|
||||
|
16
src/heap.cc
16
src/heap.cc
@ -2409,6 +2409,22 @@ MaybeObject* Heap::AllocateMap(InstanceType instance_type,
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Heap::AllocateFillerObject(int size,
|
||||
bool double_align,
|
||||
AllocationSpace space) {
|
||||
HeapObject* allocation;
|
||||
{ MaybeObject* maybe_allocation = AllocateRaw(size, space, space);
|
||||
if (!maybe_allocation->To(&allocation)) return maybe_allocation;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address());
|
||||
ASSERT(chunk->owner()->identity() == space);
|
||||
#endif
|
||||
CreateFillerObjectAt(allocation->address(), size);
|
||||
return allocation;
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Heap::AllocatePolymorphicCodeCache() {
|
||||
return AllocateStruct(POLYMORPHIC_CODE_CACHE_TYPE);
|
||||
}
|
||||
|
@ -754,6 +754,12 @@ class Heap {
|
||||
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();
|
||||
|
||||
|
@ -9791,45 +9791,28 @@ RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_ResolvePossiblyDirectEval) {
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
static MaybeObject* Allocate(Isolate* isolate,
|
||||
int size,
|
||||
bool double_align,
|
||||
AllocationSpace space) {
|
||||
Heap* heap = isolate->heap();
|
||||
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateInNewSpace) {
|
||||
HandleScope scope(isolate);
|
||||
ASSERT(args.length() == 1);
|
||||
CONVERT_SMI_ARG_CHECKED(size, 0);
|
||||
RUNTIME_ASSERT(IsAligned(size, kPointerSize));
|
||||
RUNTIME_ASSERT(size > 0);
|
||||
RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize);
|
||||
HeapObject* allocation;
|
||||
{ MaybeObject* maybe_allocation = heap->AllocateRaw(size, space, space);
|
||||
if (!maybe_allocation->To(&allocation)) return maybe_allocation;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
MemoryChunk* chunk = MemoryChunk::FromAddress(allocation->address());
|
||||
ASSERT(chunk->owner()->identity() == space);
|
||||
#endif
|
||||
heap->CreateFillerObjectAt(allocation->address(), size);
|
||||
return allocation;
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateInNewSpace) {
|
||||
SealHandleScope shs(isolate);
|
||||
ASSERT(args.length() == 1);
|
||||
CONVERT_SMI_ARG_CHECKED(size, 0);
|
||||
return Allocate(isolate, size, false, NEW_SPACE);
|
||||
return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE);
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateInTargetSpace) {
|
||||
SealHandleScope shs(isolate);
|
||||
HandleScope scope(isolate);
|
||||
ASSERT(args.length() == 2);
|
||||
CONVERT_SMI_ARG_CHECKED(size, 0);
|
||||
CONVERT_SMI_ARG_CHECKED(flags, 1);
|
||||
RUNTIME_ASSERT(IsAligned(size, kPointerSize));
|
||||
RUNTIME_ASSERT(size > 0);
|
||||
RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize);
|
||||
bool double_align = AllocateDoubleAlignFlag::decode(flags);
|
||||
AllocationSpace space = AllocateTargetSpace::decode(flags);
|
||||
return Allocate(isolate, size, double_align, space);
|
||||
return *isolate->factory()->NewFillerObject(size, double_align, space);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user