1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions
8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
11 // - Redistribution in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the
16 // - Neither the name of Sun Microsystems or the names of contributors may
17 // be used to endorse or promote products derived from this software without
18 // specific prior written permission.
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 // OF THE POSSIBILITY OF SUCH DAMAGE.
33 // The original source code covered by the above license above has been modified
34 // significantly by Google Inc.
35 // Copyright 2014 the V8 project authors. All rights reserved.
37 #ifndef V8_PPC_ASSEMBLER_PPC_INL_H_
38 #define V8_PPC_ASSEMBLER_PPC_INL_H_
40 #include "src/ppc/assembler-ppc.h"
42 #include "src/assembler.h"
43 #include "src/debug/debug.h"
50 bool CpuFeatures::SupportsCrankshaft() { return true; }
53 void RelocInfo::apply(intptr_t delta) {
54 // absolute code pointer inside code object moves with the code object.
55 if (IsInternalReference(rmode_)) {
57 Address target = Memory::Address_at(pc_);
58 Memory::Address_at(pc_) = target + delta;
61 DCHECK(IsInternalReferenceEncoded(rmode_));
62 Address target = Assembler::target_address_at(pc_, host_);
63 Assembler::set_target_address_at(pc_, host_, target + delta,
69 Address RelocInfo::target_internal_reference() {
70 if (IsInternalReference(rmode_)) {
72 return Memory::Address_at(pc_);
75 DCHECK(IsInternalReferenceEncoded(rmode_));
76 return Assembler::target_address_at(pc_, host_);
81 Address RelocInfo::target_internal_reference_address() {
82 DCHECK(IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_));
83 return reinterpret_cast<Address>(pc_);
87 Address RelocInfo::target_address() {
88 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
89 return Assembler::target_address_at(pc_, host_);
93 Address RelocInfo::target_address_address() {
94 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) ||
95 rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE);
97 if (FLAG_enable_embedded_constant_pool &&
98 Assembler::IsConstantPoolLoadStart(pc_)) {
99 // We return the PC for embedded constant pool since this function is used
100 // by the serializer and expects the address to reside within the code
102 return reinterpret_cast<Address>(pc_);
105 // Read the address of the word containing the target_address in an
106 // instruction stream.
107 // The only architecture-independent user of this function is the serializer.
108 // The serializer uses it to find out how many raw bytes of instruction to
109 // output before the next target.
110 // For an instruction like LIS/ORI where the target bits are mixed into the
111 // instruction bits, the size of the target will be zero, indicating that the
112 // serializer should not step forward in memory after a target is resolved
114 return reinterpret_cast<Address>(pc_);
118 Address RelocInfo::constant_pool_entry_address() {
119 if (FLAG_enable_embedded_constant_pool) {
120 Address constant_pool = host_->constant_pool();
121 DCHECK(constant_pool);
122 ConstantPoolEntry::Access access;
123 if (Assembler::IsConstantPoolLoadStart(pc_, &access))
124 return Assembler::target_constant_pool_address_at(
125 pc_, constant_pool, access, ConstantPoolEntry::INTPTR);
132 int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; }
135 void RelocInfo::set_target_address(Address target,
136 WriteBarrierMode write_barrier_mode,
137 ICacheFlushMode icache_flush_mode) {
138 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
139 Assembler::set_target_address_at(pc_, host_, target, icache_flush_mode);
140 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL &&
141 IsCodeTarget(rmode_)) {
142 Object* target_code = Code::GetCodeFromTargetAddress(target);
143 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
144 host(), this, HeapObject::cast(target_code));
149 Address Assembler::target_address_from_return_address(Address pc) {
150 // Returns the address of the call target from the return address that will
151 // be returned to after a call.
152 // Call sequence is :
153 // mov ip, @ call address
158 ConstantPoolEntry::Access access;
159 if (FLAG_enable_embedded_constant_pool &&
160 IsConstantPoolLoadEnd(pc - 3 * kInstrSize, &access)) {
161 len = (access == ConstantPoolEntry::OVERFLOWED) ? 2 : 1;
163 len = kMovInstructionsNoConstantPool;
165 return pc - (len + 2) * kInstrSize;
169 Address Assembler::return_address_from_call_start(Address pc) {
171 ConstantPoolEntry::Access access;
172 if (FLAG_enable_embedded_constant_pool &&
173 IsConstantPoolLoadStart(pc, &access)) {
174 len = (access == ConstantPoolEntry::OVERFLOWED) ? 2 : 1;
176 len = kMovInstructionsNoConstantPool;
178 return pc + (len + 2) * kInstrSize;
182 Object* RelocInfo::target_object() {
183 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
184 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_));
188 Handle<Object> RelocInfo::target_object_handle(Assembler* origin) {
189 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
190 return Handle<Object>(
191 reinterpret_cast<Object**>(Assembler::target_address_at(pc_, host_)));
195 void RelocInfo::set_target_object(Object* target,
196 WriteBarrierMode write_barrier_mode,
197 ICacheFlushMode icache_flush_mode) {
198 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
199 Assembler::set_target_address_at(
200 pc_, host_, reinterpret_cast<Address>(target), icache_flush_mode);
201 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL &&
202 target->IsHeapObject()) {
203 host()->GetHeap()->incremental_marking()->RecordWrite(
204 host(), &Memory::Object_at(pc_), HeapObject::cast(target));
209 Address RelocInfo::target_external_reference() {
210 DCHECK(rmode_ == EXTERNAL_REFERENCE);
211 return Assembler::target_address_at(pc_, host_);
215 Address RelocInfo::target_runtime_entry(Assembler* origin) {
216 DCHECK(IsRuntimeEntry(rmode_));
217 return target_address();
221 void RelocInfo::set_target_runtime_entry(Address target,
222 WriteBarrierMode write_barrier_mode,
223 ICacheFlushMode icache_flush_mode) {
224 DCHECK(IsRuntimeEntry(rmode_));
225 if (target_address() != target)
226 set_target_address(target, write_barrier_mode, icache_flush_mode);
230 Handle<Cell> RelocInfo::target_cell_handle() {
231 DCHECK(rmode_ == RelocInfo::CELL);
232 Address address = Memory::Address_at(pc_);
233 return Handle<Cell>(reinterpret_cast<Cell**>(address));
237 Cell* RelocInfo::target_cell() {
238 DCHECK(rmode_ == RelocInfo::CELL);
239 return Cell::FromValueAddress(Memory::Address_at(pc_));
243 void RelocInfo::set_target_cell(Cell* cell, WriteBarrierMode write_barrier_mode,
244 ICacheFlushMode icache_flush_mode) {
245 DCHECK(rmode_ == RelocInfo::CELL);
246 Address address = cell->address() + Cell::kValueOffset;
247 Memory::Address_at(pc_) = address;
248 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
249 // TODO(1550) We are passing NULL as a slot because cell can never be on
250 // evacuation candidate.
251 host()->GetHeap()->incremental_marking()->RecordWrite(host(), NULL, cell);
256 static const int kNoCodeAgeInstructions =
257 FLAG_enable_embedded_constant_pool ? 7 : 6;
258 static const int kCodeAgingInstructions =
259 Assembler::kMovInstructionsNoConstantPool + 3;
260 static const int kNoCodeAgeSequenceInstructions =
261 ((kNoCodeAgeInstructions >= kCodeAgingInstructions)
262 ? kNoCodeAgeInstructions
263 : kCodeAgingInstructions);
264 static const int kNoCodeAgeSequenceNops =
265 (kNoCodeAgeSequenceInstructions - kNoCodeAgeInstructions);
266 static const int kCodeAgingSequenceNops =
267 (kNoCodeAgeSequenceInstructions - kCodeAgingInstructions);
268 static const int kCodeAgingTargetDelta = 1 * Assembler::kInstrSize;
269 static const int kNoCodeAgeSequenceLength =
270 (kNoCodeAgeSequenceInstructions * Assembler::kInstrSize);
273 Handle<Object> RelocInfo::code_age_stub_handle(Assembler* origin) {
274 UNREACHABLE(); // This should never be reached on PPC.
275 return Handle<Object>();
279 Code* RelocInfo::code_age_stub() {
280 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
281 return Code::GetCodeFromTargetAddress(
282 Assembler::target_address_at(pc_ + kCodeAgingTargetDelta, host_));
286 void RelocInfo::set_code_age_stub(Code* stub,
287 ICacheFlushMode icache_flush_mode) {
288 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
289 Assembler::set_target_address_at(pc_ + kCodeAgingTargetDelta, host_,
290 stub->instruction_start(),
295 Address RelocInfo::debug_call_address() {
296 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
297 return Assembler::target_address_at(pc_, host_);
301 void RelocInfo::set_debug_call_address(Address target) {
302 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
303 Assembler::set_target_address_at(pc_, host_, target);
304 if (host() != NULL) {
305 Object* target_code = Code::GetCodeFromTargetAddress(target);
306 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
307 host(), this, HeapObject::cast(target_code));
312 void RelocInfo::WipeOut() {
313 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) ||
314 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) ||
315 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_));
316 if (IsInternalReference(rmode_)) {
318 Memory::Address_at(pc_) = NULL;
319 } else if (IsInternalReferenceEncoded(rmode_)) {
321 // 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(pc_, host_, NULL);
329 bool RelocInfo::IsPatchedReturnSequence() {
331 // The patched return sequence is defined by
332 // BreakLocation::SetDebugBreakAtReturn()
335 Instr instr0 = Assembler::instr_at(pc_);
336 Instr instr1 = Assembler::instr_at(pc_ + 1 * Assembler::kInstrSize);
337 #if V8_TARGET_ARCH_PPC64
338 Instr instr3 = Assembler::instr_at(pc_ + (3 * Assembler::kInstrSize));
339 Instr instr4 = Assembler::instr_at(pc_ + (4 * Assembler::kInstrSize));
340 Instr binstr = Assembler::instr_at(pc_ + (7 * Assembler::kInstrSize));
342 Instr binstr = Assembler::instr_at(pc_ + 4 * Assembler::kInstrSize);
344 bool patched_return =
345 ((instr0 & kOpcodeMask) == ADDIS && (instr1 & kOpcodeMask) == ORI &&
346 #if V8_TARGET_ARCH_PPC64
347 (instr3 & kOpcodeMask) == ORIS && (instr4 & kOpcodeMask) == ORI &&
349 (binstr == 0x7d821008)); // twge r2, r2
351 // printf("IsPatchedReturnSequence: %d\n", patched_return);
352 return patched_return;
356 bool RelocInfo::IsPatchedDebugBreakSlotSequence() {
357 Instr current_instr = Assembler::instr_at(pc_);
358 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP);
362 void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) {
363 RelocInfo::Mode mode = rmode();
364 if (mode == RelocInfo::EMBEDDED_OBJECT) {
365 visitor->VisitEmbeddedPointer(this);
366 } else if (RelocInfo::IsCodeTarget(mode)) {
367 visitor->VisitCodeTarget(this);
368 } else if (mode == RelocInfo::CELL) {
369 visitor->VisitCell(this);
370 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
371 visitor->VisitExternalReference(this);
372 } else if (mode == RelocInfo::INTERNAL_REFERENCE ||
373 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) {
374 visitor->VisitInternalReference(this);
375 } else if (RelocInfo::IsCodeAgeSequence(mode)) {
376 visitor->VisitCodeAgeSequence(this);
377 } else if (RelocInfo::IsDebugBreakSlot(mode) &&
378 IsPatchedDebugBreakSlotSequence()) {
379 visitor->VisitDebugTarget(this);
380 } else if (IsRuntimeEntry(mode)) {
381 visitor->VisitRuntimeEntry(this);
386 template <typename StaticVisitor>
387 void RelocInfo::Visit(Heap* heap) {
388 RelocInfo::Mode mode = rmode();
389 if (mode == RelocInfo::EMBEDDED_OBJECT) {
390 StaticVisitor::VisitEmbeddedPointer(heap, this);
391 } else if (RelocInfo::IsCodeTarget(mode)) {
392 StaticVisitor::VisitCodeTarget(heap, this);
393 } else if (mode == RelocInfo::CELL) {
394 StaticVisitor::VisitCell(heap, this);
395 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
396 StaticVisitor::VisitExternalReference(this);
397 } else if (mode == RelocInfo::INTERNAL_REFERENCE ||
398 mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) {
399 StaticVisitor::VisitInternalReference(this);
400 } else if (RelocInfo::IsCodeAgeSequence(mode)) {
401 StaticVisitor::VisitCodeAgeSequence(heap, this);
402 } else if (RelocInfo::IsDebugBreakSlot(mode) &&
403 IsPatchedDebugBreakSlotSequence()) {
404 StaticVisitor::VisitDebugTarget(heap, this);
405 } else if (IsRuntimeEntry(mode)) {
406 StaticVisitor::VisitRuntimeEntry(this);
410 Operand::Operand(intptr_t immediate, RelocInfo::Mode rmode) {
416 Operand::Operand(const ExternalReference& f) {
418 imm_ = reinterpret_cast<intptr_t>(f.address());
419 rmode_ = RelocInfo::EXTERNAL_REFERENCE;
422 Operand::Operand(Smi* value) {
424 imm_ = reinterpret_cast<intptr_t>(value);
425 rmode_ = kRelocInfo_NONEPTR;
428 Operand::Operand(Register rm) {
430 rmode_ = kRelocInfo_NONEPTR; // PPC -why doesn't ARM do this?
433 void Assembler::CheckBuffer() {
434 if (buffer_space() <= kGap) {
439 void Assembler::TrackBranch() {
440 DCHECK(!trampoline_emitted_);
441 int count = tracked_branch_count_++;
443 // We leave space (kMaxBlockTrampolineSectionSize)
444 // for BlockTrampolinePoolScope buffer.
445 next_trampoline_check_ =
446 pc_offset() + kMaxCondBranchReach - kMaxBlockTrampolineSectionSize;
448 next_trampoline_check_ -= kTrampolineSlotsSize;
452 void Assembler::UntrackBranch() {
453 DCHECK(!trampoline_emitted_);
454 DCHECK(tracked_branch_count_ > 0);
455 int count = --tracked_branch_count_;
458 next_trampoline_check_ = kMaxInt;
460 next_trampoline_check_ += kTrampolineSlotsSize;
464 void Assembler::CheckTrampolinePoolQuick() {
465 if (pc_offset() >= next_trampoline_check_) {
466 CheckTrampolinePool();
470 void Assembler::emit(Instr x) {
472 *reinterpret_cast<Instr*>(pc_) = x;
474 CheckTrampolinePoolQuick();
477 bool Operand::is_reg() const { return rm_.is_valid(); }
480 // Fetch the 32bit value from the FIXED_SEQUENCE lis/ori
481 Address Assembler::target_address_at(Address pc, Address constant_pool) {
482 if (FLAG_enable_embedded_constant_pool && constant_pool) {
483 ConstantPoolEntry::Access access;
484 if (IsConstantPoolLoadStart(pc, &access))
485 return Memory::Address_at(target_constant_pool_address_at(
486 pc, constant_pool, access, ConstantPoolEntry::INTPTR));
489 Instr instr1 = instr_at(pc);
490 Instr instr2 = instr_at(pc + kInstrSize);
491 // Interpret 2 instructions generated by lis/ori
492 if (IsLis(instr1) && IsOri(instr2)) {
493 #if V8_TARGET_ARCH_PPC64
494 Instr instr4 = instr_at(pc + (3 * kInstrSize));
495 Instr instr5 = instr_at(pc + (4 * kInstrSize));
496 // Assemble the 64 bit value.
497 uint64_t hi = (static_cast<uint32_t>((instr1 & kImm16Mask) << 16) |
498 static_cast<uint32_t>(instr2 & kImm16Mask));
499 uint64_t lo = (static_cast<uint32_t>((instr4 & kImm16Mask) << 16) |
500 static_cast<uint32_t>(instr5 & kImm16Mask));
501 return reinterpret_cast<Address>((hi << 32) | lo);
503 // Assemble the 32 bit value.
504 return reinterpret_cast<Address>(((instr1 & kImm16Mask) << 16) |
505 (instr2 & kImm16Mask));
514 #if V8_TARGET_ARCH_PPC64
515 const int kLoadIntptrOpcode = LD;
517 const int kLoadIntptrOpcode = LWZ;
520 // Constant pool load sequence detection:
521 // 1) REGULAR access:
522 // load <dst>, kConstantPoolRegister + <offset>
524 // 2) OVERFLOWED access:
525 // addis <scratch>, kConstantPoolRegister, <offset_high>
526 // load <dst>, <scratch> + <offset_low>
527 bool Assembler::IsConstantPoolLoadStart(Address pc,
528 ConstantPoolEntry::Access* access) {
529 Instr instr = instr_at(pc);
530 int opcode = instr & kOpcodeMask;
531 if (!GetRA(instr).is(kConstantPoolRegister)) return false;
532 bool overflowed = (opcode == ADDIS);
535 opcode = instr_at(pc + kInstrSize) & kOpcodeMask;
537 DCHECK(opcode == kLoadIntptrOpcode || opcode == LFD);
540 *access = (overflowed ? ConstantPoolEntry::OVERFLOWED
541 : ConstantPoolEntry::REGULAR);
547 bool Assembler::IsConstantPoolLoadEnd(Address pc,
548 ConstantPoolEntry::Access* access) {
549 Instr instr = instr_at(pc);
550 int opcode = instr & kOpcodeMask;
551 bool overflowed = false;
552 if (!(opcode == kLoadIntptrOpcode || opcode == LFD)) return false;
553 if (!GetRA(instr).is(kConstantPoolRegister)) {
554 instr = instr_at(pc - kInstrSize);
555 opcode = instr & kOpcodeMask;
556 if ((opcode != ADDIS) || !GetRA(instr).is(kConstantPoolRegister)) {
562 *access = (overflowed ? ConstantPoolEntry::OVERFLOWED
563 : ConstantPoolEntry::REGULAR);
569 int Assembler::GetConstantPoolOffset(Address pc,
570 ConstantPoolEntry::Access access,
571 ConstantPoolEntry::Type type) {
572 bool overflowed = (access == ConstantPoolEntry::OVERFLOWED);
574 ConstantPoolEntry::Access access_check =
575 static_cast<ConstantPoolEntry::Access>(-1);
576 DCHECK(IsConstantPoolLoadStart(pc, &access_check));
577 DCHECK(access_check == access);
581 offset = (instr_at(pc) & kImm16Mask) << 16;
582 offset += SIGN_EXT_IMM16(instr_at(pc + kInstrSize) & kImm16Mask);
583 DCHECK(!is_int16(offset));
585 offset = SIGN_EXT_IMM16((instr_at(pc) & kImm16Mask));
591 void Assembler::PatchConstantPoolAccessInstruction(
592 int pc_offset, int offset, ConstantPoolEntry::Access access,
593 ConstantPoolEntry::Type type) {
594 Address pc = buffer_ + pc_offset;
595 bool overflowed = (access == ConstantPoolEntry::OVERFLOWED);
596 CHECK(overflowed != is_int16(offset));
598 ConstantPoolEntry::Access access_check =
599 static_cast<ConstantPoolEntry::Access>(-1);
600 DCHECK(IsConstantPoolLoadStart(pc, &access_check));
601 DCHECK(access_check == access);
604 int hi_word = static_cast<int>(offset >> 16);
605 int lo_word = static_cast<int>(offset & 0xffff);
606 if (lo_word & 0x8000) hi_word++;
608 Instr instr1 = instr_at(pc);
609 Instr instr2 = instr_at(pc + kInstrSize);
610 instr1 &= ~kImm16Mask;
611 instr1 |= (hi_word & kImm16Mask);
612 instr2 &= ~kImm16Mask;
613 instr2 |= (lo_word & kImm16Mask);
614 instr_at_put(pc, instr1);
615 instr_at_put(pc + kInstrSize, instr2);
617 Instr instr = instr_at(pc);
618 instr &= ~kImm16Mask;
619 instr |= (offset & kImm16Mask);
620 instr_at_put(pc, instr);
625 Address Assembler::target_constant_pool_address_at(
626 Address pc, Address constant_pool, ConstantPoolEntry::Access access,
627 ConstantPoolEntry::Type type) {
628 Address addr = constant_pool;
630 addr += GetConstantPoolOffset(pc, access, type);
635 // This sets the branch destination (which gets loaded at the call address).
636 // This is for calls and branches within generated code. The serializer
637 // has already deserialized the mov instructions etc.
638 // There is a FIXED_SEQUENCE assumption here
639 void Assembler::deserialization_set_special_target_at(
640 Address instruction_payload, Code* code, Address target) {
641 set_target_address_at(instruction_payload, code, target);
645 void Assembler::deserialization_set_target_internal_reference_at(
646 Address pc, Address target, RelocInfo::Mode mode) {
647 if (RelocInfo::IsInternalReferenceEncoded(mode)) {
649 set_target_address_at(pc, code, target, SKIP_ICACHE_FLUSH);
651 Memory::Address_at(pc) = target;
656 // This code assumes the FIXED_SEQUENCE of lis/ori
657 void Assembler::set_target_address_at(Address pc, Address constant_pool,
659 ICacheFlushMode icache_flush_mode) {
660 if (FLAG_enable_embedded_constant_pool && constant_pool) {
661 ConstantPoolEntry::Access access;
662 if (IsConstantPoolLoadStart(pc, &access)) {
663 Memory::Address_at(target_constant_pool_address_at(
664 pc, constant_pool, access, ConstantPoolEntry::INTPTR)) = target;
669 Instr instr1 = instr_at(pc);
670 Instr instr2 = instr_at(pc + kInstrSize);
671 // Interpret 2 instructions generated by lis/ori
672 if (IsLis(instr1) && IsOri(instr2)) {
673 #if V8_TARGET_ARCH_PPC64
674 Instr instr4 = instr_at(pc + (3 * kInstrSize));
675 Instr instr5 = instr_at(pc + (4 * kInstrSize));
676 // Needs to be fixed up when mov changes to handle 64-bit values.
677 uint32_t* p = reinterpret_cast<uint32_t*>(pc);
678 uintptr_t itarget = reinterpret_cast<uintptr_t>(target);
680 instr5 &= ~kImm16Mask;
681 instr5 |= itarget & kImm16Mask;
682 itarget = itarget >> 16;
684 instr4 &= ~kImm16Mask;
685 instr4 |= itarget & kImm16Mask;
686 itarget = itarget >> 16;
688 instr2 &= ~kImm16Mask;
689 instr2 |= itarget & kImm16Mask;
690 itarget = itarget >> 16;
692 instr1 &= ~kImm16Mask;
693 instr1 |= itarget & kImm16Mask;
694 itarget = itarget >> 16;
700 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
701 CpuFeatures::FlushICache(p, 5 * kInstrSize);
704 uint32_t* p = reinterpret_cast<uint32_t*>(pc);
705 uint32_t itarget = reinterpret_cast<uint32_t>(target);
706 int lo_word = itarget & kImm16Mask;
707 int hi_word = itarget >> 16;
708 instr1 &= ~kImm16Mask;
710 instr2 &= ~kImm16Mask;
715 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
716 CpuFeatures::FlushICache(p, 2 * kInstrSize);
724 } // namespace v8::internal
726 #endif // V8_PPC_ASSEMBLER_PPC_INL_H_