Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 7307030: Implement ICs for FastDoubleArray loads and stores (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nit Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 3772 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 __ mov(eax, ebx); 3783 __ mov(eax, ebx);
3784 __ ret(0); 3784 __ ret(0);
3785 3785
3786 __ bind(&miss_force_generic); 3786 __ bind(&miss_force_generic);
3787 Handle<Code> miss_ic = 3787 Handle<Code> miss_ic =
3788 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); 3788 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
3789 __ jmp(miss_ic, RelocInfo::CODE_TARGET); 3789 __ jmp(miss_ic, RelocInfo::CODE_TARGET);
3790 } 3790 }
3791 3791
3792 3792
3793 void KeyedLoadStubCompiler::GenerateLoadFastDoubleElement(
3794 MacroAssembler* masm) {
3795 // ----------- S t a t e -------------
3796 // -- eax : key
3797 // -- edx : receiver
3798 // -- esp[0] : return address
3799 // -----------------------------------
3800 Label miss_force_generic, slow_allocate_heapnumber;
3801
3802 // This stub is meant to be tail-jumped to, the receiver must already
3803 // have been verified by the caller to not be a smi.
3804
3805 // Check that the key is a smi.
3806 __ JumpIfNotSmi(eax, &miss_force_generic);
3807
3808 // Get the elements array.
3809 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset));
3810 __ AssertFastElements(ecx);
3811
3812 // Check that the key is within bounds.
3813 __ cmp(eax, FieldOperand(ecx, FixedDoubleArray::kLengthOffset));
3814 __ j(above_equal, &miss_force_generic);
3815
3816 // Check for the hole
3817 uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32);
3818 __ cmp(FieldOperand(ecx, eax, times_4, offset), Immediate(kHoleNanUpper32));
3819 __ j(equal, &miss_force_generic);
3820
3821 // Always allocate a heap number for the result.
3822 __ fld_d(FieldOperand(ecx, eax, times_4, FixedDoubleArray::kHeaderSize));
Mads Ager (chromium) 2011/07/12 12:03:26 This looks dangerous. Can't this lead to an unbala
danno 2011/07/13 08:59:52 Done.
3823 __ AllocateHeapNumber(ecx, ebx, edi, &slow_allocate_heapnumber);
3824 // Set the value.
3825 __ fstp_d(FieldOperand(ecx, HeapNumber::kValueOffset));
3826 __ mov(eax, ecx);
3827 __ ret(0);
3828
3829 __ bind(&slow_allocate_heapnumber);
3830 Handle<Code> slow_ic =
3831 masm->isolate()->builtins()->KeyedLoadIC_Slow();
3832 __ jmp(slow_ic, RelocInfo::CODE_TARGET);
3833
3834 __ bind(&miss_force_generic);
3835 Handle<Code> miss_ic =
3836 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
3837 __ jmp(miss_ic, RelocInfo::CODE_TARGET);
3838 }
3839
3840
3793 void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, 3841 void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm,
3794 bool is_js_array) { 3842 bool is_js_array) {
3795 // ----------- S t a t e ------------- 3843 // ----------- S t a t e -------------
3796 // -- eax : value 3844 // -- eax : value
3797 // -- ecx : key 3845 // -- ecx : key
3798 // -- edx : receiver 3846 // -- edx : receiver
3799 // -- esp[0] : return address 3847 // -- esp[0] : return address
3800 // ----------------------------------- 3848 // -----------------------------------
3801 Label miss_force_generic; 3849 Label miss_force_generic;
3802 3850
(...skipping 29 matching lines...) Expand all
3832 __ ret(0); 3880 __ ret(0);
3833 3881
3834 // Handle store cache miss, replacing the ic with the generic stub. 3882 // Handle store cache miss, replacing the ic with the generic stub.
3835 __ bind(&miss_force_generic); 3883 __ bind(&miss_force_generic);
3836 Handle<Code> ic_force_generic = 3884 Handle<Code> ic_force_generic =
3837 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); 3885 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
3838 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); 3886 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
3839 } 3887 }
3840 3888
3841 3889
3890 void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
3891 MacroAssembler* masm,
3892 bool is_js_array) {
3893 // ----------- S t a t e -------------
3894 // -- eax : value
3895 // -- ecx : key
3896 // -- edx : receiver
3897 // -- esp[0] : return address
3898 // -----------------------------------
3899 Label miss_force_generic, smi_value, is_nan, have_double_value;
3900
3901 // This stub is meant to be tail-jumped to, the receiver must already
3902 // have been verified by the caller to not be a smi.
3903
3904 // Check that the key is a smi.
3905 __ JumpIfNotSmi(ecx, &miss_force_generic);
3906
3907 // Get the elements array.
3908 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
3909 __ AssertFastElements(edi);
3910
3911 if (is_js_array) {
3912 // Check that the key is within bounds.
3913 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis.
3914 __ j(above_equal, &miss_force_generic);
Mads Ager (chromium) 2011/07/12 12:03:26 Move the identical branch instructions out of the
danno 2011/07/13 08:59:52 Done.
3915 } else {
3916 // Check that the key is within bounds.
3917 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis.
3918 __ j(above_equal, &miss_force_generic);
3919 }
3920
3921 __ JumpIfSmi(eax, &smi_value, Label::kNear);
3922
3923 __ CheckMap(eax,
3924 masm->isolate()->factory()->heap_number_map(),
3925 &miss_force_generic,
3926 DONT_DO_SMI_CHECK);
3927
3928 // Double value, check for any nan and canonicalize.
3929 uint32_t offset = HeapNumber::kValueOffset + sizeof(kHoleNanLower32);
3930 __ cmp(FieldOperand(eax, offset), Immediate(0x7ff00000));
3931 __ j(greater, &is_nan, Label::kNear);
3932
3933 ExternalReference canonical_nan_reference =
3934 ExternalReference::address_of_canonical_non_hole_nan();
3935 if (CpuFeatures::IsSupported(SSE2)) {
3936 CpuFeatures::Scope use_sse2(SSE2);
3937 __ movdbl(xmm0, FieldOperand(eax, HeapNumber::kValueOffset));
3938 __ bind(&have_double_value);
3939 __ movdbl(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize),
3940 xmm0);
3941 __ ret(0);
3942 __ bind(&is_nan);
3943 __ movdbl(xmm0, Operand::StaticVariable(canonical_nan_reference));
3944 __ jmp(&have_double_value, Label::kNear);
3945 } else {
3946 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset));
3947 __ bind(&have_double_value);
3948 __ fstp_d(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize));
3949 __ ret(0);
3950 __ bind(&is_nan);
3951 __ fld_d(Operand::StaticVariable(canonical_nan_reference));
3952 __ jmp(&have_double_value, Label::kNear);
3953 }
3954
3955 __ bind(&smi_value);
3956
3957 // Value is a smi. convert to a double and store.
3958 __ SmiUntag(eax);
3959 __ push(eax);
3960 __ fild_s(Operand(esp, 0));
3961 __ pop(eax);
3962 __ fstp_d(FieldOperand(edi, ecx, times_4, FixedDoubleArray::kHeaderSize));
3963 __ ret(0);
3964
3965 // Handle store cache miss, replacing the ic with the generic stub.
3966 __ bind(&miss_force_generic);
3967 Handle<Code> ic_force_generic =
3968 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
3969 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
3970 }
3971
3972
3842 #undef __ 3973 #undef __
3843 3974
3844 } } // namespace v8::internal 3975 } } // namespace v8::internal
3845 3976
3846 #endif // V8_TARGET_ARCH_IA32 3977 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698