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 (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { | 121 if (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { |
122 // Absolute code pointer inside code object moves with the code object. | 122 // Absolute code pointer inside code object moves with the code object. |
123 byte* p = reinterpret_cast<byte*>(pc_); | 123 byte* p = reinterpret_cast<byte*>(pc_); |
124 int count = Assembler::RelocateInternalReference(rmode_, p, delta); | 124 int count = Assembler::RelocateInternalReference(rmode_, p, delta); |
125 CpuFeatures::FlushICache(p, count * sizeof(uint32_t)); | 125 CpuFeatures::FlushICache(p, count * sizeof(uint32_t)); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 | 129 |
130 Address RelocInfo::target_address() { | 130 Address RelocInfo::target_address() { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 host(), this, HeapObject::cast(target_code)); | 182 host(), this, HeapObject::cast(target_code)); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 | 186 |
187 Address Assembler::target_address_from_return_address(Address pc) { | 187 Address Assembler::target_address_from_return_address(Address pc) { |
188 return pc - kCallTargetAddressOffset; | 188 return pc - kCallTargetAddressOffset; |
189 } | 189 } |
190 | 190 |
191 | 191 |
192 Address Assembler::break_address_from_return_address(Address pc) { | |
193 return pc - Assembler::kPatchDebugBreakSlotReturnOffset; | |
194 } | |
195 | |
196 | |
197 void Assembler::set_target_internal_reference_encoded_at(Address pc, | 192 void Assembler::set_target_internal_reference_encoded_at(Address pc, |
198 Address target) { | 193 Address target) { |
199 // Encoded internal references are j/jal instructions. | 194 // Encoded internal references are j/jal instructions. |
200 Instr instr = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); | 195 Instr instr = Assembler::instr_at(pc + 0 * Assembler::kInstrSize); |
201 | 196 |
202 uint64_t imm28 = | 197 uint64_t imm28 = |
203 (reinterpret_cast<uint64_t>(target) & static_cast<uint64_t>(kImm28Mask)); | 198 (reinterpret_cast<uint64_t>(target) & static_cast<uint64_t>(kImm28Mask)); |
204 | 199 |
205 instr &= ~kImm26Mask; | 200 instr &= ~kImm26Mask; |
206 uint64_t imm26 = imm28 >> 2; | 201 uint64_t imm26 = imm28 >> 2; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 337 |
343 void RelocInfo::set_code_age_stub(Code* stub, | 338 void RelocInfo::set_code_age_stub(Code* stub, |
344 ICacheFlushMode icache_flush_mode) { | 339 ICacheFlushMode icache_flush_mode) { |
345 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 340 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
346 Assembler::set_target_address_at(pc_ + Assembler::kInstrSize, | 341 Assembler::set_target_address_at(pc_ + Assembler::kInstrSize, |
347 host_, | 342 host_, |
348 stub->instruction_start()); | 343 stub->instruction_start()); |
349 } | 344 } |
350 | 345 |
351 | 346 |
352 Address RelocInfo::call_address() { | 347 Address RelocInfo::debug_call_address() { |
353 DCHECK((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 348 // The pc_ offset of 0 assumes patched debug break slot or return |
354 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 349 // sequence. |
355 // The pc_ offset of 0 assumes mips patched return sequence per | 350 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
356 // debug-mips.cc BreakLocation::SetDebugBreakAtReturn(), or | |
357 // debug break slot per BreakLocation::SetDebugBreakAtSlot(). | |
358 return Assembler::target_address_at(pc_, host_); | 351 return Assembler::target_address_at(pc_, host_); |
359 } | 352 } |
360 | 353 |
361 | 354 |
362 void RelocInfo::set_call_address(Address target) { | 355 void RelocInfo::set_debug_call_address(Address target) { |
363 DCHECK((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | 356 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
364 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | 357 // The pc_ offset of 0 assumes patched debug break slot or return |
365 // The pc_ offset of 0 assumes mips patched return sequence per | 358 // sequence. |
366 // debug-mips.cc BreakLocation::SetDebugBreakAtReturn(), or | |
367 // debug break slot per BreakLocation::SetDebugBreakAtSlot(). | |
368 Assembler::set_target_address_at(pc_, host_, target); | 359 Assembler::set_target_address_at(pc_, host_, target); |
369 if (host() != NULL) { | 360 if (host() != NULL) { |
370 Object* target_code = Code::GetCodeFromTargetAddress(target); | 361 Object* target_code = Code::GetCodeFromTargetAddress(target); |
371 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 362 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
372 host(), this, HeapObject::cast(target_code)); | 363 host(), this, HeapObject::cast(target_code)); |
373 } | 364 } |
374 } | 365 } |
375 | 366 |
376 | 367 |
377 Object* RelocInfo::call_object() { | |
378 return *call_object_address(); | |
379 } | |
380 | |
381 | |
382 Object** RelocInfo::call_object_address() { | |
383 DCHECK((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || | |
384 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); | |
385 return reinterpret_cast<Object**>(pc_ + 6 * Assembler::kInstrSize); | |
386 } | |
387 | |
388 | |
389 void RelocInfo::set_call_object(Object* target) { | |
390 *call_object_address() = target; | |
391 } | |
392 | |
393 | |
394 void RelocInfo::WipeOut() { | 368 void RelocInfo::WipeOut() { |
395 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || | 369 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || |
396 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || | 370 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || |
397 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); | 371 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); |
398 if (IsInternalReference(rmode_)) { | 372 if (IsInternalReference(rmode_)) { |
399 Memory::Address_at(pc_) = NULL; | 373 Memory::Address_at(pc_) = NULL; |
400 } else if (IsInternalReferenceEncoded(rmode_)) { | 374 } else if (IsInternalReferenceEncoded(rmode_)) { |
401 Assembler::set_target_internal_reference_encoded_at(pc_, nullptr); | 375 Assembler::set_target_internal_reference_encoded_at(pc_, nullptr); |
402 } else { | 376 } else { |
403 Assembler::set_target_address_at(pc_, host_, NULL); | 377 Assembler::set_target_address_at(pc_, host_, NULL); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 visitor->VisitCodeTarget(this); | 409 visitor->VisitCodeTarget(this); |
436 } else if (mode == RelocInfo::CELL) { | 410 } else if (mode == RelocInfo::CELL) { |
437 visitor->VisitCell(this); | 411 visitor->VisitCell(this); |
438 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 412 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
439 visitor->VisitExternalReference(this); | 413 visitor->VisitExternalReference(this); |
440 } else if (mode == RelocInfo::INTERNAL_REFERENCE || | 414 } else if (mode == RelocInfo::INTERNAL_REFERENCE || |
441 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { | 415 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { |
442 visitor->VisitInternalReference(this); | 416 visitor->VisitInternalReference(this); |
443 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 417 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
444 visitor->VisitCodeAgeSequence(this); | 418 visitor->VisitCodeAgeSequence(this); |
445 } else if (((RelocInfo::IsJSReturn(mode) && | 419 } else if (RelocInfo::IsDebugBreakSlot(mode) && |
446 IsPatchedReturnSequence()) || | 420 IsPatchedDebugBreakSlotSequence() && |
447 (RelocInfo::IsDebugBreakSlot(mode) && | |
448 IsPatchedDebugBreakSlotSequence())) && | |
449 isolate->debug()->has_break_points()) { | 421 isolate->debug()->has_break_points()) { |
450 visitor->VisitDebugTarget(this); | 422 visitor->VisitDebugTarget(this); |
451 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 423 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
452 visitor->VisitRuntimeEntry(this); | 424 visitor->VisitRuntimeEntry(this); |
453 } | 425 } |
454 } | 426 } |
455 | 427 |
456 | 428 |
457 template<typename StaticVisitor> | 429 template<typename StaticVisitor> |
458 void RelocInfo::Visit(Heap* heap) { | 430 void RelocInfo::Visit(Heap* heap) { |
459 RelocInfo::Mode mode = rmode(); | 431 RelocInfo::Mode mode = rmode(); |
460 if (mode == RelocInfo::EMBEDDED_OBJECT) { | 432 if (mode == RelocInfo::EMBEDDED_OBJECT) { |
461 StaticVisitor::VisitEmbeddedPointer(heap, this); | 433 StaticVisitor::VisitEmbeddedPointer(heap, this); |
462 } else if (RelocInfo::IsCodeTarget(mode)) { | 434 } else if (RelocInfo::IsCodeTarget(mode)) { |
463 StaticVisitor::VisitCodeTarget(heap, this); | 435 StaticVisitor::VisitCodeTarget(heap, this); |
464 } else if (mode == RelocInfo::CELL) { | 436 } else if (mode == RelocInfo::CELL) { |
465 StaticVisitor::VisitCell(heap, this); | 437 StaticVisitor::VisitCell(heap, this); |
466 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { | 438 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { |
467 StaticVisitor::VisitExternalReference(this); | 439 StaticVisitor::VisitExternalReference(this); |
468 } else if (mode == RelocInfo::INTERNAL_REFERENCE || | 440 } else if (mode == RelocInfo::INTERNAL_REFERENCE || |
469 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { | 441 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { |
470 StaticVisitor::VisitInternalReference(this); | 442 StaticVisitor::VisitInternalReference(this); |
471 } else if (RelocInfo::IsCodeAgeSequence(mode)) { | 443 } else if (RelocInfo::IsCodeAgeSequence(mode)) { |
472 StaticVisitor::VisitCodeAgeSequence(heap, this); | 444 StaticVisitor::VisitCodeAgeSequence(heap, this); |
473 } else if (heap->isolate()->debug()->has_break_points() && | 445 } else if (heap->isolate()->debug()->has_break_points() && |
474 ((RelocInfo::IsJSReturn(mode) && | 446 RelocInfo::IsDebugBreakSlot(mode) && |
475 IsPatchedReturnSequence()) || | 447 IsPatchedDebugBreakSlotSequence()) { |
476 (RelocInfo::IsDebugBreakSlot(mode) && | |
477 IsPatchedDebugBreakSlotSequence()))) { | |
478 StaticVisitor::VisitDebugTarget(heap, this); | 448 StaticVisitor::VisitDebugTarget(heap, this); |
479 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 449 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
480 StaticVisitor::VisitRuntimeEntry(this); | 450 StaticVisitor::VisitRuntimeEntry(this); |
481 } | 451 } |
482 } | 452 } |
483 | 453 |
484 | 454 |
485 // ----------------------------------------------------------------------------- | 455 // ----------------------------------------------------------------------------- |
486 // Assembler. | 456 // Assembler. |
487 | 457 |
(...skipping 28 matching lines...) Expand all Loading... |
516 } | 486 } |
517 *reinterpret_cast<uint64_t*>(pc_) = x; | 487 *reinterpret_cast<uint64_t*>(pc_) = x; |
518 pc_ += kInstrSize * 2; | 488 pc_ += kInstrSize * 2; |
519 CheckTrampolinePoolQuick(); | 489 CheckTrampolinePoolQuick(); |
520 } | 490 } |
521 | 491 |
522 | 492 |
523 } } // namespace v8::internal | 493 } } // namespace v8::internal |
524 | 494 |
525 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ | 495 #endif // V8_MIPS_ASSEMBLER_MIPS_INL_H_ |
OLD | NEW |