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