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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 Address Assembler::target_address_from_return_address(Address pc) { | 193 Address Assembler::target_address_from_return_address(Address pc) { |
194 return pc - kCallTargetAddressOffset; | 194 return pc - kCallTargetAddressOffset; |
195 } | 195 } |
196 | 196 |
197 | 197 |
198 Address Assembler::break_address_from_return_address(Address pc) { | 198 Address Assembler::break_address_from_return_address(Address pc) { |
199 return pc - Assembler::kPatchDebugBreakSlotReturnOffset; | 199 return pc - Assembler::kPatchDebugBreakSlotReturnOffset; |
200 } | 200 } |
201 | 201 |
202 | 202 |
203 void Assembler::deserialization_set_target_internal_reference_at( | |
204 Address pc, Address target) { | |
205 if (IsLui(instr_at(pc))) { | |
paul.l...
2015/03/18 20:57:07
This is not correct, we need rmode here to differe
| |
206 // Encoded internal references are lui/ori load of 32-bit abolute address. | |
207 Instr instr_lui = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); | |
208 Instr instr_ori = Assembler::instr_at(pc + 1 * Assembler::kInstrSize); | |
209 DCHECK(Assembler::IsLui(instr_lui)); | |
210 DCHECK(Assembler::IsOri(instr_ori)); | |
211 instr_lui &= ~kImm16Mask; | |
212 instr_ori &= ~kImm16Mask; | |
213 int32_t imm = reinterpret_cast<int32_t>(target); | |
214 DCHECK((imm & 3) == 0); | |
215 Assembler::instr_at_put(pc + 0 * Assembler::kInstrSize, | |
216 instr_lui | ((imm >> kLuiShift) & kImm16Mask)); | |
217 Assembler::instr_at_put(pc + 1 * Assembler::kInstrSize, | |
218 instr_ori | (imm & kImm16Mask)); | |
219 } else { | |
220 Memory::Address_at(pc) = target; | |
221 } | |
222 } | |
223 | |
224 | |
203 Object* RelocInfo::target_object() { | 225 Object* RelocInfo::target_object() { |
204 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 226 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
205 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_)); | 227 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_)); |
206 } | 228 } |
207 | 229 |
208 | 230 |
209 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { | 231 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) { |
210 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 232 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
211 return Handle<Object>(reinterpret_cast<Object**>( | 233 return Handle<Object>(reinterpret_cast<Object**>( |
212 Assembler::target_address_at(pc_, host_))); | 234 Assembler::target_address_at(pc_, host_))); |
(...skipping 19 matching lines...) Expand all Loading... | |
232 Address RelocInfo::target_external_reference() { | 254 Address RelocInfo::target_external_reference() { |
233 DCHECK(rmode_ == EXTERNAL_REFERENCE); | 255 DCHECK(rmode_ == EXTERNAL_REFERENCE); |
234 return Assembler::target_address_at(pc_, host_); | 256 return Assembler::target_address_at(pc_, host_); |
235 } | 257 } |
236 | 258 |
237 | 259 |
238 Address RelocInfo::target_internal_reference() { | 260 Address RelocInfo::target_internal_reference() { |
239 if (rmode_ == INTERNAL_REFERENCE) { | 261 if (rmode_ == INTERNAL_REFERENCE) { |
240 return Memory::Address_at(pc_); | 262 return Memory::Address_at(pc_); |
241 } else { | 263 } else { |
264 // Encoded internal references are lui/ori load of 32-bit abolute address. | |
242 DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); | 265 DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); |
243 Instr instr_lui = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize); | 266 Instr instr_lui = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize); |
244 Instr instr_ori = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); | 267 Instr instr_ori = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); |
245 DCHECK(Assembler::IsLui(instr_lui)); | 268 DCHECK(Assembler::IsLui(instr_lui)); |
246 DCHECK(Assembler::IsOri(instr_ori)); | 269 DCHECK(Assembler::IsOri(instr_ori)); |
247 int32_t imm = (instr_lui & static_cast<int32_t>(kImm16Mask)) << kLuiShift; | 270 int32_t imm = (instr_lui & static_cast<int32_t>(kImm16Mask)) << kLuiShift; |
248 imm |= (instr_ori & static_cast<int32_t>(kImm16Mask)); | 271 imm |= (instr_ori & static_cast<int32_t>(kImm16Mask)); |
249 return reinterpret_cast<Address>(imm); | 272 return reinterpret_cast<Address>(imm); |
250 } | 273 } |
251 } | 274 } |
252 | 275 |
253 | 276 |
254 void RelocInfo::set_target_internal_reference(Address target) { | 277 Address RelocInfo::target_internal_reference_address() { |
255 if (rmode_ == INTERNAL_REFERENCE) { | 278 DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); |
256 Memory::Address_at(pc_) = target; | 279 return reinterpret_cast<Address>(pc_); |
257 } else { | |
258 // Encoded internal references are lui/ori load of 32-bit abolute address. | |
259 DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); | |
260 Instr instr_lui = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize); | |
261 Instr instr_ori = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); | |
262 DCHECK(Assembler::IsLui(instr_lui)); | |
263 DCHECK(Assembler::IsOri(instr_ori)); | |
264 instr_lui &= ~kImm16Mask; | |
265 instr_ori &= ~kImm16Mask; | |
266 int32_t imm = reinterpret_cast<int32_t>(target); | |
267 DCHECK((imm & 3) == 0); | |
268 Assembler::instr_at_put(pc_ + 0 * Assembler::kInstrSize, | |
269 instr_lui | ((imm >> kLuiShift) & kImm16Mask)); | |
270 Assembler::instr_at_put(pc_ + 1 * Assembler::kInstrSize, | |
271 instr_ori | (imm & kImm16Mask)); | |
272 // Currently used only by deserializer, and all code will be flushed | |
273 // after complete deserialization, no need to flush on each reference. | |
274 } | |
275 } | 280 } |
276 | 281 |
277 | 282 |
278 Address RelocInfo::target_runtime_entry(Assembler* origin) { | 283 Address RelocInfo::target_runtime_entry(Assembler* origin) { |
279 DCHECK(IsRuntimeEntry(rmode_)); | 284 DCHECK(IsRuntimeEntry(rmode_)); |
280 return target_address(); | 285 return target_address(); |
281 } | 286 } |
282 | 287 |
283 | 288 |
284 void RelocInfo::set_target_runtime_entry(Address target, | 289 void RelocInfo::set_target_runtime_entry(Address target, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); | 384 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); |
380 } | 385 } |
381 | 386 |
382 | 387 |
383 void RelocInfo::set_call_object(Object* target) { | 388 void RelocInfo::set_call_object(Object* target) { |
384 *call_object_address() = target; | 389 *call_object_address() = target; |
385 } | 390 } |
386 | 391 |
387 | 392 |
388 void RelocInfo::WipeOut() { | 393 void RelocInfo::WipeOut() { |
389 DCHECK(IsEmbeddedObject(rmode_) || | 394 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || |
390 IsCodeTarget(rmode_) || | 395 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || |
391 IsRuntimeEntry(rmode_) || | 396 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); |
392 IsExternalReference(rmode_)); | 397 if (IsInternalReference(rmode_)) { |
393 Assembler::set_target_address_at(pc_, host_, NULL); | 398 Memory::Address_at(pc_) = NULL; |
399 } else if (IsInternalReferenceEncoded(rmode_)) { | |
400 Instr instr_lui = Assembler::instr_at(pc_ + 0 * Assembler::kInstrSize); | |
401 Instr instr_ori = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); | |
402 DCHECK(Assembler::IsLui(instr_lui)); | |
403 DCHECK(Assembler::IsOri(instr_ori)); | |
404 instr_lui &= ~kImm16Mask; | |
405 instr_ori &= ~kImm16Mask; | |
406 int32_t imm = 0; | |
407 Assembler::instr_at_put(pc_ + 0 * Assembler::kInstrSize, | |
408 instr_lui | ((imm >> kLuiShift) & kImm16Mask)); | |
409 Assembler::instr_at_put(pc_ + 1 * Assembler::kInstrSize, | |
410 instr_ori | (imm & kImm16Mask)); | |
411 // Currently used only by deserializer, and all code will be flushed | |
412 // after complete deserialization, no need to flush on each reference. | |
413 } else { | |
414 Assembler::set_target_address_at(pc_, host_, NULL); | |
415 } | |
394 } | 416 } |
395 | 417 |
396 | 418 |
397 bool RelocInfo::IsPatchedReturnSequence() { | 419 bool RelocInfo::IsPatchedReturnSequence() { |
398 Instr instr0 = Assembler::instr_at(pc_); | 420 Instr instr0 = Assembler::instr_at(pc_); |
399 Instr instr1 = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); | 421 Instr instr1 = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize); |
400 Instr instr2 = Assembler::instr_at(pc_ + 2 * Assembler::kInstrSize); | 422 Instr instr2 = Assembler::instr_at(pc_ + 2 * Assembler::kInstrSize); |
401 bool patched_return = ((instr0 & kOpcodeMask) == LUI && | 423 bool patched_return = ((instr0 & kOpcodeMask) == LUI && |
402 (instr1 & kOpcodeMask) == ORI && | 424 (instr1 & kOpcodeMask) == ORI && |
403 ((instr2 & kOpcodeMask) == JAL || | 425 ((instr2 & kOpcodeMask) == JAL || |
(...skipping 12 matching lines...) Expand all Loading... | |
416 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { | 438 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { |
417 RelocInfo::Mode mode = rmode(); | 439 RelocInfo::Mode mode = rmode(); |
418 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 440 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
419 visitor->VisitEmbeddedPointer(this); | 441 visitor->VisitEmbeddedPointer(this); |
420 } else if (RelocInfo::IsCodeTarget(mode)) { | 442 } else if (RelocInfo::IsCodeTarget(mode)) { |
421 visitor->VisitCodeTarget(this); | 443 visitor->VisitCodeTarget(this); |
422 } else if (mode == RelocInfo::CELL) { | 444 } else if (mode == RelocInfo::CELL) { |
423 visitor->VisitCell(this); | 445 visitor->VisitCell(this); |
424 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 446 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
425 visitor->VisitExternalReference(this); | 447 visitor->VisitExternalReference(this); |
448 } else if (mode == RelocInfo::INTERNAL_REFERENCE || | |
449 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { | |
450 visitor->VisitInternalReference(this); | |
426 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 451 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
427 visitor->VisitCodeAgeSequence(this); | 452 visitor->VisitCodeAgeSequence(this); |
428 } else if (((RelocInfo::IsJSReturn(mode) && | 453 } else if (((RelocInfo::IsJSReturn(mode) && |
429 IsPatchedReturnSequence()) || | 454 IsPatchedReturnSequence()) || |
430 (RelocInfo::IsDebugBreakSlot(mode) && | 455 (RelocInfo::IsDebugBreakSlot(mode) && |
431 IsPatchedDebugBreakSlotSequence())) && | 456 IsPatchedDebugBreakSlotSequence())) && |
432 isolate->debug()->has_break_points()) { | 457 isolate->debug()->has_break_points()) { |
433 visitor->VisitDebugTarget(this); | 458 visitor->VisitDebugTarget(this); |
434 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 459 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
435 visitor->VisitRuntimeEntry(this); | 460 visitor->VisitRuntimeEntry(this); |
436 } | 461 } |
437 } | 462 } |
438 | 463 |
439 | 464 |
440 template<typename StaticVisitor> | 465 template<typename StaticVisitor> |
441 void RelocInfo::Visit(Heap* heap) { | 466 void RelocInfo::Visit(Heap* heap) { |
442 RelocInfo::Mode mode = rmode(); | 467 RelocInfo::Mode mode = rmode(); |
443 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 468 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
444 StaticVisitor::VisitEmbeddedPointer(heap, this); | 469 StaticVisitor::VisitEmbeddedPointer(heap, this); |
445 } else if (RelocInfo::IsCodeTarget(mode)) { | 470 } else if (RelocInfo::IsCodeTarget(mode)) { |
446 StaticVisitor::VisitCodeTarget(heap, this); | 471 StaticVisitor::VisitCodeTarget(heap, this); |
447 } else if (mode == RelocInfo::CELL) { | 472 } else if (mode == RelocInfo::CELL) { |
448 StaticVisitor::VisitCell(heap, this); | 473 StaticVisitor::VisitCell(heap, this); |
449 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 474 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
450 StaticVisitor::VisitExternalReference(this); | 475 StaticVisitor::VisitExternalReference(this); |
476 } else if (mode == RelocInfo::INTERNAL_REFERENCE || | |
477 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { | |
478 StaticVisitor::VisitInternalReference(this); | |
451 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 479 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
452 StaticVisitor::VisitCodeAgeSequence(heap, this); | 480 StaticVisitor::VisitCodeAgeSequence(heap, this); |
453 } else if (heap->isolate()->debug()->has_break_points() && | 481 } else if (heap->isolate()->debug()->has_break_points() && |
454 ((RelocInfo::IsJSReturn(mode) && | 482 ((RelocInfo::IsJSReturn(mode) && |
455 IsPatchedReturnSequence()) || | 483 IsPatchedReturnSequence()) || |
456 (RelocInfo::IsDebugBreakSlot(mode) && | 484 (RelocInfo::IsDebugBreakSlot(mode) && |
457 IsPatchedDebugBreakSlotSequence()))) { | 485 IsPatchedDebugBreakSlotSequence()))) { |
458 StaticVisitor::VisitDebugTarget(heap, this); | 486 StaticVisitor::VisitDebugTarget(heap, this); |
459 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 487 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
460 StaticVisitor::VisitRuntimeEntry(this); | 488 StaticVisitor::VisitRuntimeEntry(this); |
(...skipping 25 matching lines...) Expand all Loading... | |
486 } | 514 } |
487 *reinterpret_cast<Instr*>(pc_) = x; | 515 *reinterpret_cast<Instr*>(pc_) = x; |
488 pc_ += kInstrSize; | 516 pc_ += kInstrSize; |
489 CheckTrampolinePoolQuick(); | 517 CheckTrampolinePoolQuick(); |
490 } | 518 } |
491 | 519 |
492 | 520 |
493 } } // namespace v8::internal | 521 } } // namespace v8::internal |
494 | 522 |
495 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ | 523 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
OLD | NEW |