| 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 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 | 1627 |
| 1628 | 1628 |
| 1629 RawString* Class::Name() const { | 1629 RawString* Class::Name() const { |
| 1630 // TODO(turnidge): This assert fails for the fake kFreeListElement class. | 1630 // TODO(turnidge): This assert fails for the fake kFreeListElement class. |
| 1631 // Fix this. | 1631 // Fix this. |
| 1632 ASSERT(raw_ptr()->name_ != String::null()); | 1632 ASSERT(raw_ptr()->name_ != String::null()); |
| 1633 return raw_ptr()->name_; | 1633 return raw_ptr()->name_; |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 | 1636 |
| 1637 RawString* Class::PrettyName() const { |
| 1638 return GeneratePrettyName(); |
| 1639 } |
| 1640 |
| 1641 |
| 1637 RawString* Class::UserVisibleName() const { | 1642 RawString* Class::UserVisibleName() const { |
| 1638 ASSERT(raw_ptr()->user_name_ != String::null()); | 1643 ASSERT(raw_ptr()->user_name_ != String::null()); |
| 1639 return raw_ptr()->user_name_; | 1644 return raw_ptr()->user_name_; |
| 1640 } | 1645 } |
| 1641 | 1646 |
| 1642 | 1647 |
| 1643 RawType* Class::SignatureType() const { | 1648 RawType* Class::SignatureType() const { |
| 1644 ASSERT(IsSignatureClass()); | 1649 ASSERT(IsSignatureClass()); |
| 1645 const Function& function = Function::Handle(signature_function()); | 1650 const Function& function = Function::Handle(signature_function()); |
| 1646 ASSERT(!function.IsNull()); | 1651 ASSERT(!function.IsNull()); |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3024 set_user_name(user_name); | 3029 set_user_name(user_name); |
| 3025 } | 3030 } |
| 3026 } | 3031 } |
| 3027 | 3032 |
| 3028 | 3033 |
| 3029 void Class::set_user_name(const String& value) const { | 3034 void Class::set_user_name(const String& value) const { |
| 3030 StorePointer(&raw_ptr()->user_name_, value.raw()); | 3035 StorePointer(&raw_ptr()->user_name_, value.raw()); |
| 3031 } | 3036 } |
| 3032 | 3037 |
| 3033 | 3038 |
| 3039 RawString* Class::GeneratePrettyName() const { |
| 3040 if (!IsCanonicalSignatureClass()) { |
| 3041 const String& name = String::Handle(Name()); |
| 3042 return String::IdentifierPrettyName(name); |
| 3043 } else { |
| 3044 return Name(); |
| 3045 } |
| 3046 } |
| 3047 |
| 3048 |
| 3034 RawString* Class::GenerateUserVisibleName() const { | 3049 RawString* Class::GenerateUserVisibleName() const { |
| 3035 if (FLAG_show_internal_names) { | 3050 if (FLAG_show_internal_names) { |
| 3036 return Name(); | 3051 return Name(); |
| 3037 } | 3052 } |
| 3038 switch (id()) { | 3053 switch (id()) { |
| 3039 case kNullCid: | 3054 case kNullCid: |
| 3040 return Symbols::Null().raw(); | 3055 return Symbols::Null().raw(); |
| 3041 case kDynamicCid: | 3056 case kDynamicCid: |
| 3042 return Symbols::Dynamic().raw(); | 3057 return Symbols::Dynamic().raw(); |
| 3043 case kVoidCid: | 3058 case kVoidCid: |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 } | 3917 } |
| 3903 | 3918 |
| 3904 | 3919 |
| 3905 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | 3920 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 3906 JSONObject jsobj(stream); | 3921 JSONObject jsobj(stream); |
| 3907 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | 3922 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
| 3908 jsobj.AddProperty("type", "Null"); | 3923 jsobj.AddProperty("type", "Null"); |
| 3909 return; | 3924 return; |
| 3910 } | 3925 } |
| 3911 const char* internal_class_name = String::Handle(Name()).ToCString(); | 3926 const char* internal_class_name = String::Handle(Name()).ToCString(); |
| 3912 const char* user_visible_class_name = | 3927 const char* pretty_class_name = |
| 3913 String::Handle(UserVisibleName()).ToCString(); | 3928 String::Handle(PrettyName()).ToCString(); |
| 3914 jsobj.AddProperty("type", JSONType(ref)); | 3929 jsobj.AddProperty("type", JSONType(ref)); |
| 3915 jsobj.AddPropertyF("id", "classes/%" Pd "", id()); | 3930 jsobj.AddPropertyF("id", "classes/%" Pd "", id()); |
| 3916 jsobj.AddProperty("name", internal_class_name); | 3931 jsobj.AddProperty("name", internal_class_name); |
| 3917 jsobj.AddProperty("user_name", user_visible_class_name); | 3932 jsobj.AddProperty("user_name", pretty_class_name); |
| 3918 if (ref) { | 3933 if (ref) { |
| 3919 return; | 3934 return; |
| 3920 } | 3935 } |
| 3921 | 3936 |
| 3922 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); | 3937 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); |
| 3923 if (!err.IsNull()) { | 3938 if (!err.IsNull()) { |
| 3924 jsobj.AddProperty("error", err); | 3939 jsobj.AddProperty("error", err); |
| 3925 } | 3940 } |
| 3926 jsobj.AddProperty("implemented", is_implemented()); | 3941 jsobj.AddProperty("implemented", is_implemented()); |
| 3927 jsobj.AddProperty("abstract", is_abstract()); | 3942 jsobj.AddProperty("abstract", is_abstract()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3991 subclasses_array.AddValue(subclass); | 4006 subclasses_array.AddValue(subclass); |
| 3992 } | 4007 } |
| 3993 } | 4008 } |
| 3994 } | 4009 } |
| 3995 } | 4010 } |
| 3996 { | 4011 { |
| 3997 JSONObject typesRef(&jsobj, "canonicalTypes"); | 4012 JSONObject typesRef(&jsobj, "canonicalTypes"); |
| 3998 typesRef.AddProperty("type", "@TypeList"); | 4013 typesRef.AddProperty("type", "@TypeList"); |
| 3999 typesRef.AddPropertyF("id", "classes/%" Pd "/types", id()); | 4014 typesRef.AddPropertyF("id", "classes/%" Pd "/types", id()); |
| 4000 jsobj.AddPropertyF("name", "canonical types of %s", internal_class_name); | 4015 jsobj.AddPropertyF("name", "canonical types of %s", internal_class_name); |
| 4001 jsobj.AddPropertyF("user_name", "canonical types of %s", | 4016 jsobj.AddPropertyF("user_name", "canonical types of %s", pretty_class_name); |
| 4002 user_visible_class_name); | |
| 4003 } | 4017 } |
| 4004 } | 4018 } |
| 4005 | 4019 |
| 4006 | 4020 |
| 4007 void Class::InsertCanonicalConstant(intptr_t index, | 4021 void Class::InsertCanonicalConstant(intptr_t index, |
| 4008 const Instance& constant) const { | 4022 const Instance& constant) const { |
| 4009 // The constant needs to be added to the list. Grow the list if it is full. | 4023 // The constant needs to be added to the list. Grow the list if it is full. |
| 4010 Array& canonical_list = Array::Handle(constants()); | 4024 Array& canonical_list = Array::Handle(constants()); |
| 4011 const intptr_t list_len = canonical_list.Length(); | 4025 const intptr_t list_len = canonical_list.Length(); |
| 4012 if (index >= list_len) { | 4026 if (index >= list_len) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4245 // preserved when the table grows and the entries get rehashed. Use the ring. | 4259 // preserved when the table grows and the entries get rehashed. Use the ring. |
| 4246 Isolate* isolate = Isolate::Current(); | 4260 Isolate* isolate = Isolate::Current(); |
| 4247 ObjectStore* object_store = isolate->object_store(); | 4261 ObjectStore* object_store = isolate->object_store(); |
| 4248 const Array& table = Array::Handle(object_store->canonical_type_arguments()); | 4262 const Array& table = Array::Handle(object_store->canonical_type_arguments()); |
| 4249 ASSERT(table.Length() > 0); | 4263 ASSERT(table.Length() > 0); |
| 4250 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 4264 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 4251 const intptr_t id = ring->GetIdForObject(raw()); | 4265 const intptr_t id = ring->GetIdForObject(raw()); |
| 4252 jsobj.AddProperty("type", JSONType(ref)); | 4266 jsobj.AddProperty("type", JSONType(ref)); |
| 4253 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 4267 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 4254 const char* name = String::Handle(Name()).ToCString(); | 4268 const char* name = String::Handle(Name()).ToCString(); |
| 4255 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 4269 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 4256 jsobj.AddProperty("name", name); | 4270 jsobj.AddProperty("name", name); |
| 4257 jsobj.AddProperty("user_name", user_name); | 4271 jsobj.AddProperty("user_name", pretty_name); |
| 4258 jsobj.AddProperty("length", Length()); | 4272 jsobj.AddProperty("length", Length()); |
| 4259 jsobj.AddProperty("num_instantiations", NumInstantiations()); | 4273 jsobj.AddProperty("num_instantiations", NumInstantiations()); |
| 4260 if (ref) { | 4274 if (ref) { |
| 4261 return; | 4275 return; |
| 4262 } | 4276 } |
| 4263 { | 4277 { |
| 4264 JSONArray jsarr(&jsobj, "types"); | 4278 JSONArray jsarr(&jsobj, "types"); |
| 4265 AbstractType& type_arg = AbstractType::Handle(); | 4279 AbstractType& type_arg = AbstractType::Handle(); |
| 4266 for (intptr_t i = 0; i < Length(); i++) { | 4280 for (intptr_t i = 0; i < Length(); i++) { |
| 4267 type_arg = TypeAt(i); | 4281 type_arg = TypeAt(i); |
| (...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6258 ASSERT(obj.IsPatchClass()); | 6272 ASSERT(obj.IsPatchClass()); |
| 6259 return PatchClass::Cast(obj).Script(); | 6273 return PatchClass::Cast(obj).Script(); |
| 6260 } | 6274 } |
| 6261 | 6275 |
| 6262 | 6276 |
| 6263 bool Function::HasOptimizedCode() const { | 6277 bool Function::HasOptimizedCode() const { |
| 6264 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); | 6278 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); |
| 6265 } | 6279 } |
| 6266 | 6280 |
| 6267 | 6281 |
| 6282 RawString* Function::PrettyName() const { |
| 6283 const String& str = String::Handle(name()); |
| 6284 return String::IdentifierPrettyName(str); |
| 6285 } |
| 6286 |
| 6287 |
| 6268 RawString* Function::UserVisibleName() const { | 6288 RawString* Function::UserVisibleName() const { |
| 6269 const String& str = String::Handle(name()); | 6289 return PrettyName(); |
| 6270 return String::IdentifierPrettyName(str); | 6290 } |
| 6291 |
| 6292 |
| 6293 RawString* Function::QualifiedPrettyName() const { |
| 6294 String& tmp = String::Handle(); |
| 6295 const Class& cls = Class::Handle(Owner()); |
| 6296 |
| 6297 if (IsClosureFunction()) { |
| 6298 if (IsLocalFunction() && !IsImplicitClosureFunction()) { |
| 6299 const Function& parent = Function::Handle(parent_function()); |
| 6300 tmp = parent.QualifiedPrettyName(); |
| 6301 } else { |
| 6302 return PrettyName(); |
| 6303 } |
| 6304 } else { |
| 6305 if (cls.IsTopLevel()) { |
| 6306 return PrettyName(); |
| 6307 } else { |
| 6308 tmp = cls.PrettyName(); |
| 6309 } |
| 6310 } |
| 6311 tmp = String::Concat(tmp, Symbols::Dot()); |
| 6312 const String& suffix = String::Handle(PrettyName()); |
| 6313 return String::Concat(tmp, suffix); |
| 6271 } | 6314 } |
| 6272 | 6315 |
| 6273 | 6316 |
| 6274 RawString* Function::QualifiedUserVisibleName() const { | 6317 RawString* Function::QualifiedUserVisibleName() const { |
| 6275 String& tmp = String::Handle(); | 6318 String& tmp = String::Handle(); |
| 6276 const Class& cls = Class::Handle(Owner()); | 6319 const Class& cls = Class::Handle(Owner()); |
| 6277 | 6320 |
| 6278 if (IsClosureFunction()) { | 6321 if (IsClosureFunction()) { |
| 6279 if (IsLocalFunction() && !IsImplicitClosureFunction()) { | 6322 if (IsLocalFunction() && !IsImplicitClosureFunction()) { |
| 6280 const Function& parent = Function::Handle(parent_function()); | 6323 const Function& parent = Function::Handle(parent_function()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6429 static_str, abstract_str, kind_str, const_str) + 1; | 6472 static_str, abstract_str, kind_str, const_str) + 1; |
| 6430 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6473 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6431 OS::SNPrint(chars, len, kFormat, function_name, | 6474 OS::SNPrint(chars, len, kFormat, function_name, |
| 6432 static_str, abstract_str, kind_str, const_str); | 6475 static_str, abstract_str, kind_str, const_str); |
| 6433 return chars; | 6476 return chars; |
| 6434 } | 6477 } |
| 6435 | 6478 |
| 6436 | 6479 |
| 6437 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | 6480 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 6438 const char* internal_name = String::Handle(name()).ToCString(); | 6481 const char* internal_name = String::Handle(name()).ToCString(); |
| 6439 const char* user_name = | 6482 const char* pretty_name = |
| 6440 String::Handle(UserVisibleName()).ToCString(); | 6483 String::Handle(PrettyName()).ToCString(); |
| 6441 Class& cls = Class::Handle(Owner()); | 6484 Class& cls = Class::Handle(Owner()); |
| 6442 ASSERT(!cls.IsNull()); | 6485 ASSERT(!cls.IsNull()); |
| 6443 Error& err = Error::Handle(); | 6486 Error& err = Error::Handle(); |
| 6444 err ^= cls.EnsureIsFinalized(Isolate::Current()); | 6487 err ^= cls.EnsureIsFinalized(Isolate::Current()); |
| 6445 ASSERT(err.IsNull()); | 6488 ASSERT(err.IsNull()); |
| 6446 intptr_t id = -1; | 6489 intptr_t id = -1; |
| 6447 const char* selector = NULL; | 6490 const char* selector = NULL; |
| 6448 if (IsNonImplicitClosureFunction()) { | 6491 if (IsNonImplicitClosureFunction()) { |
| 6449 id = cls.FindClosureIndex(*this); | 6492 id = cls.FindClosureIndex(*this); |
| 6450 selector = "closures"; | 6493 selector = "closures"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6465 // id ring. Current known examples are signature functions of closures | 6508 // id ring. Current known examples are signature functions of closures |
| 6466 // and stubs like 'megamorphic_miss'. | 6509 // and stubs like 'megamorphic_miss'. |
| 6467 if (id < 0) { | 6510 if (id < 0) { |
| 6468 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 6511 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 6469 id = ring->GetIdForObject(raw()); | 6512 id = ring->GetIdForObject(raw()); |
| 6470 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 6513 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 6471 } else { | 6514 } else { |
| 6472 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); | 6515 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); |
| 6473 } | 6516 } |
| 6474 jsobj.AddProperty("name", internal_name); | 6517 jsobj.AddProperty("name", internal_name); |
| 6475 jsobj.AddProperty("user_name", user_name); | 6518 jsobj.AddProperty("user_name", pretty_name); |
| 6476 if (cls.IsTopLevel()) { | 6519 if (cls.IsTopLevel()) { |
| 6477 const Library& library = Library::Handle(cls.library()); | 6520 const Library& library = Library::Handle(cls.library()); |
| 6478 jsobj.AddProperty("owner", library); | 6521 jsobj.AddProperty("owner", library); |
| 6479 } else { | 6522 } else { |
| 6480 jsobj.AddProperty("owner", cls); | 6523 jsobj.AddProperty("owner", cls); |
| 6481 } | 6524 } |
| 6482 const Function& parent = Function::Handle(parent_function()); | 6525 const Function& parent = Function::Handle(parent_function()); |
| 6483 if (!parent.IsNull()) { | 6526 if (!parent.IsNull()) { |
| 6484 jsobj.AddProperty("parent", parent); | 6527 jsobj.AddProperty("parent", parent); |
| 6485 } | 6528 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6726 PatchClass::Handle(PatchClass::New(new_owner, owner)); | 6769 PatchClass::Handle(PatchClass::New(new_owner, owner)); |
| 6727 clone.set_owner(clone_owner); | 6770 clone.set_owner(clone_owner); |
| 6728 clone.set_dependent_code(Object::null_array()); | 6771 clone.set_dependent_code(Object::null_array()); |
| 6729 if (!clone.is_static()) { | 6772 if (!clone.is_static()) { |
| 6730 clone.SetOffset(0); | 6773 clone.SetOffset(0); |
| 6731 } | 6774 } |
| 6732 return clone.raw(); | 6775 return clone.raw(); |
| 6733 } | 6776 } |
| 6734 | 6777 |
| 6735 | 6778 |
| 6779 RawString* Field::PrettyName() const { |
| 6780 const String& str = String::Handle(name()); |
| 6781 return String::IdentifierPrettyName(str); |
| 6782 } |
| 6783 |
| 6784 |
| 6736 RawString* Field::UserVisibleName() const { | 6785 RawString* Field::UserVisibleName() const { |
| 6737 const String& str = String::Handle(name()); | 6786 return PrettyName(); |
| 6738 return String::IdentifierPrettyName(str); | |
| 6739 } | 6787 } |
| 6740 | 6788 |
| 6741 | 6789 |
| 6742 intptr_t Field::guarded_list_length() const { | 6790 intptr_t Field::guarded_list_length() const { |
| 6743 return Smi::Value(raw_ptr()->guarded_list_length_); | 6791 return Smi::Value(raw_ptr()->guarded_list_length_); |
| 6744 } | 6792 } |
| 6745 | 6793 |
| 6746 | 6794 |
| 6747 void Field::set_guarded_list_length(intptr_t list_length) const { | 6795 void Field::set_guarded_list_length(intptr_t list_length) const { |
| 6748 raw_ptr()->guarded_list_length_ = Smi::New(list_length); | 6796 raw_ptr()->guarded_list_length_ = Smi::New(list_length); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6780 intptr_t len = | 6828 intptr_t len = |
| 6781 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; | 6829 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; |
| 6782 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6830 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6783 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); | 6831 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); |
| 6784 return chars; | 6832 return chars; |
| 6785 } | 6833 } |
| 6786 | 6834 |
| 6787 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { | 6835 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 6788 JSONObject jsobj(stream); | 6836 JSONObject jsobj(stream); |
| 6789 const char* internal_field_name = String::Handle(name()).ToCString(); | 6837 const char* internal_field_name = String::Handle(name()).ToCString(); |
| 6790 const char* field_name = String::Handle(UserVisibleName()).ToCString(); | 6838 const char* field_name = String::Handle(PrettyName()).ToCString(); |
| 6791 Class& cls = Class::Handle(owner()); | 6839 Class& cls = Class::Handle(owner()); |
| 6792 intptr_t id = cls.FindFieldIndex(*this); | 6840 intptr_t id = cls.FindFieldIndex(*this); |
| 6793 ASSERT(id >= 0); | 6841 ASSERT(id >= 0); |
| 6794 intptr_t cid = cls.id(); | 6842 intptr_t cid = cls.id(); |
| 6795 jsobj.AddProperty("type", JSONType(ref)); | 6843 jsobj.AddProperty("type", JSONType(ref)); |
| 6796 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); | 6844 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); |
| 6797 jsobj.AddProperty("name", internal_field_name); | 6845 jsobj.AddProperty("name", internal_field_name); |
| 6798 jsobj.AddProperty("user_name", field_name); | 6846 jsobj.AddProperty("user_name", field_name); |
| 6799 if (is_static()) { | 6847 if (is_static()) { |
| 6800 const Instance& valueObj = Instance::Handle(value()); | 6848 const Instance& valueObj = Instance::Handle(value()); |
| (...skipping 4852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11653 ASSERT(!cls_name.IsNull()); | 11701 ASSERT(!cls_name.IsNull()); |
| 11654 return String::Concat(Symbols::AllocationStubFor(), cls_name); | 11702 return String::Concat(Symbols::AllocationStubFor(), cls_name); |
| 11655 } else { | 11703 } else { |
| 11656 ASSERT(obj.IsFunction()); | 11704 ASSERT(obj.IsFunction()); |
| 11657 // Dart function. | 11705 // Dart function. |
| 11658 return Function::Cast(obj).name(); | 11706 return Function::Cast(obj).name(); |
| 11659 } | 11707 } |
| 11660 } | 11708 } |
| 11661 | 11709 |
| 11662 | 11710 |
| 11663 RawString* Code::UserName() const { | 11711 RawString* Code::PrettyName() const { |
| 11664 const Object& obj = Object::Handle(owner()); | 11712 const Object& obj = Object::Handle(owner()); |
| 11665 if (obj.IsNull()) { | 11713 if (obj.IsNull()) { |
| 11666 // Regular stub. | 11714 // Regular stub. |
| 11667 const char* name = StubCode::NameOfStub(EntryPoint()); | 11715 const char* name = StubCode::NameOfStub(EntryPoint()); |
| 11668 ASSERT(name != NULL); | 11716 ASSERT(name != NULL); |
| 11669 const String& stub_name = String::Handle(String::New(name)); | 11717 const String& stub_name = String::Handle(String::New(name)); |
| 11670 return String::Concat(Symbols::StubPrefix(), stub_name); | 11718 return String::Concat(Symbols::StubPrefix(), stub_name); |
| 11671 } else if (obj.IsClass()) { | 11719 } else if (obj.IsClass()) { |
| 11672 // Allocation stub. | 11720 // Allocation stub. |
| 11673 const Class& cls = Class::Cast(obj); | 11721 const Class& cls = Class::Cast(obj); |
| 11674 String& cls_name = String::Handle(cls.Name()); | 11722 String& cls_name = String::Handle(cls.Name()); |
| 11675 ASSERT(!cls_name.IsNull()); | 11723 ASSERT(!cls_name.IsNull()); |
| 11676 return String::Concat(Symbols::AllocationStubFor(), cls_name); | 11724 return String::Concat(Symbols::AllocationStubFor(), cls_name); |
| 11677 } else { | 11725 } else { |
| 11678 ASSERT(obj.IsFunction()); | 11726 ASSERT(obj.IsFunction()); |
| 11679 // Dart function. | 11727 // Dart function. |
| 11680 return Function::Cast(obj).QualifiedUserVisibleName(); | 11728 return Function::Cast(obj).QualifiedPrettyName(); |
| 11681 } | 11729 } |
| 11682 } | 11730 } |
| 11683 | 11731 |
| 11684 | 11732 |
| 11685 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { | 11733 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 11686 JSONObject jsobj(stream); | 11734 JSONObject jsobj(stream); |
| 11687 jsobj.AddProperty("type", JSONType(ref)); | 11735 jsobj.AddProperty("type", JSONType(ref)); |
| 11688 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(), | 11736 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(), |
| 11689 EntryPoint()); | 11737 EntryPoint()); |
| 11690 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); | 11738 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); |
| 11691 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); | 11739 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); |
| 11692 jsobj.AddProperty("is_optimized", is_optimized()); | 11740 jsobj.AddProperty("is_optimized", is_optimized()); |
| 11693 jsobj.AddProperty("is_alive", is_alive()); | 11741 jsobj.AddProperty("is_alive", is_alive()); |
| 11694 jsobj.AddProperty("kind", "Dart"); | 11742 jsobj.AddProperty("kind", "Dart"); |
| 11695 const String& name = String::Handle(Name()); | 11743 const String& name = String::Handle(Name()); |
| 11696 const String& user_name = String::Handle(UserName()); | 11744 const String& pretty_name = String::Handle(PrettyName()); |
| 11697 const char* name_prefix = is_optimized() ? "*" : ""; | 11745 const char* name_prefix = is_optimized() ? "*" : ""; |
| 11698 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); | 11746 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); |
| 11699 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, user_name.ToCString()); | 11747 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, pretty_name.ToCString()); |
| 11700 const Object& obj = Object::Handle(owner()); | 11748 const Object& obj = Object::Handle(owner()); |
| 11701 if (obj.IsFunction()) { | 11749 if (obj.IsFunction()) { |
| 11702 jsobj.AddProperty("function", obj); | 11750 jsobj.AddProperty("function", obj); |
| 11703 } else { | 11751 } else { |
| 11704 // Generate a fake function reference. | 11752 // Generate a fake function reference. |
| 11705 JSONObject func(&jsobj, "function"); | 11753 JSONObject func(&jsobj, "function"); |
| 11706 func.AddProperty("type", "@Function"); | 11754 func.AddProperty("type", "@Function"); |
| 11707 func.AddProperty("kind", "Stub"); | 11755 func.AddProperty("kind", "Stub"); |
| 11708 func.AddPropertyF("id", "functions/stub-%" Pd "", EntryPoint()); | 11756 func.AddPropertyF("id", "functions/stub-%" Pd "", EntryPoint()); |
| 11709 func.AddProperty("user_name", user_name.ToCString()); | 11757 func.AddProperty("user_name", pretty_name.ToCString()); |
| 11710 func.AddProperty("name", name.ToCString()); | 11758 func.AddProperty("name", name.ToCString()); |
| 11711 } | 11759 } |
| 11712 if (ref) { | 11760 if (ref) { |
| 11713 return; | 11761 return; |
| 11714 } | 11762 } |
| 11715 const Array& array = Array::Handle(ObjectPool()); | 11763 const Array& array = Array::Handle(ObjectPool()); |
| 11716 jsobj.AddProperty("object_pool", array); | 11764 jsobj.AddProperty("object_pool", array); |
| 11717 { | 11765 { |
| 11718 JSONArray jsarr(&jsobj, "disassembly"); | 11766 JSONArray jsarr(&jsobj, "disassembly"); |
| 11719 if (is_alive()) { | 11767 if (is_alive()) { |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13224 } | 13272 } |
| 13225 (*trail)->Add(*this); | 13273 (*trail)->Add(*this); |
| 13226 (*trail)->Add(buddy); | 13274 (*trail)->Add(buddy); |
| 13227 } | 13275 } |
| 13228 | 13276 |
| 13229 | 13277 |
| 13230 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { | 13278 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { |
| 13231 if (IsBoundedType()) { | 13279 if (IsBoundedType()) { |
| 13232 const AbstractType& type = AbstractType::Handle( | 13280 const AbstractType& type = AbstractType::Handle( |
| 13233 BoundedType::Cast(*this).type()); | 13281 BoundedType::Cast(*this).type()); |
| 13234 if (name_visibility == kUserVisibleName) { | 13282 if (name_visibility == kPrettyName) { |
| 13283 return type.BuildName(kPrettyName); |
| 13284 } else if (name_visibility == kUserVisibleName) { |
| 13235 return type.BuildName(kUserVisibleName); | 13285 return type.BuildName(kUserVisibleName); |
| 13236 } | 13286 } |
| 13237 String& type_name = String::Handle(type.BuildName(kInternalName)); | 13287 String& type_name = String::Handle(type.BuildName(kInternalName)); |
| 13238 type_name = String::Concat(type_name, Symbols::SpaceExtendsSpace()); | 13288 type_name = String::Concat(type_name, Symbols::SpaceExtendsSpace()); |
| 13239 // Build the bound name without causing divergence. | 13289 // Build the bound name without causing divergence. |
| 13240 const AbstractType& bound = AbstractType::Handle( | 13290 const AbstractType& bound = AbstractType::Handle( |
| 13241 BoundedType::Cast(*this).bound()); | 13291 BoundedType::Cast(*this).bound()); |
| 13242 String& bound_name = String::Handle(); | 13292 String& bound_name = String::Handle(); |
| 13243 if (bound.IsTypeParameter()) { | 13293 if (bound.IsTypeParameter()) { |
| 13244 bound_name = TypeParameter::Cast(bound).name(); | 13294 bound_name = TypeParameter::Cast(bound).name(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 13269 if (IsResolved() || !cls.IsMixinApplication()) { | 13319 if (IsResolved() || !cls.IsMixinApplication()) { |
| 13270 // Do not print the full vector, but only the declared type parameters. | 13320 // Do not print the full vector, but only the declared type parameters. |
| 13271 num_type_params = cls.NumTypeParameters(); | 13321 num_type_params = cls.NumTypeParameters(); |
| 13272 } else { | 13322 } else { |
| 13273 // Do not print the type parameters of an unresolved mixin application, | 13323 // Do not print the type parameters of an unresolved mixin application, |
| 13274 // since it would prematurely trigger the application of the mixin type. | 13324 // since it would prematurely trigger the application of the mixin type. |
| 13275 num_type_params = 0; | 13325 num_type_params = 0; |
| 13276 } | 13326 } |
| 13277 if (name_visibility == kInternalName) { | 13327 if (name_visibility == kInternalName) { |
| 13278 class_name = cls.Name(); | 13328 class_name = cls.Name(); |
| 13329 } else if (name_visibility == kPrettyName) { |
| 13330 class_name = cls.PrettyName(); |
| 13279 } else { | 13331 } else { |
| 13280 ASSERT(name_visibility == kUserVisibleName); | 13332 ASSERT(name_visibility == kUserVisibleName); |
| 13281 // Map internal types to their corresponding public interfaces. | 13333 // Map internal types to their corresponding public interfaces. |
| 13282 class_name = cls.UserVisibleName(); | 13334 class_name = cls.UserVisibleName(); |
| 13283 } | 13335 } |
| 13284 if (num_type_params > num_args) { | 13336 if (num_type_params > num_args) { |
| 13285 first_type_param_index = 0; | 13337 first_type_param_index = 0; |
| 13286 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 13338 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 13287 // Most probably a malformed type. Do not fill up with "dynamic", | 13339 // Most probably a malformed type. Do not fill up with "dynamic", |
| 13288 // but use actual vector. | 13340 // but use actual vector. |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14115 ASSERT(id >= 0); | 14167 ASSERT(id >= 0); |
| 14116 intptr_t cid = type_cls.id(); | 14168 intptr_t cid = type_cls.id(); |
| 14117 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); | 14169 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); |
| 14118 jsobj.AddProperty("type_class", type_cls); | 14170 jsobj.AddProperty("type_class", type_cls); |
| 14119 } else { | 14171 } else { |
| 14120 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14172 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14121 const intptr_t id = ring->GetIdForObject(raw()); | 14173 const intptr_t id = ring->GetIdForObject(raw()); |
| 14122 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14174 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14123 } | 14175 } |
| 14124 const char* name = String::Handle(Name()).ToCString(); | 14176 const char* name = String::Handle(Name()).ToCString(); |
| 14125 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14177 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14126 jsobj.AddProperty("name", name); | 14178 jsobj.AddProperty("name", name); |
| 14127 jsobj.AddProperty("user_name", user_name); | 14179 jsobj.AddProperty("user_name", pretty_name); |
| 14128 if (ref) { | 14180 if (ref) { |
| 14129 return; | 14181 return; |
| 14130 } | 14182 } |
| 14131 jsobj.AddProperty("type_arguments", TypeArguments::Handle(arguments())); | 14183 jsobj.AddProperty("type_arguments", TypeArguments::Handle(arguments())); |
| 14132 } | 14184 } |
| 14133 | 14185 |
| 14134 | 14186 |
| 14135 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { | 14187 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { |
| 14136 if (TestAndAddToTrail(&trail)) { | 14188 if (TestAndAddToTrail(&trail)) { |
| 14137 return true; | 14189 return true; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14279 } | 14331 } |
| 14280 | 14332 |
| 14281 | 14333 |
| 14282 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14334 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 14283 JSONObject jsobj(stream); | 14335 JSONObject jsobj(stream); |
| 14284 PrintSharedInstanceJSON(&jsobj, ref); | 14336 PrintSharedInstanceJSON(&jsobj, ref); |
| 14285 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14337 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14286 const intptr_t id = ring->GetIdForObject(raw()); | 14338 const intptr_t id = ring->GetIdForObject(raw()); |
| 14287 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14339 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14288 const char* name = String::Handle(Name()).ToCString(); | 14340 const char* name = String::Handle(Name()).ToCString(); |
| 14289 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14341 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14290 jsobj.AddProperty("name", name); | 14342 jsobj.AddProperty("name", name); |
| 14291 jsobj.AddProperty("user_name", user_name); | 14343 jsobj.AddProperty("user_name", pretty_name); |
| 14292 if (ref) { | 14344 if (ref) { |
| 14293 return; | 14345 return; |
| 14294 } | 14346 } |
| 14295 jsobj.AddProperty("ref_type", AbstractType::Handle(type())); | 14347 jsobj.AddProperty("ref_type", AbstractType::Handle(type())); |
| 14296 } | 14348 } |
| 14297 | 14349 |
| 14298 | 14350 |
| 14299 void TypeParameter::set_is_finalized() const { | 14351 void TypeParameter::set_is_finalized() const { |
| 14300 ASSERT(!IsFinalized()); | 14352 ASSERT(!IsFinalized()); |
| 14301 set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 14353 set_type_state(RawTypeParameter::kFinalizedUninstantiated); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14496 } | 14548 } |
| 14497 | 14549 |
| 14498 | 14550 |
| 14499 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14551 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 14500 JSONObject jsobj(stream); | 14552 JSONObject jsobj(stream); |
| 14501 PrintSharedInstanceJSON(&jsobj, ref); | 14553 PrintSharedInstanceJSON(&jsobj, ref); |
| 14502 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14554 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14503 const intptr_t id = ring->GetIdForObject(raw()); | 14555 const intptr_t id = ring->GetIdForObject(raw()); |
| 14504 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14556 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14505 const char* name = String::Handle(Name()).ToCString(); | 14557 const char* name = String::Handle(Name()).ToCString(); |
| 14506 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14558 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14507 jsobj.AddProperty("name", name); | 14559 jsobj.AddProperty("name", name); |
| 14508 jsobj.AddProperty("user_name", user_name); | 14560 jsobj.AddProperty("user_name", pretty_name); |
| 14509 const Class& param_cls = Class::Handle(parameterized_class()); | 14561 const Class& param_cls = Class::Handle(parameterized_class()); |
| 14510 jsobj.AddProperty("parameterized_class", param_cls); | 14562 jsobj.AddProperty("parameterized_class", param_cls); |
| 14511 if (ref) { | 14563 if (ref) { |
| 14512 return; | 14564 return; |
| 14513 } | 14565 } |
| 14514 jsobj.AddProperty("index", index()); | 14566 jsobj.AddProperty("index", index()); |
| 14515 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 14567 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
| 14516 jsobj.AddProperty("upper_bound", upper_bound); | 14568 jsobj.AddProperty("upper_bound", upper_bound); |
| 14517 } | 14569 } |
| 14518 | 14570 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14700 } | 14752 } |
| 14701 | 14753 |
| 14702 | 14754 |
| 14703 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14755 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 14704 JSONObject jsobj(stream); | 14756 JSONObject jsobj(stream); |
| 14705 PrintSharedInstanceJSON(&jsobj, ref); | 14757 PrintSharedInstanceJSON(&jsobj, ref); |
| 14706 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14758 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14707 const intptr_t id = ring->GetIdForObject(raw()); | 14759 const intptr_t id = ring->GetIdForObject(raw()); |
| 14708 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14760 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14709 const char* name = String::Handle(Name()).ToCString(); | 14761 const char* name = String::Handle(Name()).ToCString(); |
| 14710 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14762 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14711 jsobj.AddProperty("name", name); | 14763 jsobj.AddProperty("name", name); |
| 14712 jsobj.AddProperty("user_name", user_name); | 14764 jsobj.AddProperty("user_name", pretty_name); |
| 14713 if (ref) { | 14765 if (ref) { |
| 14714 return; | 14766 return; |
| 14715 } | 14767 } |
| 14716 jsobj.AddProperty("bounded_type", AbstractType::Handle(type())); | 14768 jsobj.AddProperty("bounded_type", AbstractType::Handle(type())); |
| 14717 jsobj.AddProperty("upper_bound", AbstractType::Handle(bound())); | 14769 jsobj.AddProperty("upper_bound", AbstractType::Handle(bound())); |
| 14718 } | 14770 } |
| 14719 | 14771 |
| 14720 | 14772 |
| 14721 intptr_t MixinAppType::token_pos() const { | 14773 intptr_t MixinAppType::token_pos() const { |
| 14722 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); | 14774 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); |
| (...skipping 4001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18724 return tag_label.ToCString(); | 18776 return tag_label.ToCString(); |
| 18725 } | 18777 } |
| 18726 | 18778 |
| 18727 | 18779 |
| 18728 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 18780 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 18729 Instance::PrintJSONImpl(stream, ref); | 18781 Instance::PrintJSONImpl(stream, ref); |
| 18730 } | 18782 } |
| 18731 | 18783 |
| 18732 | 18784 |
| 18733 } // namespace dart | 18785 } // namespace dart |
| OLD | NEW |