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

Side by Side Diff: src/ia32/ic-ia32.cc

Issue 8022002: Optimize KeyedStoreGeneric for Smi arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback 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 | « no previous file | src/ia32/macro-assembler-ia32.h » ('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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 727
728 728
729 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm, 729 void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
730 StrictModeFlag strict_mode) { 730 StrictModeFlag strict_mode) {
731 // ----------- S t a t e ------------- 731 // ----------- S t a t e -------------
732 // -- eax : value 732 // -- eax : value
733 // -- ecx : key 733 // -- ecx : key
734 // -- edx : receiver 734 // -- edx : receiver
735 // -- esp[0] : return address 735 // -- esp[0] : return address
736 // ----------------------------------- 736 // -----------------------------------
737 Label slow, fast, array, extra; 737 Label slow, fast_object_with_map_check, fast_object_without_map_check;
738 Label fast_double_with_map_check, fast_double_without_map_check;
739 Label check_if_double_array, array, extra;
738 740
739 // Check that the object isn't a smi. 741 // Check that the object isn't a smi.
740 __ JumpIfSmi(edx, &slow); 742 __ JumpIfSmi(edx, &slow);
741 // Get the map from the receiver. 743 // Get the map from the receiver.
742 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); 744 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
743 // Check that the receiver does not require access checks. We need 745 // Check that the receiver does not require access checks. We need
744 // to do this because this generic stub does not perform map checks. 746 // to do this because this generic stub does not perform map checks.
745 __ test_b(FieldOperand(edi, Map::kBitFieldOffset), 747 __ test_b(FieldOperand(edi, Map::kBitFieldOffset),
746 1 << Map::kIsAccessCheckNeeded); 748 1 << Map::kIsAccessCheckNeeded);
747 __ j(not_zero, &slow); 749 __ j(not_zero, &slow);
748 // Check that the key is a smi. 750 // Check that the key is a smi.
749 __ JumpIfNotSmi(ecx, &slow); 751 __ JumpIfNotSmi(ecx, &slow);
750 __ CmpInstanceType(edi, JS_ARRAY_TYPE); 752 __ CmpInstanceType(edi, JS_ARRAY_TYPE);
751 __ j(equal, &array); 753 __ j(equal, &array);
752 // Check that the object is some kind of JSObject. 754 // Check that the object is some kind of JSObject.
753 __ CmpInstanceType(edi, FIRST_JS_RECEIVER_TYPE); 755 __ CmpInstanceType(edi, FIRST_JS_RECEIVER_TYPE);
754 __ j(below, &slow); 756 __ j(below, &slow);
755 __ CmpInstanceType(edi, JS_PROXY_TYPE); 757 __ CmpInstanceType(edi, JS_PROXY_TYPE);
756 __ j(equal, &slow); 758 __ j(equal, &slow);
757 __ CmpInstanceType(edi, JS_FUNCTION_PROXY_TYPE); 759 __ CmpInstanceType(edi, JS_FUNCTION_PROXY_TYPE);
758 __ j(equal, &slow); 760 __ j(equal, &slow);
759 761
760 // Object case: Check key against length in the elements array. 762 // Object case: Check key against length in the elements array.
761 // eax: value 763 // eax: value
762 // edx: JSObject 764 // edx: JSObject
763 // ecx: key (a smi) 765 // ecx: key (a smi)
764 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 766 // edi: receiver map
767 __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset));
765 // Check that the object is in fast mode and writable. 768 // Check that the object is in fast mode and writable.
766 __ CheckMap(edi, FACTORY->fixed_array_map(), &slow, DONT_DO_SMI_CHECK); 769 __ cmp(ecx, FieldOperand(ebx, FixedArray::kLengthOffset));
767 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); 770 __ j(below, &fast_object_with_map_check);
768 __ j(below, &fast);
769 771
770 // Slow case: call runtime. 772 // Slow case: call runtime.
771 __ bind(&slow); 773 __ bind(&slow);
772 GenerateRuntimeSetProperty(masm, strict_mode); 774 GenerateRuntimeSetProperty(masm, strict_mode);
773 775
774 // Extra capacity case: Check if there is extra capacity to 776 // Extra capacity case: Check if there is extra capacity to
775 // perform the store and update the length. Used for adding one 777 // perform the store and update the length. Used for adding one
776 // element to the array by writing to array[array.length]. 778 // element to the array by writing to array[array.length].
777 __ bind(&extra); 779 __ bind(&extra);
778 // eax: value 780 // eax: value
779 // edx: receiver, a JSArray 781 // edx: receiver, a JSArray
780 // ecx: key, a smi. 782 // ecx: key, a smi.
781 // edi: receiver->elements, a FixedArray 783 // ebx: receiver->elements, a FixedArray
784 // edi: receiver map
782 // flags: compare (ecx, edx.length()) 785 // flags: compare (ecx, edx.length())
783 // do not leave holes in the array: 786 // do not leave holes in the array:
784 __ j(not_equal, &slow); 787 __ j(not_equal, &slow);
785 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); 788 __ cmp(ecx, FieldOperand(ebx, FixedArray::kLengthOffset));
786 __ j(above_equal, &slow); 789 __ j(above_equal, &slow);
787 // Add 1 to receiver->length, and go to fast array write. 790 __ CheckMap(ebx, FACTORY->fixed_array_map(),
791 &check_if_double_array, DONT_DO_SMI_CHECK);
792 // Add 1 to receiver->length, and go to common element store code for Objects.
788 __ add(FieldOperand(edx, JSArray::kLengthOffset), 793 __ add(FieldOperand(edx, JSArray::kLengthOffset),
789 Immediate(Smi::FromInt(1))); 794 Immediate(Smi::FromInt(1)));
790 __ jmp(&fast); 795 __ jmp(&fast_object_without_map_check);
796
797 __ bind(&check_if_double_array);
798 __ CheckMap(ebx, FACTORY->fixed_double_array_map(), &slow, DONT_DO_SMI_CHECK);
799 // Add 1 to receiver->length, and go to common element store code for doubles.
800 __ add(FieldOperand(edx, JSArray::kLengthOffset),
801 Immediate(Smi::FromInt(1)));
802 __ jmp(&fast_double_without_map_check);
791 803
792 // Array case: Get the length and the elements array from the JS 804 // Array case: Get the length and the elements array from the JS
793 // array. Check that the array is in fast mode (and writable); if it 805 // array. Check that the array is in fast mode (and writable); if it
794 // is the length is always a smi. 806 // is the length is always a smi.
795 __ bind(&array); 807 __ bind(&array);
796 // eax: value 808 // eax: value
797 // edx: receiver, a JSArray 809 // edx: receiver, a JSArray
798 // ecx: key, a smi. 810 // ecx: key, a smi.
799 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); 811 // edi: receiver map
800 __ CheckMap(edi, FACTORY->fixed_array_map(), &slow, DONT_DO_SMI_CHECK); 812 __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset));
801 813
802 // Check the key against the length in the array, compute the 814 // Check the key against the length in the array and fall through to the
803 // address to store into and fall through to fast case. 815 // common store code.
804 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis. 816 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis.
805 __ j(above_equal, &extra); 817 __ j(above_equal, &extra);
806 818
807 // Fast case: Do the store. 819 // Fast case: Do the store, could either Object or double.
808 __ bind(&fast); 820 __ bind(&fast_object_with_map_check);
809 // eax: value 821 // eax: value
810 // ecx: key (a smi) 822 // ecx: key (a smi)
811 // edx: receiver 823 // edx: receiver
812 // edi: FixedArray receiver->elements 824 // ebx: FixedArray receiver->elements
813 825 // edi: receiver map
826 __ CheckMap(ebx, FACTORY->fixed_array_map(),
827 &fast_double_with_map_check, DONT_DO_SMI_CHECK);
828 __ bind(&fast_object_without_map_check);
829 // Smi stores don't require further checks.
814 Label non_smi_value; 830 Label non_smi_value;
815 __ JumpIfNotSmi(eax, &non_smi_value); 831 __ JumpIfNotSmi(eax, &non_smi_value);
816 // It's irrelevant whether array is smi-only or not when writing a smi. 832 // It's irrelevant whether array is smi-only or not when writing a smi.
817 __ mov(CodeGenerator::FixedArrayElementOperand(edi, ecx), eax); 833 __ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax);
818 __ ret(0); 834 __ ret(0);
819 835
820 __ bind(&non_smi_value); 836 __ bind(&non_smi_value);
821 if (FLAG_smi_only_arrays) { 837 if (FLAG_smi_only_arrays) {
822 // Escape to slow case when writing non-smi into smi-only array. 838 // Escape to slow case when writing non-smi into smi-only array.
823 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); 839 __ CheckFastObjectElements(edi, &slow, Label::kNear);
824 __ CheckFastObjectElements(ebx, &slow, Label::kNear);
825 } 840 }
841
826 // Fast elements array, store the value to the elements backing store. 842 // Fast elements array, store the value to the elements backing store.
827 __ mov(CodeGenerator::FixedArrayElementOperand(edi, ecx), eax); 843 __ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax);
828 // Update write barrier for the elements array address. 844 // Update write barrier for the elements array address.
829 __ mov(edx, Operand(eax)); // Preserve the value which is returned. 845 __ mov(edx, Operand(eax)); // Preserve the value which is returned.
830 __ RecordWriteArray( 846 __ RecordWriteArray(
831 edi, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 847 ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
848 __ ret(0);
849
850 __ bind(&fast_double_with_map_check);
851 // Check for fast double array case. If this fails, call through to the
852 // runtime.
853 __ CheckMap(ebx, FACTORY->fixed_double_array_map(), &slow, DONT_DO_SMI_CHECK);
854 __ bind(&fast_double_without_map_check);
855 // If the value is a number, store it as a double in the FastDoubleElements
856 // array.
857 __ StoreNumberToDoubleElements(eax,
858 ebx,
859 ecx,
860 edx,
861 xmm0,
862 &slow,
863 false);
832 __ ret(0); 864 __ ret(0);
833 } 865 }
834 866
835 867
836 // The generated code does not accept smi keys. 868 // The generated code does not accept smi keys.
837 // The generated code falls through if both probes miss. 869 // The generated code falls through if both probes miss.
838 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, 870 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm,
839 int argc, 871 int argc,
840 Code::Kind kind, 872 Code::Kind kind,
841 Code::ExtraICState extra_ic_state) { 873 Code::ExtraICState extra_ic_state) {
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 Condition cc = *jmp_address == Assembler::kJncShortOpcode 1683 Condition cc = *jmp_address == Assembler::kJncShortOpcode
1652 ? not_zero 1684 ? not_zero
1653 : zero; 1685 : zero;
1654 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); 1686 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
1655 } 1687 }
1656 1688
1657 1689
1658 } } // namespace v8::internal 1690 } } // namespace v8::internal
1659 1691
1660 #endif // V8_TARGET_ARCH_IA32 1692 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698