• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/codegen/reloc-info.h"
6 
7 #include "src/codegen/assembler-inl.h"
8 #include "src/codegen/code-reference.h"
9 #include "src/codegen/external-reference-encoder.h"
10 #include "src/deoptimizer/deoptimize-reason.h"
11 #include "src/deoptimizer/deoptimizer.h"
12 #include "src/heap/heap-write-barrier-inl.h"
13 #include "src/objects/code-inl.h"
14 #include "src/snapshot/embedded/embedded-data.h"
15 
16 namespace v8 {
17 namespace internal {
18 
19 const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING";
20 
21 // -----------------------------------------------------------------------------
22 // Implementation of RelocInfoWriter and RelocIterator
23 //
24 // Relocation information is written backwards in memory, from high addresses
25 // towards low addresses, byte by byte.  Therefore, in the encodings listed
26 // below, the first byte listed it at the highest address, and successive
27 // bytes in the record are at progressively lower addresses.
28 //
29 // Encoding
30 //
31 // The most common modes are given single-byte encodings.  Also, it is
32 // easy to identify the type of reloc info and skip unwanted modes in
33 // an iteration.
34 //
35 // The encoding relies on the fact that there are fewer than 14
36 // different relocation modes using standard non-compact encoding.
37 //
38 // The first byte of a relocation record has a tag in its low 2 bits:
39 // Here are the record schemes, depending on the low tag and optional higher
40 // tags.
41 //
42 // Low tag:
43 //   00: embedded_object:      [6-bit pc delta] 00
44 //
45 //   01: code_target:          [6-bit pc delta] 01
46 //
47 //   10: wasm_stub_call:       [6-bit pc delta] 10
48 //
49 //   11: long_record           [6 bit reloc mode] 11
50 //                             followed by pc delta
51 //                             followed by optional data depending on type.
52 //
53 //  If a pc delta exceeds 6 bits, it is split into a remainder that fits into
54 //  6 bits and a part that does not. The latter is encoded as a long record
55 //  with PC_JUMP as pseudo reloc info mode. The former is encoded as part of
56 //  the following record in the usual way. The long pc jump record has variable
57 //  length:
58 //               pc-jump:        [PC_JUMP] 11
59 //                               [7 bits data] 0
60 //                                  ...
61 //                               [7 bits data] 1
62 //               (Bits 6..31 of pc delta, with leading zeroes
63 //                dropped, and last non-zero chunk tagged with 1.)
64 
65 const int kTagBits = 2;
66 const int kTagMask = (1 << kTagBits) - 1;
67 const int kLongTagBits = 6;
68 
69 const int kEmbeddedObjectTag = 0;
70 const int kCodeTargetTag = 1;
71 const int kWasmStubCallTag = 2;
72 const int kDefaultTag = 3;
73 
74 const int kSmallPCDeltaBits = kBitsPerByte - kTagBits;
75 const int kSmallPCDeltaMask = (1 << kSmallPCDeltaBits) - 1;
76 const int RelocInfo::kMaxSmallPCDelta = kSmallPCDeltaMask;
77 
78 const int kChunkBits = 7;
79 const int kChunkMask = (1 << kChunkBits) - 1;
80 const int kLastChunkTagBits = 1;
81 const int kLastChunkTagMask = 1;
82 const int kLastChunkTag = 1;
83 
WriteLongPCJump(uint32_t pc_delta)84 uint32_t RelocInfoWriter::WriteLongPCJump(uint32_t pc_delta) {
85   // Return if the pc_delta can fit in kSmallPCDeltaBits bits.
86   // Otherwise write a variable length PC jump for the bits that do
87   // not fit in the kSmallPCDeltaBits bits.
88   if (is_uintn(pc_delta, kSmallPCDeltaBits)) return pc_delta;
89   WriteMode(RelocInfo::PC_JUMP);
90   uint32_t pc_jump = pc_delta >> kSmallPCDeltaBits;
91   DCHECK_GT(pc_jump, 0);
92   // Write kChunkBits size chunks of the pc_jump.
93   for (; pc_jump > 0; pc_jump = pc_jump >> kChunkBits) {
94     byte b = pc_jump & kChunkMask;
95     *--pos_ = b << kLastChunkTagBits;
96   }
97   // Tag the last chunk so it can be identified.
98   *pos_ = *pos_ | kLastChunkTag;
99   // Return the remaining kSmallPCDeltaBits of the pc_delta.
100   return pc_delta & kSmallPCDeltaMask;
101 }
102 
WriteShortTaggedPC(uint32_t pc_delta,int tag)103 void RelocInfoWriter::WriteShortTaggedPC(uint32_t pc_delta, int tag) {
104   // Write a byte of tagged pc-delta, possibly preceded by an explicit pc-jump.
105   pc_delta = WriteLongPCJump(pc_delta);
106   *--pos_ = pc_delta << kTagBits | tag;
107 }
108 
WriteShortData(intptr_t data_delta)109 void RelocInfoWriter::WriteShortData(intptr_t data_delta) {
110   *--pos_ = static_cast<byte>(data_delta);
111 }
112 
WriteMode(RelocInfo::Mode rmode)113 void RelocInfoWriter::WriteMode(RelocInfo::Mode rmode) {
114   STATIC_ASSERT(RelocInfo::NUMBER_OF_MODES <= (1 << kLongTagBits));
115   *--pos_ = static_cast<int>((rmode << kTagBits) | kDefaultTag);
116 }
117 
WriteModeAndPC(uint32_t pc_delta,RelocInfo::Mode rmode)118 void RelocInfoWriter::WriteModeAndPC(uint32_t pc_delta, RelocInfo::Mode rmode) {
119   // Write two-byte tagged pc-delta, possibly preceded by var. length pc-jump.
120   pc_delta = WriteLongPCJump(pc_delta);
121   WriteMode(rmode);
122   *--pos_ = pc_delta;
123 }
124 
WriteIntData(int number)125 void RelocInfoWriter::WriteIntData(int number) {
126   for (int i = 0; i < kIntSize; i++) {
127     *--pos_ = static_cast<byte>(number);
128     // Signed right shift is arithmetic shift.  Tested in test-utils.cc.
129     number = number >> kBitsPerByte;
130   }
131 }
132 
WriteData(intptr_t data_delta)133 void RelocInfoWriter::WriteData(intptr_t data_delta) {
134   for (int i = 0; i < kIntptrSize; i++) {
135     *--pos_ = static_cast<byte>(data_delta);
136     // Signed right shift is arithmetic shift.  Tested in test-utils.cc.
137     data_delta = data_delta >> kBitsPerByte;
138   }
139 }
140 
Write(const RelocInfo * rinfo)141 void RelocInfoWriter::Write(const RelocInfo* rinfo) {
142   RelocInfo::Mode rmode = rinfo->rmode();
143 #ifdef DEBUG
144   byte* begin_pos = pos_;
145 #endif
146   DCHECK(rinfo->rmode() < RelocInfo::NUMBER_OF_MODES);
147   DCHECK_GE(rinfo->pc() - reinterpret_cast<Address>(last_pc_), 0);
148   // Use unsigned delta-encoding for pc.
149   uint32_t pc_delta =
150       static_cast<uint32_t>(rinfo->pc() - reinterpret_cast<Address>(last_pc_));
151 
152   // The two most common modes are given small tags, and usually fit in a byte.
153   if (rmode == RelocInfo::FULL_EMBEDDED_OBJECT) {
154     WriteShortTaggedPC(pc_delta, kEmbeddedObjectTag);
155   } else if (rmode == RelocInfo::CODE_TARGET) {
156     WriteShortTaggedPC(pc_delta, kCodeTargetTag);
157     DCHECK_LE(begin_pos - pos_, RelocInfo::kMaxCallSize);
158   } else if (rmode == RelocInfo::WASM_STUB_CALL) {
159     WriteShortTaggedPC(pc_delta, kWasmStubCallTag);
160   } else {
161     WriteModeAndPC(pc_delta, rmode);
162     if (RelocInfo::IsDeoptReason(rmode)) {
163       DCHECK_LT(rinfo->data(), 1 << kBitsPerByte);
164       WriteShortData(rinfo->data());
165     } else if (RelocInfo::IsConstPool(rmode) ||
166                RelocInfo::IsVeneerPool(rmode) || RelocInfo::IsDeoptId(rmode) ||
167                RelocInfo::IsDeoptPosition(rmode)) {
168       WriteIntData(static_cast<int>(rinfo->data()));
169     }
170   }
171   last_pc_ = reinterpret_cast<byte*>(rinfo->pc());
172 #ifdef DEBUG
173   DCHECK_LE(begin_pos - pos_, kMaxSize);
174 #endif
175 }
176 
AdvanceGetTag()177 inline int RelocIterator::AdvanceGetTag() { return *--pos_ & kTagMask; }
178 
GetMode()179 inline RelocInfo::Mode RelocIterator::GetMode() {
180   return static_cast<RelocInfo::Mode>((*pos_ >> kTagBits) &
181                                       ((1 << kLongTagBits) - 1));
182 }
183 
ReadShortTaggedPC()184 inline void RelocIterator::ReadShortTaggedPC() {
185   rinfo_.pc_ += *pos_ >> kTagBits;
186 }
187 
AdvanceReadPC()188 inline void RelocIterator::AdvanceReadPC() { rinfo_.pc_ += *--pos_; }
189 
AdvanceReadInt()190 void RelocIterator::AdvanceReadInt() {
191   int x = 0;
192   for (int i = 0; i < kIntSize; i++) {
193     x |= static_cast<int>(*--pos_) << i * kBitsPerByte;
194   }
195   rinfo_.data_ = x;
196 }
197 
AdvanceReadData()198 void RelocIterator::AdvanceReadData() {
199   intptr_t x = 0;
200   for (int i = 0; i < kIntptrSize; i++) {
201     x |= static_cast<intptr_t>(*--pos_) << i * kBitsPerByte;
202   }
203   rinfo_.data_ = x;
204 }
205 
AdvanceReadLongPCJump()206 void RelocIterator::AdvanceReadLongPCJump() {
207   // Read the 32-kSmallPCDeltaBits most significant bits of the
208   // pc jump in kChunkBits bit chunks and shift them into place.
209   // Stop when the last chunk is encountered.
210   uint32_t pc_jump = 0;
211   for (int i = 0; i < kIntSize; i++) {
212     byte pc_jump_part = *--pos_;
213     pc_jump |= (pc_jump_part >> kLastChunkTagBits) << i * kChunkBits;
214     if ((pc_jump_part & kLastChunkTagMask) == 1) break;
215   }
216   // The least significant kSmallPCDeltaBits bits will be added
217   // later.
218   rinfo_.pc_ += pc_jump << kSmallPCDeltaBits;
219 }
220 
ReadShortData()221 inline void RelocIterator::ReadShortData() {
222   uint8_t unsigned_b = *pos_;
223   rinfo_.data_ = unsigned_b;
224 }
225 
next()226 void RelocIterator::next() {
227   DCHECK(!done());
228   // Basically, do the opposite of RelocInfoWriter::Write.
229   // Reading of data is as far as possible avoided for unwanted modes,
230   // but we must always update the pc.
231   //
232   // We exit this loop by returning when we find a mode we want.
233   while (pos_ > end_) {
234     int tag = AdvanceGetTag();
235     if (tag == kEmbeddedObjectTag) {
236       ReadShortTaggedPC();
237       if (SetMode(RelocInfo::FULL_EMBEDDED_OBJECT)) return;
238     } else if (tag == kCodeTargetTag) {
239       ReadShortTaggedPC();
240       if (SetMode(RelocInfo::CODE_TARGET)) return;
241     } else if (tag == kWasmStubCallTag) {
242       ReadShortTaggedPC();
243       if (SetMode(RelocInfo::WASM_STUB_CALL)) return;
244     } else {
245       DCHECK_EQ(tag, kDefaultTag);
246       RelocInfo::Mode rmode = GetMode();
247       if (rmode == RelocInfo::PC_JUMP) {
248         AdvanceReadLongPCJump();
249       } else {
250         AdvanceReadPC();
251         if (RelocInfo::IsDeoptReason(rmode)) {
252           Advance();
253           if (SetMode(rmode)) {
254             ReadShortData();
255             return;
256           }
257         } else if (RelocInfo::IsConstPool(rmode) ||
258                    RelocInfo::IsVeneerPool(rmode) ||
259                    RelocInfo::IsDeoptId(rmode) ||
260                    RelocInfo::IsDeoptPosition(rmode)) {
261           if (SetMode(rmode)) {
262             AdvanceReadInt();
263             return;
264           }
265           Advance(kIntSize);
266         } else if (SetMode(static_cast<RelocInfo::Mode>(rmode))) {
267           return;
268         }
269       }
270     }
271   }
272   done_ = true;
273 }
274 
RelocIterator(Code code,int mode_mask)275 RelocIterator::RelocIterator(Code code, int mode_mask)
276     : RelocIterator(code, code.unchecked_relocation_info(), mode_mask) {}
277 
RelocIterator(Code code,ByteArray relocation_info,int mode_mask)278 RelocIterator::RelocIterator(Code code, ByteArray relocation_info,
279                              int mode_mask)
280     : RelocIterator(code, code.raw_instruction_start(), code.constant_pool(),
281                     relocation_info.GetDataEndAddress(),
282                     relocation_info.GetDataStartAddress(), mode_mask) {}
283 
RelocIterator(const CodeReference code_reference,int mode_mask)284 RelocIterator::RelocIterator(const CodeReference code_reference, int mode_mask)
285     : RelocIterator(Code(), code_reference.instruction_start(),
286                     code_reference.constant_pool(),
287                     code_reference.relocation_end(),
288                     code_reference.relocation_start(), mode_mask) {}
289 
RelocIterator(EmbeddedData * embedded_data,Code code,int mode_mask)290 RelocIterator::RelocIterator(EmbeddedData* embedded_data, Code code,
291                              int mode_mask)
292     : RelocIterator(
293           code, embedded_data->InstructionStartOfBuiltin(code.builtin_index()),
294           code.constant_pool(),
295           code.relocation_start() + code.relocation_size(),
296           code.relocation_start(), mode_mask) {}
297 
RelocIterator(const CodeDesc & desc,int mode_mask)298 RelocIterator::RelocIterator(const CodeDesc& desc, int mode_mask)
299     : RelocIterator(Code(), reinterpret_cast<Address>(desc.buffer), 0,
300                     desc.buffer + desc.buffer_size,
301                     desc.buffer + desc.buffer_size - desc.reloc_size,
302                     mode_mask) {}
303 
RelocIterator(Vector<byte> instructions,Vector<const byte> reloc_info,Address const_pool,int mode_mask)304 RelocIterator::RelocIterator(Vector<byte> instructions,
305                              Vector<const byte> reloc_info, Address const_pool,
306                              int mode_mask)
307     : RelocIterator(Code(), reinterpret_cast<Address>(instructions.begin()),
308                     const_pool, reloc_info.begin() + reloc_info.size(),
309                     reloc_info.begin(), mode_mask) {}
310 
RelocIterator(Code host,Address pc,Address constant_pool,const byte * pos,const byte * end,int mode_mask)311 RelocIterator::RelocIterator(Code host, Address pc, Address constant_pool,
312                              const byte* pos, const byte* end, int mode_mask)
313     : pos_(pos), end_(end), mode_mask_(mode_mask) {
314   // Relocation info is read backwards.
315   DCHECK_GE(pos_, end_);
316   rinfo_.host_ = host;
317   rinfo_.pc_ = pc;
318   rinfo_.constant_pool_ = constant_pool;
319   if (mode_mask_ == 0) pos_ = end_;
320   next();
321 }
322 
323 // -----------------------------------------------------------------------------
324 // Implementation of RelocInfo
325 
326 // static
OffHeapTargetIsCodedSpecially()327 bool RelocInfo::OffHeapTargetIsCodedSpecially() {
328 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_ARM64) || \
329     defined(V8_TARGET_ARCH_X64)
330   return false;
331 #elif defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_MIPS) || \
332     defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) ||  \
333     defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390)
334   return true;
335 #endif
336 }
337 
wasm_call_address() const338 Address RelocInfo::wasm_call_address() const {
339   DCHECK_EQ(rmode_, WASM_CALL);
340   return Assembler::target_address_at(pc_, constant_pool_);
341 }
342 
set_wasm_call_address(Address address,ICacheFlushMode icache_flush_mode)343 void RelocInfo::set_wasm_call_address(Address address,
344                                       ICacheFlushMode icache_flush_mode) {
345   DCHECK_EQ(rmode_, WASM_CALL);
346   Assembler::set_target_address_at(pc_, constant_pool_, address,
347                                    icache_flush_mode);
348 }
349 
wasm_stub_call_address() const350 Address RelocInfo::wasm_stub_call_address() const {
351   DCHECK_EQ(rmode_, WASM_STUB_CALL);
352   return Assembler::target_address_at(pc_, constant_pool_);
353 }
354 
set_wasm_stub_call_address(Address address,ICacheFlushMode icache_flush_mode)355 void RelocInfo::set_wasm_stub_call_address(Address address,
356                                            ICacheFlushMode icache_flush_mode) {
357   DCHECK_EQ(rmode_, WASM_STUB_CALL);
358   Assembler::set_target_address_at(pc_, constant_pool_, address,
359                                    icache_flush_mode);
360 }
361 
set_target_address(Address target,WriteBarrierMode write_barrier_mode,ICacheFlushMode icache_flush_mode)362 void RelocInfo::set_target_address(Address target,
363                                    WriteBarrierMode write_barrier_mode,
364                                    ICacheFlushMode icache_flush_mode) {
365   DCHECK(IsCodeTargetMode(rmode_) || IsRuntimeEntry(rmode_) ||
366          IsWasmCall(rmode_));
367   Assembler::set_target_address_at(pc_, constant_pool_, target,
368                                    icache_flush_mode);
369   if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null() &&
370       IsCodeTargetMode(rmode_) && !FLAG_disable_write_barriers) {
371     Code target_code = Code::GetCodeFromTargetAddress(target);
372     WriteBarrier::Marking(host(), this, target_code);
373   }
374 }
375 
HasTargetAddressAddress() const376 bool RelocInfo::HasTargetAddressAddress() const {
377   // TODO(jgruber): Investigate whether WASM_CALL is still appropriate on
378   // non-intel platforms now that wasm code is no longer on the heap.
379 #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64)
380   static constexpr int kTargetAddressAddressModeMask =
381       ModeMask(CODE_TARGET) | ModeMask(FULL_EMBEDDED_OBJECT) |
382       ModeMask(COMPRESSED_EMBEDDED_OBJECT) | ModeMask(EXTERNAL_REFERENCE) |
383       ModeMask(OFF_HEAP_TARGET) | ModeMask(RUNTIME_ENTRY) |
384       ModeMask(WASM_CALL) | ModeMask(WASM_STUB_CALL);
385 #else
386   static constexpr int kTargetAddressAddressModeMask =
387       ModeMask(CODE_TARGET) | ModeMask(RELATIVE_CODE_TARGET) |
388       ModeMask(FULL_EMBEDDED_OBJECT) | ModeMask(EXTERNAL_REFERENCE) |
389       ModeMask(OFF_HEAP_TARGET) | ModeMask(RUNTIME_ENTRY) | ModeMask(WASM_CALL);
390 #endif
391   return (ModeMask(rmode_) & kTargetAddressAddressModeMask) != 0;
392 }
393 
RequiresRelocationAfterCodegen(const CodeDesc & desc)394 bool RelocInfo::RequiresRelocationAfterCodegen(const CodeDesc& desc) {
395   RelocIterator it(desc, RelocInfo::PostCodegenRelocationMask());
396   return !it.done();
397 }
398 
RequiresRelocation(Code code)399 bool RelocInfo::RequiresRelocation(Code code) {
400   RelocIterator it(code, RelocInfo::kApplyMask);
401   return !it.done();
402 }
403 
404 #ifdef ENABLE_DISASSEMBLER
RelocModeName(RelocInfo::Mode rmode)405 const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
406   switch (rmode) {
407     case NONE:
408       return "no reloc";
409     case COMPRESSED_EMBEDDED_OBJECT:
410       return "compressed embedded object";
411     case FULL_EMBEDDED_OBJECT:
412       return "full embedded object";
413     case CODE_TARGET:
414       return "code target";
415     case RELATIVE_CODE_TARGET:
416       return "relative code target";
417     case RUNTIME_ENTRY:
418       return "runtime entry";
419     case EXTERNAL_REFERENCE:
420       return "external reference";
421     case INTERNAL_REFERENCE:
422       return "internal reference";
423     case INTERNAL_REFERENCE_ENCODED:
424       return "encoded internal reference";
425     case OFF_HEAP_TARGET:
426       return "off heap target";
427     case DEOPT_SCRIPT_OFFSET:
428       return "deopt script offset";
429     case DEOPT_INLINING_ID:
430       return "deopt inlining id";
431     case DEOPT_REASON:
432       return "deopt reason";
433     case DEOPT_ID:
434       return "deopt index";
435     case CONST_POOL:
436       return "constant pool";
437     case VENEER_POOL:
438       return "veneer pool";
439     case WASM_CALL:
440       return "internal wasm call";
441     case WASM_STUB_CALL:
442       return "wasm stub call";
443     case NUMBER_OF_MODES:
444     case PC_JUMP:
445       UNREACHABLE();
446   }
447   return "unknown relocation type";
448 }
449 
Print(Isolate * isolate,std::ostream & os)450 void RelocInfo::Print(Isolate* isolate, std::ostream& os) {  // NOLINT
451   os << reinterpret_cast<const void*>(pc_) << "  " << RelocModeName(rmode_);
452   if (rmode_ == DEOPT_SCRIPT_OFFSET || rmode_ == DEOPT_INLINING_ID) {
453     os << "  (" << data() << ")";
454   } else if (rmode_ == DEOPT_REASON) {
455     os << "  ("
456        << DeoptimizeReasonToString(static_cast<DeoptimizeReason>(data_)) << ")";
457   } else if (rmode_ == FULL_EMBEDDED_OBJECT) {
458     os << "  (" << Brief(target_object()) << ")";
459   } else if (rmode_ == COMPRESSED_EMBEDDED_OBJECT) {
460     os << "  (" << Brief(target_object()) << " compressed)";
461   } else if (rmode_ == EXTERNAL_REFERENCE) {
462     if (isolate) {
463       ExternalReferenceEncoder ref_encoder(isolate);
464       os << " ("
465          << ref_encoder.NameOfAddress(isolate, target_external_reference())
466          << ") ";
467     }
468     os << " (" << reinterpret_cast<const void*>(target_external_reference())
469        << ")";
470   } else if (IsCodeTargetMode(rmode_)) {
471     const Address code_target = target_address();
472     Code code = Code::GetCodeFromTargetAddress(code_target);
473     DCHECK(code.IsCode());
474     os << " (" << CodeKindToString(code.kind());
475     if (Builtins::IsBuiltin(code)) {
476       os << " " << Builtins::name(code.builtin_index());
477     }
478     os << ")  (" << reinterpret_cast<const void*>(target_address()) << ")";
479   } else if (IsRuntimeEntry(rmode_)) {
480     // Deoptimization bailouts are stored as runtime entries.
481     DeoptimizeKind type;
482     if (Deoptimizer::IsDeoptimizationEntry(isolate, target_address(), &type)) {
483       os << "  (" << Deoptimizer::MessageFor(type, false)
484          << " deoptimization bailout)";
485     }
486   } else if (IsConstPool(rmode_)) {
487     os << " (size " << static_cast<int>(data_) << ")";
488   }
489 
490   os << "\n";
491 }
492 #endif  // ENABLE_DISASSEMBLER
493 
494 #ifdef VERIFY_HEAP
Verify(Isolate * isolate)495 void RelocInfo::Verify(Isolate* isolate) {
496   switch (rmode_) {
497     case COMPRESSED_EMBEDDED_OBJECT:
498     case FULL_EMBEDDED_OBJECT:
499       Object::VerifyPointer(isolate, target_object());
500       break;
501     case CODE_TARGET:
502     case RELATIVE_CODE_TARGET: {
503       // convert inline target address to code object
504       Address addr = target_address();
505       CHECK_NE(addr, kNullAddress);
506       // Check that we can find the right code object.
507       Code code = Code::GetCodeFromTargetAddress(addr);
508       Object found = isolate->FindCodeObject(addr);
509       CHECK(found.IsCode());
510       CHECK(code.address() == HeapObject::cast(found).address());
511       break;
512     }
513     case INTERNAL_REFERENCE:
514     case INTERNAL_REFERENCE_ENCODED: {
515       Address target = target_internal_reference();
516       Address pc = target_internal_reference_address();
517       Code code = Code::cast(isolate->FindCodeObject(pc));
518       CHECK(target >= code.InstructionStart());
519       CHECK(target <= code.InstructionEnd());
520       break;
521     }
522     case OFF_HEAP_TARGET: {
523       Address addr = target_off_heap_target();
524       CHECK_NE(addr, kNullAddress);
525       CHECK(!InstructionStream::TryLookupCode(isolate, addr).is_null());
526       break;
527     }
528     case RUNTIME_ENTRY:
529     case EXTERNAL_REFERENCE:
530     case DEOPT_SCRIPT_OFFSET:
531     case DEOPT_INLINING_ID:
532     case DEOPT_REASON:
533     case DEOPT_ID:
534     case CONST_POOL:
535     case VENEER_POOL:
536     case WASM_CALL:
537     case WASM_STUB_CALL:
538     case NONE:
539       break;
540     case NUMBER_OF_MODES:
541     case PC_JUMP:
542       UNREACHABLE();
543   }
544 }
545 #endif  // VERIFY_HEAP
546 
547 }  // namespace internal
548 }  // namespace v8
549