Revision: 20735
Author:   [email protected]
Date:     Mon Apr 14 16:05:19 2014 UTC
Log:      Handlify Heap::AllocateJSArrayStorage and friends.

[email protected]

Review URL: https://codereview.chromium.org/236983002
http://code.google.com/p/v8/source/detail?r=20735

Modified:
 /branches/bleeding_edge/src/factory.cc
 /branches/bleeding_edge/src/factory.h
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h

=======================================
--- /branches/bleeding_edge/src/factory.cc      Mon Apr 14 11:43:40 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc      Mon Apr 14 16:05:19 2014 UTC
@@ -30,7 +30,9 @@
   ASSERT(0 <= size);
   CALL_HEAP_FUNCTION(
       isolate(),
-      isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure),
+      isolate()->heap()->AllocateFixedArrayWithFiller(size,
+                                                      pretenure,
+                                                      *the_hole_value()),
       FixedArray);
 }

@@ -51,6 +53,18 @@
isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure),
       FixedDoubleArray);
 }
+
+
+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(
@@ -1446,14 +1460,38 @@


 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));
 }


=======================================
--- /branches/bleeding_edge/src/factory.h       Mon Apr 14 09:19:09 2014 UTC
+++ /branches/bleeding_edge/src/factory.h       Mon Apr 14 16:05:19 2014 UTC
@@ -32,6 +32,11 @@
       int size,
       PretenureFlag pretenure = NOT_TENURED);

+  // Allocate a new fixed double array with hole values.
+  Handle<FixedDoubleArray> NewFixedDoubleArrayWithHoles(
+      int size,
+      PretenureFlag pretenure = NOT_TENURED);
+
   Handle<ConstantPoolArray> NewConstantPoolArray(
       int number_of_int64_entries,
       int number_of_code_ptr_entries,
=======================================
--- /branches/bleeding_edge/src/heap.cc Mon Apr 14 11:43:40 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Mon Apr 14 16:05:19 2014 UTC
@@ -4273,46 +4273,6 @@
 #endif
   return result;
 }
-
-
-MaybeObject* Heap::AllocateJSArrayStorage(
-    JSArray* array,
-    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 array;
-  }
-
-  FixedArrayBase* elms;
-  MaybeObject* maybe_elms = NULL;
-  ElementsKind elements_kind = array->GetElementsKind();
-  if (IsFastDoubleElementsKind(elements_kind)) {
-    if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
-      maybe_elms = AllocateUninitializedFixedDoubleArray(capacity);
-    } else {
-      ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
-      maybe_elms = AllocateFixedDoubleArrayWithHoles(capacity);
-    }
-  } else {
-    ASSERT(IsFastSmiOrObjectElementsKind(elements_kind));
-    if (mode == DONT_INITIALIZE_ARRAY_ELEMENTS) {
-      maybe_elms = AllocateUninitializedFixedArray(capacity);
-    } else {
-      ASSERT(mode == INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
-      maybe_elms = AllocateFixedArrayWithHoles(capacity);
-    }
-  }
-  if (!maybe_elms->To(&elms)) return maybe_elms;
-
-  array->set_elements(elms);
-  array->set_length(Smi::FromInt(length));
-  return array;
-}


 MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) {
@@ -4935,12 +4895,6 @@
MaybeObject* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) { return AllocateFixedArrayWithFiller(length, pretenure, undefined_value());
 }
-
-
-MaybeObject* Heap::AllocateFixedArrayWithHoles(int length,
-                                               PretenureFlag pretenure) {
-  return AllocateFixedArrayWithFiller(length, pretenure, the_hole_value());
-}


 MaybeObject* Heap::AllocateUninitializedFixedArray(int length) {
@@ -4988,27 +4942,6 @@
   elements->set_length(length);
   return elements;
 }
-
-
-MaybeObject* Heap::AllocateFixedDoubleArrayWithHoles(
-    int length,
-    PretenureFlag pretenure) {
-  if (length == 0) return empty_fixed_array();
-
-  Object* elements_object;
-  MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(length, pretenure);
-  if (!maybe_obj->ToObject(&elements_object)) return maybe_obj;
-  FixedDoubleArray* elements =
-      reinterpret_cast<FixedDoubleArray*>(elements_object);
-
-  for (int i = 0; i < length; ++i) {
-    elements->set_the_hole(i);
-  }
-
-  elements->set_map_no_write_barrier(fixed_double_array_map());
-  elements->set_length(length);
-  return elements;
-}


 MaybeObject* Heap::AllocateRawFixedDoubleArray(int length,
=======================================
--- /branches/bleeding_edge/src/heap.h  Fri Apr 11 09:20:56 2014 UTC
+++ /branches/bleeding_edge/src/heap.h  Mon Apr 14 16:05:19 2014 UTC
@@ -716,12 +716,6 @@
       PretenureFlag pretenure = NOT_TENURED,
       AllocationSite* allocation_site = NULL);

-  MUST_USE_RESULT MaybeObject* AllocateJSArrayStorage(
-      JSArray* array,
-      int length,
-      int capacity,
-      ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS);
-
   // Returns a deep copy of the JavaScript object.
   // Properties and elements are copied too.
   // Returns failure if allocation failed.
@@ -983,14 +977,6 @@
   MUST_USE_RESULT MaybeObject* CopyConstantPoolArrayWithMap(
       ConstantPoolArray* src, Map* map);

-  // Allocates a fixed array initialized with the hole values.
- // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
-  // failed.
-  // Please note this does not perform a garbage collection.
-  MUST_USE_RESULT MaybeObject* AllocateFixedArrayWithHoles(
-      int length,
-      PretenureFlag pretenure = NOT_TENURED);
-
   MUST_USE_RESULT MaybeObject* AllocateConstantPoolArray(
       int number_of_int64_entries,
       int number_of_code_ptr_entries,
@@ -1004,13 +990,6 @@
       int length,
       PretenureFlag pretenure = NOT_TENURED);

-  // Allocates a fixed double array with hole values. Returns
- // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
-  // Please note this does not perform a garbage collection.
-  MUST_USE_RESULT MaybeObject* AllocateFixedDoubleArrayWithHoles(
-      int length,
-      PretenureFlag pretenure = NOT_TENURED);
-
   // AllocateHashTable is identical to AllocateFixedArray except
   // that the resulting object has hash_table_map as map.
   MUST_USE_RESULT MaybeObject* AllocateHashTable(

--
--
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.

Reply via email to