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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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 4044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4055 } | 4055 } |
4056 | 4056 |
4057 #undef __ | 4057 #undef __ |
4058 | 4058 |
4059 | 4059 |
4060 void BackEdgeTable::PatchAt(Code* unoptimized_code, | 4060 void BackEdgeTable::PatchAt(Code* unoptimized_code, |
4061 Address pc, | 4061 Address pc, |
4062 BackEdgeState target_state, | 4062 BackEdgeState target_state, |
4063 Code* replacement_code) { | 4063 Code* replacement_code) { |
4064 static const int kInstrSize = Assembler::kInstrSize; | 4064 static const int kInstrSize = Assembler::kInstrSize; |
4065 Address branch_address = pc - 8 * kInstrSize; | 4065 Address pc_immediate_load_address = |
| 4066 Assembler::target_address_from_return_address(pc); |
| 4067 Address branch_address = pc_immediate_load_address - 2 * kInstrSize; |
4066 Isolate* isolate = unoptimized_code->GetIsolate(); | 4068 Isolate* isolate = unoptimized_code->GetIsolate(); |
4067 CodePatcher patcher(isolate, branch_address, 1); | 4069 CodePatcher patcher(isolate, branch_address, 1); |
4068 | 4070 |
4069 switch (target_state) { | 4071 switch (target_state) { |
4070 case INTERRUPT: | 4072 case INTERRUPT: |
4071 // slt at, a3, zero_reg (in case of count based interrupts) | 4073 // slt at, a3, zero_reg (in case of count based interrupts) |
4072 // beq at, zero_reg, ok | 4074 // beq at, zero_reg, ok |
4073 // lui t9, <interrupt stub address> upper | 4075 // lui t9, <interrupt stub address> upper |
4074 // ori t9, <interrupt stub address> u-middle | 4076 // ori t9, <interrupt stub address> u-middle |
4075 // dsll t9, t9, 16 | 4077 // dsll t9, t9, 16 |
4076 // ori t9, <interrupt stub address> lower | 4078 // ori t9, <interrupt stub address> lower |
4077 // jalr t9 | 4079 // jalr t9 |
4078 // nop | 4080 // nop |
4079 // ok-label ----- pc_after points here | 4081 // ok-label ----- pc_after points here |
4080 patcher.masm()->slt(at, a3, zero_reg); | 4082 patcher.masm()->slt(at, a3, zero_reg); |
4081 break; | 4083 break; |
4082 case ON_STACK_REPLACEMENT: | 4084 case ON_STACK_REPLACEMENT: |
4083 // addiu at, zero_reg, 1 | 4085 // addiu at, zero_reg, 1 |
4084 // beq at, zero_reg, ok ;; Not changed | 4086 // beq at, zero_reg, ok ;; Not changed |
4085 // lui t9, <on-stack replacement address> upper | 4087 // lui t9, <on-stack replacement address> upper |
4086 // ori t9, <on-stack replacement address> middle | 4088 // ori t9, <on-stack replacement address> middle |
4087 // dsll t9, t9, 16 | 4089 // dsll t9, t9, 16 |
4088 // ori t9, <on-stack replacement address> lower | 4090 // ori t9, <on-stack replacement address> lower |
4089 // jalr t9 ;; Not changed | 4091 // jalr t9 ;; Not changed |
4090 // nop ;; Not changed | 4092 // nop ;; Not changed |
4091 // ok-label ----- pc_after points here | 4093 // ok-label ----- pc_after points here |
4092 patcher.masm()->daddiu(at, zero_reg, 1); | 4094 patcher.masm()->daddiu(at, zero_reg, 1); |
4093 break; | 4095 break; |
4094 } | 4096 } |
4095 Address pc_immediate_load_address = pc - 6 * kInstrSize; | |
4096 // Replace the stack check address in the load-immediate (6-instr sequence) | 4097 // Replace the stack check address in the load-immediate (6-instr sequence) |
4097 // with the entry address of the replacement code. | 4098 // with the entry address of the replacement code. |
4098 Assembler::set_target_address_at(isolate, pc_immediate_load_address, | 4099 Assembler::set_target_address_at(isolate, pc_immediate_load_address, |
4099 replacement_code->entry()); | 4100 replacement_code->entry()); |
4100 | 4101 |
4101 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 4102 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
4102 unoptimized_code, pc_immediate_load_address, replacement_code); | 4103 unoptimized_code, pc_immediate_load_address, replacement_code); |
4103 } | 4104 } |
4104 | 4105 |
4105 | 4106 |
4106 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( | 4107 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( |
4107 Isolate* isolate, | 4108 Isolate* isolate, |
4108 Code* unoptimized_code, | 4109 Code* unoptimized_code, |
4109 Address pc) { | 4110 Address pc) { |
4110 static const int kInstrSize = Assembler::kInstrSize; | 4111 static const int kInstrSize = Assembler::kInstrSize; |
4111 Address branch_address = pc - 8 * kInstrSize; | 4112 Address pc_immediate_load_address = |
4112 #ifdef DEBUG | 4113 Assembler::target_address_from_return_address(pc); |
4113 Address pc_immediate_load_address = pc - 6 * kInstrSize; | 4114 Address branch_address = pc_immediate_load_address - 2 * kInstrSize; |
4114 #endif | |
4115 | 4115 |
4116 DCHECK(Assembler::IsBeq(Assembler::instr_at(pc - 7 * kInstrSize))); | 4116 DCHECK(Assembler::IsBeq(Assembler::instr_at(branch_address + kInstrSize))); |
4117 if (!Assembler::IsAddImmediate(Assembler::instr_at(branch_address))) { | 4117 if (!Assembler::IsAddImmediate(Assembler::instr_at(branch_address))) { |
4118 DCHECK(reinterpret_cast<uint64_t>( | 4118 DCHECK(reinterpret_cast<uint64_t>( |
4119 Assembler::target_address_at(pc_immediate_load_address)) == | 4119 Assembler::target_address_at(pc_immediate_load_address)) == |
4120 reinterpret_cast<uint64_t>( | 4120 reinterpret_cast<uint64_t>( |
4121 isolate->builtins()->InterruptCheck()->entry())); | 4121 isolate->builtins()->InterruptCheck()->entry())); |
4122 return INTERRUPT; | 4122 return INTERRUPT; |
4123 } | 4123 } |
4124 | 4124 |
4125 DCHECK(Assembler::IsAddImmediate(Assembler::instr_at(branch_address))); | 4125 DCHECK(Assembler::IsAddImmediate(Assembler::instr_at(branch_address))); |
4126 | 4126 |
4127 DCHECK(reinterpret_cast<uint64_t>( | 4127 DCHECK(reinterpret_cast<uint64_t>( |
4128 Assembler::target_address_at(pc_immediate_load_address)) == | 4128 Assembler::target_address_at(pc_immediate_load_address)) == |
4129 reinterpret_cast<uint64_t>( | 4129 reinterpret_cast<uint64_t>( |
4130 isolate->builtins()->OnStackReplacement()->entry())); | 4130 isolate->builtins()->OnStackReplacement()->entry())); |
4131 return ON_STACK_REPLACEMENT; | 4131 return ON_STACK_REPLACEMENT; |
4132 } | 4132 } |
4133 | 4133 |
4134 | 4134 |
4135 } // namespace internal | 4135 } // namespace internal |
4136 } // namespace v8 | 4136 } // namespace v8 |
4137 | 4137 |
4138 #endif // V8_TARGET_ARCH_MIPS64 | 4138 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |