Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
dart::Disassembler Class Reference

#include <disassembler.h>

Inheritance diagram for dart::Disassembler:
dart::AllStatic

Static Public Member Functions

static void Disassemble (uword start, uword end, DisassemblyFormatter *formatter, const Code &code, const CodeComments *comments=nullptr)
 
static void Disassemble (uword start, uword end, DisassemblyFormatter *formatter)
 
static void Disassemble (uword start, uword end, DisassemblyFormatter *formatter, const CodeComments *comments)
 
static void Disassemble (uword start, uword end, const Code &code)
 
static void Disassemble (uword start, uword end)
 
static void Disassemble (uword start, uword end, char *buffer, uintptr_t buffer_size)
 
static void DecodeInstruction (char *hex_buffer, intptr_t hex_size, char *human_buffer, intptr_t human_size, int *out_instr_len, const Code &code, Object **object, uword pc)
 
static void DisassembleCode (const Function &function, const Code &code, bool optimized)
 
static void DisassembleStub (const char *name, const Code &code)
 

Detailed Description

Definition at line 119 of file disassembler.h.

Member Function Documentation

◆ DecodeInstruction()

static void dart::Disassembler::DecodeInstruction ( char *  hex_buffer,
intptr_t  hex_size,
char *  human_buffer,
intptr_t  human_size,
int out_instr_len,
const Code code,
Object **  object,
uword  pc 
)
static

◆ Disassemble() [1/6]

static void dart::Disassembler::Disassemble ( uword  start,
uword  end 
)
inlinestatic

Definition at line 157 of file disassembler.h.

157 {
158#if !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
159 DisassembleToStdout stdout_formatter;
160 LogBlock lb;
161 Disassemble(start, end, &stdout_formatter);
162#else
163 UNREACHABLE();
164#endif
165 }
#define UNREACHABLE()
Definition assert.h:248
static void Disassemble(uword start, uword end, DisassemblyFormatter *formatter, const Code &code, const CodeComments *comments=nullptr)
glong glong end

◆ Disassemble() [2/6]

static void dart::Disassembler::Disassemble ( uword  start,
uword  end,
char *  buffer,
uintptr_t  buffer_size 
)
inlinestatic

Definition at line 167 of file disassembler.h.

170 {
171#if !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
172 DisassembleToMemory memory_formatter(buffer, buffer_size);
173 LogBlock lb;
174 Disassemble(start, end, &memory_formatter);
175#else
176 UNREACHABLE();
177#endif
178 }
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
static const uint8_t buffer[]

◆ Disassemble() [3/6]

static void dart::Disassembler::Disassemble ( uword  start,
uword  end,
const Code code 
)
inlinestatic

Definition at line 143 of file disassembler.h.

143 {
144#if !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
145 DisassembleToStdout stdout_formatter;
146 LogBlock lb;
147 if (!code.IsNull()) {
148 Disassemble(start, end, &stdout_formatter, code, &code.comments());
149 } else {
150 Disassemble(start, end, &stdout_formatter, code);
151 }
152#else
153 UNREACHABLE();
154#endif
155 }

◆ Disassemble() [4/6]

static void dart::Disassembler::Disassemble ( uword  start,
uword  end,
DisassemblyFormatter formatter 
)
inlinestatic

Definition at line 130 of file disassembler.h.

132 {
133 Disassemble(start, end, formatter, Code::Handle());
134 }
static Object & Handle()
Definition object.h:407

◆ Disassemble() [5/6]

void dart::Disassembler::Disassemble ( uword  start,
uword  end,
DisassemblyFormatter formatter,
const Code code,
const CodeComments *  comments = nullptr 
)
static

Definition at line 145 of file disassembler.cc.

