| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 10374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10385 RawCode* Code::LookupCode(uword pc) { | 10385 RawCode* Code::LookupCode(uword pc) { |
| 10386 return LookupCodeInIsolate(Isolate::Current(), pc); | 10386 return LookupCodeInIsolate(Isolate::Current(), pc); |
| 10387 } | 10387 } |
| 10388 | 10388 |
| 10389 | 10389 |
| 10390 RawCode* Code::LookupCodeInVmIsolate(uword pc) { | 10390 RawCode* Code::LookupCodeInVmIsolate(uword pc) { |
| 10391 return LookupCodeInIsolate(Dart::vm_isolate(), pc); | 10391 return LookupCodeInIsolate(Dart::vm_isolate(), pc); |
| 10392 } | 10392 } |
| 10393 | 10393 |
| 10394 | 10394 |
| 10395 // Given a pc and a timestamp, lookup the code. |
| 10396 RawCode* Code::FindCode(uword pc, int64_t timestamp) { |
| 10397 Code& code = Code::Handle(Code::LookupCode(pc)); |
| 10398 if (!code.IsNull() && (code.compile_timestamp() == timestamp) && |
| 10399 (code.EntryPoint() == pc)) { |
| 10400 // Found code in isolate. |
| 10401 return code.raw(); |
| 10402 } |
| 10403 code ^= Code::LookupCodeInVmIsolate(pc); |
| 10404 if (!code.IsNull() && (code.compile_timestamp() == timestamp) && |
| 10405 (code.EntryPoint() == pc)) { |
| 10406 // Found code in VM isolate. |
| 10407 return code.raw(); |
| 10408 } |
| 10409 return Code::null(); |
| 10410 } |
| 10411 |
| 10412 |
| 10395 intptr_t Code::GetTokenIndexOfPC(uword pc) const { | 10413 intptr_t Code::GetTokenIndexOfPC(uword pc) const { |
| 10396 intptr_t token_pos = -1; | 10414 intptr_t token_pos = -1; |
| 10397 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 10415 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
| 10398 for (intptr_t i = 0; i < descriptors.Length(); i++) { | 10416 for (intptr_t i = 0; i < descriptors.Length(); i++) { |
| 10399 if (descriptors.PC(i) == pc) { | 10417 if (descriptors.PC(i) == pc) { |
| 10400 token_pos = descriptors.TokenPos(i); | 10418 token_pos = descriptors.TokenPos(i); |
| 10401 break; | 10419 break; |
| 10402 } | 10420 } |
| 10403 } | 10421 } |
| 10404 return token_pos; | 10422 return token_pos; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10478 ASSERT(obj.IsFunction()); | 10496 ASSERT(obj.IsFunction()); |
| 10479 // Dart function. | 10497 // Dart function. |
| 10480 return Function::Cast(obj).QualifiedUserVisibleName(); | 10498 return Function::Cast(obj).QualifiedUserVisibleName(); |
| 10481 } | 10499 } |
| 10482 } | 10500 } |
| 10483 | 10501 |
| 10484 | 10502 |
| 10485 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { | 10503 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 10486 JSONObject jsobj(stream); | 10504 JSONObject jsobj(stream); |
| 10487 jsobj.AddProperty("type", JSONType(ref)); | 10505 jsobj.AddProperty("type", JSONType(ref)); |
| 10488 jsobj.AddPropertyF("id", "code/%" Px "", EntryPoint()); | 10506 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(), |
| 10507 EntryPoint()); |
| 10489 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); | 10508 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); |
| 10490 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); | 10509 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); |
| 10491 jsobj.AddProperty("is_optimized", is_optimized()); | 10510 jsobj.AddProperty("is_optimized", is_optimized()); |
| 10492 jsobj.AddProperty("is_alive", is_alive()); | 10511 jsobj.AddProperty("is_alive", is_alive()); |
| 10512 jsobj.AddProperty("kind", "Dart"); |
| 10493 const String& name = String::Handle(Name()); | 10513 const String& name = String::Handle(Name()); |
| 10494 const String& user_name = String::Handle(UserName()); | 10514 const String& user_name = String::Handle(UserName()); |
| 10495 const char* name_prefix = is_optimized() ? "*" : ""; | 10515 const char* name_prefix = is_optimized() ? "*" : ""; |
| 10496 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); | 10516 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); |
| 10497 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, user_name.ToCString()); | 10517 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, user_name.ToCString()); |
| 10498 const Object& obj = Object::Handle(owner()); | 10518 const Object& obj = Object::Handle(owner()); |
| 10499 if (obj.IsFunction()) { | 10519 if (obj.IsFunction()) { |
| 10500 jsobj.AddProperty("function", obj); | 10520 jsobj.AddProperty("function", obj); |
| 10501 } else { | 10521 } else { |
| 10502 // Generate a fake function reference. | 10522 // Generate a fake function reference. |
| 10503 JSONObject func(&jsobj, "function"); | 10523 JSONObject func(&jsobj, "function"); |
| 10504 func.AddProperty("type", "@Function"); | 10524 func.AddProperty("type", "@Function"); |
| 10505 func.AddProperty("kind", "Stub"); | 10525 func.AddProperty("kind", "Stub"); |
| 10506 func.AddPropertyF("id", "stub/functions/%" Pd "", EntryPoint()); | 10526 func.AddPropertyF("id", "functions/stub-%" Pd "", EntryPoint()); |
| 10507 func.AddProperty("user_name", user_name.ToCString()); | 10527 func.AddProperty("user_name", user_name.ToCString()); |
| 10508 func.AddProperty("name", name.ToCString()); | 10528 func.AddProperty("name", name.ToCString()); |
| 10509 } | 10529 } |
| 10510 if (ref) { | 10530 if (ref) { |
| 10511 return; | 10531 return; |
| 10512 } | 10532 } |
| 10513 JSONArray jsarr(&jsobj, "disassembly"); | 10533 JSONArray jsarr(&jsobj, "disassembly"); |
| 10514 if (is_alive()) { | 10534 if (is_alive()) { |
| 10515 // Only disassemble alive code objects. | 10535 // Only disassemble alive code objects. |
| 10516 DisassembleToJSONStream formatter(jsarr); | 10536 DisassembleToJSONStream formatter(jsarr); |
| (...skipping 7118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17635 return "_MirrorReference"; | 17655 return "_MirrorReference"; |
| 17636 } | 17656 } |
| 17637 | 17657 |
| 17638 | 17658 |
| 17639 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17659 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17640 Instance::PrintToJSONStream(stream, ref); | 17660 Instance::PrintToJSONStream(stream, ref); |
| 17641 } | 17661 } |
| 17642 | 17662 |
| 17643 | 17663 |
| 17644 } // namespace dart | 17664 } // namespace dart |
| OLD | NEW |