OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
8 // | 8 // |
9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
(...skipping 4040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4051 } | 4051 } |
4052 | 4052 |
4053 #undef __ | 4053 #undef __ |
4054 | 4054 |
4055 | 4055 |
4056 void BackEdgeTable::PatchAt(Code* unoptimized_code, | 4056 void BackEdgeTable::PatchAt(Code* unoptimized_code, |
4057 Address pc, | 4057 Address pc, |
4058 BackEdgeState target_state, | 4058 BackEdgeState target_state, |
4059 Code* replacement_code) { | 4059 Code* replacement_code) { |
4060 static const int kInstrSize = Assembler::kInstrSize; | 4060 static const int kInstrSize = Assembler::kInstrSize; |
4061 Address branch_address = pc - 6 * kInstrSize; | 4061 Address pc_immediate_load_address = |
| 4062 Assembler::target_address_from_return_address(pc); |
| 4063 Address branch_address = pc_immediate_load_address - 2 * kInstrSize; |
4062 Isolate* isolate = unoptimized_code->GetIsolate(); | 4064 Isolate* isolate = unoptimized_code->GetIsolate(); |
4063 CodePatcher patcher(isolate, branch_address, 1); | 4065 CodePatcher patcher(isolate, branch_address, 1); |
4064 | 4066 |
4065 switch (target_state) { | 4067 switch (target_state) { |
4066 case INTERRUPT: | 4068 case INTERRUPT: |
4067 // slt at, a3, zero_reg (in case of count based interrupts) | 4069 // slt at, a3, zero_reg (in case of count based interrupts) |
4068 // beq at, zero_reg, ok | 4070 // beq at, zero_reg, ok |
4069 // lui t9, <interrupt stub address> upper | 4071 // lui t9, <interrupt stub address> upper |
4070 // ori t9, <interrupt stub address> lower | 4072 // ori t9, <interrupt stub address> lower |
4071 // jalr t9 | 4073 // jalr t9 |
4072 // nop | 4074 // nop |
4073 // ok-label ----- pc_after points here | 4075 // ok-label ----- pc_after points here |
4074 patcher.masm()->slt(at, a3, zero_reg); | 4076 patcher.masm()->slt(at, a3, zero_reg); |
4075 break; | 4077 break; |
4076 case ON_STACK_REPLACEMENT: | 4078 case ON_STACK_REPLACEMENT: |
4077 // addiu at, zero_reg, 1 | 4079 // addiu at, zero_reg, 1 |
4078 // beq at, zero_reg, ok ;; Not changed | 4080 // beq at, zero_reg, ok ;; Not changed |
4079 // lui t9, <on-stack replacement address> upper | 4081 // lui t9, <on-stack replacement address> upper |
4080 // ori t9, <on-stack replacement address> lower | 4082 // ori t9, <on-stack replacement address> lower |
4081 // jalr t9 ;; Not changed | 4083 // jalr t9 ;; Not changed |
4082 // nop ;; Not changed | 4084 // nop ;; Not changed |
4083 // ok-label ----- pc_after points here | 4085 // ok-label ----- pc_after points here |
4084 patcher.masm()->addiu(at, zero_reg, 1); | 4086 patcher.masm()->addiu(at, zero_reg, 1); |
4085 break; | 4087 break; |
4086 } | 4088 } |
4087 Address pc_immediate_load_address = pc - 4 * kInstrSize; | |
4088 // Replace the stack check address in the load-immediate (lui/ori pair) | 4089 // Replace the stack check address in the load-immediate (lui/ori pair) |
4089 // with the entry address of the replacement code. | 4090 // with the entry address of the replacement code. |
4090 Assembler::set_target_address_at(isolate, pc_immediate_load_address, | 4091 Assembler::set_target_address_at(isolate, pc_immediate_load_address, |
4091 replacement_code->entry()); | 4092 replacement_code->entry()); |
4092 | 4093 |
4093 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 4094 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
4094 unoptimized_code, pc_immediate_load_address, replacement_code); | 4095 unoptimized_code, pc_immediate_load_address, replacement_code); |
4095 } | 4096 } |
4096 | 4097 |
4097 | 4098 |
4098 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( | 4099 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( |
4099 Isolate* isolate, | 4100 Isolate* isolate, |
4100 Code* unoptimized_code, | 4101 Code* unoptimized_code, |
4101 Address pc) { | 4102 Address pc) { |
4102 static const int kInstrSize = Assembler::kInstrSize; | 4103 static const int kInstrSize = Assembler::kInstrSize; |
4103 Address branch_address = pc - 6 * kInstrSize; | 4104 Address pc_immediate_load_address = |
4104 #ifdef DEBUG | 4105 Assembler::target_address_from_return_address(pc); |
4105 Address pc_immediate_load_address = pc - 4 * kInstrSize; | 4106 Address branch_address = pc_immediate_load_address - 2 * kInstrSize; |
4106 #endif | |
4107 | 4107 |
4108 DCHECK(Assembler::IsBeq(Assembler::instr_at(pc - 5 * kInstrSize))); | 4108 DCHECK(Assembler::IsBeq(Assembler::instr_at(branch_address + kInstrSize))); |
4109 if (!Assembler::IsAddImmediate(Assembler::instr_at(branch_address))) { | 4109 if (!Assembler::IsAddImmediate(Assembler::instr_at(branch_address))) { |
4110 DCHECK(reinterpret_cast<uint32_t>( | 4110 DCHECK(reinterpret_cast<uint32_t>( |
4111 Assembler::target_address_at(pc_immediate_load_address)) == | 4111 Assembler::target_address_at(pc_immediate_load_address)) == |
4112 reinterpret_cast<uint32_t>( | 4112 reinterpret_cast<uint32_t>( |
4113 isolate->builtins()->InterruptCheck()->entry())); | 4113 isolate->builtins()->InterruptCheck()->entry())); |
4114 return INTERRUPT; | 4114 return INTERRUPT; |
4115 } | 4115 } |
4116 | 4116 |
4117 DCHECK(Assembler::IsAddImmediate(Assembler::instr_at(branch_address))); | 4117 DCHECK(Assembler::IsAddImmediate(Assembler::instr_at(branch_address))); |
4118 | 4118 |
4119 DCHECK(reinterpret_cast<uint32_t>( | 4119 DCHECK(reinterpret_cast<uint32_t>( |
4120 Assembler::target_address_at(pc_immediate_load_address)) == | 4120 Assembler::target_address_at(pc_immediate_load_address)) == |
4121 reinterpret_cast<uint32_t>( | 4121 reinterpret_cast<uint32_t>( |
4122 isolate->builtins()->OnStackReplacement()->entry())); | 4122 isolate->builtins()->OnStackReplacement()->entry())); |
4123 return ON_STACK_REPLACEMENT; | 4123 return ON_STACK_REPLACEMENT; |
4124 } | 4124 } |
4125 | 4125 |
4126 | 4126 |
4127 } // namespace internal | 4127 } // namespace internal |
4128 } // namespace v8 | 4128 } // namespace v8 |
4129 | 4129 |
4130 #endif // V8_TARGET_ARCH_MIPS | 4130 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |