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

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

Issue 8054043: Porting r9456 to x64 (Optimize KeyedStoreGeneric for Smi arrays). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: minor change. Created 9 years, 2 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
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3740 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 3751
3752 void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement( 3752 void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
3753 MacroAssembler* masm, 3753 MacroAssembler* masm,
3754 bool is_js_array) { 3754 bool is_js_array) {
3755 // ----------- S t a t e ------------- 3755 // ----------- S t a t e -------------
3756 // -- rax : value 3756 // -- rax : value
3757 // -- rcx : key 3757 // -- rcx : key
3758 // -- rdx : receiver 3758 // -- rdx : receiver
3759 // -- rsp[0] : return address 3759 // -- rsp[0] : return address
3760 // ----------------------------------- 3760 // -----------------------------------
3761 Label miss_force_generic, smi_value, is_nan, maybe_nan; 3761 Label miss_force_generic;
3762 Label have_double_value, not_nan;
3763 3762
3764 // This stub is meant to be tail-jumped to, the receiver must already 3763 // This stub is meant to be tail-jumped to, the receiver must already
3765 // have been verified by the caller to not be a smi. 3764 // have been verified by the caller to not be a smi.
3766 3765
3767 // Check that the key is a smi. 3766 // Check that the key is a smi.
3768 __ JumpIfNotSmi(rcx, &miss_force_generic); 3767 __ JumpIfNotSmi(rcx, &miss_force_generic);
3769 3768
3770 // Get the elements array. 3769 // Get the elements array.
3771 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset)); 3770 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset));
3772 __ AssertFastElements(rdi); 3771 __ AssertFastElements(rdi);
3773 3772
3774 // Check that the key is within bounds. 3773 // Check that the key is within bounds.
3775 if (is_js_array) { 3774 if (is_js_array) {
3776 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset)); 3775 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset));
3777 } else { 3776 } else {
3778 __ SmiCompare(rcx, FieldOperand(rdi, FixedDoubleArray::kLengthOffset)); 3777 __ SmiCompare(rcx, FieldOperand(rdi, FixedDoubleArray::kLengthOffset));
3779 } 3778 }
3780 __ j(above_equal, &miss_force_generic); 3779 __ j(above_equal, &miss_force_generic);
3781 3780
3782 // Handle smi values specially 3781 // Handle smi values specially
3783 __ JumpIfSmi(rax, &smi_value, Label::kNear);
3784
3785 __ CheckMap(rax,
3786 masm->isolate()->factory()->heap_number_map(),
3787 &miss_force_generic,
3788 DONT_DO_SMI_CHECK);
3789
3790 // Double value, canonicalize NaN.
3791 uint32_t offset = HeapNumber::kValueOffset + sizeof(kHoleNanLower32);
3792 __ cmpl(FieldOperand(rax, offset),
3793 Immediate(kNaNOrInfinityLowerBoundUpper32));
3794 __ j(greater_equal, &maybe_nan, Label::kNear);
3795
3796 __ bind(&not_nan);
3797 __ movsd(xmm0, FieldOperand(rax, HeapNumber::kValueOffset));
3798 __ bind(&have_double_value);
3799 __ SmiToInteger32(rcx, rcx); 3782 __ SmiToInteger32(rcx, rcx);
3800 __ movsd(FieldOperand(rdi, rcx, times_8, FixedDoubleArray::kHeaderSize), 3783 __ StoreNumberToDoubleElements(rax, rdi, rcx, xmm0, &miss_force_generic);
3801 xmm0);
3802 __ ret(0);
3803
3804 __ bind(&maybe_nan);
3805 // Could be NaN or Infinity. If fraction is not zero, it's NaN, otherwise
3806 // it's an Infinity, and the non-NaN code path applies.
3807 __ j(greater, &is_nan, Label::kNear);
3808 __ cmpl(FieldOperand(rax, HeapNumber::kValueOffset), Immediate(0));
3809 __ j(zero, &not_nan);
3810 __ bind(&is_nan);
3811 // Convert all NaNs to the same canonical NaN value when they are stored in
3812 // the double array.
3813 __ Set(kScratchRegister, BitCast<uint64_t>(
3814 FixedDoubleArray::canonical_not_the_hole_nan_as_double()));
3815 __ movq(xmm0, kScratchRegister);
3816 __ jmp(&have_double_value, Label::kNear);
3817
3818 __ bind(&smi_value);
3819 // Value is a smi. convert to a double and store.
3820 // Preserve original value.
3821 __ SmiToInteger32(rdx, rax);
3822 __ push(rdx);
3823 __ fild_s(Operand(rsp, 0));
3824 __ pop(rdx);
3825 __ SmiToInteger32(rcx, rcx);
3826 __ fstp_d(FieldOperand(rdi, rcx, times_8, FixedDoubleArray::kHeaderSize));
3827 __ ret(0); 3784 __ ret(0);
3828 3785
3829 // Handle store cache miss, replacing the ic with the generic stub. 3786 // Handle store cache miss, replacing the ic with the generic stub.
3830 __ bind(&miss_force_generic); 3787 __ bind(&miss_force_generic);
3831 Handle<Code> ic_force_generic = 3788 Handle<Code> ic_force_generic =
3832 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); 3789 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
3833 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); 3790 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
3834 } 3791 }
3835 3792
3836 3793
3837 #undef __ 3794 #undef __
3838 3795
3839 } } // namespace v8::internal 3796 } } // namespace v8::internal
3840 3797
3841 #endif // V8_TARGET_ARCH_X64 3798 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698