| 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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 __ IncrementCounter(&Counters::load_miss, 1, r3, r4); | 897 __ IncrementCounter(&Counters::load_miss, 1, r3, r4); |
| 898 | 898 |
| 899 __ mov(r3, r0); | 899 __ mov(r3, r0); |
| 900 __ Push(r3, r2); | 900 __ Push(r3, r2); |
| 901 | 901 |
| 902 // Perform tail call to the entry. | 902 // Perform tail call to the entry. |
| 903 ExternalReference ref = ExternalReference(IC_Utility(kLoadIC_Miss)); | 903 ExternalReference ref = ExternalReference(IC_Utility(kLoadIC_Miss)); |
| 904 __ TailCallExternalReference(ref, 2, 1); | 904 __ TailCallExternalReference(ref, 2, 1); |
| 905 } | 905 } |
| 906 | 906 |
| 907 | 907 // Returns the code marker, or the 0 if the code is not marked. |
| 908 static inline bool IsInlinedICSite(Address address, | 908 static inline int InlinedICSiteMarker(Address address, |
| 909 Address* inline_end_address) { | 909 Address* inline_end_address) { |
| 910 // If the instruction after the call site is not the pseudo instruction nop1 | 910 // If the instruction after the call site is not the pseudo instruction nop1 |
| 911 // then this is not related to an inlined in-object property load. The nop1 | 911 // then this is not related to an inlined in-object property load. The nop1 |
| 912 // instruction is located just after the call to the IC in the deferred code | 912 // instruction is located just after the call to the IC in the deferred code |
| 913 // handling the miss in the inlined code. After the nop1 instruction there is | 913 // handling the miss in the inlined code. After the nop1 instruction there is |
| 914 // a branch instruction for jumping back from the deferred code. | 914 // a branch instruction for jumping back from the deferred code. |
| 915 Address address_after_call = address + Assembler::kCallTargetAddressOffset; | 915 Address address_after_call = address + Assembler::kCallTargetAddressOffset; |
| 916 Instr instr_after_call = Assembler::instr_at(address_after_call); | 916 Instr instr_after_call = Assembler::instr_at(address_after_call); |
| 917 if (!Assembler::IsNop(instr_after_call, PROPERTY_ACCESS_INLINED)) { | 917 int code_marker = MacroAssembler::GetCodeMarker(instr_after_call); |
| 918 return false; | 918 |
| 919 } | 919 // A negative result means the code is not marked. |
| 920 if (code_marker <= 0) return 0; |
| 921 |
| 920 Address address_after_nop = address_after_call + Assembler::kInstrSize; | 922 Address address_after_nop = address_after_call + Assembler::kInstrSize; |
| 921 Instr instr_after_nop = Assembler::instr_at(address_after_nop); | 923 Instr instr_after_nop = Assembler::instr_at(address_after_nop); |
| 922 // There may be some reg-reg move and frame merging code to skip over before | 924 // There may be some reg-reg move and frame merging code to skip over before |
| 923 // the branch back from the DeferredReferenceGetKeyedValue code to the inlined | 925 // the branch back from the DeferredReferenceGetKeyedValue code to the inlined |
| 924 // code. | 926 // code. |
| 925 while (!Assembler::IsBranch(instr_after_nop)) { | 927 while (!Assembler::IsBranch(instr_after_nop)) { |
| 926 address_after_nop += Assembler::kInstrSize; | 928 address_after_nop += Assembler::kInstrSize; |
| 927 instr_after_nop = Assembler::instr_at(address_after_nop); | 929 instr_after_nop = Assembler::instr_at(address_after_nop); |
| 928 } | 930 } |
| 929 | 931 |
| 930 // Find the end of the inlined code for handling the load. | 932 // Find the end of the inlined code for handling the load. |
| 931 int b_offset = | 933 int b_offset = |
| 932 Assembler::GetBranchOffset(instr_after_nop) + Assembler::kPcLoadDelta; | 934 Assembler::GetBranchOffset(instr_after_nop) + Assembler::kPcLoadDelta; |
| 933 ASSERT(b_offset < 0); // Jumping back from deferred code. | 935 ASSERT(b_offset < 0); // Jumping back from deferred code. |
| 934 *inline_end_address = address_after_nop + b_offset; | 936 *inline_end_address = address_after_nop + b_offset; |
| 935 | 937 |
| 936 return true; | 938 return code_marker; |
| 937 } | 939 } |
| 938 | 940 |
| 939 | 941 |
| 940 bool LoadIC::PatchInlinedLoad(Address address, Object* map, int offset) { | 942 bool LoadIC::PatchInlinedLoad(Address address, Object* map, int offset) { |
| 941 // Find the end of the inlined code for handling the load if this is an | 943 // Find the end of the inlined code for handling the load if this is an |
| 942 // inlined IC call site. | 944 // inlined IC call site. |
| 943 Address inline_end_address; | 945 Address inline_end_address; |
| 944 if (!IsInlinedICSite(address, &inline_end_address)) return false; | 946 if (InlinedICSiteMarker(address, &inline_end_address) |
| 947 != Assembler::PROPERTY_ACCESS_INLINED) { |
| 948 return false; |
| 949 } |
| 945 | 950 |
| 946 // Patch the offset of the property load instruction (ldr r0, [r1, #+XXX]). | 951 // Patch the offset of the property load instruction (ldr r0, [r1, #+XXX]). |
| 947 // The immediate must be representable in 12 bits. | 952 // The immediate must be representable in 12 bits. |
| 948 ASSERT((JSObject::kMaxInstanceSize - JSObject::kHeaderSize) < (1 << 12)); | 953 ASSERT((JSObject::kMaxInstanceSize - JSObject::kHeaderSize) < (1 << 12)); |
| 949 Address ldr_property_instr_address = | 954 Address ldr_property_instr_address = |
| 950 inline_end_address - Assembler::kInstrSize; | 955 inline_end_address - Assembler::kInstrSize; |
| 951 ASSERT(Assembler::IsLdrRegisterImmediate( | 956 ASSERT(Assembler::IsLdrRegisterImmediate( |
| 952 Assembler::instr_at(ldr_property_instr_address))); | 957 Assembler::instr_at(ldr_property_instr_address))); |
| 953 Instr ldr_property_instr = Assembler::instr_at(ldr_property_instr_address); | 958 Instr ldr_property_instr = Assembler::instr_at(ldr_property_instr_address); |
| 954 ldr_property_instr = Assembler::SetLdrRegisterImmediateOffset( | 959 ldr_property_instr = Assembler::SetLdrRegisterImmediateOffset( |
| 955 ldr_property_instr, offset - kHeapObjectTag); | 960 ldr_property_instr, offset - kHeapObjectTag); |
| 956 Assembler::instr_at_put(ldr_property_instr_address, ldr_property_instr); | 961 Assembler::instr_at_put(ldr_property_instr_address, ldr_property_instr); |
| 957 | 962 |
| 958 // Indicate that code has changed. | 963 // Indicate that code has changed. |
| 959 CPU::FlushICache(ldr_property_instr_address, 1 * Assembler::kInstrSize); | 964 CPU::FlushICache(ldr_property_instr_address, 1 * Assembler::kInstrSize); |
| 960 | 965 |
| 961 // Patch the map check. | 966 // Patch the map check. |
| 967 // For PROPERTY_ACCESS_INLINED, the load map instruction is generated |
| 968 // 4 instructions before the end of the inlined code. |
| 969 // See codgen-arm.cc CodeGenerator::EmitNamedLoad. |
| 970 int ldr_map_offset = -4; |
| 962 Address ldr_map_instr_address = | 971 Address ldr_map_instr_address = |
| 963 inline_end_address - 4 * Assembler::kInstrSize; | 972 inline_end_address + ldr_map_offset * Assembler::kInstrSize; |
| 964 Assembler::set_target_address_at(ldr_map_instr_address, | 973 Assembler::set_target_address_at(ldr_map_instr_address, |
| 965 reinterpret_cast<Address>(map)); | 974 reinterpret_cast<Address>(map)); |
| 966 return true; | 975 return true; |
| 967 } | 976 } |
| 968 | 977 |
| 969 | 978 |
| 970 bool LoadIC::PatchInlinedContextualLoad(Address address, | 979 bool LoadIC::PatchInlinedContextualLoad(Address address, |
| 971 Object* map, | 980 Object* map, |
| 972 Object* cell, | 981 Object* cell, |
| 973 bool is_dont_delete) { | 982 bool is_dont_delete) { |
| 974 // TODO(<bug#>): implement this. | 983 // Find the end of the inlined code for handling the contextual load if |
| 975 return false; | 984 // this is inlined IC call site. |
| 985 Address inline_end_address; |
| 986 int marker = InlinedICSiteMarker(address, &inline_end_address); |
| 987 if (!((marker == Assembler::PROPERTY_ACCESS_INLINED_CONTEXT) || |
| 988 (marker == Assembler::PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE))) { |
| 989 return false; |
| 990 } |
| 991 // On ARM we don't rely on the is_dont_delete argument as the hint is already |
| 992 // embedded in the code marker. |
| 993 bool marker_is_dont_delete = |
| 994 marker == Assembler::PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE; |
| 995 |
| 996 // These are the offsets from the end of the inlined code. |
| 997 // See codgen-arm.cc CodeGenerator::EmitNamedLoad. |
| 998 int ldr_map_offset = marker_is_dont_delete ? -5: -8; |
| 999 int ldr_cell_offset = marker_is_dont_delete ? -2: -5; |
| 1000 if (FLAG_debug_code && marker_is_dont_delete) { |
| 1001 // Three extra instructions were generated to check for the_hole_value. |
| 1002 ldr_map_offset -= 3; |
| 1003 ldr_cell_offset -= 3; |
| 1004 } |
| 1005 Address ldr_map_instr_address = |
| 1006 inline_end_address + ldr_map_offset * Assembler::kInstrSize; |
| 1007 Address ldr_cell_instr_address = |
| 1008 inline_end_address + ldr_cell_offset * Assembler::kInstrSize; |
| 1009 |
| 1010 // Patch the map check. |
| 1011 Assembler::set_target_address_at(ldr_map_instr_address, |
| 1012 reinterpret_cast<Address>(map)); |
| 1013 // Patch the cell address. |
| 1014 Assembler::set_target_address_at(ldr_cell_instr_address, |
| 1015 reinterpret_cast<Address>(cell)); |
| 1016 |
| 1017 return true; |
| 976 } | 1018 } |
| 977 | 1019 |
| 978 | 1020 |
| 979 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { | 1021 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { |
| 980 // Find the end of the inlined code for the store if there is an | 1022 // Find the end of the inlined code for the store if there is an |
| 981 // inlined version of the store. | 1023 // inlined version of the store. |
| 982 Address inline_end_address; | 1024 Address inline_end_address; |
| 983 if (!IsInlinedICSite(address, &inline_end_address)) return false; | 1025 if (InlinedICSiteMarker(address, &inline_end_address) |
| 1026 != Assembler::PROPERTY_ACCESS_INLINED) { |
| 1027 return false; |
| 1028 } |
| 984 | 1029 |
| 985 // Compute the address of the map load instruction. | 1030 // Compute the address of the map load instruction. |
| 986 Address ldr_map_instr_address = | 1031 Address ldr_map_instr_address = |
| 987 inline_end_address - | 1032 inline_end_address - |
| 988 (CodeGenerator::GetInlinedNamedStoreInstructionsAfterPatch() * | 1033 (CodeGenerator::GetInlinedNamedStoreInstructionsAfterPatch() * |
| 989 Assembler::kInstrSize); | 1034 Assembler::kInstrSize); |
| 990 | 1035 |
| 991 // Update the offsets if initializing the inlined store. No reason | 1036 // Update the offsets if initializing the inlined store. No reason |
| 992 // to update the offsets when clearing the inlined version because | 1037 // to update the offsets when clearing the inlined version because |
| 993 // it will bail out in the map check. | 1038 // it will bail out in the map check. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1018 // Patch the map check. | 1063 // Patch the map check. |
| 1019 Assembler::set_target_address_at(ldr_map_instr_address, | 1064 Assembler::set_target_address_at(ldr_map_instr_address, |
| 1020 reinterpret_cast<Address>(map)); | 1065 reinterpret_cast<Address>(map)); |
| 1021 | 1066 |
| 1022 return true; | 1067 return true; |
| 1023 } | 1068 } |
| 1024 | 1069 |
| 1025 | 1070 |
| 1026 bool KeyedLoadIC::PatchInlinedLoad(Address address, Object* map) { | 1071 bool KeyedLoadIC::PatchInlinedLoad(Address address, Object* map) { |
| 1027 Address inline_end_address; | 1072 Address inline_end_address; |
| 1028 if (!IsInlinedICSite(address, &inline_end_address)) return false; | 1073 if (InlinedICSiteMarker(address, &inline_end_address) |
| 1074 != Assembler::PROPERTY_ACCESS_INLINED) { |
| 1075 return false; |
| 1076 } |
| 1029 | 1077 |
| 1030 // Patch the map check. | 1078 // Patch the map check. |
| 1031 Address ldr_map_instr_address = | 1079 Address ldr_map_instr_address = |
| 1032 inline_end_address - | 1080 inline_end_address - |
| 1033 (CodeGenerator::GetInlinedKeyedLoadInstructionsAfterPatch() * | 1081 (CodeGenerator::GetInlinedKeyedLoadInstructionsAfterPatch() * |
| 1034 Assembler::kInstrSize); | 1082 Assembler::kInstrSize); |
| 1035 Assembler::set_target_address_at(ldr_map_instr_address, | 1083 Assembler::set_target_address_at(ldr_map_instr_address, |
| 1036 reinterpret_cast<Address>(map)); | 1084 reinterpret_cast<Address>(map)); |
| 1037 return true; | 1085 return true; |
| 1038 } | 1086 } |
| 1039 | 1087 |
| 1040 | 1088 |
| 1041 bool KeyedStoreIC::PatchInlinedStore(Address address, Object* map) { | 1089 bool KeyedStoreIC::PatchInlinedStore(Address address, Object* map) { |
| 1042 // Find the end of the inlined code for handling the store if this is an | 1090 // Find the end of the inlined code for handling the store if this is an |
| 1043 // inlined IC call site. | 1091 // inlined IC call site. |
| 1044 Address inline_end_address; | 1092 Address inline_end_address; |
| 1045 if (!IsInlinedICSite(address, &inline_end_address)) return false; | 1093 if (InlinedICSiteMarker(address, &inline_end_address) |
| 1094 != Assembler::PROPERTY_ACCESS_INLINED) { |
| 1095 return false; |
| 1096 } |
| 1046 | 1097 |
| 1047 // Patch the map check. | 1098 // Patch the map check. |
| 1048 Address ldr_map_instr_address = | 1099 Address ldr_map_instr_address = |
| 1049 inline_end_address - | 1100 inline_end_address - |
| 1050 (CodeGenerator::kInlinedKeyedStoreInstructionsAfterPatch * | 1101 (CodeGenerator::kInlinedKeyedStoreInstructionsAfterPatch * |
| 1051 Assembler::kInstrSize); | 1102 Assembler::kInstrSize); |
| 1052 Assembler::set_target_address_at(ldr_map_instr_address, | 1103 Assembler::set_target_address_at(ldr_map_instr_address, |
| 1053 reinterpret_cast<Address>(map)); | 1104 reinterpret_cast<Address>(map)); |
| 1054 return true; | 1105 return true; |
| 1055 } | 1106 } |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2255 GenerateMiss(masm); | 2306 GenerateMiss(masm); |
| 2256 } | 2307 } |
| 2257 | 2308 |
| 2258 | 2309 |
| 2259 #undef __ | 2310 #undef __ |
| 2260 | 2311 |
| 2261 | 2312 |
| 2262 } } // namespace v8::internal | 2313 } } // namespace v8::internal |
| 2263 | 2314 |
| 2264 #endif // V8_TARGET_ARCH_ARM | 2315 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |