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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 DCHECK(reg.is_valid()); | 110 DCHECK(reg.is_valid()); |
111 DCHECK(!reg.is(kDoubleRegZero)); | 111 DCHECK(!reg.is(kDoubleRegZero)); |
112 DCHECK(!reg.is(kLithiumScratchDouble)); | 112 DCHECK(!reg.is(kLithiumScratchDouble)); |
113 return (reg.code() / 2); | 113 return (reg.code() / 2); |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 // ----------------------------------------------------------------------------- | 117 // ----------------------------------------------------------------------------- |
118 // RelocInfo. | 118 // RelocInfo. |
119 | 119 |
120 void RelocInfo::apply(intptr_t delta, ICacheFlushMode icache_flush_mode) { | 120 void RelocInfo::apply(intptr_t delta) { |
121 if (IsCodeTarget(rmode_)) { | 121 if (IsCodeTarget(rmode_)) { |
122 uint32_t scope1 = (uint32_t) target_address() & ~kImm28Mask; | 122 uint32_t scope1 = (uint32_t) target_address() & ~kImm28Mask; |
123 uint32_t scope2 = reinterpret_cast<uint32_t>(pc_) & ~kImm28Mask; | 123 uint32_t scope2 = reinterpret_cast<uint32_t>(pc_) & ~kImm28Mask; |
124 | 124 |
125 if (scope1 != scope2) { | 125 if (scope1 != scope2) { |
126 Assembler::JumpToJumpRegister(pc_); | 126 Assembler::JumpToJumpRegister(pc_); |
127 } | 127 } |
128 } | 128 } |
129 if (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { | 129 if (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { |
130 // Absolute code pointer inside code object moves with the code object. | 130 // Absolute code pointer inside code object moves with the code object. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 host(), this, HeapObject::cast(target_code)); | 188 host(), this, HeapObject::cast(target_code)); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 | 192 |
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) { | |
199 return pc - Assembler::kPatchDebugBreakSlotReturnOffset; | |
200 } | |
201 | |
202 | |
203 void Assembler::set_target_internal_reference_encoded_at(Address pc, | 198 void Assembler::set_target_internal_reference_encoded_at(Address pc, |
204 Address target) { | 199 Address target) { |
205 // Encoded internal references are lui/ori load of 32-bit abolute address. | 200 // Encoded internal references are lui/ori load of 32-bit abolute address. |
206 Instr instr_lui = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); | 201 Instr instr_lui = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); |
207 Instr instr_ori = Assembler::instr_at(pc + 1 * Assembler::kInstrSize); | 202 Instr instr_ori = Assembler::instr_at(pc + 1 * Assembler::kInstrSize); |
208 DCHECK(Assembler::IsLui(instr_lui)); | 203 DCHECK(Assembler::IsLui(instr_lui)); |
209 DCHECK(Assembler::IsOri(instr_ori)); | 204 DCHECK(Assembler::IsOri(instr_ori)); |
210 instr_lui &= ~kImm16Mask; | 205 instr_lui &= ~kImm16Mask; |
211 instr_ori &= ~kImm16Mask; | 206 instr_ori &= ~kImm16Mask; |
212 int32_t imm = reinterpret_cast<int32_t>(target); | 207 int32_t imm = reinterpret_cast<int32_t>(target); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 347 |
353 void RelocInfo::set_code_age_stub(Code* stub, | 348 void RelocInfo::set_code_age_stub(Code* stub, |
354 ICacheFlushMode icache_flush_mode) { | 349 ICacheFlushMode icache_flush_mode) { |
355 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 350 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
356 Assembler::set_target_address_at(pc_ + Assembler::kInstrSize, | 351 Assembler::set_target_address_at(pc_ + Assembler::kInstrSize, |
357 host_, | 352 host_, |
358 stub->instruction_start()); | 353 stub->instruction_start()); |
359 } | 354 } |
360 | 355 |
361 | 356 |
362 Address RelocInfo::call_address() { | 357 Address RelocInfo::debug_call_address() { |
363 DCHECK((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 358 // The pc_ offset of 0 assumes patched debug break slot or return |
364 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 359 // sequence. |
365 // The pc_ offset of 0 assumes mips patched return sequence per | 360 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
366 // debug-mips.cc BreakLocation::SetDebugBreakAtReturn(), or | |
367 // debug break slot per BreakLocation::SetDebugBreakAtSlot(). | |
368 return Assembler::target_address_at(pc_, host_); | 361 return Assembler::target_address_at(pc_, host_); |
369 } | 362 } |
370 | 363 |
371 | 364 |
372 void RelocInfo::set_call_address(Address target) { | 365 void RelocInfo::set_debug_call_address(Address target) { |
373 DCHECK((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 366 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
374 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 367 // The pc_ offset of 0 assumes patched debug break slot or return |
375 // The pc_ offset of 0 assumes mips patched return sequence per | 368 // sequence. |
376 // debug-mips.cc BreakLocation::SetDebugBreakAtReturn(), or | |
377 // debug break slot per BreakLocation::SetDebugBreakAtSlot(). | |
378 Assembler::set_target_address_at(pc_, host_, target); | 369 Assembler::set_target_address_at(pc_, host_, target); |
379 if (host() != NULL) { | 370 if (host() != NULL) { |
380 Object* target_code = Code::GetCodeFromTargetAddress(target); | 371 Object* target_code = Code::GetCodeFromTargetAddress(target); |
381 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 372 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
382 host(), this, HeapObject::cast(target_code)); | 373 host(), this, HeapObject::cast(target_code)); |
383 } | 374 } |
384 } | 375 } |
385 | 376 |
386 | 377 |
387 Object* RelocInfo::call_object() { | |
388 return *call_object_address(); | |
389 } | |
390 | |
391 | |
392 Object** RelocInfo::call_object_address() { | |
393 DCHECK((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | |
394 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | |
395 return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize); | |
396 } | |
397 | |
398 | |
399 void RelocInfo::set_call_object(Object* target) { | |
400 *call_object_address() = target; | |
401 } | |
402 | |
403 | |
404 void RelocInfo::WipeOut() { | 378 void RelocInfo::WipeOut() { |
405 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || | 379 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || |
406 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || | 380 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || |
407 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); | 381 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); |
408 if (IsInternalReference(rmode_)) { | 382 if (IsInternalReference(rmode_)) { |
409 Memory::Address_at(pc_) = NULL; | 383 Memory::Address_at(pc_) = NULL; |
410 } else if (IsInternalReferenceEncoded(rmode_)) { | 384 } else if (IsInternalReferenceEncoded(rmode_)) { |
411 Assembler::set_target_internal_reference_encoded_at(pc_, nullptr); | 385 Assembler::set_target_internal_reference_encoded_at(pc_, nullptr); |
412 } else { | 386 } else { |
413 Assembler::set_target_address_at(pc_, host_, NULL); | 387 Assembler::set_target_address_at(pc_, host_, NULL); |
(...skipping 28 matching lines...) Expand all Loading... |
442 visitor->VisitCodeTarget(this); | 416 visitor->VisitCodeTarget(this); |
443 } else if (mode == RelocInfo::CELL) { | 417 } else if (mode == RelocInfo::CELL) { |
444 visitor->VisitCell(this); | 418 visitor->VisitCell(this); |
445 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 419 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
446 visitor->VisitExternalReference(this); | 420 visitor->VisitExternalReference(this); |
447 } else if (mode == RelocInfo::INTERNAL_REFERENCE || | 421 } else if (mode == RelocInfo::INTERNAL_REFERENCE || |
448 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { | 422 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { |
449 visitor->VisitInternalReference(this); | 423 visitor->VisitInternalReference(this); |
450 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 424 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
451 visitor->VisitCodeAgeSequence(this); | 425 visitor->VisitCodeAgeSequence(this); |
452 } else if (((RelocInfo::IsJSReturn(mode) && | 426 } else if (RelocInfo::IsDebugBreakSlot(mode) && |
453 IsPatchedReturnSequence()) || | 427 IsPatchedDebugBreakSlotSequence() && |
454 (RelocInfo::IsDebugBreakSlot(mode) && | |
455 IsPatchedDebugBreakSlotSequence())) && | |
456 isolate->debug()->has_break_points()) { | 428 isolate->debug()->has_break_points()) { |
457 visitor->VisitDebugTarget(this); | 429 visitor->VisitDebugTarget(this); |
458 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 430 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
459 visitor->VisitRuntimeEntry(this); | 431 visitor->VisitRuntimeEntry(this); |
460 } | 432 } |
461 } | 433 } |
462 | 434 |
463 | 435 |
464 template<typename StaticVisitor> | 436 template<typename StaticVisitor> |
465 void RelocInfo::Visit(Heap* heap) { | 437 void RelocInfo::Visit(Heap* heap) { |
466 RelocInfo::Mode mode = rmode(); | 438 RelocInfo::Mode mode = rmode(); |
467 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 439 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
468 StaticVisitor::VisitEmbeddedPointer(heap, this); | 440 StaticVisitor::VisitEmbeddedPointer(heap, this); |
469 } else if (RelocInfo::IsCodeTarget(mode)) { | 441 } else if (RelocInfo::IsCodeTarget(mode)) { |
470 StaticVisitor::VisitCodeTarget(heap, this); | 442 StaticVisitor::VisitCodeTarget(heap, this); |
471 } else if (mode == RelocInfo::CELL) { | 443 } else if (mode == RelocInfo::CELL) { |
472 StaticVisitor::VisitCell(heap, this); | 444 StaticVisitor::VisitCell(heap, this); |
473 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 445 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
474 StaticVisitor::VisitExternalReference(this); | 446 StaticVisitor::VisitExternalReference(this); |
475 } else if (mode == RelocInfo::INTERNAL_REFERENCE || | 447 } else if (mode == RelocInfo::INTERNAL_REFERENCE || |
476 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { | 448 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { |
477 StaticVisitor::VisitInternalReference(this); | 449 StaticVisitor::VisitInternalReference(this); |
478 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 450 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
479 StaticVisitor::VisitCodeAgeSequence(heap, this); | 451 StaticVisitor::VisitCodeAgeSequence(heap, this); |
480 } else if (heap->isolate()->debug()->has_break_points() && | 452 } else if (heap->isolate()->debug()->has_break_points() && |
481 ((RelocInfo::IsJSReturn(mode) && | 453 RelocInfo::IsDebugBreakSlot(mode) && |
482 IsPatchedReturnSequence()) || | 454 IsPatchedDebugBreakSlotSequence()) { |
483 (RelocInfo::IsDebugBreakSlot(mode) && | |
484 IsPatchedDebugBreakSlotSequence()))) { | |
485 StaticVisitor::VisitDebugTarget(heap, this); | 455 StaticVisitor::VisitDebugTarget(heap, this); |
486 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 456 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
487 StaticVisitor::VisitRuntimeEntry(this); | 457 StaticVisitor::VisitRuntimeEntry(this); |
488 } | 458 } |
489 } | 459 } |
490 | 460 |
491 | 461 |
492 // ----------------------------------------------------------------------------- | 462 // ----------------------------------------------------------------------------- |
493 // Assembler. | 463 // Assembler. |
494 | 464 |
(...skipping 18 matching lines...) Expand all Loading... |
513 } | 483 } |
514 *reinterpret_cast<Instr*>(pc_) = x; | 484 *reinterpret_cast<Instr*>(pc_) = x; |
515 pc_ += kInstrSize; | 485 pc_ += kInstrSize; |
516 CheckTrampolinePoolQuick(); | 486 CheckTrampolinePoolQuick(); |
517 } | 487 } |
518 | 488 |
519 | 489 |
520 } } // namespace v8::internal | 490 } } // namespace v8::internal |
521 | 491 |
522 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ | 492 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
OLD | NEW |