OLD | NEW |
---|---|
1 | 1 |
2 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 2 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
3 // All Rights Reserved. | 3 // All Rights Reserved. |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // - Redistributions of source code must retain the above copyright notice, | 9 // - Redistributions of source code must retain the above copyright notice, |
10 // this list of conditions and the following disclaimer. | 10 // this list of conditions and the following disclaimer. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 Address Assembler::target_address_from_return_address(Address pc) { | 156 Address Assembler::target_address_from_return_address(Address pc) { |
157 return pc - kCallTargetAddressOffset; | 157 return pc - kCallTargetAddressOffset; |
158 } | 158 } |
159 | 159 |
160 | 160 |
161 void Assembler::set_target_internal_reference_encoded_at(Address pc, | 161 void Assembler::set_target_internal_reference_encoded_at(Address pc, |
162 Address target) { | 162 Address target) { |
163 // Encoded internal references are lui/ori load of 32-bit abolute address. | 163 Instr instr1 = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); |
164 Instr instr_lui = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); | 164 Instr instr2 = Assembler::instr_at(pc + 1 * Assembler::kInstrSize); |
165 Instr instr_ori = Assembler::instr_at(pc + 1 * Assembler::kInstrSize); | 165 DCHECK(Assembler::IsLui(instr1)); |
166 DCHECK(Assembler::IsLui(instr_lui)); | 166 DCHECK(Assembler::IsOri(instr2) || Assembler::IsJicOrJialc(instr2)); |
167 DCHECK(Assembler::IsOri(instr_ori)); | 167 instr1 &= ~kImm16Mask; |
168 instr_lui &= ~kImm16Mask; | 168 instr2 &= ~kImm16Mask; |
169 instr_ori &= ~kImm16Mask; | |
170 int32_t imm = reinterpret_cast<int32_t>(target); | 169 int32_t imm = reinterpret_cast<int32_t>(target); |
171 DCHECK((imm & 3) == 0); | 170 DCHECK((imm & 3) == 0); |
172 Assembler::instr_at_put(pc + 0 * Assembler::kInstrSize, | 171 if (Assembler::IsJicOrJialc(instr2)) { |
173 instr_lui | ((imm >> kLuiShift) & kImm16Mask)); | 172 // Encoded internal references are lui/jic load of 32-bit abolute address. |
174 Assembler::instr_at_put(pc + 1 * Assembler::kInstrSize, | 173 uint32_t lui_offsetU, jic_offsetU; |
175 instr_ori | (imm & kImm16Mask)); | 174 Assembler::unpackTargetAddressUnsigned(imm, lui_offsetU, jic_offsetU); |
175 | |
176 Assembler::instr_at_put(pc + 0 * Assembler::kInstrSize, | |
177 instr1 | lui_offsetU); | |
178 Assembler::instr_at_put(pc + 1 * Assembler::kInstrSize, | |
179 instr2 | jic_offsetU); | |
180 } else { | |
181 // Encoded internal references are lui/ori load of 32-bit abolute address. | |
182 Assembler::instr_at_put(pc + 0 * Assembler::kInstrSize, | |
183 instr1 | ((imm >> kLuiShift) & kImm16Mask)); | |
184 Assembler::instr_at_put(pc + 1 * Assembler::kInstrSize, | |
185 instr2 | (imm & kImm16Mask)); | |
186 } | |
176 | 187 |
177 // Currently used only by deserializer, and all code will be flushed | 188 // Currently used only by deserializer, and all code will be flushed |
178 // after complete deserialization, no need to flush on each reference. | 189 // after complete deserialization, no need to flush on each reference. |
179 } | 190 } |
180 | 191 |
181 | 192 |
182 void Assembler::deserialization_set_target_internal_reference_at( | 193 void Assembler::deserialization_set_target_internal_reference_at( |
183 Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { | 194 Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { |
184 if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { | 195 if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { |
185 DCHECK(IsLui(instr_at(pc))); | 196 DCHECK(IsLui(instr_at(pc))); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 Address RelocInfo::target_external_reference() { | 234 Address RelocInfo::target_external_reference() { |
224 DCHECK(rmode_ == EXTERNAL_REFERENCE); | 235 DCHECK(rmode_ == EXTERNAL_REFERENCE); |
225 return Assembler::target_address_at(pc_, host_); | 236 return Assembler::target_address_at(pc_, host_); |
226 } | 237 } |
227 | 238 |
228 | 239 |
229 Address RelocInfo::target_internal_reference() { | 240 Address RelocInfo::target_internal_reference() { |
230 if (rmode_ == INTERNAL_REFERENCE) { | 241 if (rmode_ == INTERNAL_REFERENCE) { |
231 return Memory::Address_at(pc_); | 242 return Memory::Address_at(pc_); |
232 } else { | 243 } else { |
233 // Encoded internal references are lui/ori load of 32-bit abolute address. | 244 // Encoded internal references are lui/ori or lui/jic load of 32-bit abolute |
245 // address. | |
234 DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); | 246 DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); |
235 Instr instr_lui = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize); | 247 Instr instr1 = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize); |
236 Instr instr_ori = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); | 248 Instr instr2 = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); |
237 DCHECK(Assembler::IsLui(instr_lui)); | 249 DCHECK(Assembler::IsLui(instr1)); |
238 DCHECK(Assembler::IsOri(instr_ori)); | 250 DCHECK(Assembler::IsOri(instr2) || Assembler::IsJicOrJialc(instr2)); |
239 int32_t imm = (instr_lui & static_cast<int32_t>(kImm16Mask)) << kLuiShift; | 251 if (Assembler::IsJicOrJialc(instr2)) { |
240 imm |= (instr_ori & static_cast<int32_t>(kImm16Mask)); | 252 return reinterpret_cast<Address>( |
253 Assembler::createTargetAddress(instr1, instr2)); | |
254 } | |
255 int32_t imm = (instr1 & static_cast<int32_t>(kImm16Mask)) << kLuiShift; | |
256 imm |= (instr2 & static_cast<int32_t>(kImm16Mask)); | |
241 return reinterpret_cast<Address>(imm); | 257 return reinterpret_cast<Address>(imm); |
242 } | 258 } |
243 } | 259 } |
244 | 260 |
245 | 261 |
246 Address RelocInfo::target_internal_reference_address() { | 262 Address RelocInfo::target_internal_reference_address() { |
247 DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); | 263 DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); |
248 return reinterpret_cast<Address>(pc_); | 264 return reinterpret_cast<Address>(pc_); |
249 } | 265 } |
250 | 266 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 } else { | 364 } else { |
349 Assembler::set_target_address_at(isolate_, pc_, host_, NULL); | 365 Assembler::set_target_address_at(isolate_, pc_, host_, NULL); |
350 } | 366 } |
351 } | 367 } |
352 | 368 |
353 | 369 |
354 bool RelocInfo::IsPatchedReturnSequence() { | 370 bool RelocInfo::IsPatchedReturnSequence() { |
355 Instr instr0 = Assembler::instr_at(pc_); | 371 Instr instr0 = Assembler::instr_at(pc_); |
356 Instr instr1 = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); | 372 Instr instr1 = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); |
357 Instr instr2 = Assembler::instr_at(pc_ + 2 * Assembler::kInstrSize); | 373 Instr instr2 = Assembler::instr_at(pc_ + 2 * Assembler::kInstrSize); |
358 bool patched_return = ((instr0 & kOpcodeMask) == LUI && | 374 if (Assembler::IsLui(instr0) && Assembler::IsOri(instr1) && |
359 (instr1 & kOpcodeMask) == ORI && | 375 (Assembler::IsJal(instr2) || Assembler::IsJalr(instr2))) { |
paul.l...
2016/01/11 22:34:57
I suspect that 'IsJal(instr2)' is not needed anymo
miran.karic
2016/02/18 08:38:04
Done.
| |
360 ((instr2 & kOpcodeMask) == JAL || | 376 return true; |
361 ((instr2 & kOpcodeMask) == SPECIAL && | 377 } |
362 (instr2 & kFunctionFieldMask) == JALR))); | 378 if (Assembler::IsLui(instr0) && Assembler::IsJicOrJialc(instr1)) { |
363 return patched_return; | 379 return true; |
380 } | |
381 return false; | |
364 } | 382 } |
365 | 383 |
366 | 384 |
367 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { | 385 bool RelocInfo::IsPatchedDebugBreakSlotSequence() { |
368 Instr current_instr = Assembler::instr_at(pc_); | 386 Instr current_instr = Assembler::instr_at(pc_); |
369 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); | 387 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); |
370 } | 388 } |
371 | 389 |
372 | 390 |
373 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { | 391 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 EmittedCompactBranchInstruction(); | 474 EmittedCompactBranchInstruction(); |
457 } | 475 } |
458 CheckTrampolinePoolQuick(); | 476 CheckTrampolinePoolQuick(); |
459 } | 477 } |
460 | 478 |
461 | 479 |
462 } // namespace internal | 480 } // namespace internal |
463 } // namespace v8 | 481 } // namespace v8 |
464 | 482 |
465 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ | 483 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
OLD | NEW |