blob: 400d5436a19fddf6c0abbdf6134d5b66f6237523 [file] [log] [blame]
Ben Murdochda12d292016-06-02 14:46:10 +01001// Copyright (c) 1994-2006 Sun Microsystems Inc.
2// All Rights Reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions
6// are met:
7//
8// - Redistributions of source code must retain the above copyright notice,
9// this list of conditions and the following disclaimer.
10//
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
14// distribution.
15//
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.
19//
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.
32
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.
36
37#ifndef V8_S390_ASSEMBLER_S390_INL_H_
38#define V8_S390_ASSEMBLER_S390_INL_H_
39
40#include "src/s390/assembler-s390.h"
41
42#include "src/assembler.h"
43#include "src/debug/debug.h"
44
45namespace v8 {
46namespace internal {
47
48bool CpuFeatures::SupportsCrankshaft() { return true; }
49
50void RelocInfo::apply(intptr_t delta) {
51 // Absolute code pointer inside code object moves with the code object.
52 if (IsInternalReference(rmode_)) {
53 // Jump table entry
54 Address target = Memory::Address_at(pc_);
55 Memory::Address_at(pc_) = target + delta;
56 } else if (IsCodeTarget(rmode_)) {
57 SixByteInstr instr =
58 Instruction::InstructionBits(reinterpret_cast<const byte*>(pc_));
59 int32_t dis = static_cast<int32_t>(instr & 0xFFFFFFFF) * 2 // halfwords
60 - static_cast<int32_t>(delta);
61 instr >>= 32; // Clear the 4-byte displacement field.
62 instr <<= 32;
63 instr |= static_cast<uint32_t>(dis / 2);
64 Instruction::SetInstructionBits<SixByteInstr>(reinterpret_cast<byte*>(pc_),
65 instr);
66 } else {
67 // mov sequence
68 DCHECK(IsInternalReferenceEncoded(rmode_));
69 Address target = Assembler::target_address_at(pc_, host_);
70 Assembler::set_target_address_at(isolate_, pc_, host_, target + delta,
71 SKIP_ICACHE_FLUSH);
72 }
73}
74
75Address RelocInfo::target_internal_reference() {
76 if (IsInternalReference(rmode_)) {
77 // Jump table entry
78 return Memory::Address_at(pc_);
79 } else {
80 // mov sequence
81 DCHECK(IsInternalReferenceEncoded(rmode_));
82 return Assembler::target_address_at(pc_, host_);
83 }
84}
85
86Address RelocInfo::target_internal_reference_address() {
87 DCHECK(IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_));
88 return reinterpret_cast<Address>(pc_);
89}
90
91Address RelocInfo::target_address() {
92 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
93 return Assembler::target_address_at(pc_, host_);
94}
95
96Address RelocInfo::wasm_memory_reference() {
97 DCHECK(IsWasmMemoryReference(rmode_));
98 return Assembler::target_address_at(pc_, host_);
99}
100
101Address RelocInfo::target_address_address() {
102 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) ||
103 rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE);
104
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
113 // and written.
114 return reinterpret_cast<Address>(pc_);
115}
116
117Address RelocInfo::constant_pool_entry_address() {
118 UNREACHABLE();
119 return NULL;
120}
121
122int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; }
123
124void RelocInfo::set_target_address(Address target,
125 WriteBarrierMode write_barrier_mode,
126 ICacheFlushMode icache_flush_mode) {
127 DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
128 Assembler::set_target_address_at(isolate_, pc_, host_, target,
129 icache_flush_mode);
130 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL &&
131 IsCodeTarget(rmode_)) {
132 Object* target_code = Code::GetCodeFromTargetAddress(target);
133 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
134 host(), this, HeapObject::cast(target_code));
135 }
136}
137
138Address Assembler::target_address_from_return_address(Address pc) {
139 // Returns the address of the call target from the return address that will
140 // be returned to after a call.
141 // Sequence is:
142 // BRASL r14, RI
143 return pc - kCallTargetAddressOffset;
144}
145
146Address Assembler::return_address_from_call_start(Address pc) {
147 // Sequence is:
148 // BRASL r14, RI
149 return pc + kCallTargetAddressOffset;
150}
151
152Handle<Object> Assembler::code_target_object_handle_at(Address pc) {
153 SixByteInstr instr =
154 Instruction::InstructionBits(reinterpret_cast<const byte*>(pc));
155 int index = instr & 0xFFFFFFFF;
156 return code_targets_[index];
157}
158
159void RelocInfo::update_wasm_memory_reference(
160 Address old_base, Address new_base, size_t old_size, size_t new_size,
161 ICacheFlushMode icache_flush_mode) {
162 DCHECK(IsWasmMemoryReference(rmode_));
163 DCHECK(old_base <= wasm_memory_reference() &&
164 wasm_memory_reference() < old_base + old_size);
165 Address updated_reference = new_base + (wasm_memory_reference() - old_base);
166 DCHECK(new_base <= updated_reference &&
167 updated_reference < new_base + new_size);
168 Assembler::set_target_address_at(isolate_, pc_, host_, updated_reference,
169 icache_flush_mode);
170}
171
172Object* RelocInfo::target_object() {
173 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
174 return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_));
175}
176
177Handle<Object> RelocInfo::target_object_handle(Assembler* origin) {
178 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
179 if (rmode_ == EMBEDDED_OBJECT) {
180 return Handle<Object>(
181 reinterpret_cast<Object**>(Assembler::target_address_at(pc_, host_)));
182 } else {
183 return origin->code_target_object_handle_at(pc_);
184 }
185}
186
187void RelocInfo::set_target_object(Object* target,
188 WriteBarrierMode write_barrier_mode,
189 ICacheFlushMode icache_flush_mode) {
190 DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
191 Assembler::set_target_address_at(isolate_, pc_, host_,
192 reinterpret_cast<Address>(target),
193 icache_flush_mode);
194 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL &&
195 target->IsHeapObject()) {
196 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
197 host(), this, HeapObject::cast(target));
198 }
199}
200
201Address RelocInfo::target_external_reference() {
202 DCHECK(rmode_ == EXTERNAL_REFERENCE);
203 return Assembler::target_address_at(pc_, host_);
204}
205
206Address RelocInfo::target_runtime_entry(Assembler* origin) {
207 DCHECK(IsRuntimeEntry(rmode_));
208 return target_address();
209}
210
211void RelocInfo::set_target_runtime_entry(Address target,
212 WriteBarrierMode write_barrier_mode,
213 ICacheFlushMode icache_flush_mode) {
214 DCHECK(IsRuntimeEntry(rmode_));
215 if (target_address() != target)
216 set_target_address(target, write_barrier_mode, icache_flush_mode);
217}
218
219Handle<Cell> RelocInfo::target_cell_handle() {
220 DCHECK(rmode_ == RelocInfo::CELL);
221 Address address = Memory::Address_at(pc_);
222 return Handle<Cell>(reinterpret_cast<Cell**>(address));
223}
224
225Cell* RelocInfo::target_cell() {
226 DCHECK(rmode_ == RelocInfo::CELL);
227 return Cell::FromValueAddress(Memory::Address_at(pc_));
228}
229
230void RelocInfo::set_target_cell(Cell* cell, WriteBarrierMode write_barrier_mode,
231 ICacheFlushMode icache_flush_mode) {
232 DCHECK(rmode_ == RelocInfo::CELL);
233 Address address = cell->address() + Cell::kValueOffset;
234 Memory::Address_at(pc_) = address;
235 if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) {
236 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(host(), this,
237 cell);
238 }
239}
240
241#if V8_TARGET_ARCH_S390X
242// NOP(2byte) + PUSH + MOV + BASR =
243// NOP + LAY + STG + IIHF + IILF + BASR
244static const int kCodeAgingSequenceLength = 28;
245static const int kCodeAgingTargetDelta = 14; // Jump past NOP + PUSH to IIHF
246 // LAY + 4 * STG + LA
247static const int kNoCodeAgeSequenceLength = 34;
248#else
249#if (V8_HOST_ARCH_S390)
250// NOP + NILH + LAY + ST + IILF + BASR
251static const int kCodeAgingSequenceLength = 24;
252static const int kCodeAgingTargetDelta = 16; // Jump past NOP to IILF
253// NILH + LAY + 4 * ST + LA
254static const int kNoCodeAgeSequenceLength = 30;
255#else
256// NOP + LAY + ST + IILF + BASR
257static const int kCodeAgingSequenceLength = 20;
258static const int kCodeAgingTargetDelta = 12; // Jump past NOP to IILF
259// LAY + 4 * ST + LA
260static const int kNoCodeAgeSequenceLength = 26;
261#endif
262#endif
263
264Handle<Object> RelocInfo::code_age_stub_handle(Assembler* origin) {
265 UNREACHABLE(); // This should never be reached on S390.
266 return Handle<Object>();
267}
268
269Code* RelocInfo::code_age_stub() {
270 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
271 return Code::GetCodeFromTargetAddress(
272 Assembler::target_address_at(pc_ + kCodeAgingTargetDelta, host_));
273}
274
275void RelocInfo::set_code_age_stub(Code* stub,
276 ICacheFlushMode icache_flush_mode) {
277 DCHECK(rmode_ == RelocInfo::CODE_AGE_SEQUENCE);
278 Assembler::set_target_address_at(isolate_, pc_ + kCodeAgingTargetDelta, host_,
279 stub->instruction_start(),
280 icache_flush_mode);
281}
282
283Address RelocInfo::debug_call_address() {
284 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
285 return Assembler::target_address_at(pc_, host_);
286}
287
288void RelocInfo::set_debug_call_address(Address target) {
289 DCHECK(IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence());
290 Assembler::set_target_address_at(isolate_, pc_, host_, target);
291 if (host() != NULL) {
292 Object* target_code = Code::GetCodeFromTargetAddress(target);
293 host()->GetHeap()->incremental_marking()->RecordWriteIntoCode(
294 host(), this, HeapObject::cast(target_code));
295 }
296}
297
298void RelocInfo::WipeOut() {
299 DCHECK(IsEmbeddedObject(rmode_) || IsCodeTarget(rmode_) ||
300 IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) ||
301 IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_));
302 if (IsInternalReference(rmode_)) {
303 // Jump table entry
304 Memory::Address_at(pc_) = NULL;
305 } else if (IsInternalReferenceEncoded(rmode_)) {
306 // mov sequence
307 // Currently used only by deserializer, no need to flush.
308 Assembler::set_target_address_at(isolate_, pc_, host_, NULL,
309 SKIP_ICACHE_FLUSH);
310 } else {
311 Assembler::set_target_address_at(isolate_, pc_, host_, NULL);
312 }
313}
314
315void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) {
316 RelocInfo::Mode mode = rmode();
317 if (mode == RelocInfo::EMBEDDED_OBJECT) {
318 visitor->VisitEmbeddedPointer(this);
319 } else if (RelocInfo::IsCodeTarget(mode)) {
320 visitor->VisitCodeTarget(this);
321 } else if (mode == RelocInfo::CELL) {
322 visitor->VisitCell(this);
323 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
324 visitor->VisitExternalReference(this);
325 } else if (mode == RelocInfo::INTERNAL_REFERENCE) {
326 visitor->VisitInternalReference(this);
327 } else if (RelocInfo::IsCodeAgeSequence(mode)) {
328 visitor->VisitCodeAgeSequence(this);
329 } else if (RelocInfo::IsDebugBreakSlot(mode) &&
330 IsPatchedDebugBreakSlotSequence()) {
331 visitor->VisitDebugTarget(this);
332 } else if (IsRuntimeEntry(mode)) {
333 visitor->VisitRuntimeEntry(this);
334 }
335}
336
337template <typename StaticVisitor>
338void RelocInfo::Visit(Heap* heap) {
339 RelocInfo::Mode mode = rmode();
340 if (mode == RelocInfo::EMBEDDED_OBJECT) {
341 StaticVisitor::VisitEmbeddedPointer(heap, this);
342 } else if (RelocInfo::IsCodeTarget(mode)) {
343 StaticVisitor::VisitCodeTarget(heap, this);
344 } else if (mode == RelocInfo::CELL) {
345 StaticVisitor::VisitCell(heap, this);
346 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
347 StaticVisitor::VisitExternalReference(this);
348 } else if (mode == RelocInfo::INTERNAL_REFERENCE) {
349 StaticVisitor::VisitInternalReference(this);
350 } else if (RelocInfo::IsCodeAgeSequence(mode)) {
351 StaticVisitor::VisitCodeAgeSequence(heap, this);
352 } else if (RelocInfo::IsDebugBreakSlot(mode) &&
353 IsPatchedDebugBreakSlotSequence()) {
354 StaticVisitor::VisitDebugTarget(heap, this);
355 } else if (IsRuntimeEntry(mode)) {
356 StaticVisitor::VisitRuntimeEntry(this);
357 }
358}
359
360// Operand constructors
361Operand::Operand(intptr_t immediate, RelocInfo::Mode rmode) {
362 rm_ = no_reg;
363 imm_ = immediate;
364 rmode_ = rmode;
365}
366
367Operand::Operand(const ExternalReference& f) {
368 rm_ = no_reg;
369 imm_ = reinterpret_cast<intptr_t>(f.address());
370 rmode_ = RelocInfo::EXTERNAL_REFERENCE;
371}
372
373Operand::Operand(Smi* value) {
374 rm_ = no_reg;
375 imm_ = reinterpret_cast<intptr_t>(value);
376 rmode_ = kRelocInfo_NONEPTR;
377}
378
379Operand::Operand(Register rm) {
380 rm_ = rm;
381 rmode_ = kRelocInfo_NONEPTR; // S390 -why doesn't ARM do this?
382}
383
384void Assembler::CheckBuffer() {
385 if (buffer_space() <= kGap) {
386 GrowBuffer();
387 }
388}
389
390int32_t Assembler::emit_code_target(Handle<Code> target, RelocInfo::Mode rmode,
391 TypeFeedbackId ast_id) {
392 DCHECK(RelocInfo::IsCodeTarget(rmode));
393 if (rmode == RelocInfo::CODE_TARGET && !ast_id.IsNone()) {
394 SetRecordedAstId(ast_id);
395 RecordRelocInfo(RelocInfo::CODE_TARGET_WITH_ID);
396 } else {
397 RecordRelocInfo(rmode);
398 }
399
400 int current = code_targets_.length();
401 if (current > 0 && code_targets_.last().is_identical_to(target)) {
402 // Optimization if we keep jumping to the same code target.
403 current--;
404 } else {
405 code_targets_.Add(target);
406 }
407 return current;
408}
409
410// Helper to emit the binary encoding of a 2 byte instruction
411void Assembler::emit2bytes(uint16_t x) {
412 CheckBuffer();
413#if V8_TARGET_LITTLE_ENDIAN
414 // We need to emit instructions in big endian format as disassembler /
415 // simulator require the first byte of the instruction in order to decode
416 // the instruction length. Swap the bytes.
417 x = ((x & 0x00FF) << 8) | ((x & 0xFF00) >> 8);
418#endif
419 *reinterpret_cast<uint16_t*>(pc_) = x;
420 pc_ += 2;
421}
422
423// Helper to emit the binary encoding of a 4 byte instruction
424void Assembler::emit4bytes(uint32_t x) {
425 CheckBuffer();
426#if V8_TARGET_LITTLE_ENDIAN
427 // We need to emit instructions in big endian format as disassembler /
428 // simulator require the first byte of the instruction in order to decode
429 // the instruction length. Swap the bytes.
430 x = ((x & 0x000000FF) << 24) | ((x & 0x0000FF00) << 8) |
431 ((x & 0x00FF0000) >> 8) | ((x & 0xFF000000) >> 24);
432#endif
433 *reinterpret_cast<uint32_t*>(pc_) = x;
434 pc_ += 4;
435}
436
437// Helper to emit the binary encoding of a 6 byte instruction
438void Assembler::emit6bytes(uint64_t x) {
439 CheckBuffer();
440#if V8_TARGET_LITTLE_ENDIAN
441 // We need to emit instructions in big endian format as disassembler /
442 // simulator require the first byte of the instruction in order to decode
443 // the instruction length. Swap the bytes.
444 x = (static_cast<uint64_t>(x & 0xFF) << 40) |
445 (static_cast<uint64_t>((x >> 8) & 0xFF) << 32) |
446 (static_cast<uint64_t>((x >> 16) & 0xFF) << 24) |
447 (static_cast<uint64_t>((x >> 24) & 0xFF) << 16) |
448 (static_cast<uint64_t>((x >> 32) & 0xFF) << 8) |
449 (static_cast<uint64_t>((x >> 40) & 0xFF));
450 x |= (*reinterpret_cast<uint64_t*>(pc_) >> 48) << 48;
451#else
452 // We need to pad two bytes of zeros in order to get the 6-bytes
453 // stored from low address.
454 x = x << 16;
455 x |= *reinterpret_cast<uint64_t*>(pc_) & 0xFFFF;
456#endif
457 // It is safe to store 8-bytes, as CheckBuffer() guarantees we have kGap
458 // space left over.
459 *reinterpret_cast<uint64_t*>(pc_) = x;
460 pc_ += 6;
461}
462
463bool Operand::is_reg() const { return rm_.is_valid(); }
464
465// Fetch the 32bit value from the FIXED_SEQUENCE IIHF / IILF
466Address Assembler::target_address_at(Address pc, Address constant_pool) {
467 // S390 Instruction!
468 // We want to check for instructions generated by Asm::mov()
469 Opcode op1 = Instruction::S390OpcodeValue(reinterpret_cast<const byte*>(pc));
470 SixByteInstr instr_1 =
471 Instruction::InstructionBits(reinterpret_cast<const byte*>(pc));
472
473 if (BRASL == op1 || BRCL == op1) {
474 int32_t dis = static_cast<int32_t>(instr_1 & 0xFFFFFFFF) * 2;
475 return reinterpret_cast<Address>(reinterpret_cast<uint64_t>(pc) + dis);
476 }
477
478#if V8_TARGET_ARCH_S390X
479 int instr1_length =
480 Instruction::InstructionLength(reinterpret_cast<const byte*>(pc));
481 Opcode op2 = Instruction::S390OpcodeValue(
482 reinterpret_cast<const byte*>(pc + instr1_length));
483 SixByteInstr instr_2 = Instruction::InstructionBits(
484 reinterpret_cast<const byte*>(pc + instr1_length));
485 // IIHF for hi_32, IILF for lo_32
486 if (IIHF == op1 && IILF == op2) {
487 return reinterpret_cast<Address>(((instr_1 & 0xFFFFFFFF) << 32) |
488 ((instr_2 & 0xFFFFFFFF)));
489 }
490#else
491 // IILF loads 32-bits
492 if (IILF == op1 || CFI == op1) {
493 return reinterpret_cast<Address>((instr_1 & 0xFFFFFFFF));
494 }
495#endif
496
497 UNIMPLEMENTED();
498 return (Address)0;
499}
500
501// This sets the branch destination (which gets loaded at the call address).
502// This is for calls and branches within generated code. The serializer
503// has already deserialized the mov instructions etc.
504// There is a FIXED_SEQUENCE assumption here
505void Assembler::deserialization_set_special_target_at(
506 Isolate* isolate, Address instruction_payload, Code* code, Address target) {
507 set_target_address_at(isolate, instruction_payload, code, target);
508}
509
510void Assembler::deserialization_set_target_internal_reference_at(
511 Isolate* isolate, Address pc, Address target, RelocInfo::Mode mode) {
512 if (RelocInfo::IsInternalReferenceEncoded(mode)) {
513 Code* code = NULL;
514 set_target_address_at(isolate, pc, code, target, SKIP_ICACHE_FLUSH);
515 } else {
516 Memory::Address_at(pc) = target;
517 }
518}
519
520// This code assumes the FIXED_SEQUENCE of IIHF/IILF
521void Assembler::set_target_address_at(Isolate* isolate, Address pc,
522 Address constant_pool, Address target,
523 ICacheFlushMode icache_flush_mode) {
524 // Check for instructions generated by Asm::mov()
525 Opcode op1 = Instruction::S390OpcodeValue(reinterpret_cast<const byte*>(pc));
526 SixByteInstr instr_1 =
527 Instruction::InstructionBits(reinterpret_cast<const byte*>(pc));
528 bool patched = false;
529
530 if (BRASL == op1 || BRCL == op1) {
531 instr_1 >>= 32; // Zero out the lower 32-bits
532 instr_1 <<= 32;
533 int32_t halfwords = (target - pc) / 2; // number of halfwords
534 instr_1 |= static_cast<uint32_t>(halfwords);
535 Instruction::SetInstructionBits<SixByteInstr>(reinterpret_cast<byte*>(pc),
536 instr_1);
537 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
538 Assembler::FlushICache(isolate, pc, 6);
539 }
540 patched = true;
541 } else {
542#if V8_TARGET_ARCH_S390X
543 int instr1_length =
544 Instruction::InstructionLength(reinterpret_cast<const byte*>(pc));
545 Opcode op2 = Instruction::S390OpcodeValue(
546 reinterpret_cast<const byte*>(pc + instr1_length));
547 SixByteInstr instr_2 = Instruction::InstructionBits(
548 reinterpret_cast<const byte*>(pc + instr1_length));
549 // IIHF for hi_32, IILF for lo_32
550 if (IIHF == op1 && IILF == op2) {
551 // IIHF
552 instr_1 >>= 32; // Zero out the lower 32-bits
553 instr_1 <<= 32;
554 instr_1 |= reinterpret_cast<uint64_t>(target) >> 32;
555
556 Instruction::SetInstructionBits<SixByteInstr>(reinterpret_cast<byte*>(pc),
557 instr_1);
558
559 // IILF
560 instr_2 >>= 32;
561 instr_2 <<= 32;
562 instr_2 |= reinterpret_cast<uint64_t>(target) & 0xFFFFFFFF;
563
564 Instruction::SetInstructionBits<SixByteInstr>(
565 reinterpret_cast<byte*>(pc + instr1_length), instr_2);
566 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
567 Assembler::FlushICache(isolate, pc, 12);
568 }
569 patched = true;
570 }
571#else
572 // IILF loads 32-bits
573 if (IILF == op1 || CFI == op1) {
574 instr_1 >>= 32; // Zero out the lower 32-bits
575 instr_1 <<= 32;
576 instr_1 |= reinterpret_cast<uint32_t>(target);
577
578 Instruction::SetInstructionBits<SixByteInstr>(reinterpret_cast<byte*>(pc),
579 instr_1);
580 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
581 Assembler::FlushICache(isolate, pc, 6);
582 }
583 patched = true;
584 }
585#endif
586 }
587 if (!patched) UNREACHABLE();
588}
589
590} // namespace internal
591} // namespace v8
592
593#endif // V8_S390_ASSEMBLER_S390_INL_H_