Chromium Code Reviews| 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 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2792 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); | 2793 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); |
| 2793 const char* class_name = String::Handle(Name()).ToCString(); | 2794 const char* class_name = String::Handle(Name()).ToCString(); |
| 2794 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; | 2795 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; |
| 2795 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2796 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2796 OS::SNPrint(chars, len, format, library_name, class_name); | 2797 OS::SNPrint(chars, len, format, library_name, class_name); |
| 2797 return chars; | 2798 return chars; |
| 2798 } | 2799 } |
| 2799 | 2800 |
| 2800 | 2801 |
| 2801 void Class::PrintToJSONStream(JSONStream* stream, bool ref) const { | 2802 void Class::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 2803 const char* class_name = String::Handle(UserVisibleName()).ToCString(); | |
| 2804 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | |
| 2805 intptr_t id = ring->GetIdForObject(raw()); | |
| 2806 if (ref) { | |
| 2807 stream->OpenObject(); | |
| 2808 stream->PrintProperty("type", "@Class"); | |
| 2809 stream->PrintProperty("id", id); | |
| 2810 stream->PrintProperty("name", class_name); | |
| 2811 stream->CloseObject(); | |
| 2812 return; | |
| 2813 } | |
| 2802 stream->OpenObject(); | 2814 stream->OpenObject(); |
| 2815 stream->PrintProperty("type", "Class"); | |
| 2816 stream->PrintProperty("id", id); | |
| 2817 stream->PrintProperty("name", class_name); | |
| 2818 stream->PrintProperty("library", Object::Handle(library())); | |
| 2803 stream->CloseObject(); | 2819 stream->CloseObject(); |
| 2804 } | 2820 } |
| 2805 | 2821 |
| 2806 | 2822 |
| 2807 void Class::InsertCanonicalConstant(intptr_t index, | 2823 void Class::InsertCanonicalConstant(intptr_t index, |
| 2808 const Instance& constant) const { | 2824 const Instance& constant) const { |
| 2809 // The constant needs to be added to the list. Grow the list if it is full. | 2825 // The constant needs to be added to the list. Grow the list if it is full. |
| 2810 Array& canonical_list = Array::Handle(constants()); | 2826 Array& canonical_list = Array::Handle(constants()); |
| 2811 const intptr_t list_len = canonical_list.Length(); | 2827 const intptr_t list_len = canonical_list.Length(); |
| 2812 if (index >= list_len) { | 2828 if (index >= list_len) { |
| (...skipping 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4952 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 4968 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
| 4953 static_str, abstract_str, kind_str, const_str) + 1; | 4969 static_str, abstract_str, kind_str, const_str) + 1; |
| 4954 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 4970 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 4955 OS::SNPrint(chars, len, kFormat, function_name, | 4971 OS::SNPrint(chars, len, kFormat, function_name, |
| 4956 static_str, abstract_str, kind_str, const_str); | 4972 static_str, abstract_str, kind_str, const_str); |
| 4957 return chars; | 4973 return chars; |
| 4958 } | 4974 } |
| 4959 | 4975 |
| 4960 | 4976 |
| 4961 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { | 4977 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 4978 const char* function_name = | |
| 4979 String::Handle(QualifiedUserVisibleName()).ToCString(); | |
| 4980 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | |
| 4981 intptr_t id = ring->GetIdForObject(raw()); | |
| 4982 if (ref) { | |
| 4983 stream->OpenObject(); | |
| 4984 stream->PrintProperty("type", "@Function"); | |
| 4985 stream->PrintProperty("id", id); | |
| 4986 stream->PrintProperty("name", function_name); | |
| 4987 stream->CloseObject(); | |
| 4988 return; | |
| 4989 } | |
| 4962 stream->OpenObject(); | 4990 stream->OpenObject(); |
| 4991 stream->PrintProperty("type", "Function"); | |
| 4992 stream->PrintProperty("name", function_name); | |
| 4993 stream->PrintProperty("id", id); | |
| 4994 stream->PrintPropertyBool("is_static", is_static()); | |
| 4995 stream->PrintPropertyBool("is_const", is_const()); | |
| 4996 stream->PrintPropertyBool("is_optimizable", is_optimizable()); | |
| 4997 stream->PrintPropertyBool("is_inlinable", IsInlineable()); | |
| 4998 const char* kind_string = NULL; | |
| 4999 switch (kind()) { | |
| 5000 case RawFunction::kRegularFunction: | |
| 5001 kind_string = "regular"; | |
| 5002 break; | |
| 5003 case RawFunction::kGetterFunction: | |
| 5004 kind_string = "getter"; | |
| 5005 break; | |
| 5006 case RawFunction::kSetterFunction: | |
| 5007 kind_string = "setter"; | |
| 5008 break; | |
| 5009 case RawFunction::kImplicitGetter: | |
| 5010 kind_string = "implicit getter"; | |
| 5011 break; | |
| 5012 case RawFunction::kImplicitSetter: | |
| 5013 kind_string = "implicit setter"; | |
| 5014 break; | |
| 5015 case RawFunction::kMethodExtractor: | |
| 5016 kind_string = "method extractor"; | |
| 5017 break; | |
| 5018 case RawFunction::kNoSuchMethodDispatcher: | |
| 5019 kind_string = "no such method"; | |
| 5020 break; | |
| 5021 case RawFunction::kClosureFunction: | |
| 5022 kind_string = "closure"; | |
| 5023 break; | |
| 5024 case RawFunction::kConstructor: | |
| 5025 kind_string = "constructor"; | |
| 5026 break; | |
| 5027 case RawFunction::kImplicitStaticFinalGetter: | |
| 5028 kind_string = "static final getter"; | |
| 5029 break; | |
| 5030 default: | |
| 5031 UNREACHABLE(); | |
| 5032 } | |
| 5033 stream->PrintProperty("kind", kind_string); | |
| 5034 stream->PrintProperty("unoptimized_code", Object::Handle(unoptimized_code())); | |
| 5035 stream->PrintProperty("usage_counter", usage_counter()); | |
| 5036 stream->PrintProperty("optimized_call_site_count", | |
| 5037 optimized_call_site_count()); | |
| 5038 stream->PrintProperty("code", Object::Handle(CurrentCode())); | |
| 5039 stream->PrintProperty("deoptimizations", | |
| 5040 static_cast<intptr_t>(deoptimization_counter())); | |
| 4963 stream->CloseObject(); | 5041 stream->CloseObject(); |
| 4964 } | 5042 } |
| 4965 | 5043 |
| 4966 | 5044 |
| 4967 void ClosureData::set_context_scope(const ContextScope& value) const { | 5045 void ClosureData::set_context_scope(const ContextScope& value) const { |
| 4968 StorePointer(&raw_ptr()->context_scope_, value.raw()); | 5046 StorePointer(&raw_ptr()->context_scope_, value.raw()); |
| 4969 } | 5047 } |
| 4970 | 5048 |
| 4971 | 5049 |
| 4972 void ClosureData::set_implicit_static_closure(const Instance& closure) const { | 5050 void ClosureData::set_implicit_static_closure(const Instance& closure) const { |
| (...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7176 const char* kFormat = "Library:'%s'"; | 7254 const char* kFormat = "Library:'%s'"; |
| 7177 const String& name = String::Handle(url()); | 7255 const String& name = String::Handle(url()); |
| 7178 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; | 7256 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; |
| 7179 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 7257 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 7180 OS::SNPrint(chars, len, kFormat, name.ToCString()); | 7258 OS::SNPrint(chars, len, kFormat, name.ToCString()); |
| 7181 return chars; | 7259 return chars; |
| 7182 } | 7260 } |
| 7183 | 7261 |
| 7184 | 7262 |
| 7185 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const { | 7263 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 7264 const char* library_name = String::Handle(name()).ToCString(); | |
| 7265 const char* library_url = String::Handle(url()).ToCString(); | |
| 7266 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | |
| 7267 intptr_t id = ring->GetIdForObject(raw()); | |
| 7268 if (ref) { | |
| 7269 // Print a reference | |
| 7270 stream->OpenObject(); | |
| 7271 stream->PrintProperty("type", "@Library"); | |
| 7272 stream->PrintProperty("id", id); | |
| 7273 stream->PrintProperty("name", library_name); | |
| 7274 stream->CloseObject(); | |
| 7275 return; | |
| 7276 } | |
| 7186 stream->OpenObject(); | 7277 stream->OpenObject(); |
| 7278 stream->PrintProperty("type", "Library"); | |
| 7279 stream->PrintProperty("id", id); | |
| 7280 stream->PrintProperty("name", library_name); | |
| 7281 stream->PrintProperty("url", library_url); | |
| 7282 ClassDictionaryIterator class_iter(*this); | |
| 7283 stream->OpenArray("classes"); | |
| 7284 while (class_iter.HasNext()) { | |
| 7285 const Class& klass = Class::Handle(class_iter.GetNextClass()); | |
|
siva
2013/08/01 18:16:18
Hoist the handle creation outside the loop.
Class
Cutch
2013/08/01 22:22:04
Done.
| |
| 7286 stream->PrintValue(klass); | |
| 7287 } | |
| 7288 stream->CloseArray(); | |
| 7289 stream->OpenArray("libraries"); | |
| 7290 for (intptr_t i = 0; i < num_imports(); i++) { | |
| 7291 const Library& lib = Library::Handle(ImportLibraryAt(i)); | |
|
siva
2013/08/01 18:16:18
Ditto comment about handle creation to be hoisted
Cutch
2013/08/01 22:22:04
Done.
| |
| 7292 stream->PrintValue(lib); | |
| 7293 } | |
| 7294 stream->CloseArray(); | |
| 7187 stream->CloseObject(); | 7295 stream->CloseObject(); |
| 7188 } | 7296 } |
| 7189 | 7297 |
| 7190 | 7298 |
| 7191 RawLibrary* LibraryPrefix::GetLibrary(int index) const { | 7299 RawLibrary* LibraryPrefix::GetLibrary(int index) const { |
| 7192 if ((index >= 0) || (index < num_imports())) { | 7300 if ((index >= 0) || (index < num_imports())) { |
| 7193 const Array& imports = Array::Handle(this->imports()); | 7301 const Array& imports = Array::Handle(this->imports()); |
| 7194 Namespace& import = Namespace::Handle(); | 7302 Namespace& import = Namespace::Handle(); |
| 7195 import ^= imports.At(index); | 7303 import ^= imports.At(index); |
| 7196 return import.library(); | 7304 return import.library(); |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8589 const char* Code::ToCString() const { | 8697 const char* Code::ToCString() const { |
| 8590 const char* kFormat = "Code entry:%p"; | 8698 const char* kFormat = "Code entry:%p"; |
| 8591 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; | 8699 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; |
| 8592 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 8700 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 8593 OS::SNPrint(chars, len, kFormat, EntryPoint()); | 8701 OS::SNPrint(chars, len, kFormat, EntryPoint()); |
| 8594 return chars; | 8702 return chars; |
| 8595 } | 8703 } |
| 8596 | 8704 |
| 8597 | 8705 |
| 8598 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { | 8706 void Code::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 8707 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | |
| 8708 intptr_t id = ring->GetIdForObject(raw()); | |
| 8709 if (ref) { | |
| 8710 stream->OpenObject(); | |
| 8711 stream->PrintProperty("type", "@Code"); | |
| 8712 stream->PrintProperty("id", id); | |
| 8713 stream->CloseObject(); | |
| 8714 return; | |
| 8715 } | |
| 8599 stream->OpenObject(); | 8716 stream->OpenObject(); |
| 8717 stream->PrintProperty("type", "Code"); | |
| 8718 stream->PrintProperty("id", id); | |
| 8719 stream->PrintPropertyBool("is_optimized", is_optimized()); | |
| 8720 stream->PrintPropertyBool("is_alive", is_alive()); | |
| 8721 stream->PrintProperty("function", Object::Handle(function())); | |
| 8722 stream->OpenArray("disassembly"); | |
| 8723 DisassembleToJSONStream formatter(stream); | |
| 8724 const Instructions& instr = Instructions::Handle(instructions()); | |
| 8725 uword start = instr.EntryPoint(); | |
| 8726 Disassembler::Disassemble(start, start + instr.size(), &formatter, | |
| 8727 comments()); | |
| 8728 stream->CloseArray(); | |
| 8600 stream->CloseObject(); | 8729 stream->CloseObject(); |
| 8601 } | 8730 } |
| 8602 | 8731 |
| 8603 | 8732 |
| 8604 uword Code::GetPatchCodePc() const { | 8733 uword Code::GetPatchCodePc() const { |
| 8605 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 8734 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
| 8606 return descriptors.GetPcForKind(PcDescriptors::kPatchCode); | 8735 return descriptors.GetPcForKind(PcDescriptors::kPatchCode); |
| 8607 } | 8736 } |
| 8608 | 8737 |
| 8609 | 8738 |
| (...skipping 5772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14382 } | 14511 } |
| 14383 | 14512 |
| 14384 | 14513 |
| 14385 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14514 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 14386 stream->OpenObject(); | 14515 stream->OpenObject(); |
| 14387 stream->CloseObject(); | 14516 stream->CloseObject(); |
| 14388 } | 14517 } |
| 14389 | 14518 |
| 14390 | 14519 |
| 14391 } // namespace dart | 14520 } // namespace dart |
| OLD | NEW |