OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void RelocInfo::apply(intptr_t delta) { | 53 void RelocInfo::apply(intptr_t delta) { |
54 // absolute code pointer inside code object moves with the code object. | 54 // absolute code pointer inside code object moves with the code object. |
55 if (IsInternalReference(rmode_)) { | 55 if (IsInternalReference(rmode_)) { |
56 // Jump table entry | 56 // Jump table entry |
57 Address target = Memory::Address_at(pc_); | 57 Address target = Memory::Address_at(pc_); |
58 Memory::Address_at(pc_) = target + delta; | 58 Memory::Address_at(pc_) = target + delta; |
59 } else { | 59 } else { |
60 // mov sequence | 60 // mov sequence |
61 DCHECK(IsInternalReferenceEncoded(rmode_)); | 61 DCHECK(IsInternalReferenceEncoded(rmode_)); |
62 Address target = Assembler::target_address_at(pc_, host_); | 62 Address target = Assembler::target_address_at(pc_, host_); |
63 Assembler::set_target_address_at(pc_, host_, target + delta, | 63 Assembler::set_target_address_at(isolate_, pc_, host_, target + delta, |
64 SKIP_ICACHE_FLUSH); | 64 SKIP_ICACHE_FLUSH); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 Address RelocInfo::target_internal_reference() { | 69 Address RelocInfo::target_internal_reference() { |
70 if (IsInternalReference(rmode_)) { | 70 if (IsInternalReference(rmode_)) { |
71 // Jump table entry | 71 // Jump table entry |
72 return Memory::Address_at(pc_); | 72 return Memory::Address_at(pc_); |
73 } else { | 73 } else { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; } | 132 int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; } |
133 | 133 |
134 | 134 |
135 void RelocInfo::set_target_address(Address target, | 135 void RelocInfo::set_target_address(Address target, |
136 WriteBarrierMode write_barrier_mode, | 136 WriteBarrierMode write_barrier_mode, |
137 ICacheFlushMode icache_flush_mode) { | 137 ICacheFlushMode icache_flush_mode) { |
138 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); | 138 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); |
139 Assembler::set_target_address_at(pc_, host_, target, icache_flush_mode); | 139 Assembler::set_target_address_at(isolate_, pc_, host_, target, |
| 140 icache_flush_mode); |
140 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && | 141 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && |
141 IsCodeTarget(rmode_)) { | 142 IsCodeTarget(rmode_)) { |
142 Object* target_code = Code::GetCodeFromTargetAddress(target); | 143 Object* target_code = Code::GetCodeFromTargetAddress(target); |
143 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 144 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
144 host(), this, HeapObject::cast(target_code)); | 145 host(), this, HeapObject::cast(target_code)); |
145 } | 146 } |
146 } | 147 } |
147 | 148 |
148 | 149 |
149 Address Assembler::target_address_from_return_address(Address pc) { | 150 Address Assembler::target_address_from_return_address(Address pc) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 190 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
190 return Handle<Object>( | 191 return Handle<Object>( |
191 reinterpret_cast<Object**>(Assembler::target_address_at(pc_, host_))); | 192 reinterpret_cast<Object**>(Assembler::target_address_at(pc_, host_))); |
192 } | 193 } |
193 | 194 |
194 | 195 |
195 void RelocInfo::set_target_object(Object* target, | 196 void RelocInfo::set_target_object(Object* target, |
196 WriteBarrierMode write_barrier_mode, | 197 WriteBarrierMode write_barrier_mode, |
197 ICacheFlushMode icache_flush_mode) { | 198 ICacheFlushMode icache_flush_mode) { |
198 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 199 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
199 Assembler::set_target_address_at( | 200 Assembler::set_target_address_at(isolate_, pc_, host_, |
200 pc_, host_, reinterpret_cast<Address>(target), icache_flush_mode); | 201 reinterpret_cast<Address>(target), |
| 202 icache_flush_mode); |
201 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && | 203 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && |
202 target->IsHeapObject()) { | 204 target->IsHeapObject()) { |
203 host()->GetHeap()->incremental_marking()->RecordWrite( | 205 host()->GetHeap()->incremental_marking()->RecordWrite( |
204 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); | 206 host(), &Memory::Object_at(pc_), HeapObject::cast(target)); |
205 } | 207 } |
206 } | 208 } |
207 | 209 |
208 | 210 |
209 Address RelocInfo::target_external_reference() { | 211 Address RelocInfo::target_external_reference() { |
210 DCHECK(rmode_ == EXTERNAL_REFERENCE); | 212 DCHECK(rmode_ == EXTERNAL_REFERENCE); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 Code* RelocInfo::code_age_stub() { | 281 Code* RelocInfo::code_age_stub() { |
280 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 282 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
281 return Code::GetCodeFromTargetAddress( | 283 return Code::GetCodeFromTargetAddress( |
282 Assembler::target_address_at(pc_ + kCodeAgingTargetDelta, host_)); | 284 Assembler::target_address_at(pc_ + kCodeAgingTargetDelta, host_)); |
283 } | 285 } |
284 | 286 |
285 | 287 |
286 void RelocInfo::set_code_age_stub(Code* stub, | 288 void RelocInfo::set_code_age_stub(Code* stub, |
287 ICacheFlushMode icache_flush_mode) { | 289 ICacheFlushMode icache_flush_mode) { |
288 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); | 290 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE); |
289 Assembler::set_target_address_at(pc_ + kCodeAgingTargetDelta, host_, | 291 Assembler::set_target_address_at(isolate_, pc_ + kCodeAgingTargetDelta, host_, |
290 stub->instruction_start(), | 292 stub->instruction_start(), |
291 icache_flush_mode); | 293 icache_flush_mode); |
292 } | 294 } |
293 | 295 |
294 | 296 |
295 Address RelocInfo::debug_call_address() { | 297 Address RelocInfo::debug_call_address() { |
296 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); | 298 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
297 return Assembler::target_address_at(pc_, host_); | 299 return Assembler::target_address_at(pc_, host_); |
298 } | 300 } |
299 | 301 |
300 | 302 |
301 void RelocInfo::set_debug_call_address(Address target) { | 303 void RelocInfo::set_debug_call_address(Address target) { |
302 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); | 304 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()); |
303 Assembler::set_target_address_at(pc_, host_, target); | 305 Assembler::set_target_address_at(isolate_, pc_, host_, target); |
304 if (host() != NULL) { | 306 if (host() != NULL) { |
305 Object* target_code = Code::GetCodeFromTargetAddress(target); | 307 Object* target_code = Code::GetCodeFromTargetAddress(target); |
306 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( | 308 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( |
307 host(), this, HeapObject::cast(target_code)); | 309 host(), this, HeapObject::cast(target_code)); |
308 } | 310 } |
309 } | 311 } |
310 | 312 |
311 | 313 |
312 void RelocInfo::WipeOut() { | 314 void RelocInfo::WipeOut() { |
313 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || | 315 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || |
314 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || | 316 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || |
315 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); | 317 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)); |
316 if (IsInternalReference(rmode_)) { | 318 if (IsInternalReference(rmode_)) { |
317 // Jump table entry | 319 // Jump table entry |
318 Memory::Address_at(pc_) = NULL; | 320 Memory::Address_at(pc_) = NULL; |
319 } else if (IsInternalReferenceEncoded(rmode_)) { | 321 } else if (IsInternalReferenceEncoded(rmode_)) { |
320 // mov sequence | 322 // mov sequence |
321 // Currently used only by deserializer, no need to flush. | 323 // Currently used only by deserializer, no need to flush. |
322 Assembler::set_target_address_at(pc_, host_, NULL, SKIP_ICACHE_FLUSH); | 324 Assembler::set_target_address_at(isolate_, pc_, host_, NULL, |
| 325 SKIP_ICACHE_FLUSH); |
323 } else { | 326 } else { |
324 Assembler::set_target_address_at(pc_, host_, NULL); | 327 Assembler::set_target_address_at(isolate_, pc_, host_, NULL); |
325 } | 328 } |
326 } | 329 } |
327 | 330 |
328 | 331 |
329 bool RelocInfo::IsPatchedReturnSequence() { | 332 bool RelocInfo::IsPatchedReturnSequence() { |
330 // | 333 // |
331 // The patched return sequence is defined by | 334 // The patched return sequence is defined by |
332 // BreakLocation::SetDebugBreakAtReturn() | 335 // BreakLocation::SetDebugBreakAtReturn() |
333 // FIXED_SEQUENCE | 336 // FIXED_SEQUENCE |
334 | 337 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 addr += GetConstantPoolOffset(pc, access, type); | 633 addr += GetConstantPoolOffset(pc, access, type); |
631 return addr; | 634 return addr; |
632 } | 635 } |
633 | 636 |
634 | 637 |
635 // This sets the branch destination (which gets loaded at the call address). | 638 // This sets the branch destination (which gets loaded at the call address). |
636 // This is for calls and branches within generated code. The serializer | 639 // This is for calls and branches within generated code. The serializer |
637 // has already deserialized the mov instructions etc. | 640 // has already deserialized the mov instructions etc. |
638 // There is a FIXED_SEQUENCE assumption here | 641 // There is a FIXED_SEQUENCE assumption here |
639 void Assembler::deserialization_set_special_target_at( | 642 void Assembler::deserialization_set_special_target_at( |
640 Address instruction_payload, Code* code, Address target) { | 643 Isolate* isolate, Address instruction_payload, Code* code, Address target) { |
641 set_target_address_at(instruction_payload, code, target); | 644 set_target_address_at(isolate, instruction_payload, code, target); |
642 } | 645 } |
643 | 646 |
644 | 647 |
645 void Assembler::deserialization_set_target_internal_reference_at( | 648 void Assembler::deserialization_set_target_internal_reference_at( |
646 Address pc, Address target, RelocInfo::Mode mode) { | 649 Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) { |
647 if (RelocInfo::IsInternalReferenceEncoded(mode)) { | 650 if (RelocInfo::IsInternalReferenceEncoded(mode)) { |
648 Code* code = NULL; | 651 Code* code = NULL; |
649 set_target_address_at(pc, code, target, SKIP_ICACHE_FLUSH); | 652 set_target_address_at(isolate, pc, code, target, SKIP_ICACHE_FLUSH); |
650 } else { | 653 } else { |
651 Memory::Address_at(pc) = target; | 654 Memory::Address_at(pc) = target; |
652 } | 655 } |
653 } | 656 } |
654 | 657 |
655 | 658 |
656 // This code assumes the FIXED_SEQUENCE of lis/ori | 659 // This code assumes the FIXED_SEQUENCE of lis/ori |
657 void Assembler::set_target_address_at(Address pc, Address constant_pool, | 660 void Assembler::set_target_address_at(Isolate* isolate, Address pc, |
658 Address target, | 661 Address constant_pool, Address target, |
659 ICacheFlushMode icache_flush_mode) { | 662 ICacheFlushMode icache_flush_mode) { |
660 if (FLAG_enable_embedded_constant_pool && constant_pool) { | 663 if (FLAG_enable_embedded_constant_pool && constant_pool) { |
661 ConstantPoolEntry::Access access; | 664 ConstantPoolEntry::Access access; |
662 if (IsConstantPoolLoadStart(pc, &access)) { | 665 if (IsConstantPoolLoadStart(pc, &access)) { |
663 Memory::Address_at(target_constant_pool_address_at( | 666 Memory::Address_at(target_constant_pool_address_at( |
664 pc, constant_pool, access, ConstantPoolEntry::INTPTR)) = target; | 667 pc, constant_pool, access, ConstantPoolEntry::INTPTR)) = target; |
665 return; | 668 return; |
666 } | 669 } |
667 } | 670 } |
668 | 671 |
(...skipping 22 matching lines...) Expand all Loading... |
691 | 694 |
692 instr1 &= ~kImm16Mask; | 695 instr1 &= ~kImm16Mask; |
693 instr1 |= itarget & kImm16Mask; | 696 instr1 |= itarget & kImm16Mask; |
694 itarget = itarget >> 16; | 697 itarget = itarget >> 16; |
695 | 698 |
696 *p = instr1; | 699 *p = instr1; |
697 *(p + 1) = instr2; | 700 *(p + 1) = instr2; |
698 *(p + 3) = instr4; | 701 *(p + 3) = instr4; |
699 *(p + 4) = instr5; | 702 *(p + 4) = instr5; |
700 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 703 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
701 Assembler::FlushICacheWithoutIsolate(p, 5 * kInstrSize); | 704 Assembler::FlushICache(isolate, p, 5 * kInstrSize); |
702 } | 705 } |
703 #else | 706 #else |
704 uint32_t* p = reinterpret_cast<uint32_t*>(pc); | 707 uint32_t* p = reinterpret_cast<uint32_t*>(pc); |
705 uint32_t itarget = reinterpret_cast<uint32_t>(target); | 708 uint32_t itarget = reinterpret_cast<uint32_t>(target); |
706 int lo_word = itarget & kImm16Mask; | 709 int lo_word = itarget & kImm16Mask; |
707 int hi_word = itarget >> 16; | 710 int hi_word = itarget >> 16; |
708 instr1 &= ~kImm16Mask; | 711 instr1 &= ~kImm16Mask; |
709 instr1 |= hi_word; | 712 instr1 |= hi_word; |
710 instr2 &= ~kImm16Mask; | 713 instr2 &= ~kImm16Mask; |
711 instr2 |= lo_word; | 714 instr2 |= lo_word; |
712 | 715 |
713 *p = instr1; | 716 *p = instr1; |
714 *(p + 1) = instr2; | 717 *(p + 1) = instr2; |
715 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 718 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
716 Assembler::FlushICacheWithoutIsolate(p, 2 * kInstrSize); | 719 Assembler::FlushICache(isolate, p, 2 * kInstrSize); |
717 } | 720 } |
718 #endif | 721 #endif |
719 return; | 722 return; |
720 } | 723 } |
721 UNREACHABLE(); | 724 UNREACHABLE(); |
722 } | 725 } |
723 } // namespace internal | 726 } // namespace internal |
724 } // namespace v8 | 727 } // namespace v8 |
725 | 728 |
726 #endif // V8_PPC_ASSEMBLER_PPC_INL_H_ | 729 #endif // V8_PPC_ASSEMBLER_PPC_INL_H_ |
OLD | NEW |