Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 3be70ddfc1d04f47bf94aa62ef48a5deb5c43604..533f5347f17f16f3b3cb8261515f4388c0732139 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -5711,6 +5711,7 @@ void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { |
const char* function_name = |
String::Handle(QualifiedUserVisibleName()).ToCString(); |
Class& cls = Class::Handle(Owner()); |
+ ASSERT(!cls.IsNull()); |
Error& err = Error::Handle(); |
err ^= cls.EnsureIsFinalized(Isolate::Current()); |
ASSERT(err.IsNull()); |
@@ -5721,11 +5722,20 @@ void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { |
} else { |
id = cls.FindFunctionIndex(func); |
} |
+ bool object_ref = id < 0; |
Ivan Posva
2013/12/30 23:06:09
Please handle implicit closure functions as discus
|
+ if (object_ref) { |
+ // We do not have a stable way of referencing this function, |
+ // generate a temporary id. |
+ ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
+ id = ring->GetIdForObject(raw()); |
+ } |
ASSERT(id >= 0); |
intptr_t cid = cls.id(); |
JSONObject jsobj(stream); |
jsobj.AddProperty("type", JSONType(ref)); |
- if (IsNonImplicitClosureFunction()) { |
+ if (object_ref) { |
+ jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
+ } else if (IsNonImplicitClosureFunction()) { |
jsobj.AddPropertyF("id", "classes/%" Pd "/closures/%" Pd "", cid, id); |
} else { |
jsobj.AddPropertyF("id", "classes/%" Pd "/functions/%" Pd "", cid, id); |
@@ -9692,9 +9702,36 @@ void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { |
void Code::Disassemble() const { |
+ const bool fix_patch = CodePatcher::CodeIsPatchable(*this) && |
+ CodePatcher::IsEntryPatched(*this); |
+ if (fix_patch) { |
+ // Undo the patch. |
+ CodePatcher::RestoreEntry(*this); |
+ } |
srdjan
2013/12/30 17:54:46
Add comment that restore/repatch is necesseary to
Cutch
2013/12/30 21:32:40
Done.
|
const Instructions& instr = Instructions::Handle(instructions()); |
uword start = instr.EntryPoint(); |
Disassembler::Disassemble(start, start + instr.size(), comments()); |
+ if (fix_patch) { |
+ // Redo the patch. |
+ CodePatcher::PatchEntry(*this); |
+ } |
+} |
+ |
+ |
+void Code::Disassemble(DisassemblyFormatter* formatter) const { |
+ const bool fix_patch = CodePatcher::CodeIsPatchable(*this) && |
+ CodePatcher::IsEntryPatched(*this); |
+ if (fix_patch) { |
+ // Undo the patch. |
+ CodePatcher::RestoreEntry(*this); |
+ } |
+ const Instructions& instr = Instructions::Handle(instructions()); |
+ uword start = instr.EntryPoint(); |
+ Disassembler::Disassemble(start, start + instr.size(), formatter, comments()); |
+ if (fix_patch) { |
+ // Redo the patch. |
+ CodePatcher::PatchEntry(*this); |
+ } |
} |
@@ -9876,16 +9913,16 @@ const char* Code::ToCString() const { |
void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { |
- Isolate* isolate = Isolate::Current(); |
- ObjectIdRing* ring = isolate->object_id_ring(); |
- intptr_t id = ring->GetIdForObject(raw()); |
JSONObject jsobj(stream); |
jsobj.AddProperty("type", JSONType(ref)); |
- jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
+ jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint()); |
+ jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); |
+ jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); |
Function& func = Function::Handle(); |
- String& name = String::Handle(); |
func ^= function(); |
ASSERT(!func.IsNull()); |
+ String& name = String::Handle(); |
+ ASSERT(!func.IsNull()); |
name ^= func.name(); |
const char* internal_function_name = name.ToCString(); |
jsobj.AddPropertyF("name", "%s%s", is_optimized() ? "*" : "", |
@@ -9902,10 +9939,7 @@ void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { |
jsobj.AddProperty("function", Object::Handle(function())); |
JSONArray jsarr(&jsobj, "disassembly"); |
DisassembleToJSONStream formatter(jsarr); |
- const Instructions& instr = Instructions::Handle(instructions()); |
- uword start = instr.EntryPoint(); |
- Disassembler::Disassemble(start, start + instr.size(), &formatter, |
- comments()); |
+ Disassemble(&formatter); |
} |