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

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

Issue 9837109: Improve performance of keyed loads/stores which have a HeapNumber index. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: fixed formatting Created 8 years, 9 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 | « no previous file | src/ic.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 // For floating-point array type: 3360 // For floating-point array type:
3361 // FP(0): value 3361 // FP(0): value
3362 3362
3363 if (elements_kind == EXTERNAL_INT_ELEMENTS || 3363 if (elements_kind == EXTERNAL_INT_ELEMENTS ||
3364 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) { 3364 elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) {
3365 // For the Int and UnsignedInt array types, we need to see whether 3365 // For the Int and UnsignedInt array types, we need to see whether
3366 // the value can be represented in a Smi. If not, we need to convert 3366 // the value can be represented in a Smi. If not, we need to convert
3367 // it to a HeapNumber. 3367 // it to a HeapNumber.
3368 Label box_int; 3368 Label box_int;
3369 if (elements_kind == EXTERNAL_INT_ELEMENTS) { 3369 if (elements_kind == EXTERNAL_INT_ELEMENTS) {
3370 __ cmp(ecx, 0xC0000000); 3370 __ cmp(ecx, 0xc0000000);
3371 __ j(sign, &box_int); 3371 __ j(sign, &box_int);
3372 } else { 3372 } else {
3373 ASSERT_EQ(EXTERNAL_UNSIGNED_INT_ELEMENTS, elements_kind); 3373 ASSERT_EQ(EXTERNAL_UNSIGNED_INT_ELEMENTS, elements_kind);
3374 // The test is different for unsigned int values. Since we need 3374 // The test is different for unsigned int values. Since we need
3375 // the value to be in the range of a positive smi, we can't 3375 // the value to be in the range of a positive smi, we can't
3376 // handle either of the top two bits being set in the value. 3376 // handle either of the top two bits being set in the value.
3377 __ test(ecx, Immediate(0xC0000000)); 3377 __ test(ecx, Immediate(0xc0000000));
3378 __ j(not_zero, &box_int); 3378 __ j(not_zero, &box_int);
3379 } 3379 }
3380 3380
3381 __ mov(eax, ecx); 3381 __ mov(eax, ecx);
3382 __ SmiTag(eax); 3382 __ SmiTag(eax);
3383 __ ret(0); 3383 __ ret(0);
3384 3384
3385 __ bind(&box_int); 3385 __ bind(&box_int);
3386 3386
3387 // Allocate a HeapNumber for the int and perform int-to-double 3387 // Allocate a HeapNumber for the int and perform int-to-double
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 // -- esp[0] : return address 3646 // -- esp[0] : return address
3647 // ----------------------------------- 3647 // -----------------------------------
3648 3648
3649 __ bind(&miss_force_generic); 3649 __ bind(&miss_force_generic);
3650 Handle<Code> miss_ic = 3650 Handle<Code> miss_ic =
3651 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); 3651 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
3652 __ jmp(miss_ic, RelocInfo::CODE_TARGET); 3652 __ jmp(miss_ic, RelocInfo::CODE_TARGET);
3653 } 3653 }
3654 3654
3655 3655
3656 static void GenerateSmiAsHeapNumberCheck(MacroAssembler* masm,
Jakob Kummerow 2012/03/29 11:38:45 "Smi as HeapNumber" sounds like a Smi->HeapNumber
3657 Register key,
3658 Register scratch,
3659 XMMRegister xmm_scratch0,
3660 XMMRegister xmm_scratch1,
3661 Label* fail) {
3662 // Check that key is a smi or if SSE2 in available a heap number
Jakob Kummerow 2012/03/29 11:38:45 nit: s/in/is/
3663 // containing a smi and branch if the check fails.
3664 if (CpuFeatures::IsSupported(SSE2)) {
3665 CpuFeatures::Scope use_sse2(SSE2);
3666 Label key_ok;
3667 __ JumpIfSmi(key, &key_ok);
3668 __ cmp(FieldOperand(key, HeapObject::kMapOffset),
3669 Immediate(Handle<Map>(masm->isolate()->heap()->heap_number_map())));
3670 __ j(not_equal, fail);
3671 __ movdbl(xmm_scratch0, FieldOperand(key, HeapNumber::kValueOffset));
3672 __ cvttsd2si(scratch, Operand(xmm_scratch0));
3673 __ cvtsi2sd(xmm_scratch1, scratch);
3674 __ ucomisd(xmm_scratch1, xmm_scratch0);
3675 __ j(not_equal, fail);
3676 __ j(parity_even, fail); // NaN.
3677 // Check if the key fits in the smi range.
3678 __ cmp(scratch, 0xc0000000);
3679 __ j(sign, fail);
3680 __ SmiTag(scratch);
3681 __ mov(key, scratch);
3682 __ bind(&key_ok);
3683 } else {
3684 __ JumpIfNotSmi(eax, fail);
3685 }
3686 }
3687
3688
3656 void KeyedLoadStubCompiler::GenerateLoadFastElement(MacroAssembler* masm) { 3689 void KeyedLoadStubCompiler::GenerateLoadFastElement(MacroAssembler* masm) {
3657 // ----------- S t a t e ------------- 3690 // ----------- S t a t e -------------
3658 // -- eax : key 3691 // -- eax : key
3659 // -- edx : receiver 3692 // -- edx : receiver
3660 // -- esp[0] : return address 3693 // -- esp[0] : return address
3661 // ----------------------------------- 3694 // -----------------------------------
3662 Label miss_force_generic; 3695 Label miss_force_generic;
3663 3696
3664 // This stub is meant to be tail-jumped to, the receiver must already 3697 // This stub is meant to be tail-jumped to, the receiver must already
3665 // have been verified by the caller to not be a smi. 3698 // have been verified by the caller to not be a smi.
3666 3699
3667 // Check that the key is a smi. 3700 // Check that the key is a smi or a heap number convertible to a smi.
3668 __ JumpIfNotSmi(eax, &miss_force_generic); 3701 GenerateSmiAsHeapNumberCheck(masm, eax, ecx, xmm0, xmm1, &miss_force_generic);
3669 3702
3670 // Get the elements array. 3703 // Get the elements array.
3671 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset)); 3704 __ mov(ecx, FieldOperand(edx, JSObject::kElementsOffset));
3672 __ AssertFastElements(ecx); 3705 __ AssertFastElements(ecx);
3673 3706
3674 // Check that the key is within bounds. 3707 // Check that the key is within bounds.
3675 __ cmp(eax, FieldOperand(ecx, FixedArray::kLengthOffset)); 3708 __ cmp(eax, FieldOperand(ecx, FixedArray::kLengthOffset));
3676 __ j(above_equal, &miss_force_generic); 3709 __ j(above_equal, &miss_force_generic);
3677 3710
3678 // Load the result and make sure it's not the hole. 3711 // Load the result and make sure it's not the hole.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3764 // -- ecx : key 3797 // -- ecx : key
3765 // -- edx : receiver 3798 // -- edx : receiver
3766 // -- esp[0] : return address 3799 // -- esp[0] : return address
3767 // ----------------------------------- 3800 // -----------------------------------
3768 Label miss_force_generic, grow, slow, transition_elements_kind; 3801 Label miss_force_generic, grow, slow, transition_elements_kind;
3769 Label check_capacity, prepare_slow, finish_store, commit_backing_store; 3802 Label check_capacity, prepare_slow, finish_store, commit_backing_store;
3770 3803
3771 // This stub is meant to be tail-jumped to, the receiver must already 3804 // This stub is meant to be tail-jumped to, the receiver must already
3772 // have been verified by the caller to not be a smi. 3805 // have been verified by the caller to not be a smi.
3773 3806
3774 // Check that the key is a smi. 3807 // Check that the key is a smi or a heap number convertible to a smi.
3775 __ JumpIfNotSmi(ecx, &miss_force_generic); 3808 GenerateSmiAsHeapNumberCheck(masm, ecx, ebx, xmm0, xmm1, &miss_force_generic);
3776 3809
3777 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { 3810 if (elements_kind == FAST_SMI_ONLY_ELEMENTS) {
3778 __ JumpIfNotSmi(eax, &transition_elements_kind); 3811 __ JumpIfNotSmi(eax, &transition_elements_kind);
3779 } 3812 }
3780 3813
3781 // Get the elements array and make sure it is a fast element array, not 'cow'. 3814 // Get the elements array and make sure it is a fast element array, not 'cow'.
3782 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 3815 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
3783 if (is_js_array) { 3816 if (is_js_array) {
3784 // Check that the key is within bounds. 3817 // Check that the key is within bounds.
3785 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. 3818 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
4036 __ jmp(ic_slow, RelocInfo::CODE_TARGET); 4069 __ jmp(ic_slow, RelocInfo::CODE_TARGET);
4037 } 4070 }
4038 } 4071 }
4039 4072
4040 4073
4041 #undef __ 4074 #undef __
4042 4075
4043 } } // namespace v8::internal 4076 } } // namespace v8::internal
4044 4077
4045 #endif // V8_TARGET_ARCH_IA32 4078 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698