Revision: 9751
Author:   [email protected]
Date:     Mon Oct 24 04:16:38 2011
Log:      Further improvements upon r9747.

Review URL: http://codereview.chromium.org/8372028
http://code.google.com/p/v8/source/detail?r=9751

Modified:
 /branches/bleeding_edge/src/arm/builtins-arm.cc
 /branches/bleeding_edge/src/ia32/builtins-ia32.cc
 /branches/bleeding_edge/src/x64/builtins-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/builtins-arm.cc     Mon Oct 24 00:55:50 2011
+++ /branches/bleeding_edge/src/arm/builtins-arm.cc     Mon Oct 24 04:16:38 2011
@@ -96,8 +96,8 @@
                                  Register scratch2,
                                  Register scratch3,
                                  Label* gc_required) {
-  int initial_capacity = JSArray::kPreallocatedArrayElements;
-  ASSERT(initial_capacity >= 0);
+  const int initial_capacity = JSArray::kPreallocatedArrayElements;
+  STATIC_ASSERT(initial_capacity >= 0);
   // Load the initial map from the array function.
   __ ldr(scratch1, FieldMemOperand(array_function,
JSFunction::kPrototypeOrInitialMapOffset));
@@ -147,11 +147,24 @@
   ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset);
   __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex));

-  // Fill the FixedArray with the hole value.
+  // Fill the FixedArray with the hole value. Inline the code if short.
+  if (initial_capacity == 0) return;
   ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize);
   __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex);
-  for (int i = 0; i < initial_capacity; i++) {
+  static const int kLoopUnfoldLimit = 4;
+  if (initial_capacity <= kLoopUnfoldLimit) {
+    for (int i = 0; i < initial_capacity; i++) {
+      __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex));
+    }
+  } else {
+    Label loop, entry;
+    __ add(scratch2, scratch1, Operand(initial_capacity * kPointerSize));
+    __ b(&entry);
+    __ bind(&loop);
     __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex));
+    __ bind(&entry);
+    __ cmp(scratch1, scratch2);
+    __ b(lt, &loop);
   }
 }

@@ -180,11 +193,8 @@
                          JSFunction::kPrototypeOrInitialMapOffset));

   if (FLAG_debug_code) {  // Assert that array size is not zero.
-    Label not_empty;
     __ tst(array_size, array_size);
-    __ b(ne, &not_empty);
-    __ Abort("array size is unexpectedly 0");
-    __ bind(&not_empty);
+    __ Assert(ne, "array size is unexpectedly 0");
   }

