Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4831 | 4831 |
| 4832 *stack_depth = 0; | 4832 *stack_depth = 0; |
| 4833 *context_length = 0; | 4833 *context_length = 0; |
| 4834 return previous_; | 4834 return previous_; |
| 4835 } | 4835 } |
| 4836 | 4836 |
| 4837 | 4837 |
| 4838 #undef __ | 4838 #undef __ |
| 4839 | 4839 |
| 4840 | 4840 |
| 4841 static const int32_t kBranchBeforeInterrupt = 0x5a000004; | 4841 static Address GetInterruptImmediateLoadAddress(Address pc) { |
| 4842 Address immediate_load_address = pc - 2 * Assembler::kInstrSize; | |
| 4843 if (FLAG_enable_ool_constant_pool && | |
| 4844 Assembler::IsMovT(Memory::int32_at(immediate_load_address))) { | |
|
Rodolph Perfetta (ARM)
2014/03/10 16:19:59
Is there a case where ool is enable and we don't h
rmcilroy
2014/03/11 19:05:53
Yes, the possibilities are:
existing inline const
| |
| 4845 immediate_load_address -= Assembler::kInstrSize; | |
| 4846 } | |
| 4847 return immediate_load_address; | |
| 4848 } | |
| 4842 | 4849 |
| 4843 | 4850 |
| 4844 void BackEdgeTable::PatchAt(Code* unoptimized_code, | 4851 void BackEdgeTable::PatchAt(Code* unoptimized_code, |
| 4845 Address pc, | 4852 Address pc, |
| 4846 BackEdgeState target_state, | 4853 BackEdgeState target_state, |
| 4847 Code* replacement_code) { | 4854 Code* replacement_code) { |
| 4848 static const int kInstrSize = Assembler::kInstrSize; | 4855 static const int kInstrSize = Assembler::kInstrSize; |
| 4849 Address branch_address = pc - 3 * kInstrSize; | 4856 Address pc_immediate_load_address = GetInterruptImmediateLoadAddress(pc); |
| 4857 Address branch_address = pc_immediate_load_address - kInstrSize; | |
| 4858 int branch_offset = (2 * kInstrSize) + (pc - pc_immediate_load_address); | |
|
Rodolph Perfetta (ARM)
2014/03/10 16:19:59
Some comments about the 2 * kInstrSize would be ni
rmcilroy
2014/03/11 19:05:53
Done (and reworked the calculation to be more unde
| |
| 4850 CodePatcher patcher(branch_address, 1); | 4859 CodePatcher patcher(branch_address, 1); |
| 4851 | |
| 4852 switch (target_state) { | 4860 switch (target_state) { |
| 4853 case INTERRUPT: | 4861 case INTERRUPT: |
| 4854 // <decrement profiling counter> | 4862 patcher.masm()->b(branch_offset, pl); |
|
Rodolph Perfetta (ARM)
2014/03/10 16:19:59
While I agree the encoding isn't that interesting,
rmcilroy
2014/03/11 19:05:53
Done.
| |
| 4855 // 2a 00 00 01 bpl ok | 4863 ASSERT(Assembler::IsBranch(Assembler::instr_at(branch_address))); |
|
Rodolph Perfetta (ARM)
2014/03/10 16:19:59
This assert check that b(...) will emit a branch,
rmcilroy
2014/03/11 19:05:53
Agreed, not useful. Removed.
| |
| 4856 // e5 9f c? ?? ldr ip, [pc, <interrupt stub address>] | |
| 4857 // e1 2f ff 3c blx ip | |
| 4858 // ok-label | |
| 4859 patcher.masm()->b(4 * kInstrSize, pl); // Jump offset is 4 instructions. | |
| 4860 ASSERT_EQ(kBranchBeforeInterrupt, Memory::int32_at(branch_address)); | |
| 4861 break; | 4864 break; |
| 4862 case ON_STACK_REPLACEMENT: | 4865 case ON_STACK_REPLACEMENT: |
| 4863 case OSR_AFTER_STACK_CHECK: | 4866 case OSR_AFTER_STACK_CHECK: |
| 4864 // <decrement profiling counter> | |
| 4865 // e1 a0 00 00 mov r0, r0 (NOP) | |
| 4866 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>] | |
| 4867 // e1 2f ff 3c blx ip | |
| 4868 // ok-label | |
| 4869 patcher.masm()->nop(); | 4867 patcher.masm()->nop(); |
| 4870 break; | 4868 break; |
| 4871 } | 4869 } |
| 4872 | 4870 |
| 4873 Address pc_immediate_load_address = pc - 2 * kInstrSize; | 4871 Assembler::set_target_address_at(pc_immediate_load_address, unoptimized_code, |
| 4874 // Replace the call address. | 4872 replacement_code->entry()); |
| 4875 uint32_t interrupt_address_offset = | |
| 4876 Memory::uint16_at(pc_immediate_load_address) & 0xfff; | |
| 4877 Address interrupt_address_pointer = pc + interrupt_address_offset; | |
| 4878 Memory::uint32_at(interrupt_address_pointer) = | |
| 4879 reinterpret_cast<uint32_t>(replacement_code->entry()); | |
| 4880 | 4873 |
| 4881 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 4874 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
| 4882 unoptimized_code, pc_immediate_load_address, replacement_code); | 4875 unoptimized_code, pc_immediate_load_address, replacement_code); |
| 4883 } | 4876 } |
| 4884 | 4877 |
| 4885 | 4878 |
| 4886 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( | 4879 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( |
| 4887 Isolate* isolate, | 4880 Isolate* isolate, |
| 4888 Code* unoptimized_code, | 4881 Code* unoptimized_code, |
| 4889 Address pc) { | 4882 Address pc) { |
| 4890 static const int kInstrSize = Assembler::kInstrSize; | 4883 static const int kInstrSize = Assembler::kInstrSize; |
| 4891 ASSERT(Memory::int32_at(pc - kInstrSize) == kBlxIp); | 4884 ASSERT(Memory::int32_at(pc - kInstrSize) == kBlxIp); |
| 4892 | 4885 |
| 4893 Address branch_address = pc - 3 * kInstrSize; | 4886 Address pc_immediate_load_address = GetInterruptImmediateLoadAddress(pc); |
| 4894 Address pc_immediate_load_address = pc - 2 * kInstrSize; | 4887 Address branch_address = pc_immediate_load_address - kInstrSize; |
| 4895 uint32_t interrupt_address_offset = | 4888 Address interrupt_address = Assembler::target_address_at( |
| 4896 Memory::uint16_at(pc_immediate_load_address) & 0xfff; | 4889 pc_immediate_load_address, unoptimized_code); |
| 4897 Address interrupt_address_pointer = pc + interrupt_address_offset; | |
| 4898 | 4890 |
| 4899 if (Memory::int32_at(branch_address) == kBranchBeforeInterrupt) { | 4891 if (Assembler::IsBranch(Assembler::instr_at(branch_address))) { |
| 4900 ASSERT(Memory::uint32_at(interrupt_address_pointer) == | 4892 ASSERT(interrupt_address == |
| 4901 reinterpret_cast<uint32_t>( | 4893 isolate->builtins()->InterruptCheck()->entry()); |
| 4902 isolate->builtins()->InterruptCheck()->entry())); | |
| 4903 ASSERT(Assembler::IsLdrPcImmediateOffset( | |
| 4904 Assembler::instr_at(pc_immediate_load_address))); | |
| 4905 return INTERRUPT; | 4894 return INTERRUPT; |
| 4906 } | 4895 } |
| 4907 | 4896 |
| 4908 ASSERT(Assembler::IsNop(Assembler::instr_at(branch_address))); | 4897 ASSERT(Assembler::IsNop(Assembler::instr_at(branch_address))); |
| 4909 ASSERT(Assembler::IsLdrPcImmediateOffset( | |
| 4910 Assembler::instr_at(pc_immediate_load_address))); | |
| 4911 | 4898 |
| 4912 if (Memory::uint32_at(interrupt_address_pointer) == | 4899 if (interrupt_address == |
| 4913 reinterpret_cast<uint32_t>( | 4900 isolate->builtins()->OnStackReplacement()->entry()) { |
| 4914 isolate->builtins()->OnStackReplacement()->entry())) { | |
| 4915 return ON_STACK_REPLACEMENT; | 4901 return ON_STACK_REPLACEMENT; |
| 4916 } | 4902 } |
| 4917 | 4903 |
| 4918 ASSERT(Memory::uint32_at(interrupt_address_pointer) == | 4904 ASSERT(interrupt_address == |
| 4919 reinterpret_cast<uint32_t>( | 4905 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 4920 isolate->builtins()->OsrAfterStackCheck()->entry())); | |
| 4921 return OSR_AFTER_STACK_CHECK; | 4906 return OSR_AFTER_STACK_CHECK; |
| 4922 } | 4907 } |
| 4923 | 4908 |
| 4924 | 4909 |
| 4925 } } // namespace v8::internal | 4910 } } // namespace v8::internal |
| 4926 | 4911 |
| 4927 #endif // V8_TARGET_ARCH_ARM | 4912 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |