Index: src/ia32/code-stubs-ia32.cc |
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
index 7a1967e0ccb71af533fd4c4843339aff2432dd30..fe1641c374bc769d2bbb1bde13d2b6a5e2ec1e56 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -239,7 +239,12 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
// [esp + (3 * kPointerSize)]: literals array. |
// All sizes here are multiples of kPointerSize. |
- int elements_size = (length_ > 0) ? FixedArray::SizeFor(length_) : 0; |
+ int elements_size = 0; |
+ if (length_ > 0) { |
+ elements_size = mode_ == CLONE_DOUBLE_ELEMENTS |
+ ? FixedDoubleArray::SizeFor(length_) |
+ : FixedArray::SizeFor(length_); |
+ } |
int size = JSArray::kSize + elements_size; |
// Load boilerplate object into ecx and check if we need to create a |
@@ -262,6 +267,9 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
if (mode_ == CLONE_ELEMENTS) { |
message = "Expected (writable) fixed array"; |
expected_map = factory->fixed_array_map(); |
+ } else if (mode_ == CLONE_DOUBLE_ELEMENTS) { |
+ message = "Expected (writable) fixed double array"; |
+ expected_map = factory->fixed_double_array_map(); |
} else { |
ASSERT(mode_ == COPY_ON_WRITE_ELEMENTS); |
message = "Expected copy-on-write fixed array"; |
@@ -294,9 +302,24 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { |
__ mov(FieldOperand(eax, JSArray::kElementsOffset), edx); |
// Copy the elements array. |
- for (int i = 0; i < elements_size; i += kPointerSize) { |
- __ mov(ebx, FieldOperand(ecx, i)); |
- __ mov(FieldOperand(edx, i), ebx); |
+ if (mode_ == CLONE_ELEMENTS) { |
+ for (int i = 0; i < elements_size; i += kPointerSize) { |
+ __ mov(ebx, FieldOperand(ecx, i)); |
+ __ mov(FieldOperand(edx, i), ebx); |
+ } |
+ } else { |
+ ASSERT(mode_ == CLONE_DOUBLE_ELEMENTS); |
+ int i; |
+ for (i = 0; i < FixedDoubleArray::kHeaderSize; i += kPointerSize) { |
+ __ mov(ebx, FieldOperand(ecx, i)); |
+ __ mov(FieldOperand(edx, i), ebx); |
+ } |
+ while (i < elements_size) { |
+ __ fld_d(FieldOperand(ecx, i)); |
+ __ fstp_d(FieldOperand(edx, i)); |
+ i += kDoubleSize; |
+ } |
+ ASSERT(i == elements_size); |
} |
} |