Index: src/ia32/stub-cache-ia32.cc |
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc |
index c3cec4b7cafc47a0f69a8f53ce4aea55f735dc60..b4eff5a7cc7b17a7854e95fedc8b059642d2f93a 100644 |
--- a/src/ia32/stub-cache-ia32.cc |
+++ b/src/ia32/stub-cache-ia32.cc |
@@ -1454,7 +1454,7 @@ MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, |
__ j(not_equal, &call_builtin); |
if (argc == 1) { // Otherwise fall through to call builtin. |
- Label exit, attempt_to_grow_elements, with_write_barrier; |
+ Label attempt_to_grow_elements, with_write_barrier; |
// Get the array's length into eax and calculate new length. |
__ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); |
@@ -1469,6 +1469,10 @@ MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, |
__ cmp(eax, Operand(ecx)); |
__ j(greater, &attempt_to_grow_elements); |
+ // Check if value is a smi. |
+ __ mov(ecx, Operand(esp, argc * kPointerSize)); |
+ __ JumpIfNotSmi(ecx, &with_write_barrier); |
+ |
// Save new length. |
__ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
@@ -1476,17 +1480,26 @@ MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, |
__ lea(edx, FieldOperand(ebx, |
eax, times_half_pointer_size, |
FixedArray::kHeaderSize - argc * kPointerSize)); |
- __ mov(ecx, Operand(esp, argc * kPointerSize)); |
__ mov(Operand(edx, 0), ecx); |
- // Check if value is a smi. |
- __ JumpIfNotSmi(ecx, &with_write_barrier); |
- |
- __ bind(&exit); |
__ ret((argc + 1) * kPointerSize); |
__ bind(&with_write_barrier); |
+ if (FLAG_smi_only_arrays) { |
+ __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); |
+ __ CheckFastObjectElements(edi, &call_builtin); |
+ } |
+ |
+ // Save new length. |
+ __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); |
+ |
+ // Push the element. |
+ __ lea(edx, FieldOperand(ebx, |
+ eax, times_half_pointer_size, |
+ FixedArray::kHeaderSize - argc * kPointerSize)); |
+ __ mov(Operand(edx, 0), ecx); |
+ |
__ RecordWrite( |
ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
@@ -1497,6 +1510,17 @@ MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, |
__ jmp(&call_builtin); |
} |
+ __ mov(edi, Operand(esp, argc * kPointerSize)); |
+ if (FLAG_smi_only_arrays) { |
+ // Growing elements that are SMI-only requires special handling in case |
+ // the new element is non-Smi. For now, delegate to the builtin. |
+ Label no_fast_elements_check; |
+ __ JumpIfSmi(edi, &no_fast_elements_check); |
+ __ mov(esi, FieldOperand(edx, HeapObject::kMapOffset)); |
+ __ CheckFastObjectElements(esi, &call_builtin, Label::kFar); |
+ __ bind(&no_fast_elements_check); |
+ } |
+ |
// We could be lucky and the elements array could be at the top of |
// new-space. In this case we can just grow it in place by moving the |
// allocation pointer up. |
@@ -1522,10 +1546,9 @@ MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, |
// We fit and could grow elements. |
__ mov(Operand::StaticVariable(new_space_allocation_top), ecx); |
- __ mov(ecx, Operand(esp, argc * kPointerSize)); |
// Push the argument... |
- __ mov(Operand(edx, 0), ecx); |
+ __ mov(Operand(edx, 0), edi); |
// ... and fill the rest with holes. |
for (int i = 1; i < kAllocationDelta; i++) { |
__ mov(Operand(edx, i * kPointerSize), |
@@ -1537,7 +1560,7 @@ MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object, |
// tell the incremental marker to rescan the object that we just grew. We |
// don't need to worry about the holes because they are in old space and |
// already marked black. |
- __ RecordWrite(ebx, edx, ecx, kDontSaveFPRegs, OMIT_REMEMBERED_SET); |
+ __ RecordWrite(ebx, edx, edi, kDontSaveFPRegs, OMIT_REMEMBERED_SET); |
// Restore receiver to edx as finish sequence assumes it's here. |
__ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
@@ -3877,8 +3900,10 @@ void KeyedLoadStubCompiler::GenerateLoadFastDoubleElement( |
} |
-void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, |
- bool is_js_array) { |
+void KeyedStoreStubCompiler::GenerateStoreFastElement( |
+ MacroAssembler* masm, |
+ bool is_js_array, |
+ ElementsKind elements_kind) { |
// ----------- S t a t e ------------- |
// -- eax : value |
// -- ecx : key |
@@ -3909,12 +3934,28 @@ void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, |
__ j(above_equal, &miss_force_generic); |
} |
- // Do the store and update the write barrier. |
- __ lea(ecx, FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize)); |
- __ mov(Operand(ecx, 0), eax); |
- // Make sure to preserve the value in register eax. |
- __ mov(edx, Operand(eax)); |
- __ RecordWrite(edi, ecx, edx, kDontSaveFPRegs); |
+ if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { |
+ __ JumpIfNotSmi(eax, &miss_force_generic); |
+ // ecx is a smi, don't use times_half_pointer_size istead of |
+ // times_pointer_size |
+ __ mov(FieldOperand(edi, |
+ ecx, |
+ times_half_pointer_size, |
+ FixedArray::kHeaderSize), eax); |
+ } else { |
+ ASSERT(elements_kind == FAST_ELEMENTS); |
+ // Do the store and update the write barrier. |
+ // ecx is a smi, don't use times_half_pointer_size istead of |
+ // times_pointer_size |
+ __ lea(ecx, FieldOperand(edi, |
+ ecx, |
+ times_half_pointer_size, |
+ FixedArray::kHeaderSize)); |
+ __ mov(Operand(ecx, 0), eax); |
+ // Make sure to preserve the value in register eax. |
+ __ mov(edx, Operand(eax)); |
+ __ RecordWrite(edi, ecx, edx, kDontSaveFPRegs); |
+ } |
// Done. |
__ ret(0); |