Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index dc49aab1bd1dd37f821bedca25fd0836a4212c73..c632854e931b90b9e6f7506bc14bb5b83a905cfa 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -4528,7 +4528,7 @@ void Function::SetCode(const Code& value) const { |
StorePointer(&raw_ptr()->code_, value.raw()); |
ASSERT(Function::Handle(value.function()).IsNull() || |
(value.function() == this->raw())); |
- value.set_function(*this); |
+ value.set_owner_function(*this); |
} |
@@ -10258,8 +10258,8 @@ bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { |
} |
-RawCode* Code::LookupCode(uword pc) { |
- Isolate* isolate = Isolate::Current(); |
+RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { |
+ ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); |
NoGCScope no_gc; |
FindRawCodeVisitor visitor(pc); |
RawInstructions* instr; |
@@ -10274,6 +10274,16 @@ RawCode* Code::LookupCode(uword pc) { |
} |
+RawCode* Code::LookupCode(uword pc) { |
+ return LookupCodeInIsolate(Isolate::Current(), pc); |
+} |
+ |
+ |
+RawCode* Code::LookupCodeInVmIsolate(uword pc) { |
+ return LookupCodeInIsolate(Dart::vm_isolate(), pc); |
+} |
+ |
+ |
intptr_t Code::GetTokenIndexOfPC(uword pc) const { |
intptr_t token_pos = -1; |
const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
@@ -10328,25 +10338,49 @@ void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { |
jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint()); |
jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); |
jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); |
- Function& func = Function::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() ? "*" : "", |
- internal_function_name); |
- name ^= func.QualifiedUserVisibleName(); |
- const char* function_name = name.ToCString(); |
- jsobj.AddPropertyF("user_name", "%s%s", is_optimized() ? "*" : "", |
- function_name); |
+ jsobj.AddProperty("is_optimized", is_optimized()); |
+ jsobj.AddProperty("is_alive", is_alive()); |
+ if (OwnerIsNotNullFunction()) { |
Ivan Posva
2014/02/28 21:46:33
How about just adding Code::Name() and Code::UserN
|
+ // Dart function. |
+ jsobj.AddProperty("kind", "Dart"); |
+ Function& func = Function::Handle(); |
+ String& name = String::Handle(); |
+ func ^= function(); |
+ ASSERT(!func.IsNull()); |
+ name ^= func.name(); |
+ ASSERT(!name.IsNull()); |
+ const char* name_c = name.ToCString(); |
+ jsobj.AddPropertyF("name", "%s%s", is_optimized() ? "*" : "", name_c); |
+ name ^= func.QualifiedUserVisibleName(); |
+ ASSERT(!name.IsNull()); |
+ name_c = name.ToCString(); |
+ jsobj.AddPropertyF("user_name", "%s%s", is_optimized() ? "*" : "", name_c); |
+ jsobj.AddProperty("function", Object::Handle(function())); |
+ } else if (OwnerIsAllocationStub()) { |
+ // Allocation stub. |
+ jsobj.AddProperty("kind", "DartAllocationStub"); |
+ Isolate* isolate = Isolate::Current(); |
+ ClassTable* class_table = isolate->class_table(); |
+ intptr_t cid = Smi::Value(allocation_stub_class_id()); |
+ Class& cls = Class::Handle(); |
+ cls ^= class_table->At(cid); |
+ ASSERT(!cls.IsNull()); |
+ String& cls_name = String::Handle(cls.UserVisibleName()); |
+ ASSERT(!cls_name.IsNull()); |
+ const char* name = cls_name.ToCString(); |
+ jsobj.AddPropertyF("name", "Allocation stub for %s\n", name); |
+ jsobj.AddPropertyF("user_name", "Allocation stub for %s\n", name); |
+ } else { |
+ // Regular stub. |
+ jsobj.AddProperty("kind", "DartStub"); |
+ const char* name = StubCode::NameOfStub(EntryPoint()); |
+ ASSERT(name != NULL); |
+ jsobj.AddProperty("name", name); |
+ jsobj.AddProperty("user_name", name); |
+ } |
if (ref) { |
return; |
} |
- jsobj.AddProperty("is_optimized", is_optimized()); |
- jsobj.AddProperty("is_alive", is_alive()); |
- jsobj.AddProperty("function", Object::Handle(function())); |
JSONArray jsarr(&jsobj, "disassembly"); |
if (is_alive()) { |
// Only disassemble alive code objects. |