OLD | NEW |
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 Loading... |
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_extra_double, 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 __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
765 // Check that the object is in fast mode and writable. | 767 // Check that the object is in fast mode and writable. |
766 __ CheckMap(edi, FACTORY->fixed_array_map(), &slow, DONT_DO_SMI_CHECK); | 768 __ cmp(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
767 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); | 769 __ j(below, &fast_object_with_map_check); |
768 __ j(below, &fast); | |
769 | 770 |
770 // Slow case: call runtime. | 771 // Slow case: call runtime. |
771 __ bind(&slow); | 772 __ bind(&slow); |
772 GenerateRuntimeSetProperty(masm, strict_mode); | 773 GenerateRuntimeSetProperty(masm, strict_mode); |
773 | 774 |
774 // Extra capacity case: Check if there is extra capacity to | 775 // Extra capacity case: Check if there is extra capacity to |
775 // perform the store and update the length. Used for adding one | 776 // perform the store and update the length. Used for adding one |
776 // element to the array by writing to array[array.length]. | 777 // element to the array by writing to array[array.length]. |
777 __ bind(&extra); | 778 __ bind(&extra); |
778 // eax: value | 779 // eax: value |
779 // edx: receiver, a JSArray | 780 // edx: receiver, a JSArray |
780 // ecx: key, a smi. | 781 // ecx: key, a smi. |
781 // edi: receiver->elements, a FixedArray | 782 // ebx: receiver->elements, a FixedArray |
782 // flags: compare (ecx, edx.length()) | 783 // flags: compare (ecx, edx.length()) |
783 // do not leave holes in the array: | 784 // do not leave holes in the array: |
784 __ j(not_equal, &slow); | 785 __ j(not_equal, &slow); |
785 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); | 786 __ cmp(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); |
786 __ j(above_equal, &slow); | 787 __ j(above_equal, &slow); |
787 // Add 1 to receiver->length, and go to fast array write. | 788 // Add 1 to receiver->length, and go to fast array write. |
| 789 __ CheckMap(ebx, FACTORY->fixed_array_map(), |
| 790 &check_extra_double, DONT_DO_SMI_CHECK); |
788 __ add(FieldOperand(edx, JSArray::kLengthOffset), | 791 __ add(FieldOperand(edx, JSArray::kLengthOffset), |
789 Immediate(Smi::FromInt(1))); | 792 Immediate(Smi::FromInt(1))); |
790 __ jmp(&fast); | 793 __ jmp(&fast_object_without_map_check); |
| 794 |
| 795 __ bind(&check_extra_double); |
| 796 __ CheckMap(ebx, FACTORY->fixed_double_array_map(), &slow, DONT_DO_SMI_CHECK); |
| 797 __ add(FieldOperand(edx, JSArray::kLengthOffset), |
| 798 Immediate(Smi::FromInt(1))); |
| 799 __ jmp(&fast_double_without_map_check); |
791 | 800 |
792 // Array case: Get the length and the elements array from the JS | 801 // 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 | 802 // array. Check that the array is in fast mode (and writable); if it |
794 // is the length is always a smi. | 803 // is the length is always a smi. |
795 __ bind(&array); | 804 __ bind(&array); |
796 // eax: value | 805 // eax: value |
797 // edx: receiver, a JSArray | 806 // edx: receiver, a JSArray |
798 // ecx: key, a smi. | 807 // ecx: key, a smi. |
799 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset)); | 808 __ mov(ebx, FieldOperand(edx, JSObject::kElementsOffset)); |
800 __ CheckMap(edi, FACTORY->fixed_array_map(), &slow, DONT_DO_SMI_CHECK); | |
801 | 809 |
802 // Check the key against the length in the array, compute the | 810 // Check the key against the length in the array, compute the |
803 // address to store into and fall through to fast case. | 811 // address to store into and fall through to fast case. |
804 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis. | 812 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // Compare smis. |
805 __ j(above_equal, &extra); | 813 __ j(above_equal, &extra); |
806 | 814 |
807 // Fast case: Do the store. | 815 // Fast case: Do the store. |
808 __ bind(&fast); | 816 __ bind(&fast_object_with_map_check); |
809 // eax: value | 817 // eax: value |
810 // ecx: key (a smi) | 818 // ecx: key (a smi) |
811 // edx: receiver | 819 // edx: receiver |
812 // edi: FixedArray receiver->elements | 820 // ebx: FixedArray receiver->elements |
813 | 821 __ CheckMap(ebx, FACTORY->fixed_array_map(), |
| 822 &fast_double_with_map_check, DONT_DO_SMI_CHECK); |
| 823 __ bind(&fast_object_without_map_check); |
| 824 // Smi stores don't require further checks. |
814 Label non_smi_value; | 825 Label non_smi_value; |
815 __ JumpIfNotSmi(eax, &non_smi_value); | 826 __ JumpIfNotSmi(eax, &non_smi_value); |
816 // It's irrelevant whether array is smi-only or not when writing a smi. | 827 // It's irrelevant whether array is smi-only or not when writing a smi. |
817 __ mov(CodeGenerator::FixedArrayElementOperand(edi, ecx), eax); | 828 __ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax); |
818 __ ret(0); | 829 __ ret(0); |
819 | 830 |
820 __ bind(&non_smi_value); | 831 __ bind(&non_smi_value); |
821 if (FLAG_smi_only_arrays) { | 832 if (FLAG_smi_only_arrays) { |
822 // Escape to slow case when writing non-smi into smi-only array. | 833 // Escape to slow case when writing non-smi into smi-only array. |
823 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); | |
824 __ CheckFastObjectElements(ebx, &slow, Label::kNear); | 834 __ CheckFastObjectElements(ebx, &slow, Label::kNear); |
825 } | 835 } |
| 836 |
826 // Fast elements array, store the value to the elements backing store. | 837 // Fast elements array, store the value to the elements backing store. |
827 __ mov(CodeGenerator::FixedArrayElementOperand(edi, ecx), eax); | 838 __ mov(CodeGenerator::FixedArrayElementOperand(ebx, ecx), eax); |
828 // Update write barrier for the elements array address. | 839 // Update write barrier for the elements array address. |
829 __ mov(edx, Operand(eax)); // Preserve the value which is returned. | 840 __ mov(edx, Operand(eax)); // Preserve the value which is returned. |
830 __ RecordWriteArray( | 841 __ RecordWriteArray( |
831 edi, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); | 842 ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
| 843 __ ret(0); |
| 844 |
| 845 __ bind(&fast_double_with_map_check); |
| 846 // Check for fast double array case. If this fails, call through to the |
| 847 // runtime. |
| 848 __ CheckMap(ebx, FACTORY->fixed_double_array_map(), &slow, DONT_DO_SMI_CHECK); |
| 849 __ bind(&fast_double_without_map_check); |
| 850 // If the value is a number, store it as a double in the FastDoubleElements |
| 851 // array. |
| 852 __ StoreNumberToDoubleElements(eax, |
| 853 ebx, |
| 854 ecx, |
| 855 edx, |
| 856 xmm0, |
| 857 &slow, |
| 858 false); |
832 __ ret(0); | 859 __ ret(0); |
833 } | 860 } |
834 | 861 |
835 | 862 |
836 // The generated code does not accept smi keys. | 863 // The generated code does not accept smi keys. |
837 // The generated code falls through if both probes miss. | 864 // The generated code falls through if both probes miss. |
838 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, | 865 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, |
839 int argc, | 866 int argc, |
840 Code::Kind kind, | 867 Code::Kind kind, |
841 Code::ExtraICState extra_ic_state) { | 868 Code::ExtraICState extra_ic_state) { |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1678 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
1652 ? not_zero | 1679 ? not_zero |
1653 : zero; | 1680 : zero; |
1654 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1681 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1655 } | 1682 } |
1656 | 1683 |
1657 | 1684 |
1658 } } // namespace v8::internal | 1685 } } // namespace v8::internal |
1659 | 1686 |
1660 #endif // V8_TARGET_ARCH_IA32 | 1687 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |