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

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

Issue 7307030: Implement ICs for FastDoubleArray loads and stores (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix asserts 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
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/mjsunit/unbox-double-arrays.js » ('j') | 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 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3577 __ ret(0); 3577 __ ret(0);
3578 3578
3579 __ bind(&miss_force_generic); 3579 __ bind(&miss_force_generic);
3580 Code* code = masm->isolate()->builtins()->builtin( 3580 Code* code = masm->isolate()->builtins()->builtin(
3581 Builtins::kKeyedLoadIC_MissForceGeneric); 3581 Builtins::kKeyedLoadIC_MissForceGeneric);
3582 Handle<Code> ic(code); 3582 Handle<Code> ic(code);
3583 __ jmp(ic, RelocInfo::CODE_TARGET); 3583 __ jmp(ic, RelocInfo::CODE_TARGET);
3584 } 3584 }
3585 3585
3586 3586
3587 void KeyedLoadStubCompiler::GenerateLoadFastDoubleElement(
3588 MacroAssembler* masm) {
3589 // ----------- S t a t e -------------
3590 // -- rax : key
3591 // -- rdx : receiver
3592 // -- rsp[0] : return address
3593 // -----------------------------------
3594 Label miss_force_generic, slow_allocate_heapnumber;
3595
3596 // This stub is meant to be tail-jumped to, the receiver must already
3597 // have been verified by the caller to not be a smi.
3598
3599 // Check that the key is a smi.
3600 __ JumpIfNotSmi(rax, &miss_force_generic);
3601
3602 // Get the elements array.
3603 __ movq(rcx, FieldOperand(rdx, JSObject::kElementsOffset));
3604 __ AssertFastElements(rcx);
3605
3606 // Check that the key is within bounds.
3607 __ SmiCompare(rax, FieldOperand(rcx, FixedArray::kLengthOffset));
3608 __ j(above_equal, &miss_force_generic);
3609
3610 // Check for the hole
3611 __ SmiToInteger32(kScratchRegister, rax);
3612 uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32);
3613 __ cmpl(FieldOperand(rcx, kScratchRegister, times_8, offset),
3614 Immediate(kHoleNanUpper32));
3615 __ j(equal, &miss_force_generic);
3616
3617 // Always allocate a heap number for the result.
3618 __ movsd(xmm0, FieldOperand(rcx, kScratchRegister, times_8,
3619 FixedDoubleArray::kHeaderSize));
3620 __ AllocateHeapNumber(rcx, rbx, &slow_allocate_heapnumber);
3621 // Set the value.
3622 __ movq(rax, rcx);
3623 __ movsd(FieldOperand(rcx, HeapNumber::kValueOffset), xmm0);
3624 __ ret(0);
3625
3626 __ bind(&slow_allocate_heapnumber);
3627 Handle<Code> slow_ic =
3628 masm->isolate()->builtins()->KeyedLoadIC_Slow();
3629 __ jmp(slow_ic, RelocInfo::CODE_TARGET);
3630
3631 __ bind(&miss_force_generic);
3632 Handle<Code> miss_ic =
3633 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
3634 __ jmp(miss_ic, RelocInfo::CODE_TARGET);
3635 }
3636
3637
3587 void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, 3638 void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm,
3588 bool is_js_array) { 3639 bool is_js_array) {
3589 // ----------- S t a t e ------------- 3640 // ----------- S t a t e -------------
3590 // -- rax : value 3641 // -- rax : value
3591 // -- rcx : key 3642 // -- rcx : key
3592 // -- rdx : receiver 3643 // -- rdx : receiver
3593 // -- rsp[0] : return address 3644 // -- rsp[0] : return address
3594 // ----------------------------------- 3645 // -----------------------------------
3595 Label miss_force_generic; 3646 Label miss_force_generic;
3596 3647
(...skipping 30 matching lines...) Expand all
3627 __ ret(0); 3678 __ ret(0);
3628 3679
3629 // Handle store cache miss. 3680 // Handle store cache miss.
3630 __ bind(&miss_force_generic); 3681 __ bind(&miss_force_generic);
3631 Handle<Code> ic_force_generic = 3682 Handle<Code> ic_force_generic =
3632 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); 3683 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
3633 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); 3684 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
3634 } 3685 }
3635 3686
3636 3687
3688 void KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(
3689 MacroAssembler* masm,
3690 bool is_js_array) {
3691 // ----------- S t a t e -------------
3692 // -- rax : value
3693 // -- rcx : key
3694 // -- rdx : receiver
3695 // -- rsp[0] : return address
3696 // -----------------------------------
3697 Label miss_force_generic, smi_value, is_nan, maybe_nan;
3698 Label have_double_value, not_nan;
3699
3700 // This stub is meant to be tail-jumped to, the receiver must already
3701 // have been verified by the caller to not be a smi.
3702
3703 // Check that the key is a smi.
3704 __ JumpIfNotSmi(rcx, &miss_force_generic);
3705
3706 // Get the elements array.
3707 __ movq(rdi, FieldOperand(rdx, JSObject::kElementsOffset));
3708 __ AssertFastElements(rdi);
3709
3710 // Check that the key is within bounds.
3711 if (is_js_array) {
3712 __ SmiCompare(rcx, FieldOperand(rdx, JSArray::kLengthOffset));
3713 } else {
3714 __ SmiCompare(rcx, FieldOperand(rdi, FixedDoubleArray::kLengthOffset));
3715 }
3716 __ j(above_equal, &miss_force_generic);
3717
3718 // Handle smi values specially
3719 __ JumpIfSmi(rax, &smi_value, Label::kNear);
3720
3721 __ CheckMap(rax,
3722 masm->isolate()->factory()->heap_number_map(),
3723 &miss_force_generic,
3724 DONT_DO_SMI_CHECK);
3725
3726 // Double value, canonicalize NaN.
3727 uint32_t offset = HeapNumber::kValueOffset + sizeof(kHoleNanLower32);
3728 __ cmpl(FieldOperand(rax, offset),
3729 Immediate(kNaNOrInfinityLowerBoundUpper32));
3730 __ j(greater_equal, &maybe_nan, Label::kNear);
3731
3732 __ bind(&not_nan);
3733 __ movsd(xmm0, FieldOperand(rax, HeapNumber::kValueOffset));
3734 __ bind(&have_double_value);
3735 __ SmiToInteger32(rcx, rcx);
3736 __ movsd(FieldOperand(rdi, rcx, times_8, FixedDoubleArray::kHeaderSize),
3737 xmm0);
3738 __ ret(0);
3739
3740 __ bind(&maybe_nan);
3741 // Could be NaN or Infinity. If fraction is not zero, it's NaN, otherwise
3742 // it's an Infinity, and the non-NaN code path applies.
3743 __ j(greater, &is_nan, Label::kNear);
3744 __ cmpl(FieldOperand(rax, HeapNumber::kValueOffset), Immediate(0));
3745 __ j(zero, &not_nan);
3746 __ bind(&is_nan);
3747 // Convert all NaNs to the same canonical NaN value when they are stored in
3748 // the double array.
3749 ExternalReference canonical_nan_reference =
3750 ExternalReference::address_of_canonical_non_hole_nan();
3751 __ Set(kScratchRegister, kCanonicalNonHoleNanInt64);
3752 __ movq(xmm0, kScratchRegister);
3753 __ jmp(&have_double_value, Label::kNear);
3754
3755 __ bind(&smi_value);
3756 // Value is a smi. convert to a double and store.
3757 __ SmiToInteger32(rax, rax);
3758 __ push(rax);
3759 __ fild_s(Operand(rsp, 0));
3760 __ pop(rax);
3761 __ SmiToInteger32(rcx, rcx);
3762 __ fstp_d(FieldOperand(rdi, rcx, times_8, FixedDoubleArray::kHeaderSize));
3763 __ ret(0);
3764
3765 // Handle store cache miss, replacing the ic with the generic stub.
3766 __ bind(&miss_force_generic);
3767 Handle<Code> ic_force_generic =
3768 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
3769 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
3770 }
3771
3772
3637 #undef __ 3773 #undef __
3638 3774
3639 } } // namespace v8::internal 3775 } } // namespace v8::internal
3640 3776
3641 #endif // V8_TARGET_ARCH_X64 3777 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/mjsunit/unbox-double-arrays.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698