17#ifdef ENABLE_DISASSEMBLER
39#ifdef V8_ENABLE_LEAPTIERING
44 istream->
address(), istream->Size(),
48 !it.
done(); it.next()) {
49 const auto mode = it.rinfo()->rmode();
52#ifdef V8_ENABLE_LEAPTIERING
76 source_position_table(),
79 !it.
done() && it.code_offset() <=
offset; it.Advance()) {
80 position = it.source_position().ScriptOffset();
94 !it.
done() && it.code_offset() <=
offset; it.Advance()) {
95 if (it.is_statement()) {
96 position = it.source_position().ScriptOffset();
105 return table.FindEntry(
pc);
112 return table.FindEntry(
pc);
116 static constexpr int kModeMask =
123 static_assert(kModeMask ==
136#if defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_MIPS64)
138#elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM64) || \
139 defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_S390X) || \
140 defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_RISCV64) || \
141 defined(V8_TARGET_ARCH_LOONG64) || defined(V8_TARGET_ARCH_RISCV32)
148 Address target_address = it.rinfo()->target_address();
161#error Unsupported architecture.
171 if (data->length() == 0)
return false;
172 if (data->GetSharedFunctionInfo() == sfi)
return true;
174 int const inlined_count = data->InlinedFunctionCount().value();
175 for (
int i = 0;
i < inlined_count; ++
i) {
181#ifdef ENABLE_DISASSEMBLER
187 size_t range_limit = 0) {
193 reinterpret_cast<uint8_t*
>(
end),
198void DisassembleOnlyCode(
const char* name, std::ostream& os,
Isolate* isolate,
200 size_t range_limit) {
201 int code_size = code->instruction_size();
202 DisassembleCodeRange(isolate, os, code, code->instruction_start(), code_size,
203 current_pc, range_limit);
206void Disassemble(
const char* name, std::ostream& os, Isolate* isolate,
210 if (name ==
nullptr && code->is_builtin()) {
213 if ((name !=
nullptr) && (name[0] !=
'\0')) {
214 os <<
"name = " << name <<
"\n";
217 << (code->is_turbofanned() ?
"turbofan"
218 : code->is_maglevved() ?
"maglev"
219 :
kind == CodeKind::BASELINE ?
"baseline"
222 os <<
"address = " <<
reinterpret_cast<void*
>(code.ptr()) <<
"\n\n";
225 int code_size = code->instruction_size();
226 os <<
"Instructions (size = " << code_size <<
")\n";
227 DisassembleCodeRange(isolate, os, code, code->instruction_start(),
228 code_size, current_pc);
230 if (
int pool_size = code->constant_pool_size()) {
232 os <<
"\nConstant Pool (size = " << pool_size <<
")\n";
234 intptr_t* ptr =
reinterpret_cast<intptr_t*
>(code->constant_pool());
237 os << static_cast<const void*>(ptr) <<
" " << buf.begin() <<
"\n";
244 if (code->has_source_position_table()) {
246 SourcePositionTableIterator it(
247 code->source_position_table(),
250 os <<
"Source positions:\n pc offset position\n";
251 for (; !it.done(); it.Advance()) {
252 os << std::setw(10) << std::hex << it.code_offset() << std::dec
253 << std::setw(10) << it.source_position().ScriptOffset()
254 << (it.is_statement() ?
" statement" :
"") <<
"\n";
261 SourcePositionTableIterator it(
262 code->source_position_table(),
265 os <<
"External Source positions:\n pc offset fileid line\n";
266 for (; !it.done(); it.Advance()) {
267 DCHECK(it.source_position().IsExternal());
268 os << std::setw(10) << std::hex << it.code_offset() << std::dec
269 << std::setw(10) << it.source_position().ExternalFileId()
270 << std::setw(10) << it.source_position().ExternalLine() <<
"\n";
277 if (code->uses_deoptimization_data()) {
280 data->PrintDeoptimizationData(os);
284 if (code->uses_safepoint_table()) {
285 if (code->is_maglevved()) {
286 MaglevSafepointTable table(isolate, current_pc, code);
289 SafepointTable table(isolate, current_pc, code);
295 if (code->has_handler_table()) {
296 HandlerTable table(code);
297 os <<
"Handler Table (size = " << table.NumberOfReturnEntries() <<
")\n";
299 table.HandlerTableReturnPrint(os);
304 os <<
"RelocInfo (size = " << code->relocation_size() <<
")\n";
305 if (code->has_instruction_stream()) {
306 for (RelocIterator it(code); !it.done(); it.next()) {
307 it.rinfo()->Print(isolate, os);
312 if (code->has_unwinding_info()) {
313 os <<
"UnwindingInfo (size = " << code->unwinding_info_size() <<
")\n";
314 EhFrameDisassembler eh_frame_disassembler(
315 reinterpret_cast<uint8_t*
>(code->unwinding_info_start()),
316 reinterpret_cast<uint8_t*
>(code->unwinding_info_end()));
317 eh_frame_disassembler.DisassembleToStream(os);
324void Code::Disassemble(
const char* name, std::ostream& os, Isolate* isolate,
326 i::Disassemble(name, os, isolate, *
this, current_pc);
329void Code::DisassembleOnlyCode(
const char* name, std::ostream& os,
330 Isolate* isolate,
Address current_pc,
331 size_t range_limit) {
332 i::DisassembleOnlyCode(name, os, isolate, *
this, current_pc, range_limit);
static Vector< T > New(size_t length)
static bool IsIsolateIndependentBuiltin(Tagged< Code > code)
static V8_EXPORT_PRIVATE const char * name(Builtin builtin)
SafepointEntry GetSafepointEntry(Isolate *isolate, Address pc)
bool has_source_position_table() const
Tagged< InstructionStream > unchecked_instruction_stream() const
void TraceMarkForDeoptimization(Isolate *isolate, LazyDeoptimizeReason reason)
void set_embedded_objects_cleared(bool flag)
static Tagged< Code > FromTargetAddress(Address address)
Tagged< Object > raw_deoptimization_data_or_interpreter_data() const
bool Inlines(Tagged< SharedFunctionInfo > sfi)
Address constant_pool() const
int SourcePosition(int offset) const
bool is_optimized_code() const
MaglevSafepointEntry GetMaglevSafepointEntry(Isolate *isolate, Address pc)
int SourceStatementPosition(int offset) const
bool is_maglevved() const
Tagged< Object > raw_position_table() const
bool IsIsolateIndependent(Isolate *isolate)
void ClearEmbeddedObjectsAndJSDispatchHandles(Heap *heap)
static void TraceMarkForDeoptimization(Isolate *isolate, Tagged< Code > code, LazyDeoptimizeReason reason)
static V8_EXPORT_PRIVATE int Decode(Isolate *isolate, std::ostream &os, uint8_t *begin, uint8_t *end, CodeReference code={}, Address current_pc=kNullAddress, size_t range_limit=0)
Tagged< Object > load() const
static bool PcIsOffHeap(Isolate *isolate, Address pc)
static constexpr bool IsCodeTargetMode(Mode mode)
static constexpr int AllRealModesMask()
static constexpr int ModeMask(Mode mode)
static constexpr bool IsEmbeddedObjectMode(Mode mode)
@ WASM_CODE_POINTER_TABLE_ENTRY
@ COMPRESSED_EMBEDDED_OBJECT
@ INTERNAL_REFERENCE_ENCODED
static int JSDispatchHandleModeMask()
static int EmbeddedObjectModeMask()
static WritableJitAllocation LookupJitAllocation(Address addr, size_t size, JitAllocationType type, bool enforce_write_api=false)
ProtectedPointerSlot RawProtectedPointerField(int byte_offset) const
int SNPrintF(Vector< char > str, const char *format,...)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
constexpr bool CodeKindIsOptimizedJSFunction(CodeKind kind)
const char * CodeKindToString(CodeKind kind)
Tagged(T object) -> Tagged< T >
void FlushInstructionCache(void *start, size_t size)
constexpr int kSystemPointerSize
constexpr JSDispatchHandle kNullJSDispatchHandle(0)
constexpr intptr_t kPointerAlignmentMask
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define CHECK_NE(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)