149 {
150 if (comments == nullptr) {
151 comments = code.IsNull() ? &Code::Comments::New(0) : &code.comments();
152 }
153 ASSERT(formatter != nullptr);
154 char hex_buffer[kHexadecimalBufferSize]; // Instruction in hexadecimal form.
155 char human_buffer[kUserReadableBufferSize]; // Human-readable instruction.
156 uword pc = start;
157 intptr_t comment_finger = 0;
158 GrowableArray<const Function*> inlined_functions;
159 GrowableArray<TokenPosition> token_positions;
160 while (pc < end) {
161 const intptr_t offset = pc - start;
162 const intptr_t old_comment_finger = comment_finger;
163 while (comment_finger < comments->Length() &&
164 comments->PCOffsetAt(comment_finger) <= offset) {
165 formatter->Print(" ;; %s\n", comments->CommentAt(comment_finger));
166 comment_finger++;
167 }
168 if (FLAG_include_inlining_info_in_disassembly &&
169 old_comment_finger != comment_finger && !code.IsNull()) {
170 char str[4000];
171 BufferFormatter f(str, sizeof(str));
172 // Comment emitted, emit inlining information.
173 code.GetInlinedFunctionsAtInstruction(offset, &inlined_functions,
174 &token_positions);
175 // Skip top scope function printing (last entry in 'inlined_functions').
176 bool first = true;
177 for (intptr_t i = 1; i < inlined_functions.length(); i++) {
178 const char* name = inlined_functions[i]->ToQualifiedCString();
179 if (first) {
180 f.Printf(" ;; Inlined [%s", name);
181 first = false;
182 } else {
183 f.Printf(" -> %s", name);
184 }
185 }
186 if (!first) {
187 f.AddString("]\n");
188 formatter->Print("%s", str);
189 }
190 }
191 int instruction_length;
192 Object* object;
193 DecodeInstruction(hex_buffer, sizeof(hex_buffer), human_buffer,
194 sizeof(human_buffer), &instruction_length, code, &object,
195 pc);
196 formatter->ConsumeInstruction(hex_buffer, sizeof(hex_buffer), human_buffer,
197 sizeof(human_buffer), object,
198 FLAG_disassemble_relative ? offset : pc);
199 pc += instruction_length;
200 }
201}
static void DecodeInstruction(char *hex_buffer, intptr_t hex_size, char *human_buffer, intptr_t human_size, int *out_instr_len, const Code &code, Object **object, uword pc)
#define ASSERT(E)
const char *const name
uintptr_t uword
Definition globals.h:501
Point offset

◆ Disassemble() [6/6]

static void dart::Disassembler::Disassemble ( uword  start,
uword  end,
DisassemblyFormatter formatter,
const CodeComments *  comments 
)
inlinestatic

Definition at line 136 of file disassembler.h.

139 {
140 Disassemble(start, end, formatter, Code::Handle(), comments);
141 }

◆ DisassembleCode()

void dart::Disassembler::DisassembleCode ( const Function function,
const Code code,
bool  optimized 
)
static

Definition at line 453 of file disassembler.cc.

455 {
456 if (code.IsUnknownDartCode()) {
457 return;
458 }
459 if (Log::Current() == Log::NoOpLog()) {
460 // Output for this isolate will be shallowed, so don't bother generating it.
461 return;
462 }
463 TextBuffer buffer(128);
464 const char* function_fullname = function.ToFullyQualifiedCString();
465 buffer.Printf("%s", Function::KindToCString(function.kind()));
466 if (function.HasSavedArgumentsDescriptor()) {
467 const auto& args_desc_array = Array::Handle(function.saved_args_desc());
468 const ArgumentsDescriptor args_desc(args_desc_array);
469 buffer.AddString(", ");
470 args_desc.PrintTo(&buffer);
471 }
472 LogBlock lb;
473 DisassembleCodeHelper(function_fullname, buffer.buffer(), code, optimized);
474}
static const char * KindToCString(UntaggedFunction::Kind kind)
Definition object.cc:8477
static Log * NoOpLog()
Definition log.cc:183
static Log * Current()
Definition log.cc:75
Dart_NativeFunction function
Definition fuchsia.cc:51

◆ DisassembleStub()

void dart::Disassembler::DisassembleStub ( const char *  name,
const Code code 
)
static

Definition at line 476 of file disassembler.cc.

476 {
477 if (Log::Current() == Log::NoOpLog()) {
478 // Output for this isolate will be shallowed, so don't bother generating it.
479 return;
480 }
481 LogBlock lb;
482 THR_Print("Code for stub '%s': {\n", name);
483 DisassembleToStdout formatter;
484 code.Disassemble(&formatter);
485 THR_Print("}\n");
486 const ObjectPool& object_pool = ObjectPool::Handle(code.object_pool());
487 if (FLAG_precompiled_mode) {
488 THR_Print("(No object pool for bare instructions.)\n");
489 } else if (!object_pool.IsNull() && object_pool.Length() > 0) {
490 object_pool.DebugPrint();
491 }
492}
#define THR_Print(format,...)
Definition log.h:20

The documentation for this class was generated from the following files: