| 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 13 matching lines...) Expand all Loading... |
| 24 #include "vm/deopt_instructions.h" | 24 #include "vm/deopt_instructions.h" |
| 25 #include "vm/disassembler.h" | 25 #include "vm/disassembler.h" |
| 26 #include "vm/double_conversion.h" | 26 #include "vm/double_conversion.h" |
| 27 #include "vm/exceptions.h" | 27 #include "vm/exceptions.h" |
| 28 #include "vm/flow_graph_builder.h" | 28 #include "vm/flow_graph_builder.h" |
| 29 #include "vm/growable_array.h" | 29 #include "vm/growable_array.h" |
| 30 #include "vm/heap.h" | 30 #include "vm/heap.h" |
| 31 #include "vm/intermediate_language.h" | 31 #include "vm/intermediate_language.h" |
| 32 #include "vm/intrinsifier.h" | 32 #include "vm/intrinsifier.h" |
| 33 #include "vm/longjump.h" | 33 #include "vm/longjump.h" |
| 34 #include "vm/object_id_ring.h" |
| 34 #include "vm/object_store.h" | 35 #include "vm/object_store.h" |
| 35 #include "vm/parser.h" | 36 #include "vm/parser.h" |
| 36 #include "vm/runtime_entry.h" | 37 #include "vm/runtime_entry.h" |
| 37 #include "vm/scopes.h" | 38 #include "vm/scopes.h" |
| 38 #include "vm/stack_frame.h" | 39 #include "vm/stack_frame.h" |
| 39 #include "vm/symbols.h" | 40 #include "vm/symbols.h" |
| 40 #include "vm/timer.h" | 41 #include "vm/timer.h" |
| 41 #include "vm/unicode.h" | 42 #include "vm/unicode.h" |
| 42 | 43 |
| 43 namespace dart { | 44 namespace dart { |
| (...skipping 2749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2793 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); | 2794 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); |
| 2794 const char* class_name = String::Handle(Name()).ToCString(); | 2795 const char* class_name = String::Handle(Name()).ToCString(); |
| 2795 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; | 2796 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; |
| 2796 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2797 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2797 OS::SNPrint(chars, len, format, library_name, class_name); | 2798 OS::SNPrint(chars, len, format, library_name, class_name); |
| 2798 return chars; | 2799 return chars; |
| 2799 } | 2800 } |
| 2800 | 2801 |
| 2801 | 2802 |
| 2802 void Class::PrintToJSONStream(JSONStream* stream, bool ref) const { | 2803 void Class::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 2804 const char* class_name = String::Handle(UserVisibleName()).ToCString(); |
| 2805 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 2806 intptr_t id = ring->GetIdForObject(raw()); |
| 2807 if (ref) { |
| 2808 stream->OpenObject(); |
| 2809 stream->PrintProperty("type", "@Class"); |
| 2810 stream->PrintProperty("id", id); |
| 2811 stream->PrintProperty("name", class_name); |
| 2812 stream->CloseObject(); |
| 2813 return; |
| 2814 } |
| 2803 stream->OpenObject(); | 2815 stream->OpenObject(); |
| 2816 stream->PrintProperty("type", "Class"); |
| 2817 stream->PrintProperty("id", id); |
| 2818 stream->PrintProperty("name", class_name); |
| 2819 stream->PrintProperty("library", Object::Handle(library())); |
| 2804 stream->CloseObject(); | 2820 stream->CloseObject(); |
| 2805 } | 2821 } |
| 2806 | 2822 |
| 2807 | 2823 |
| 2808 void Class::InsertCanonicalConstant(intptr_t index, | 2824 void Class::InsertCanonicalConstant(intptr_t index, |
| 2809 const Instance& constant) const { | 2825 const Instance& constant) const { |
| 2810 // The constant needs to be added to the list. Grow the list if it is full. | 2826 // The constant needs to be added to the list. Grow the list if it is full. |
| 2811 Array& canonical_list = Array::Handle(constants()); | 2827 Array& canonical_list = Array::Handle(constants()); |
| 2812 const intptr_t list_len = canonical_list.Length(); | 2828 const intptr_t list_len = canonical_list.Length(); |
| 2813 if (index >= list_len) { | 2829 if (index >= list_len) { |
| (...skipping 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4953 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 4969 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
| 4954 static_str, abstract_str, kind_str, const_str) + 1; | 4970 static_str, abstract_str, kind_str, const_str) + 1; |
| 4955 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 4971 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 4956 OS::SNPrint(chars, len, kFormat, function_name, | 4972 OS::SNPrint(chars, len, kFormat, function_name, |
| 4957 static_str, abstract_str, kind_str, const_str); | 4973 static_str, abstract_str, kind_str, const_str); |
| 4958 return chars; | 4974 return chars; |
| 4959 } | 4975 } |
| 4960 | 4976 |
| 4961 | 4977 |
| 4962 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { | 4978 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 4979 const char* function_name = |
| 4980 String::Handle(QualifiedUserVisibleName()).ToCString(); |
| 4981 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 4982 intptr_t id = ring->GetIdForObject(raw()); |
| 4983 if (ref) { |
| 4984 stream->OpenObject(); |
| 4985 stream->PrintProperty("type", "@Function"); |
| 4986 stream->PrintProperty("id", id); |
| 4987 stream->PrintProperty("name", function_name); |
| 4988 stream->CloseObject(); |
| 4989 return; |
| 4990 } |
| 4963 stream->OpenObject(); | 4991 stream->OpenObject(); |
| 4992 stream->PrintProperty("type", "Function"); |
| 4993 stream->PrintProperty("name", function_name); |
| 4994 stream->PrintProperty("id", id); |
| 4995 stream->PrintPropertyBool("is_static", is_static()); |
| 4996 stream->PrintPropertyBool("is_const", is_const()); |
| 4997 stream->PrintPropertyBool("is_optimizable", is_optimizable()); |
| 4998 stream->PrintPropertyBool("is_inlinable", IsInlineable()); |
| 4999 const char* kind_string = NULL; |
| 5000 switch (kind()) { |
| 5001 case RawFunction::kRegularFunction: |
| 5002 kind_string = "regular"; |
| 5003 break; |
| 5004 case RawFunction::kGetterFunction: |
| 5005 kind_string = "getter"; |
| 5006 break; |
| 5007 case RawFunction::kSetterFunction: |
| 5008 kind_string = "setter"; |
| 5009 break; |
| 5010 case RawFunction::kImplicitGetter: |
| 5011 kind_string = "implicit getter"; |
| 5012 break; |
| 5013 case RawFunction::kImplicitSetter: |
| 5014 kind_string = "implicit setter"; |
| 5015 break; |
| 5016 case RawFunction::kMethodExtractor: |
| 5017 kind_string = "method extractor"; |
| 5018 break; |
| 5019 case RawFunction::kNoSuchMethodDispatcher: |
| 5020 kind_string = "no such method"; |
| 5021 break; |
| 5022 case RawFunction::kClosureFunction: |
| 5023 kind_string = "closure"; |
| 5024 break; |
| 5025 case RawFunction::kConstructor: |
| 5026 kind_string = "constructor"; |
| 5027 break; |
| 5028 case RawFunction::kImplicitStaticFinalGetter: |
| 5029 kind_string = "static final getter"; |
| 5030 break; |
| 5031 default: |
| 5032 UNREACHABLE(); |
| 5033 } |
| 5034 stream->PrintProperty("kind", kind_string); |
| 5035 stream->PrintProperty("unoptimized_code", Object::Handle(unoptimized_code())); |
| 5036 stream->PrintProperty("usage_counter", usage_counter()); |
| 5037 stream->PrintProperty("optimized_call_site_count", |
| 5038 optimized_call_site_count()); |
| 5039 stream->PrintProperty("code", Object::Handle(CurrentCode())); |
| 5040 stream->PrintProperty("deoptimizations", |
| 5041 static_cast<intptr_t>(deoptimization_counter())); |
| 4964 stream->CloseObject(); | 5042 stream->CloseObject(); |
| 4965 } | 5043 } |
| 4966 | 5044 |
| 4967 | 5045 |
| 4968 void ClosureData::set_context_scope(const ContextScope& value) const { | 5046 void ClosureData::set_context_scope(const ContextScope& value) const { |
| 4969 StorePointer(&raw_ptr()->context_scope_, value.raw()); | 5047 StorePointer(&raw_ptr()->context_scope_, value.raw()); |
| 4970 } | 5048 } |
| 4971 | 5049 |
| 4972 | 5050 |
| 4973 void ClosureData::set_implicit_static_closure(const Instance& closure) const { | 5051 void ClosureData::set_implicit_static_closure(const Instance& closure) const { |
| (...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7184 const char* kFormat = "Library:'%s'"; | 7262 const char* kFormat = "Library:'%s'"; |
| 7185 const String& name = String::Handle(url()); | 7263 const String& name = String::Handle(url()); |
| 7186 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; | 7264 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; |
| 7187 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 7265 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 7188 OS::SNPrint(chars, len, kFormat, name.ToCString()); | 7266 OS::SNPrint(chars, len, kFormat, name.ToCString()); |
| 7189 return chars; | 7267 return chars; |
| 7190 } | 7268 } |
| 7191 | 7269 |
| 7192 | 7270 |
| 7193 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const { | 7271 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 7272 const char* library_name = String::Handle(name()).ToCString(); |
| 7273 const char* library_url = String::Handle(url()).ToCString(); |
| 7274 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 7275 intptr_t id = ring->GetIdForObject(raw()); |
| 7276 if (ref) { |
| 7277 // Print a reference |
| 7278 stream->OpenObject(); |
| 7279 stream->PrintProperty("type", "@Library"); |
| 7280 stream->PrintProperty("id", id); |
| 7281 stream->PrintProperty("name", library_name); |
| 7282 stream->CloseObject(); |
| 7283 return; |
| 7284 } |
| 7194 stream->OpenObject(); | 7285 stream->OpenObject(); |
| 7286 stream->PrintProperty("type", "Library"); |
| 7287 stream->PrintProperty("id", id); |
| 7288 stream->PrintProperty("name", library_name); |
| 7289 stream->PrintProperty("url", library_url); |
| 7290 ClassDictionaryIterator class_iter(*this); |
| 7291 stream->OpenArray("classes"); |
| 7292 Class& klass = Class::Handle(); |
| 7293 while (class_iter.HasNext()) { |
| 7294 klass = class_iter.GetNextClass(); |
| 7295 stream->PrintValue(klass); |
| 7296 } |
| 7297 stream->CloseArray(); |
| 7298 stream->OpenArray("libraries"); |
| 7299 Library& lib = Library::Handle(); |
| 7300 for (intptr_t i = 0; i < num_imports(); i++) { |
| 7301 lib = ImportLibraryAt(i); |
| 7302 stream->PrintValue(lib); |
| 7303 } |
| 7304 stream->CloseArray(); |
| 7195 stream->CloseObject(); | 7305 stream->CloseObject(); |
| 7196 } | 7306 } |
| 7197 | 7307 |
| 7198 | 7308 |
| 7199 RawLibrary* LibraryPrefix::GetLibrary(int index) const { | 7309 RawLibrary* LibraryPrefix::GetLibrary(int index) const { |
| 7200 if ((index >= 0) || (index < num_imports())) { | 7310 if ((index >= 0) || (index < num_imports())) { |
| 7201 const Array& imports = Array::Handle(this->imports()); | 7311 const Array& imports = Array::Handle(this->imports()); |
| 7202 Namespace& import = Namespace::Handle(); | 7312 Namespace& import = Namespace::Handle(); |
| 7203 import ^= imports.At(index); | 7313 import ^= imports.At(index); |
| 7204 return import.library(); | 7314 return import.library(); |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8597 const char* Code::ToCString() const { | 8707 const char* Code::ToCString() const { |
| 8598 const char* kFormat = "Code entry:%p"; | 8708 const char* kFormat = "Code entry:%p"; |
| 8599 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; | 8709 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; |
| 8600 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 8710 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 8601 OS::SNPrint(chars, len, kFormat, EntryPoint()); | 8711 OS::SNPrint(chars, len, kFormat, EntryPoint()); |
| 8602 return chars; | 8712 return chars; |
| 8603 } | 8713 } |
| 8604 | 8714 |
| 8605 | 8715 |
| 8606 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { | 8716 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 8717 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 8718 intptr_t id = ring->GetIdForObject(raw()); |
| 8719 if (ref) { |
| 8720 stream->OpenObject(); |
| 8721 stream->PrintProperty("type", "@Code"); |
| 8722 stream->PrintProperty("id", id); |
| 8723 stream->CloseObject(); |
| 8724 return; |
| 8725 } |
| 8607 stream->OpenObject(); | 8726 stream->OpenObject(); |
| 8727 stream->PrintProperty("type", "Code"); |
| 8728 stream->PrintProperty("id", id); |
| 8729 stream->PrintPropertyBool("is_optimized", is_optimized()); |
| 8730 stream->PrintPropertyBool("is_alive", is_alive()); |
| 8731 stream->PrintProperty("function", Object::Handle(function())); |
| 8732 stream->OpenArray("disassembly"); |
| 8733 DisassembleToJSONStream formatter(stream); |
| 8734 const Instructions& instr = Instructions::Handle(instructions()); |
| 8735 uword start = instr.EntryPoint(); |
| 8736 Disassembler::Disassemble(start, start + instr.size(), &formatter, |
| 8737 comments()); |
| 8738 stream->CloseArray(); |
| 8608 stream->CloseObject(); | 8739 stream->CloseObject(); |
| 8609 } | 8740 } |
| 8610 | 8741 |
| 8611 | 8742 |
| 8612 uword Code::GetPatchCodePc() const { | 8743 uword Code::GetPatchCodePc() const { |
| 8613 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 8744 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
| 8614 return descriptors.GetPcForKind(PcDescriptors::kPatchCode); | 8745 return descriptors.GetPcForKind(PcDescriptors::kPatchCode); |
| 8615 } | 8746 } |
| 8616 | 8747 |
| 8617 | 8748 |
| (...skipping 5797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14415 } | 14546 } |
| 14416 | 14547 |
| 14417 | 14548 |
| 14418 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14549 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 14419 stream->OpenObject(); | 14550 stream->OpenObject(); |
| 14420 stream->CloseObject(); | 14551 stream->CloseObject(); |
| 14421 } | 14552 } |
| 14422 | 14553 |
| 14423 | 14554 |
| 14424 } // namespace dart | 14555 } // namespace dart |
| OLD | NEW |