Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Unified Diff: src/factory.cc

Issue 236983002: Handlify Heap::AllocateJSArrayStorage and friends. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some more follow-up work. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 028dcabeb53d377dedcad947748a24614be59ccb..fc59d1126533fd510681d9c89bcf562fd7ca902e 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -30,7 +30,9 @@ Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size,
ASSERT(0 <= size);
CALL_HEAP_FUNCTION(
isolate(),
- isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure),
+ isolate()->heap()->AllocateFixedArrayWithFiller(size,
+ pretenure,
+ *the_hole_value()),
FixedArray);
}
@@ -53,6 +55,18 @@ Handle<FixedDoubleArray> Factory::NewFixedDoubleArray(int size,
}
+Handle<FixedDoubleArray> Factory::NewFixedDoubleArrayWithHoles(
+ int size,
+ PretenureFlag pretenure) {
+ ASSERT(0 <= size);
+ Handle<FixedDoubleArray> array = NewFixedDoubleArray(size, pretenure);
+ for (int i = 0; i < size; ++i) {
+ array->set_the_hole(i);
+ }
+ return array;
+}
+
+
Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
int number_of_int64_entries,
int number_of_code_ptr_entries,
@@ -1435,14 +1449,38 @@ Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
void Factory::NewJSArrayStorage(Handle<JSArray> array,
- int length,
- int capacity,
- ArrayStorageAllocationMode mode) {
- CALL_HEAP_FUNCTION_VOID(isolate(),
- isolate()->heap()->AllocateJSArrayStorage(*array,
- length,
- capacity,
- mode));
+ int length,
+ int capacity,
+ ArrayStorageAllocationMode mode) {
+ ASSERT(capacity >= length);
+
+ if (capacity == 0) {
+ array->set_length(Smi::FromInt(0));
+ array->set_elements(*empty_fixed_array());
+ return;
+ }
+
+ Handle<FixedArrayBase> elms;
+ ElementsKind elements_kind = array->GetElementsKind();
+ if (IsFastDoubleElementsKind(elements_kind)) {
+ if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
+ elms = NewFixedDoubleArray(capacity);
+ } else {
+ ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
+ elms = NewFixedDoubleArrayWithHoles(capacity);
+ }
+ } else {
+ ASSERT(IsFastSmiOrObjectElementsKind(elements_kind));
+ if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
+ elms = NewUninitializedFixedArray(capacity);
+ } else {
+ ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
+ elms = NewFixedArrayWithHoles(capacity);
+ }
+ }
+
+ array->set_elements(*elms);
+ array->set_length(Smi::FromInt(length));
}
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698