// Allocate the JSArray object together with space for a FixedArray with the
=======================================
--- /branches/bleeding_edge/src/ia32/builtins-ia32.cc Mon Oct 24 00:55:50 2011 +++ /branches/bleeding_edge/src/ia32/builtins-ia32.cc Mon Oct 24 04:16:38 2011
@@ -926,8 +926,8 @@
                                  Register scratch2,
                                  Register scratch3,
                                  Label* gc_required) {
-  int initial_capacity = JSArray::kPreallocatedArrayElements;
-  ASSERT(initial_capacity >= 0);
+  const int initial_capacity = JSArray::kPreallocatedArrayElements;
+  STATIC_ASSERT(initial_capacity >= 0);
   // Load the initial map from the array function.
   __ mov(scratch1, FieldOperand(array_function,
                                 JSFunction::kPrototypeOrInitialMapOffset));
=======================================
--- /branches/bleeding_edge/src/x64/builtins-x64.cc     Mon Oct 24 00:55:50 2011
+++ /branches/bleeding_edge/src/x64/builtins-x64.cc     Mon Oct 24 04:16:38 2011
@@ -670,7 +670,7 @@
     __ testq(rax, rax);
     __ j(not_zero, &done);
     __ pop(rbx);
-    __ Push(FACTORY->undefined_value());
+    __ Push(masm->isolate()->factory()->undefined_value());
     __ push(rbx);
     __ incq(rax);
     __ bind(&done);
@@ -1004,8 +1004,8 @@
                                  Register scratch2,
                                  Register scratch3,
                                  Label* gc_required) {
-  int initial_capacity = JSArray::kPreallocatedArrayElements;
-  ASSERT(initial_capacity >= 0);
+  const int initial_capacity = JSArray::kPreallocatedArrayElements;
+  STATIC_ASSERT(initial_capacity >= 0);

   // Load the initial map from the array function.
   __ movq(scratch1, FieldOperand(array_function,
@@ -1029,9 +1029,10 @@
   // result: JSObject
   // scratch1: initial map
   // scratch2: start of next object
+  Factory* factory = masm->isolate()->factory();
   __ movq(FieldOperand(result, JSObject::kMapOffset), scratch1);
   __ Move(FieldOperand(result, JSArray::kPropertiesOffset),
-          FACTORY->empty_fixed_array());
+          factory->empty_fixed_array());
   // Field JSArray::kElementsOffset is initialized later.
   __ Move(FieldOperand(result, JSArray::kLengthOffset), Smi::FromInt(0));

@@ -1039,7 +1040,7 @@
   // fixed array.
   if (initial_capacity == 0) {
     __ Move(FieldOperand(result, JSArray::kElementsOffset),
-            FACTORY->empty_fixed_array());
+            factory->empty_fixed_array());
     return;
   }

@@ -1056,14 +1057,14 @@
   // scratch1: elements array
   // scratch2: start of next object
   __ Move(FieldOperand(scratch1, HeapObject::kMapOffset),
-          FACTORY->fixed_array_map());
+          factory->fixed_array_map());
   __ Move(FieldOperand(scratch1, FixedArray::kLengthOffset),
           Smi::FromInt(initial_capacity));

   // Fill the FixedArray with the hole value. Inline the code if short.
   // Reconsider loop unfolding if kPreallocatedArrayElements gets changed.
   static const int kLoopUnfoldLimit = 4;
-  __ Move(scratch3, FACTORY->the_hole_value());
+  __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex);
   if (initial_capacity <= kLoopUnfoldLimit) {
// Use a scratch register here to have only one reloc info when unfolding
     // the loop.
@@ -1109,11 +1110,8 @@
                        JSFunction::kPrototypeOrInitialMapOffset));

   if (FLAG_debug_code) {  // Assert that array size is not zero.
-    Label not_empty;
     __ testq(array_size, array_size);
-    __ j(not_zero, &not_empty);
-    __ int3();
-    __ bind(&not_empty);
+    __ Assert(not_zero, "array size is unexpectedly 0");
   }

// Allocate the JSArray object together with space for a FixedArray with the
@@ -1135,8 +1133,9 @@
   // elements_array: initial map
   // elements_array_end: start of next object
   // array_size: size of array (smi)
+  Factory* factory = masm->isolate()->factory();
   __ movq(FieldOperand(result, JSObject::kMapOffset), elements_array);
-  __ Move(elements_array, FACTORY->empty_fixed_array());
+  __ Move(elements_array, factory->empty_fixed_array());
__ movq(FieldOperand(result, JSArray::kPropertiesOffset), elements_array);
   // Field JSArray::kElementsOffset is initialized later.
   __ movq(FieldOperand(result, JSArray::kLengthOffset), array_size);
@@ -1155,7 +1154,7 @@
   // elements_array_end: start of next object
   // array_size: size of array (smi)
   __ Move(FieldOperand(elements_array, JSObject::kMapOffset),
-          FACTORY->fixed_array_map());
+          factory->fixed_array_map());
// For non-empty JSArrays the length of the FixedArray and the JSArray is the
   // same.
__ movq(FieldOperand(elements_array, FixedArray::kLengthOffset), array_size);
@@ -1166,7 +1165,7 @@
   // elements_array_end: start of next object
   if (fill_with_hole) {
     Label loop, entry;
-    __ Move(scratch, FACTORY->the_hole_value());
+    __ LoadRoot(scratch, Heap::kTheHoleValueRootIndex);
     __ lea(elements_array, Operand(elements_array,
FixedArray::kHeaderSize - kHeapObjectTag));
     __ jmp(&entry);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to