 Chromium Code Reviews
 Chromium Code Reviews Issue 8054043:
  Porting r9456 to x64 (Optimize KeyedStoreGeneric for Smi arrays).  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 8054043:
  Porting r9456 to x64 (Optimize KeyedStoreGeneric for Smi arrays).  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/x64/ic-x64.cc | 
| diff --git a/src/x64/ic-x64.cc b/src/x64/ic-x64.cc | 
| index 514015ab8596ba15f11ff68fe123ed868ed36b00..a98f81b58987724c929e3500d9334d152e66b546 100644 | 
| --- a/src/x64/ic-x64.cc | 
| +++ b/src/x64/ic-x64.cc | 
| @@ -606,7 +606,9 @@ 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); | 
| @@ -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,17 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, | 
| __ SmiCompareInteger32(FieldOperand(rbx, FixedArray::kLengthOffset), rcx); | 
| __ j(below_equal, &slow); | 
| // Increment index to get new length. | 
| + __ CheckMap(rbx, FACTORY->fixed_array_map(), | 
| 
fschneider
2011/09/29 10:18:55
Use masm->isolate()->factory() instead. FACTORY ex
 
Yang
2011/09/29 11:57:49
Using CompareRoot instead.
On 2011/09/29 10:18:55
 | 
| + &check_extra_double, DONT_DO_SMI_CHECK); | 
| + __ leal(rdi, Operand(rcx, 1)); | 
| + __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rdi); | 
| + __ jmp(&fast_object_without_map_check); | 
| + | 
| + __ bind(&check_extra_double); | 
| + __ CheckMap(rbx, FACTORY->fixed_double_array_map(), &slow, DONT_DO_SMI_CHECK); | 
| 
fschneider
2011/09/29 10:18:55
You should combine the two map checks to avoid dup
 
Yang
2011/09/29 11:57:49
Loaded the map into rdi first. However, I'm not en
 | 
| __ leal(rdi, Operand(rcx, 1)); | 
| __ Integer32ToSmiField(FieldOperand(rdx, JSArray::kLengthOffset), rdi); | 
| - __ jmp(&fast); | 
| + __ 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 +685,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 +692,15 @@ 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) | 
| + __ CheckMap(rbx, FACTORY->fixed_array_map(), | 
| + &fast_double_with_map_check, DONT_DO_SMI_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. | 
| @@ -706,14 +714,23 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, | 
| __ movq(rdi, FieldOperand(rdx, HeapObject::kMapOffset)); | 
| __ CheckFastObjectElements(rdi, &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. | 
| + __ CheckMap(rbx, FACTORY->fixed_double_array_map(), &slow, DONT_DO_SMI_CHECK); | 
| + __ 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); | 
| } |