Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Unified Diff: runtime/vm/disassembler_x64.cc

Issue 2160343003: Use the Code's pointer offsets to find object references when disassembling IA32. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/disassembler_mips.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/disassembler_x64.cc
diff --git a/runtime/vm/disassembler_x64.cc b/runtime/vm/disassembler_x64.cc
index 60118f1c74693267c32341315c30f91f0725026e..f389415c533f4369c31885ec680b4d18a83be722 100644
--- a/runtime/vm/disassembler_x64.cc
+++ b/runtime/vm/disassembler_x64.cc
@@ -9,6 +9,7 @@
#include "platform/utils.h"
#include "vm/allocation.h"
#include "vm/heap.h"
+#include "vm/instructions.h"
#include "vm/os.h"
#include "vm/stack_frame.h"
#include "vm/stub_code.h"
@@ -785,65 +786,9 @@ int DisassemblerX64::PrintOperands(const char* mnem,
}
-static const char* ObjectToCStringNoGC(const Object& obj) {
- if (obj.IsSmi() ||
- obj.IsMint() ||
- obj.IsDouble() ||
- obj.IsString() ||
- obj.IsNull() ||
- obj.IsBool() ||
- obj.IsClass() ||
- obj.IsFunction() ||
- obj.IsICData() ||
- obj.IsField() ||
- obj.IsCode()) {
- return obj.ToCString();
- }
-
- const Class& clazz = Class::Handle(obj.clazz());
- const char* full_class_name = clazz.ToCString();
- return OS::SCreate(Thread::Current()->zone(),
- "instance of %s", full_class_name);
-}
-
-
void DisassemblerX64::PrintAddress(uint8_t* addr_byte_ptr) {
uword addr = reinterpret_cast<uword>(addr_byte_ptr);
Print("%#" Px "", addr);
- // Try to print as heap object or stub name
- if (((addr & kSmiTagMask) == kHeapObjectTag) &&
- reinterpret_cast<RawObject*>(addr)->IsWellFormed() &&
- reinterpret_cast<RawObject*>(addr)->IsOldObject() &&
- !Dart::vm_isolate()->heap()->CodeContains(addr) &&
- !Isolate::Current()->heap()->CodeContains(addr) &&
- Disassembler::CanFindOldObject(addr)) {
- NoSafepointScope no_safepoint;
- const Object& obj = Object::Handle(reinterpret_cast<RawObject*>(addr));
- if (obj.IsArray()) {
- const Array& arr = Array::Cast(obj);
- intptr_t len = arr.Length();
- if (len > 5) len = 5; // Print a max of 5 elements.
- Print(" Array[");
- int i = 0;
- Object& element = Object::Handle();
- while (i < len) {
- element = arr.At(i);
- if (i > 0) Print(", ");
- Print("%s", ObjectToCStringNoGC(element));
- i++;
- }
- if (i < arr.Length()) Print(", ...");
- Print("]");
- return;
- }
- Print(" '%s'", ObjectToCStringNoGC(obj));
- } else {
- // 'addr' is not an object, but probably a code address.
- const char* name_of_stub = StubCode::NameOfStub(addr);
- if (name_of_stub != NULL) {
- Print(" [stub: %s]", name_of_stub);
- }
- }
}
@@ -1935,7 +1880,8 @@ int DisassemblerX64::InstructionDecode(uword pc) {
void Disassembler::DecodeInstruction(char* hex_buffer, intptr_t hex_size,
char* human_buffer, intptr_t human_size,
- int* out_instr_len, uword pc) {
+ int* out_instr_len, const Code& code,
+ Object** object, uword pc) {
ASSERT(hex_size > 0);
ASSERT(human_size > 0);
DisassemblerX64 decoder(human_buffer, human_size);
@@ -1952,6 +1898,14 @@ void Disassembler::DecodeInstruction(char* hex_buffer, intptr_t hex_size,
if (out_instr_len) {
*out_instr_len = instruction_length;
}
+
+ *object = NULL;
+ if (!code.IsNull()) {
+ *object = &Object::Handle();
+ if (!DecodeLoadObjectFromPoolOrThread(pc, code, *object)) {
+ *object = NULL;
+ }
+ }
}
#endif // !PRODUCT
« no previous file with comments | « runtime/vm/disassembler_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698