Chromium Code Reviews| Index: src/ia32/stub-cache-ia32.cc |
| diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc |
| index 2660850889cf91489dd78da5edade31418eee2e9..a13cac42a8c1945270a4650e044055a2ca74ba95 100644 |
| --- a/src/ia32/stub-cache-ia32.cc |
| +++ b/src/ia32/stub-cache-ia32.cc |
| @@ -3790,6 +3790,56 @@ void KeyedLoadStubCompiler::GenerateLoadFastElement(MacroAssembler* masm) { |
| } |
| +void KeyedLoadStubCompiler::GenerateLoadFastDoubleElement( |
| + MacroAssembler* masm) { |
| + // ----------- S t a t e ------------- |
| + // -- eax : key |
| + // -- edx : receiver |
| + // -- esp[0] : return address |
| + // ----------------------------------- |
| + Label miss_force_generic, slow_allocate_heapnumber; |
| + |
| + // This stub is meant to be tail-jumped to, the receiver must already |
| + // have been verified by the caller to not be a smi. |
| + |
| + // Check that the key is a smi. |
| + __ JumpIfNotSmi(eax, &miss_force_generic); |
| + |
| + // Get the elements array. |
| + __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset)); |
| + __ AssertFastElements(ecx); |
| + |
| + // Check that the key is within bounds. |
| + __ cmp(eax, FieldOperand(ecx, FixedDoubleArray::kLengthOffset)); |
| + __ j(above_equal, &miss_force_generic); |
| + |
| + // Check for the hole |
| + uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32); |
| + __ cmp(FieldOperand(ecx, eax, times_4, offset), Immediate(kHoleNanUpper32)); |
| + __ j(equal, &miss_force_generic); |
| + |
| + // Always allocate a heap number for the result. |
| + __ fld_d(FieldOperand(ecx, eax, times_4, FixedDoubleArray::kHeaderSize)); |
|
Mads Ager (chromium)
2011/07/13 09:43:09
Would it be worth it to check for SSE2 here as wel
danno
2011/07/13 14:11:03
Done.
|
| + __ AllocateHeapNumber(ecx, ebx, edi, &slow_allocate_heapnumber); |
| + // Set the value. |
| + __ fstp_d(FieldOperand(ecx, HeapNumber::kValueOffset)); |
| + __ mov(eax, ecx); |
| + __ ret(0); |
| + |
| + __ bind(&slow_allocate_heapnumber); |
| + __ ffree(); |
|
Mads Ager (chromium)
2011/07/13 09:43:09
Maybe add a short comment like: Pop double from FP
danno
2011/07/13 14:11:03
Done.
|
| + __ fincstp(); |
| + Handle<Code> slow_ic = |
| + masm->isolate()->builtins()->KeyedLoadIC_Slow(); |
| + __ jmp(slow_ic, RelocInfo::CODE_TARGET); |
| + |
| + __ bind(&miss_force_generic); |
| + Handle<Code> miss_ic = |
| + masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); |
| + __ jmp(miss_ic, RelocInfo::CODE_TARGET); |
| +} |
| + |
| + |
| void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, |
| bool is_js_array) { |
| // ----------- S t a t e ------------- |
| @@ -3839,6 +3889,88 @@ void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, |
| } |
| +void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( |
| + MacroAssembler* masm, |
| + bool is_js_array) { |
| + // ----------- S t a t e ------------- |
| + // -- eax : value |
| + // -- ecx : key |
| + // -- edx : receiver |
| + // -- esp[0] : return address |
| + // ----------------------------------- |
| + Label miss_force_generic, smi_value, is_nan, have_double_value; |
| + |
| + // This stub is meant to be tail-jumped to, the receiver must already |
| + // have been verified by the caller to not be a smi. |
| + |
| + // Check that the key is a smi. |
| + __ JumpIfNotSmi(ecx, &miss_force_generic); |
| + |
| + // Get the elements array. |
| + __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); |
| + __ AssertFastElements(edi); |
| + |
| + if (is_js_array) { |
| + // Check that the key is within bounds. |
| + __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. |
| + } else { |
| + // Check that the key is within bounds. |
| + __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. |
| + } |
| + __ j(above_equal, &miss_force_generic); |
| + |
| + __ JumpIfSmi(eax, &smi_value, Label::kNear); |
| + |
| + __ CheckMap(eax, |
| + masm->isolate()->factory()->heap_number_map(), |
| + &miss_force_generic, |
| + DONT_DO_SMI_CHECK); |
| + |
| + // Double value, canonicalize NaN. |
| + uint32_t offset = HeapNumber::kValueOffset + sizeof(kHoleNanLower32); |
| + __ cmp(FieldOperand(eax, offset), Immediate(0x7ff00000)); |
|
Mads Ager (chromium)
2011/07/13 09:43:09
You had a comment about this constant in the ARM c
danno
2011/07/13 14:11:03
Done.
|
| + __ j(greater, &is_nan, Label::kNear); |
| + |
| + ExternalReference canonical_nan_reference = |
| + ExternalReference::address_of_canonical_non_hole_nan(); |
| + if (CpuFeatures::IsSupported(SSE2)) { |
| + CpuFeatures::Scope use_sse2(SSE2); |
| + __ movdbl(xmm0, FieldOperand(eax, HeapNumber::kValueOffset)); |
| + __ bind(&have_double_value); |
| + __ movdbl(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize), |
| + xmm0); |
| + __ ret(0); |
| + __ bind(&is_nan); |
| + __ movdbl(xmm0, Operand::StaticVariable(canonical_nan_reference)); |
| + __ jmp(&have_double_value, Label::kNear); |
| + } else { |
| + __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); |
| + __ bind(&have_double_value); |
| + __ fstp_d(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize)); |
| + __ ret(0); |
| + __ bind(&is_nan); |
| + __ fld_d(Operand::StaticVariable(canonical_nan_reference)); |
| + __ jmp(&have_double_value, Label::kNear); |
| + } |
| + |
| + __ bind(&smi_value); |
| + |
| + // Value is a smi. convert to a double and store. |
| + __ SmiUntag(eax); |
| + __ push(eax); |
| + __ fild_s(Operand(esp, 0)); |
| + __ pop(eax); |
| + __ fstp_d(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize)); |
| + __ ret(0); |
| + |
| + // Handle store cache miss, replacing the ic with the generic stub. |
| + __ bind(&miss_force_generic); |
| + Handle<Code> ic_force_generic = |
| + masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| + __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
| +} |
| + |
| + |
| #undef __ |
| } } // namespace v8::internal |