Chromium Code Reviews| 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 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 908 static inline bool IsInlinedICSite(Address address, | 908 static inline bool IsInlinedICSite(Address address, |
| 909 Address* inline_end_address) { | 909 Address* inline_end_address, |
| 910 Assembler::NopMarkerTypes type = | |
|
Søren Thygesen Gjesse
2010/11/19 09:08:47
I think you should loose the default value here.
Alexandre
2010/11/23 11:23:21
Done.
| |
| 911 Assembler::PROPERTY_ACCESS_INLINED) { | |
| 910 // If the instruction after the call site is not the pseudo instruction nop1 | 912 // 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 | 913 // 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 | 914 // 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 | 915 // handling the miss in the inlined code. After the nop1 instruction there is |
| 914 // a branch instruction for jumping back from the deferred code. | 916 // a branch instruction for jumping back from the deferred code. |
| 915 Address address_after_call = address + Assembler::kCallTargetAddressOffset; | 917 Address address_after_call = address + Assembler::kCallTargetAddressOffset; |
| 916 Instr instr_after_call = Assembler::instr_at(address_after_call); | 918 Instr instr_after_call = Assembler::instr_at(address_after_call); |
| 917 if (!Assembler::IsNop(instr_after_call, PROPERTY_ACCESS_INLINED)) { | 919 if (!MacroAssembler::IsMarkedCode(instr_after_call, type)) { |
| 918 return false; | 920 return false; |
| 919 } | 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 true; |
| 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 (!IsInlinedICSite(address, |
| 947 &inline_end_address, | |
| 948 Assembler::PROPERTY_ACCESS_INLINED)) { | |
| 949 return false; | |
| 950 } | |
| 945 | 951 |
| 946 // Patch the offset of the property load instruction (ldr r0, [r1, #+XXX]). | 952 // Patch the offset of the property load instruction (ldr r0, [r1, #+XXX]). |
| 947 // The immediate must be representable in 12 bits. | 953 // The immediate must be representable in 12 bits. |
| 948 ASSERT((JSObject::kMaxInstanceSize - JSObject::kHeaderSize) < (1 << 12)); | 954 ASSERT((JSObject::kMaxInstanceSize - JSObject::kHeaderSize) < (1 << 12)); |
| 949 Address ldr_property_instr_address = | 955 Address ldr_property_instr_address = |
| 950 inline_end_address - Assembler::kInstrSize; | 956 inline_end_address - Assembler::kInstrSize; |
| 951 ASSERT(Assembler::IsLdrRegisterImmediate( | 957 ASSERT(Assembler::IsLdrRegisterImmediate( |
| 952 Assembler::instr_at(ldr_property_instr_address))); | 958 Assembler::instr_at(ldr_property_instr_address))); |
| 953 Instr ldr_property_instr = Assembler::instr_at(ldr_property_instr_address); | 959 Instr ldr_property_instr = Assembler::instr_at(ldr_property_instr_address); |
| 954 ldr_property_instr = Assembler::SetLdrRegisterImmediateOffset( | 960 ldr_property_instr = Assembler::SetLdrRegisterImmediateOffset( |
| 955 ldr_property_instr, offset - kHeapObjectTag); | 961 ldr_property_instr, offset - kHeapObjectTag); |
| 956 Assembler::instr_at_put(ldr_property_instr_address, ldr_property_instr); | 962 Assembler::instr_at_put(ldr_property_instr_address, ldr_property_instr); |
| 957 | 963 |
| 958 // Indicate that code has changed. | 964 // Indicate that code has changed. |
| 959 CPU::FlushICache(ldr_property_instr_address, 1 * Assembler::kInstrSize); | 965 CPU::FlushICache(ldr_property_instr_address, 1 * Assembler::kInstrSize); |
| 960 | 966 |
| 961 // Patch the map check. | 967 // Patch the map check. |
| 968 // For PROPERTY_ACCESS_INLINED, the load map instruction is generated | |
| 969 // 4 instructions before the end of the inlined code. | |
| 970 // See codgen-arm.cc CodeGenerator::EmitNamedLoad. | |
| 971 int ldr_map_offset = -4; | |
| 962 Address ldr_map_instr_address = | 972 Address ldr_map_instr_address = |
| 963 inline_end_address - 4 * Assembler::kInstrSize; | 973 inline_end_address + ldr_map_offset * Assembler::kInstrSize; |
| 964 Assembler::set_target_address_at(ldr_map_instr_address, | 974 Assembler::set_target_address_at(ldr_map_instr_address, |
| 965 reinterpret_cast<Address>(map)); | 975 reinterpret_cast<Address>(map)); |
| 966 return true; | 976 return true; |
| 967 } | 977 } |
| 968 | 978 |
| 969 | 979 |
| 970 bool LoadIC::PatchInlinedContextualLoad(Address address, | 980 bool LoadIC::PatchInlinedContextualLoad(Address address, |
| 971 Object* map, | 981 Object* map, |
| 972 Object* cell, | 982 Object* cell, |
| 973 bool is_dont_delete) { | 983 bool is_dont_delete) { |
| 974 // TODO(<bug#>): implement this. | 984 // Find the end of the inlined code for handling the contextual load if |
| 975 return false; | 985 // this is inlined IC call site. |
| 986 Address inline_end_address; | |
| 987 if (!IsInlinedICSite(address, | |
| 988 &inline_end_address, | |
| 989 Assembler::PROPERTY_ACCESS_INLINED_CONTEXT)) { | |
| 990 return false; | |
| 991 } | |
| 992 | |
| 993 // These are the offsets from the end of the inlined code. | |
| 994 // See codgen-arm.cc CodeGenerator::EmitNamedLoad. | |
| 995 int ldr_map_offset = is_dont_delete ? -5: -8; | |
| 996 int ldr_cell_offset = is_dont_delete ? -2: -5; | |
| 997 if (is_dont_delete && FLAG_debug_code) { | |
| 998 // Three extra instructions were generated to check for the_hole_value. | |
| 999 ldr_map_offset -= 3; | |
| 1000 ldr_cell_offset -= 3; | |
| 1001 } | |
| 1002 Address ldr_map_instr_address = | |
| 1003 inline_end_address + ldr_map_offset * Assembler::kInstrSize; | |
| 1004 Address ldr_cell_instr_address = | |
| 1005 inline_end_address + ldr_cell_offset * Assembler::kInstrSize; | |
| 1006 Instr ldr_map_instr = Memory::int32_at(ldr_map_instr_address); | |
| 1007 Instr ldr_cell_instr = Memory::int32_at(ldr_cell_instr_address); | |
| 1008 | |
| 1009 // LoadIC::ClearInlinedVersion will call PatchInlinedContextualLoad with | |
|
Søren Thygesen Gjesse
2010/11/19 09:08:47
Could you please elaborate a bit here on the diffe
Alexandre
2010/11/23 11:23:21
I refactored the code following your idea to encod
| |
| 1010 // is_dont_delete == true, but we rely on it to compute offsets. This may be | |
| 1011 // the reason we fail here, so retry with is_dont_delete == false. | |
| 1012 if (is_dont_delete && !(Assembler::IsLdrPcImmediateOffset(ldr_map_instr) && | |
| 1013 Assembler::IsLdrPcImmediateOffset(ldr_cell_instr))) { | |
| 1014 is_dont_delete = false; | |
| 1015 // See offsets before when is_dont_delete is false. | |
| 1016 ldr_map_offset = -8; | |
| 1017 ldr_cell_offset = -5; | |
| 1018 // We don't need to check for FLAG_debug_code. It should be handled only | |
| 1019 // when is_dont_delete == true, so it was taken care of before. | |
| 1020 ldr_map_instr_address = | |
| 1021 inline_end_address + ldr_map_offset * Assembler::kInstrSize; | |
| 1022 ldr_cell_instr_address = | |
| 1023 inline_end_address + ldr_cell_offset * Assembler::kInstrSize; | |
| 1024 } | |
| 1025 | |
| 1026 // Patch the map check. | |
| 1027 Assembler::set_target_address_at(ldr_map_instr_address, | |
| 1028 reinterpret_cast<Address>(map)); | |
| 1029 // Patch the cell address. | |
| 1030 Assembler::set_target_address_at(ldr_cell_instr_address, | |
| 1031 reinterpret_cast<Address>(cell)); | |
| 1032 | |
| 1033 return true; | |
| 976 } | 1034 } |
| 977 | 1035 |
| 978 | 1036 |
| 979 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { | 1037 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { |
| 980 // Find the end of the inlined code for the store if there is an | 1038 // Find the end of the inlined code for the store if there is an |
| 981 // inlined version of the store. | 1039 // inlined version of the store. |
| 982 Address inline_end_address; | 1040 Address inline_end_address; |
| 983 if (!IsInlinedICSite(address, &inline_end_address)) return false; | 1041 if (!IsInlinedICSite(address, &inline_end_address)) return false; |
| 984 | 1042 |
| 985 // Compute the address of the map load instruction. | 1043 // Compute the address of the map load instruction. |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 GenerateMiss(masm); | 2313 GenerateMiss(masm); |
| 2256 } | 2314 } |
| 2257 | 2315 |
| 2258 | 2316 |
| 2259 #undef __ | 2317 #undef __ |
| 2260 | 2318 |
| 2261 | 2319 |
| 2262 } } // namespace v8::internal | 2320 } } // namespace v8::internal |
| 2263 | 2321 |
| 2264 #endif // V8_TARGET_ARCH_ARM | 2322 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |