| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3970 | 3970 |
| 3971 void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( | 3971 void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( |
| 3972 MacroAssembler* masm, | 3972 MacroAssembler* masm, |
| 3973 bool is_js_array) { | 3973 bool is_js_array) { |
| 3974 // ----------- S t a t e ------------- | 3974 // ----------- S t a t e ------------- |
| 3975 // -- eax : value | 3975 // -- eax : value |
| 3976 // -- ecx : key | 3976 // -- ecx : key |
| 3977 // -- edx : receiver | 3977 // -- edx : receiver |
| 3978 // -- esp[0] : return address | 3978 // -- esp[0] : return address |
| 3979 // ----------------------------------- | 3979 // ----------------------------------- |
| 3980 Label miss_force_generic, smi_value, is_nan, maybe_nan; | 3980 Label miss_force_generic; |
| 3981 Label have_double_value, not_nan; | |
| 3982 | 3981 |
| 3983 // This stub is meant to be tail-jumped to, the receiver must already | 3982 // This stub is meant to be tail-jumped to, the receiver must already |
| 3984 // have been verified by the caller to not be a smi. | 3983 // have been verified by the caller to not be a smi. |
| 3985 | 3984 |
| 3986 // Check that the key is a smi. | 3985 // Check that the key is a smi. |
| 3987 __ JumpIfNotSmi(ecx, &miss_force_generic); | 3986 __ JumpIfNotSmi(ecx, &miss_force_generic); |
| 3988 | 3987 |
| 3989 // Get the elements array. | 3988 // Get the elements array. |
| 3990 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); | 3989 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); |
| 3991 __ AssertFastElements(edi); | 3990 __ AssertFastElements(edi); |
| 3992 | 3991 |
| 3993 if (is_js_array) { | 3992 if (is_js_array) { |
| 3994 // Check that the key is within bounds. | 3993 // Check that the key is within bounds. |
| 3995 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. | 3994 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. |
| 3996 } else { | 3995 } else { |
| 3997 // Check that the key is within bounds. | 3996 // Check that the key is within bounds. |
| 3998 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. | 3997 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. |
| 3999 } | 3998 } |
| 4000 __ j(above_equal, &miss_force_generic); | 3999 __ j(above_equal, &miss_force_generic); |
| 4001 | 4000 |
| 4002 __ JumpIfSmi(eax, &smi_value, Label::kNear); | 4001 __ StoreNumberToDoubleElements(eax, |
| 4003 | 4002 edi, |
| 4004 __ CheckMap(eax, | 4003 ecx, |
| 4005 masm->isolate()->factory()->heap_number_map(), | 4004 edx, |
| 4006 &miss_force_generic, | 4005 xmm0, |
| 4007 DONT_DO_SMI_CHECK); | 4006 &miss_force_generic, |
| 4008 | 4007 true); |
| 4009 // Double value, canonicalize NaN. | |
| 4010 uint32_t offset = HeapNumber::kValueOffset + sizeof(kHoleNanLower32); | |
| 4011 __ cmp(FieldOperand(eax, offset), Immediate(kNaNOrInfinityLowerBoundUpper32)); | |
| 4012 __ j(greater_equal, &maybe_nan, Label::kNear); | |
| 4013 | |
| 4014 __ bind(¬_nan); | |
| 4015 ExternalReference canonical_nan_reference = | |
| 4016 ExternalReference::address_of_canonical_non_hole_nan(); | |
| 4017 if (CpuFeatures::IsSupported(SSE2)) { | |
| 4018 CpuFeatures::Scope use_sse2(SSE2); | |
| 4019 __ movdbl(xmm0, FieldOperand(eax, HeapNumber::kValueOffset)); | |
| 4020 __ bind(&have_double_value); | |
| 4021 __ movdbl(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize), | |
| 4022 xmm0); | |
| 4023 __ ret(0); | |
| 4024 } else { | |
| 4025 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); | |
| 4026 __ bind(&have_double_value); | |
| 4027 __ fstp_d(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize)); | |
| 4028 __ ret(0); | |
| 4029 } | |
| 4030 | |
| 4031 __ bind(&maybe_nan); | |
| 4032 // Could be NaN or Infinity. If fraction is not zero, it's NaN, otherwise | |
| 4033 // it's an Infinity, and the non-NaN code path applies. | |
| 4034 __ j(greater, &is_nan, Label::kNear); | |
| 4035 __ cmp(FieldOperand(eax, HeapNumber::kValueOffset), Immediate(0)); | |
| 4036 __ j(zero, ¬_nan); | |
| 4037 __ bind(&is_nan); | |
| 4038 if (CpuFeatures::IsSupported(SSE2)) { | |
| 4039 CpuFeatures::Scope use_sse2(SSE2); | |
| 4040 __ movdbl(xmm0, Operand::StaticVariable(canonical_nan_reference)); | |
| 4041 } else { | |
| 4042 __ fld_d(Operand::StaticVariable(canonical_nan_reference)); | |
| 4043 } | |
| 4044 __ jmp(&have_double_value, Label::kNear); | |
| 4045 | |
| 4046 __ bind(&smi_value); | |
| 4047 // Value is a smi. convert to a double and store. | |
| 4048 // Preserve original value. | |
| 4049 __ mov(edx, eax); | |
| 4050 __ SmiUntag(edx); | |
| 4051 __ push(edx); | |
| 4052 __ fild_s(Operand(esp, 0)); | |
| 4053 __ pop(edx); | |
| 4054 __ fstp_d(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize)); | |
| 4055 __ ret(0); | 4008 __ ret(0); |
| 4056 | 4009 |
| 4057 // Handle store cache miss, replacing the ic with the generic stub. | 4010 // Handle store cache miss, replacing the ic with the generic stub. |
| 4058 __ bind(&miss_force_generic); | 4011 __ bind(&miss_force_generic); |
| 4059 Handle<Code> ic_force_generic = | 4012 Handle<Code> ic_force_generic = |
| 4060 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 4013 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| 4061 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); | 4014 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); |
| 4062 } | 4015 } |
| 4063 | 4016 |
| 4064 | 4017 |
| 4065 #undef __ | 4018 #undef __ |
| 4066 | 4019 |
| 4067 } } // namespace v8::internal | 4020 } } // namespace v8::internal |
| 4068 | 4021 |
| 4069 #endif // V8_TARGET_ARCH_IA32 | 4022 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |