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..61708abb0df823bb4c14506bddabdc8d9159e4f9 100644 |
--- a/src/ia32/stub-cache-ia32.cc |
+++ b/src/ia32/stub-cache-ia32.cc |
@@ -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,27 @@ 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); |
Yang
2011/09/21 14:47:50
Remove unused label.
danno
2011/09/22 11:23:15
Done.
|
__ 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 +1511,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); |
Yang
2011/09/21 14:47:50
Nit: indentation.
danno
2011/09/22 11:23:15
Done.
|
+ } |
+ |
// 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 +1547,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 +1561,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 +3901,10 @@ void KeyedLoadStubCompiler::GenerateLoadFastDoubleElement( |
} |
-void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, |
- bool is_js_array) { |
+void KeyedStoreStubCompiler::GenerateStoreFastElement( |
+ MacroAssembler* masm, |
+ bool is_js_array, |
+ StoreObjectAction store_object_action) { |
fschneider
2011/09/22 07:46:38
I find the name StoreObjectAction a little mislead
danno
2011/09/22 11:23:15
Done.
|
// ----------- S t a t e ------------- |
// -- eax : value |
// -- ecx : key |
@@ -3909,12 +3935,18 @@ 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 (store_object_action == kObjectStoreForcesGeneric) { |
+ __ JumpIfNotSmi(eax, &miss_force_generic); |
+ __ mov(FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize), eax); |
Yang
2011/09/21 14:47:50
Maybe use times_half_pointer_size instead and comm
danno
2011/09/22 11:23:15
Done.
|
+ } else { |
+ ASSERT(store_object_action == kObjectStoreCausesWriteBarrier); |
+ // 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); |
+ } |
// Done. |
__ ret(0); |