Reviewers: Kevin Millikin,
Message:
Please take a look. This also changes the behavior in arm code when the
constant
is 0 (using empty fixed array singleton).
Description:
Fixing dead code in empty array init.
TEST=set JSArray::kPreallocatedArrayElements to larger than 4.
Please review this at http://codereview.chromium.org/8381014/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/builtins-arm.cc
M src/ia32/builtins-ia32.cc
M src/x64/builtins-x64.cc
Index: src/arm/builtins-arm.cc
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc
index
29bf19028cb7770963c8e1e76a530ffae05baf08..0422a8a070ea98c002b566d7094c3390d575eb05
100644
--- a/src/arm/builtins-arm.cc
+++ b/src/arm/builtins-arm.cc
@@ -104,7 +104,10 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
// Allocate the JSArray object together with space for a fixed array
with the
// requested elements.
- int size = JSArray::kSize + FixedArray::SizeFor(initial_capacity);
+ int size = JSArray::kSize;
+ if (initial_capacity > 0) {
+ size += FixedArray::SizeFor(initial_capacity);
+ }
__ AllocateInNewSpace(size,
result,
scratch2,
@@ -124,6 +127,11 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
__ mov(scratch3, Operand(0, RelocInfo::NONE));
__ str(scratch3, FieldMemOperand(result, JSArray::kLengthOffset));
+ if (initial_capacity == 0) {
+ __ str(scratch1, FieldMemOperand(result, JSArray::kElementsOffset));
+ return;
+ }
+
// Calculate the location of the elements array and set elements array
member
// of the JSArray.
// result: JSObject
@@ -148,7 +156,6 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
__ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex));
// 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);
static const int kLoopUnfoldLimit = 4;
Index: src/ia32/builtins-ia32.cc
diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc
index
70e342d3d7832e9edfd037b4eeff081526db6182..603a48a5f53497359da8e60c87208720bebf2971
100644
--- a/src/ia32/builtins-ia32.cc
+++ b/src/ia32/builtins-ia32.cc
@@ -996,6 +996,7 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
}
} else {
Label loop, entry;
+ __ add(scratch1, Immediate(FixedArray::kHeaderSize - kHeapObjectTag));
__ jmp(&entry);
__ bind(&loop);
__ mov(Operand(scratch1, 0), factory->the_hole_value());
Index: src/x64/builtins-x64.cc
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc
index
8baa2f32ff28eaffbf0c474ad4f27a84c633fba5..c048c2edaad0515aeeee76e6063b1bf2e14050c5
100644
--- a/src/x64/builtins-x64.cc
+++ b/src/x64/builtins-x64.cc
@@ -1075,6 +1075,7 @@ static void AllocateEmptyJSArray(MacroAssembler* masm,
}
} else {
Label loop, entry;
+ __ addq(scratch1, Immediate(FixedArray::kHeaderSize - kHeapObjectTag));
__ jmp(&entry);
__ bind(&loop);
__ movq(Operand(scratch1, 0), scratch3);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev