Index: src/x64/ic-x64.cc |
diff --git a/src/x64/ic-x64.cc b/src/x64/ic-x64.cc |
index 514015ab8596ba15f11ff68fe123ed868ed36b00..e9b2de7608d5c2b9c95d5a292defc639e81e041b 100644 |
--- a/src/x64/ic-x64.cc |
+++ b/src/x64/ic-x64.cc |
@@ -606,29 +606,31 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
// -- rdx : receiver |
// -- rsp[0] : return address |
// ----------------------------------- |
- Label slow, slow_with_tagged_index, fast, array, extra; |
+ Label slow, slow_with_tagged_index, fast, array, extra, check_extra_double; |
+ Label fast_object_with_map_check, fast_object_without_map_check; |
+ Label fast_double_with_map_check, fast_double_without_map_check; |
// Check that the object isn't a smi. |
__ JumpIfSmi(rdx, &slow_with_tagged_index); |
// Get the map from the receiver. |
- __ movq(rbx, FieldOperand(rdx, HeapObject::kMapOffset)); |
+ __ movq(r9, FieldOperand(rdx, HeapObject::kMapOffset)); |
// Check that the receiver does not require access checks. We need |
// to do this because this generic stub does not perform map checks. |
- __ testb(FieldOperand(rbx, Map::kBitFieldOffset), |
+ __ testb(FieldOperand(r9, Map::kBitFieldOffset), |
Immediate(1 << Map::kIsAccessCheckNeeded)); |
__ j(not_zero, &slow_with_tagged_index); |
// Check that the key is a smi. |
__ JumpIfNotSmi(rcx, &slow_with_tagged_index); |
__ SmiToInteger32(rcx, rcx); |
- __ CmpInstanceType(rbx, JS_ARRAY_TYPE); |
+ __ CmpInstanceType(r9, JS_ARRAY_TYPE); |
__ j(equal, &array); |
// Check that the object is some kind of JSObject. |
- __ CmpInstanceType(rbx, FIRST_JS_RECEIVER_TYPE); |
+ __ CmpInstanceType(r9, FIRST_JS_RECEIVER_TYPE); |
__ j(below, &slow); |
- __ CmpInstanceType(rbx, JS_PROXY_TYPE); |
+ __ CmpInstanceType(r9, JS_PROXY_TYPE); |
__ j(equal, &slow); |
- __ CmpInstanceType(rbx, JS_FUNCTION_PROXY_TYPE); |
+ __ CmpInstanceType(r9, JS_FUNCTION_PROXY_TYPE); |
__ j(equal, &slow); |
// Object case: Check key against length in the elements array. |
@@ -636,15 +638,12 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
// rdx: JSObject |
// rcx: index |
__ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); |
- // Check that the object is in fast mode and writable. |
- __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
- Heap::kFixedArrayMapRootIndex); |
- __ j(not_equal, &slow); |
+ // Check array bounds. |
__ SmiCompareInteger32(FieldOperand(rbx, FixedArray::kLengthOffset), rcx); |
// rax: value |
// rbx: FixedArray |
// rcx: index |
- __ j(above, &fast); |
+ __ j(above, &fast_object_with_map_check); |
// Slow case: call runtime. |
__ bind(&slow); |
@@ -666,9 +665,20 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
__ SmiCompareInteger32(FieldOperand(rbx, FixedArray::kLengthOffset), rcx); |
__ j(below_equal, &slow); |
// Increment index to get new length. |
+ __ movq(rdi, FieldOperand(rbx, HeapObject::kMapOffset)); |
+ __ CompareRoot(rdi, Heap::kFixedArrayMapRootIndex); |
+ __ j(not_equal, &check_extra_double); |
__ leal(rdi, Operand(rcx, 1)); |
__ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rdi); |
- __ jmp(&fast); |
+ __ jmp(&fast_object_without_map_check); |
+ |
+ __ bind(&check_extra_double); |
+ // rdi: elements array's map |
+ __ CompareRoot(rdi, Heap::kFixedDoubleArrayMapRootIndex); |
+ __ j(not_equal, &slow); |
+ __ leal(rdi, Operand(rcx, 1)); |
+ __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rdi); |
+ __ jmp(&fast_double_without_map_check); |
// Array case: Get the length and the elements array from the JS |
// array. Check that the array is in fast mode (and writable); if it |
@@ -678,9 +688,6 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
// rdx: receiver (a JSArray) |
// rcx: index |
__ movq(rbx, FieldOperand(rdx, JSObject::kElementsOffset)); |
- __ CompareRoot(FieldOperand(rbx, HeapObject::kMapOffset), |
- Heap::kFixedArrayMapRootIndex); |
- __ j(not_equal, &slow); |
// Check the key against the length in the array, compute the |
// address to store into and fall through to fast case. |
@@ -688,11 +695,16 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
__ j(below_equal, &extra); |
// Fast case: Do the store. |
- __ bind(&fast); |
+ __ bind(&fast_object_with_map_check); |
// rax: value |
// rbx: receiver's elements array (a FixedArray) |
// rcx: index |
- |
+ // rdx: receiver (a JSArray) |
+ __ movq(rdi, FieldOperand(rbx, HeapObject::kMapOffset)); |
+ __ CompareRoot(rdi, Heap::kFixedArrayMapRootIndex); |
+ __ j(not_equal, &fast_double_with_map_check); |
+ __ bind(&fast_object_without_map_check); |
+ // Smi stores don't require further checks. |
Label non_smi_value; |
__ JumpIfNotSmi(rax, &non_smi_value); |
// It's irrelevant whether array is smi-only or not when writing a smi. |
@@ -703,17 +715,28 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, |
__ bind(&non_smi_value); |
if (FLAG_smi_only_arrays) { |
// Writing a non-smi, check whether array allows non-smi elements. |
- __ movq(rdi, FieldOperand(rdx, HeapObject::kMapOffset)); |
- __ CheckFastObjectElements(rdi, &slow, Label::kNear); |
+ // r9: receiver's map |
+ __ CheckFastObjectElements(r9, &slow, Label::kNear); |
} |
- __ movq(FieldOperand(rbx, rcx, times_pointer_size, FixedArray::kHeaderSize), |
- rax); |
- __ movq(rdx, rax); |
__ lea(rcx, |
FieldOperand(rbx, rcx, times_pointer_size, FixedArray::kHeaderSize)); |
+ __ movq(Operand(rcx, 0), rax); |
+ __ movq(rdx, rax); |
__ RecordWrite( |
rbx, rcx, rdx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
__ ret(0); |
+ |
+ __ bind(&fast_double_with_map_check); |
+ // Check for fast double array case. If this fails, call through to the |
+ // runtime. |
+ // rdi: elements array's map |
+ __ CompareRoot(rdi, Heap::kFixedDoubleArrayMapRootIndex); |
+ __ j(not_equal, &slow); |
+ __ bind(&fast_double_without_map_check); |
+ // If the value is a number, store it as a double in the FastDoubleElements |
+ // array. |
+ __ StoreNumberToDoubleElements(rax, rbx, rcx, xmm0, &slow); |
+ __ ret(0); |
} |