Reviewers: Michael Starzinger,
Description:
Allocate filler objects in the factory.
[email protected]
Please review this at https://codereview.chromium.org/240393003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+46, -27 lines):
M src/factory.h
M src/factory.cc
M src/heap.h
M src/heap.cc
M src/runtime.cc
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index
aec56bf232effb1d2d2395f9358c186b77f0f047..409502dd9837378e27282d7ceae1d7e40246df5f
100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -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);
Index: src/factory.h
diff --git a/src/factory.h b/src/factory.h
index
d52e66e05f8fcd104604de901266b95d42d214f0..7e432d20546551753abdfd88ecaa90abf90fb49e
100644
--- a/src/factory.h
+++ b/src/factory.h
@@ -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);
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
f1a0bfa52b133da27ea64e3facf02c319a297924..2babe900b9ef2d15c3d1c7c36fb58d528ce25bfc
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2408,6 +2408,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);
}
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
869ea3ee1d78110af9969cd378a126a6fbf9da39..3e690cf5ff02093b6224676f0c4b8019564fc8ad
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -755,6 +755,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();
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
ab3332a2feffc712f9ab8a960aca53b720130307..978cf92e6fda00fa1237a9a35d467f17c5fd45ad
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9781,45 +9781,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_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);
+ HandleScope scope(isolate);
ASSERT(args.length() == 1);
CONVERT_SMI_ARG_CHECKED(size, 0);
- return Allocate(isolate, size, false, NEW_SPACE);
+ RUNTIME_ASSERT(IsAligned(size, kPointerSize));
+ RUNTIME_ASSERT(size > 0);
+ RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize);
+ 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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.