OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 | 722 |
723 // Perform tail call to the entry. | 723 // Perform tail call to the entry. |
724 __ TailCallRuntime(f, 2); | 724 __ TailCallRuntime(f, 2); |
725 } | 725 } |
726 | 726 |
727 | 727 |
728 // One byte opcode for test eax,0xXXXXXXXX. | 728 // One byte opcode for test eax,0xXXXXXXXX. |
729 static const byte kTestEaxByte = 0xA9; | 729 static const byte kTestEaxByte = 0xA9; |
730 | 730 |
731 | 731 |
732 bool KeyedLoadIC::HasInlinedVersion(Address address) { | 732 void LoadIC::ClearInlinedVersion(Address address) { |
733 Address test_instruction_address = address + 4; // 4 = stub address | 733 // Reset the map check of the inlined inobject property load (if |
734 return *test_instruction_address == kTestEaxByte; | 734 // present) to guarantee failure by holding an invalid map (the null |
735 // value). The offset can be patched to anything. | |
736 PatchInlinedLoad(address, Heap::null_value(), kMaxInt); | |
735 } | 737 } |
736 | 738 |
737 | 739 |
738 void KeyedLoadIC::ClearInlinedVersion(Address address) { | 740 void KeyedLoadIC::ClearInlinedVersion(Address address) { |
739 // Insert null as the map to check for to make sure the map check fails | 741 // Insert null as the map to check for to make sure the map check fails |
740 // sending control flow to the IC instead of the inlined version. | 742 // sending control flow to the IC instead of the inlined version. |
741 PatchInlinedMapCheck(address, Heap::null_value()); | 743 PatchInlinedLoad(address, Heap::null_value()); |
742 } | 744 } |
743 | 745 |
744 | 746 |
745 void KeyedLoadIC::PatchInlinedMapCheck(Address address, Object* value) { | 747 bool LoadIC::PatchInlinedLoad(Address address, Object* map, int offset) { |
748 // The address of the instruction following the call. | |
749 Address test_instruction_address = address + 4; | |
750 // If the instruction following the call is not a test eax, nothing | |
751 // was inlined. | |
752 if (*test_instruction_address != kTestEaxByte) return false; | |
753 | |
754 Address delta_address = test_instruction_address + 1; | |
755 // The delta to the start of the map chack instruction. | |
Mads Ager (chromium)
2009/04/28 09:53:54
chack -> check.
| |
756 int delta = *reinterpret_cast<int*>(delta_address); | |
757 | |
758 // The map address is the last 4 bytes of the 7-byte | |
759 // operand-immediate compare instruction, so we add 3 to get the | |
760 // offset to the last 4 bytes. | |
761 Address map_address = test_instruction_address + delta + 3; | |
762 *(reinterpret_cast<Object**>(map_address)) = map; | |
763 | |
764 // The offset is in the last 4 bytes of a six byte | |
765 // memory-to-register move instruction, so we add 2 to get the | |
766 // offset to the last 4 bytes. | |
767 Address offset_address = | |
768 test_instruction_address + delta + kOffsetToLoadInstruction + 2; | |
769 *reinterpret_cast<int*>(offset_address) = offset - kHeapObjectTag; | |
770 return true; | |
771 } | |
772 | |
773 | |
774 bool KeyedLoadIC::PatchInlinedLoad(Address address, Object* map) { | |
746 Address test_instruction_address = address + 4; // 4 = stub address | 775 Address test_instruction_address = address + 4; // 4 = stub address |
747 // The keyed load has a fast inlined case if the IC call instruction | 776 // The keyed load has a fast inlined case if the IC call instruction |
748 // is immediately followed by a test instruction. | 777 // is immediately followed by a test instruction. |
749 if (*test_instruction_address == kTestEaxByte) { | 778 if (*test_instruction_address != kTestEaxByte) return false; |
750 // Fetch the offset from the test instruction to the map cmp | 779 |
751 // instruction. This offset is stored in the last 4 bytes of the | 780 // Fetch the offset from the test instruction to the map cmp |
752 // 5 byte test instruction. | 781 // instruction. This offset is stored in the last 4 bytes of the 5 |
753 Address offset_address = test_instruction_address + 1; | 782 // byte test instruction. |
754 int offset_value = *(reinterpret_cast<int*>(offset_address)); | 783 Address delta_address = test_instruction_address + 1; |
755 // Compute the map address. The map address is in the last 4 | 784 int delta = *reinterpret_cast<int*>(delta_address); |
756 // bytes of the 7-byte operand-immediate compare instruction, so | 785 // Compute the map address. The map address is in the last 4 bytes |
757 // we add 3 to the offset to get the map address. | 786 // of the 7-byte operand-immediate compare instruction, so we add 3 |
758 Address map_address = test_instruction_address + offset_value + 3; | 787 // to the offset to get the map address. |
759 // Patch the map check. | 788 Address map_address = test_instruction_address + delta + 3; |
760 (*(reinterpret_cast<Object**>(map_address))) = value; | 789 // Patch the map check. |
761 } | 790 *(reinterpret_cast<Object**>(map_address)) = map; |
791 return true; | |
762 } | 792 } |
763 | 793 |
764 | 794 |
765 // Defined in ic.cc. | 795 // Defined in ic.cc. |
766 Object* KeyedLoadIC_Miss(Arguments args); | 796 Object* KeyedLoadIC_Miss(Arguments args); |
767 | 797 |
768 | 798 |
769 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { | 799 void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { |
770 // ----------- S t a t e ------------- | 800 // ----------- S t a t e ------------- |
771 // -- esp[0] : return address | 801 // -- esp[0] : return address |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 | 927 |
898 // Do tail-call to runtime routine. | 928 // Do tail-call to runtime routine. |
899 __ TailCallRuntime( | 929 __ TailCallRuntime( |
900 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3); | 930 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3); |
901 } | 931 } |
902 | 932 |
903 #undef __ | 933 #undef __ |
904 | 934 |
905 | 935 |
906 } } // namespace v8::internal | 936 } } // namespace v8::internal |
OLD | NEW |