| 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 ASSERT(raw_ptr()->pretty_name_ != String::null()); |
| 1639 return raw_ptr()->pretty_name_; |
| 1640 } |
| 1641 |
| 1642 |
| 1637 RawString* Class::UserVisibleName() const { | 1643 RawString* Class::UserVisibleName() const { |
| 1638 ASSERT(raw_ptr()->user_name_ != String::null()); | 1644 ASSERT(raw_ptr()->user_name_ != String::null()); |
| 1639 return raw_ptr()->user_name_; | 1645 return raw_ptr()->user_name_; |
| 1640 } | 1646 } |
| 1641 | 1647 |
| 1642 | 1648 |
| 1643 RawType* Class::SignatureType() const { | 1649 RawType* Class::SignatureType() const { |
| 1644 ASSERT(IsSignatureClass()); | 1650 ASSERT(IsSignatureClass()); |
| 1645 const Function& function = Function::Handle(signature_function()); | 1651 const Function& function = Function::Handle(signature_function()); |
| 1646 ASSERT(!function.IsNull()); | 1652 ASSERT(!function.IsNull()); |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3016 void Class::set_name(const String& value) const { | 3022 void Class::set_name(const String& value) const { |
| 3017 ASSERT(value.IsSymbol()); | 3023 ASSERT(value.IsSymbol()); |
| 3018 StorePointer(&raw_ptr()->name_, value.raw()); | 3024 StorePointer(&raw_ptr()->name_, value.raw()); |
| 3019 if (raw_ptr()->user_name_ == String::null()) { | 3025 if (raw_ptr()->user_name_ == String::null()) { |
| 3020 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes, | 3026 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes, |
| 3021 // lazily set user name for the other classes. | 3027 // lazily set user name for the other classes. |
| 3022 // Generate and set user_name. | 3028 // Generate and set user_name. |
| 3023 const String& user_name = String::Handle(GenerateUserVisibleName()); | 3029 const String& user_name = String::Handle(GenerateUserVisibleName()); |
| 3024 set_user_name(user_name); | 3030 set_user_name(user_name); |
| 3025 } | 3031 } |
| 3032 if (raw_ptr()->pretty_name_ == String::null()) { |
| 3033 const String& pretty_name = String::Handle(GeneratePrettyName()); |
| 3034 set_pretty_name(pretty_name); |
| 3035 } |
| 3026 } | 3036 } |
| 3027 | 3037 |
| 3028 | 3038 |
| 3029 void Class::set_user_name(const String& value) const { | 3039 void Class::set_user_name(const String& value) const { |
| 3030 StorePointer(&raw_ptr()->user_name_, value.raw()); | 3040 StorePointer(&raw_ptr()->user_name_, value.raw()); |
| 3031 } | 3041 } |
| 3032 | 3042 |
| 3033 | 3043 |
| 3044 void Class::set_pretty_name(const String& value) const { |
| 3045 StorePointer(&raw_ptr()->pretty_name_, value.raw()); |
| 3046 } |
| 3047 |
| 3048 |
| 3049 RawString* Class::GeneratePrettyName() const { |
| 3050 if (!IsCanonicalSignatureClass()) { |
| 3051 const String& name = String::Handle(Name()); |
| 3052 return String::IdentifierPrettyName(name); |
| 3053 } else { |
| 3054 return Name(); |
| 3055 } |
| 3056 } |
| 3057 |
| 3058 |
| 3034 RawString* Class::GenerateUserVisibleName() const { | 3059 RawString* Class::GenerateUserVisibleName() const { |
| 3035 if (FLAG_show_internal_names) { | 3060 if (FLAG_show_internal_names) { |
| 3036 return Name(); | 3061 return Name(); |
| 3037 } | 3062 } |
| 3038 switch (id()) { | 3063 switch (id()) { |
| 3039 case kNullCid: | 3064 case kNullCid: |
| 3040 return Symbols::Null().raw(); | 3065 return Symbols::Null().raw(); |
| 3041 case kDynamicCid: | 3066 case kDynamicCid: |
| 3042 return Symbols::Dynamic().raw(); | 3067 return Symbols::Dynamic().raw(); |
| 3043 case kVoidCid: | 3068 case kVoidCid: |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 } | 3927 } |
| 3903 | 3928 |
| 3904 | 3929 |
| 3905 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | 3930 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 3906 JSONObject jsobj(stream); | 3931 JSONObject jsobj(stream); |
| 3907 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | 3932 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
| 3908 jsobj.AddProperty("type", "Null"); | 3933 jsobj.AddProperty("type", "Null"); |
| 3909 return; | 3934 return; |
| 3910 } | 3935 } |
| 3911 const char* internal_class_name = String::Handle(Name()).ToCString(); | 3936 const char* internal_class_name = String::Handle(Name()).ToCString(); |
| 3912 const char* user_visible_class_name = | 3937 const char* pretty_class_name = |
| 3913 String::Handle(UserVisibleName()).ToCString(); | 3938 String::Handle(PrettyName()).ToCString(); |
| 3914 jsobj.AddProperty("type", JSONType(ref)); | 3939 jsobj.AddProperty("type", JSONType(ref)); |
| 3915 jsobj.AddPropertyF("id", "classes/%" Pd "", id()); | 3940 jsobj.AddPropertyF("id", "classes/%" Pd "", id()); |
| 3916 jsobj.AddProperty("name", internal_class_name); | 3941 jsobj.AddProperty("name", internal_class_name); |
| 3917 jsobj.AddProperty("user_name", user_visible_class_name); | 3942 jsobj.AddProperty("user_name", pretty_class_name); |
| 3918 if (ref) { | 3943 if (ref) { |
| 3919 return; | 3944 return; |
| 3920 } | 3945 } |
| 3921 | 3946 |
| 3922 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); | 3947 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); |
| 3923 if (!err.IsNull()) { | 3948 if (!err.IsNull()) { |
| 3924 jsobj.AddProperty("error", err); | 3949 jsobj.AddProperty("error", err); |
| 3925 } | 3950 } |
| 3926 jsobj.AddProperty("implemented", is_implemented()); | 3951 jsobj.AddProperty("implemented", is_implemented()); |
| 3927 jsobj.AddProperty("abstract", is_abstract()); | 3952 jsobj.AddProperty("abstract", is_abstract()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3991 subclasses_array.AddValue(subclass); | 4016 subclasses_array.AddValue(subclass); |
| 3992 } | 4017 } |
| 3993 } | 4018 } |
| 3994 } | 4019 } |
| 3995 } | 4020 } |
| 3996 { | 4021 { |
| 3997 JSONObject typesRef(&jsobj, "canonicalTypes"); | 4022 JSONObject typesRef(&jsobj, "canonicalTypes"); |
| 3998 typesRef.AddProperty("type", "@TypeList"); | 4023 typesRef.AddProperty("type", "@TypeList"); |
| 3999 typesRef.AddPropertyF("id", "classes/%" Pd "/types", id()); | 4024 typesRef.AddPropertyF("id", "classes/%" Pd "/types", id()); |
| 4000 jsobj.AddPropertyF("name", "canonical types of %s", internal_class_name); | 4025 jsobj.AddPropertyF("name", "canonical types of %s", internal_class_name); |
| 4001 jsobj.AddPropertyF("user_name", "canonical types of %s", | 4026 jsobj.AddPropertyF("user_name", "canonical types of %s", pretty_class_name); |
| 4002 user_visible_class_name); | |
| 4003 } | 4027 } |
| 4004 } | 4028 } |
| 4005 | 4029 |
| 4006 | 4030 |
| 4007 void Class::InsertCanonicalConstant(intptr_t index, | 4031 void Class::InsertCanonicalConstant(intptr_t index, |
| 4008 const Instance& constant) const { | 4032 const Instance& constant) const { |
| 4009 // The constant needs to be added to the list. Grow the list if it is full. | 4033 // The constant needs to be added to the list. Grow the list if it is full. |
| 4010 Array& canonical_list = Array::Handle(constants()); | 4034 Array& canonical_list = Array::Handle(constants()); |
| 4011 const intptr_t list_len = canonical_list.Length(); | 4035 const intptr_t list_len = canonical_list.Length(); |
| 4012 if (index >= list_len) { | 4036 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. | 4269 // preserved when the table grows and the entries get rehashed. Use the ring. |
| 4246 Isolate* isolate = Isolate::Current(); | 4270 Isolate* isolate = Isolate::Current(); |
| 4247 ObjectStore* object_store = isolate->object_store(); | 4271 ObjectStore* object_store = isolate->object_store(); |
| 4248 const Array& table = Array::Handle(object_store->canonical_type_arguments()); | 4272 const Array& table = Array::Handle(object_store->canonical_type_arguments()); |
| 4249 ASSERT(table.Length() > 0); | 4273 ASSERT(table.Length() > 0); |
| 4250 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 4274 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 4251 const intptr_t id = ring->GetIdForObject(raw()); | 4275 const intptr_t id = ring->GetIdForObject(raw()); |
| 4252 jsobj.AddProperty("type", JSONType(ref)); | 4276 jsobj.AddProperty("type", JSONType(ref)); |
| 4253 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 4277 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 4254 const char* name = String::Handle(Name()).ToCString(); | 4278 const char* name = String::Handle(Name()).ToCString(); |
| 4255 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 4279 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 4256 jsobj.AddProperty("name", name); | 4280 jsobj.AddProperty("name", name); |
| 4257 jsobj.AddProperty("user_name", user_name); | 4281 jsobj.AddProperty("user_name", pretty_name); |
| 4258 jsobj.AddProperty("length", Length()); | 4282 jsobj.AddProperty("length", Length()); |
| 4259 jsobj.AddProperty("num_instantiations", NumInstantiations()); | 4283 jsobj.AddProperty("num_instantiations", NumInstantiations()); |
| 4260 if (ref) { | 4284 if (ref) { |
| 4261 return; | 4285 return; |
| 4262 } | 4286 } |
| 4263 { | 4287 { |
| 4264 JSONArray jsarr(&jsobj, "types"); | 4288 JSONArray jsarr(&jsobj, "types"); |
| 4265 AbstractType& type_arg = AbstractType::Handle(); | 4289 AbstractType& type_arg = AbstractType::Handle(); |
| 4266 for (intptr_t i = 0; i < Length(); i++) { | 4290 for (intptr_t i = 0; i < Length(); i++) { |
| 4267 type_arg = TypeAt(i); | 4291 type_arg = TypeAt(i); |
| (...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6258 ASSERT(obj.IsPatchClass()); | 6282 ASSERT(obj.IsPatchClass()); |
| 6259 return PatchClass::Cast(obj).Script(); | 6283 return PatchClass::Cast(obj).Script(); |
| 6260 } | 6284 } |
| 6261 | 6285 |
| 6262 | 6286 |
| 6263 bool Function::HasOptimizedCode() const { | 6287 bool Function::HasOptimizedCode() const { |
| 6264 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); | 6288 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); |
| 6265 } | 6289 } |
| 6266 | 6290 |
| 6267 | 6291 |
| 6292 RawString* Function::PrettyName() const { |
| 6293 const String& str = String::Handle(name()); |
| 6294 return String::IdentifierPrettyName(str); |
| 6295 } |
| 6296 |
| 6297 |
| 6268 RawString* Function::UserVisibleName() const { | 6298 RawString* Function::UserVisibleName() const { |
| 6269 const String& str = String::Handle(name()); | 6299 return PrettyName(); |
| 6270 return String::IdentifierPrettyName(str); | 6300 } |
| 6301 |
| 6302 |
| 6303 RawString* Function::QualifiedPrettyName() const { |
| 6304 String& tmp = String::Handle(); |
| 6305 const Class& cls = Class::Handle(Owner()); |
| 6306 |
| 6307 if (IsClosureFunction()) { |
| 6308 if (IsLocalFunction() && !IsImplicitClosureFunction()) { |
| 6309 const Function& parent = Function::Handle(parent_function()); |
| 6310 tmp = parent.QualifiedPrettyName(); |
| 6311 } else { |
| 6312 return PrettyName(); |
| 6313 } |
| 6314 } else { |
| 6315 if (cls.IsTopLevel()) { |
| 6316 return PrettyName(); |
| 6317 } else { |
| 6318 tmp = cls.PrettyName(); |
| 6319 } |
| 6320 } |
| 6321 tmp = String::Concat(tmp, Symbols::Dot()); |
| 6322 const String& suffix = String::Handle(PrettyName()); |
| 6323 return String::Concat(tmp, suffix); |
| 6271 } | 6324 } |
| 6272 | 6325 |
| 6273 | 6326 |
| 6274 RawString* Function::QualifiedUserVisibleName() const { | 6327 RawString* Function::QualifiedUserVisibleName() const { |
| 6275 String& tmp = String::Handle(); | 6328 String& tmp = String::Handle(); |
| 6276 const Class& cls = Class::Handle(Owner()); | 6329 const Class& cls = Class::Handle(Owner()); |
| 6277 | 6330 |
| 6278 if (IsClosureFunction()) { | 6331 if (IsClosureFunction()) { |
| 6279 if (IsLocalFunction() && !IsImplicitClosureFunction()) { | 6332 if (IsLocalFunction() && !IsImplicitClosureFunction()) { |
| 6280 const Function& parent = Function::Handle(parent_function()); | 6333 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; | 6482 static_str, abstract_str, kind_str, const_str) + 1; |
| 6430 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6483 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6431 OS::SNPrint(chars, len, kFormat, function_name, | 6484 OS::SNPrint(chars, len, kFormat, function_name, |
| 6432 static_str, abstract_str, kind_str, const_str); | 6485 static_str, abstract_str, kind_str, const_str); |
| 6433 return chars; | 6486 return chars; |
| 6434 } | 6487 } |
| 6435 | 6488 |
| 6436 | 6489 |
| 6437 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { | 6490 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 6438 const char* internal_name = String::Handle(name()).ToCString(); | 6491 const char* internal_name = String::Handle(name()).ToCString(); |
| 6439 const char* user_name = | 6492 const char* pretty_name = |
| 6440 String::Handle(UserVisibleName()).ToCString(); | 6493 String::Handle(PrettyName()).ToCString(); |
| 6441 Class& cls = Class::Handle(Owner()); | 6494 Class& cls = Class::Handle(Owner()); |
| 6442 ASSERT(!cls.IsNull()); | 6495 ASSERT(!cls.IsNull()); |
| 6443 Error& err = Error::Handle(); | 6496 Error& err = Error::Handle(); |
| 6444 err ^= cls.EnsureIsFinalized(Isolate::Current()); | 6497 err ^= cls.EnsureIsFinalized(Isolate::Current()); |
| 6445 ASSERT(err.IsNull()); | 6498 ASSERT(err.IsNull()); |
| 6446 intptr_t id = -1; | 6499 intptr_t id = -1; |
| 6447 const char* selector = NULL; | 6500 const char* selector = NULL; |
| 6448 if (IsNonImplicitClosureFunction()) { | 6501 if (IsNonImplicitClosureFunction()) { |
| 6449 id = cls.FindClosureIndex(*this); | 6502 id = cls.FindClosureIndex(*this); |
| 6450 selector = "closures"; | 6503 selector = "closures"; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6465 // id ring. Current known examples are signature functions of closures | 6518 // id ring. Current known examples are signature functions of closures |
| 6466 // and stubs like 'megamorphic_miss'. | 6519 // and stubs like 'megamorphic_miss'. |
| 6467 if (id < 0) { | 6520 if (id < 0) { |
| 6468 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 6521 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 6469 id = ring->GetIdForObject(raw()); | 6522 id = ring->GetIdForObject(raw()); |
| 6470 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 6523 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 6471 } else { | 6524 } else { |
| 6472 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); | 6525 jsobj.AddPropertyF("id", "classes/%" Pd "/%s/%" Pd "", cid, selector, id); |
| 6473 } | 6526 } |
| 6474 jsobj.AddProperty("name", internal_name); | 6527 jsobj.AddProperty("name", internal_name); |
| 6475 jsobj.AddProperty("user_name", user_name); | 6528 jsobj.AddProperty("user_name", pretty_name); |
| 6476 if (cls.IsTopLevel()) { | 6529 if (cls.IsTopLevel()) { |
| 6477 const Library& library = Library::Handle(cls.library()); | 6530 const Library& library = Library::Handle(cls.library()); |
| 6478 jsobj.AddProperty("owner", library); | 6531 jsobj.AddProperty("owner", library); |
| 6479 } else { | 6532 } else { |
| 6480 jsobj.AddProperty("owner", cls); | 6533 jsobj.AddProperty("owner", cls); |
| 6481 } | 6534 } |
| 6482 const Function& parent = Function::Handle(parent_function()); | 6535 const Function& parent = Function::Handle(parent_function()); |
| 6483 if (!parent.IsNull()) { | 6536 if (!parent.IsNull()) { |
| 6484 jsobj.AddProperty("parent", parent); | 6537 jsobj.AddProperty("parent", parent); |
| 6485 } | 6538 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6726 PatchClass::Handle(PatchClass::New(new_owner, owner)); | 6779 PatchClass::Handle(PatchClass::New(new_owner, owner)); |
| 6727 clone.set_owner(clone_owner); | 6780 clone.set_owner(clone_owner); |
| 6728 clone.set_dependent_code(Object::null_array()); | 6781 clone.set_dependent_code(Object::null_array()); |
| 6729 if (!clone.is_static()) { | 6782 if (!clone.is_static()) { |
| 6730 clone.SetOffset(0); | 6783 clone.SetOffset(0); |
| 6731 } | 6784 } |
| 6732 return clone.raw(); | 6785 return clone.raw(); |
| 6733 } | 6786 } |
| 6734 | 6787 |
| 6735 | 6788 |
| 6789 RawString* Field::PrettyName() const { |
| 6790 const String& str = String::Handle(name()); |
| 6791 return String::IdentifierPrettyName(str); |
| 6792 } |
| 6793 |
| 6794 |
| 6736 RawString* Field::UserVisibleName() const { | 6795 RawString* Field::UserVisibleName() const { |
| 6737 const String& str = String::Handle(name()); | 6796 return PrettyName(); |
| 6738 return String::IdentifierPrettyName(str); | |
| 6739 } | 6797 } |
| 6740 | 6798 |
| 6741 | 6799 |
| 6742 intptr_t Field::guarded_list_length() const { | 6800 intptr_t Field::guarded_list_length() const { |
| 6743 return Smi::Value(raw_ptr()->guarded_list_length_); | 6801 return Smi::Value(raw_ptr()->guarded_list_length_); |
| 6744 } | 6802 } |
| 6745 | 6803 |
| 6746 | 6804 |
| 6747 void Field::set_guarded_list_length(intptr_t list_length) const { | 6805 void Field::set_guarded_list_length(intptr_t list_length) const { |
| 6748 raw_ptr()->guarded_list_length_ = Smi::New(list_length); | 6806 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 = | 6838 intptr_t len = |
| 6781 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; | 6839 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; |
| 6782 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6840 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6783 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); | 6841 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); |
| 6784 return chars; | 6842 return chars; |
| 6785 } | 6843 } |
| 6786 | 6844 |
| 6787 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { | 6845 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 6788 JSONObject jsobj(stream); | 6846 JSONObject jsobj(stream); |
| 6789 const char* internal_field_name = String::Handle(name()).ToCString(); | 6847 const char* internal_field_name = String::Handle(name()).ToCString(); |
| 6790 const char* field_name = String::Handle(UserVisibleName()).ToCString(); | 6848 const char* field_name = String::Handle(PrettyName()).ToCString(); |
| 6791 Class& cls = Class::Handle(owner()); | 6849 Class& cls = Class::Handle(owner()); |
| 6792 intptr_t id = cls.FindFieldIndex(*this); | 6850 intptr_t id = cls.FindFieldIndex(*this); |
| 6793 ASSERT(id >= 0); | 6851 ASSERT(id >= 0); |
| 6794 intptr_t cid = cls.id(); | 6852 intptr_t cid = cls.id(); |
| 6795 jsobj.AddProperty("type", JSONType(ref)); | 6853 jsobj.AddProperty("type", JSONType(ref)); |
| 6796 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); | 6854 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); |
| 6797 jsobj.AddProperty("name", internal_field_name); | 6855 jsobj.AddProperty("name", internal_field_name); |
| 6798 jsobj.AddProperty("user_name", field_name); | 6856 jsobj.AddProperty("user_name", field_name); |
| 6799 if (is_static()) { | 6857 if (is_static()) { |
| 6800 const Instance& valueObj = Instance::Handle(value()); | 6858 const Instance& valueObj = Instance::Handle(value()); |
| (...skipping 4852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11653 ASSERT(!cls_name.IsNull()); | 11711 ASSERT(!cls_name.IsNull()); |
| 11654 return String::Concat(Symbols::AllocationStubFor(), cls_name); | 11712 return String::Concat(Symbols::AllocationStubFor(), cls_name); |
| 11655 } else { | 11713 } else { |
| 11656 ASSERT(obj.IsFunction()); | 11714 ASSERT(obj.IsFunction()); |
| 11657 // Dart function. | 11715 // Dart function. |
| 11658 return Function::Cast(obj).name(); | 11716 return Function::Cast(obj).name(); |
| 11659 } | 11717 } |
| 11660 } | 11718 } |
| 11661 | 11719 |
| 11662 | 11720 |
| 11663 RawString* Code::UserName() const { | 11721 RawString* Code::PrettyName() const { |
| 11664 const Object& obj = Object::Handle(owner()); | 11722 const Object& obj = Object::Handle(owner()); |
| 11665 if (obj.IsNull()) { | 11723 if (obj.IsNull()) { |
| 11666 // Regular stub. | 11724 // Regular stub. |
| 11667 const char* name = StubCode::NameOfStub(EntryPoint()); | 11725 const char* name = StubCode::NameOfStub(EntryPoint()); |
| 11668 ASSERT(name != NULL); | 11726 ASSERT(name != NULL); |
| 11669 const String& stub_name = String::Handle(String::New(name)); | 11727 const String& stub_name = String::Handle(String::New(name)); |
| 11670 return String::Concat(Symbols::StubPrefix(), stub_name); | 11728 return String::Concat(Symbols::StubPrefix(), stub_name); |
| 11671 } else if (obj.IsClass()) { | 11729 } else if (obj.IsClass()) { |
| 11672 // Allocation stub. | 11730 // Allocation stub. |
| 11673 const Class& cls = Class::Cast(obj); | 11731 const Class& cls = Class::Cast(obj); |
| 11674 String& cls_name = String::Handle(cls.Name()); | 11732 String& cls_name = String::Handle(cls.Name()); |
| 11675 ASSERT(!cls_name.IsNull()); | 11733 ASSERT(!cls_name.IsNull()); |
| 11676 return String::Concat(Symbols::AllocationStubFor(), cls_name); | 11734 return String::Concat(Symbols::AllocationStubFor(), cls_name); |
| 11677 } else { | 11735 } else { |
| 11678 ASSERT(obj.IsFunction()); | 11736 ASSERT(obj.IsFunction()); |
| 11679 // Dart function. | 11737 // Dart function. |
| 11680 return Function::Cast(obj).QualifiedUserVisibleName(); | 11738 return Function::Cast(obj).QualifiedPrettyName(); |
| 11681 } | 11739 } |
| 11682 } | 11740 } |
| 11683 | 11741 |
| 11684 | 11742 |
| 11685 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { | 11743 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 11686 JSONObject jsobj(stream); | 11744 JSONObject jsobj(stream); |
| 11687 jsobj.AddProperty("type", JSONType(ref)); | 11745 jsobj.AddProperty("type", JSONType(ref)); |
| 11688 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(), | 11746 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(), |
| 11689 EntryPoint()); | 11747 EntryPoint()); |
| 11690 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); | 11748 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); |
| 11691 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); | 11749 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); |
| 11692 jsobj.AddProperty("is_optimized", is_optimized()); | 11750 jsobj.AddProperty("is_optimized", is_optimized()); |
| 11693 jsobj.AddProperty("is_alive", is_alive()); | 11751 jsobj.AddProperty("is_alive", is_alive()); |
| 11694 jsobj.AddProperty("kind", "Dart"); | 11752 jsobj.AddProperty("kind", "Dart"); |
| 11695 const String& name = String::Handle(Name()); | 11753 const String& name = String::Handle(Name()); |
| 11696 const String& user_name = String::Handle(UserName()); | 11754 const String& pretty_name = String::Handle(PrettyName()); |
| 11697 const char* name_prefix = is_optimized() ? "*" : ""; | 11755 const char* name_prefix = is_optimized() ? "*" : ""; |
| 11698 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); | 11756 jsobj.AddPropertyF("name", "%s%s", name_prefix, name.ToCString()); |
| 11699 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, user_name.ToCString()); | 11757 jsobj.AddPropertyF("user_name", "%s%s", name_prefix, pretty_name.ToCString()); |
| 11700 const Object& obj = Object::Handle(owner()); | 11758 const Object& obj = Object::Handle(owner()); |
| 11701 if (obj.IsFunction()) { | 11759 if (obj.IsFunction()) { |
| 11702 jsobj.AddProperty("function", obj); | 11760 jsobj.AddProperty("function", obj); |
| 11703 } else { | 11761 } else { |
| 11704 // Generate a fake function reference. | 11762 // Generate a fake function reference. |
| 11705 JSONObject func(&jsobj, "function"); | 11763 JSONObject func(&jsobj, "function"); |
| 11706 func.AddProperty("type", "@Function"); | 11764 func.AddProperty("type", "@Function"); |
| 11707 func.AddProperty("kind", "Stub"); | 11765 func.AddProperty("kind", "Stub"); |
| 11708 func.AddPropertyF("id", "functions/stub-%" Pd "", EntryPoint()); | 11766 func.AddPropertyF("id", "functions/stub-%" Pd "", EntryPoint()); |
| 11709 func.AddProperty("user_name", user_name.ToCString()); | 11767 func.AddProperty("user_name", pretty_name.ToCString()); |
| 11710 func.AddProperty("name", name.ToCString()); | 11768 func.AddProperty("name", name.ToCString()); |
| 11711 } | 11769 } |
| 11712 if (ref) { | 11770 if (ref) { |
| 11713 return; | 11771 return; |
| 11714 } | 11772 } |
| 11715 const Array& array = Array::Handle(ObjectPool()); | 11773 const Array& array = Array::Handle(ObjectPool()); |
| 11716 jsobj.AddProperty("object_pool", array); | 11774 jsobj.AddProperty("object_pool", array); |
| 11717 { | 11775 { |
| 11718 JSONArray jsarr(&jsobj, "disassembly"); | 11776 JSONArray jsarr(&jsobj, "disassembly"); |
| 11719 if (is_alive()) { | 11777 if (is_alive()) { |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13224 } | 13282 } |
| 13225 (*trail)->Add(*this); | 13283 (*trail)->Add(*this); |
| 13226 (*trail)->Add(buddy); | 13284 (*trail)->Add(buddy); |
| 13227 } | 13285 } |
| 13228 | 13286 |
| 13229 | 13287 |
| 13230 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { | 13288 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { |
| 13231 if (IsBoundedType()) { | 13289 if (IsBoundedType()) { |
| 13232 const AbstractType& type = AbstractType::Handle( | 13290 const AbstractType& type = AbstractType::Handle( |
| 13233 BoundedType::Cast(*this).type()); | 13291 BoundedType::Cast(*this).type()); |
| 13234 if (name_visibility == kUserVisibleName) { | 13292 if (name_visibility == kPrettyName) { |
| 13293 return type.BuildName(kPrettyName); |
| 13294 } else if (name_visibility == kUserVisibleName) { |
| 13235 return type.BuildName(kUserVisibleName); | 13295 return type.BuildName(kUserVisibleName); |
| 13236 } | 13296 } |
| 13237 String& type_name = String::Handle(type.BuildName(kInternalName)); | 13297 String& type_name = String::Handle(type.BuildName(kInternalName)); |
| 13238 type_name = String::Concat(type_name, Symbols::SpaceExtendsSpace()); | 13298 type_name = String::Concat(type_name, Symbols::SpaceExtendsSpace()); |
| 13239 // Build the bound name without causing divergence. | 13299 // Build the bound name without causing divergence. |
| 13240 const AbstractType& bound = AbstractType::Handle( | 13300 const AbstractType& bound = AbstractType::Handle( |
| 13241 BoundedType::Cast(*this).bound()); | 13301 BoundedType::Cast(*this).bound()); |
| 13242 String& bound_name = String::Handle(); | 13302 String& bound_name = String::Handle(); |
| 13243 if (bound.IsTypeParameter()) { | 13303 if (bound.IsTypeParameter()) { |
| 13244 bound_name = TypeParameter::Cast(bound).name(); | 13304 bound_name = TypeParameter::Cast(bound).name(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 13269 if (IsResolved() || !cls.IsMixinApplication()) { | 13329 if (IsResolved() || !cls.IsMixinApplication()) { |
| 13270 // Do not print the full vector, but only the declared type parameters. | 13330 // Do not print the full vector, but only the declared type parameters. |
| 13271 num_type_params = cls.NumTypeParameters(); | 13331 num_type_params = cls.NumTypeParameters(); |
| 13272 } else { | 13332 } else { |
| 13273 // Do not print the type parameters of an unresolved mixin application, | 13333 // Do not print the type parameters of an unresolved mixin application, |
| 13274 // since it would prematurely trigger the application of the mixin type. | 13334 // since it would prematurely trigger the application of the mixin type. |
| 13275 num_type_params = 0; | 13335 num_type_params = 0; |
| 13276 } | 13336 } |
| 13277 if (name_visibility == kInternalName) { | 13337 if (name_visibility == kInternalName) { |
| 13278 class_name = cls.Name(); | 13338 class_name = cls.Name(); |
| 13339 } else if (name_visibility == kPrettyName) { |
| 13340 class_name = cls.PrettyName(); |
| 13279 } else { | 13341 } else { |
| 13280 ASSERT(name_visibility == kUserVisibleName); | 13342 ASSERT(name_visibility == kUserVisibleName); |
| 13281 // Map internal types to their corresponding public interfaces. | 13343 // Map internal types to their corresponding public interfaces. |
| 13282 class_name = cls.UserVisibleName(); | 13344 class_name = cls.UserVisibleName(); |
| 13283 } | 13345 } |
| 13284 if (num_type_params > num_args) { | 13346 if (num_type_params > num_args) { |
| 13285 first_type_param_index = 0; | 13347 first_type_param_index = 0; |
| 13286 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { | 13348 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { |
| 13287 // Most probably a malformed type. Do not fill up with "dynamic", | 13349 // Most probably a malformed type. Do not fill up with "dynamic", |
| 13288 // but use actual vector. | 13350 // but use actual vector. |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14115 ASSERT(id >= 0); | 14177 ASSERT(id >= 0); |
| 14116 intptr_t cid = type_cls.id(); | 14178 intptr_t cid = type_cls.id(); |
| 14117 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); | 14179 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); |
| 14118 jsobj.AddProperty("type_class", type_cls); | 14180 jsobj.AddProperty("type_class", type_cls); |
| 14119 } else { | 14181 } else { |
| 14120 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14182 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14121 const intptr_t id = ring->GetIdForObject(raw()); | 14183 const intptr_t id = ring->GetIdForObject(raw()); |
| 14122 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14184 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14123 } | 14185 } |
| 14124 const char* name = String::Handle(Name()).ToCString(); | 14186 const char* name = String::Handle(Name()).ToCString(); |
| 14125 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14187 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14126 jsobj.AddProperty("name", name); | 14188 jsobj.AddProperty("name", name); |
| 14127 jsobj.AddProperty("user_name", user_name); | 14189 jsobj.AddProperty("user_name", pretty_name); |
| 14128 if (ref) { | 14190 if (ref) { |
| 14129 return; | 14191 return; |
| 14130 } | 14192 } |
| 14131 jsobj.AddProperty("type_arguments", TypeArguments::Handle(arguments())); | 14193 jsobj.AddProperty("type_arguments", TypeArguments::Handle(arguments())); |
| 14132 } | 14194 } |
| 14133 | 14195 |
| 14134 | 14196 |
| 14135 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { | 14197 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { |
| 14136 if (TestAndAddToTrail(&trail)) { | 14198 if (TestAndAddToTrail(&trail)) { |
| 14137 return true; | 14199 return true; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14279 } | 14341 } |
| 14280 | 14342 |
| 14281 | 14343 |
| 14282 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14344 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 14283 JSONObject jsobj(stream); | 14345 JSONObject jsobj(stream); |
| 14284 PrintSharedInstanceJSON(&jsobj, ref); | 14346 PrintSharedInstanceJSON(&jsobj, ref); |
| 14285 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14347 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14286 const intptr_t id = ring->GetIdForObject(raw()); | 14348 const intptr_t id = ring->GetIdForObject(raw()); |
| 14287 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14349 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14288 const char* name = String::Handle(Name()).ToCString(); | 14350 const char* name = String::Handle(Name()).ToCString(); |
| 14289 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14351 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14290 jsobj.AddProperty("name", name); | 14352 jsobj.AddProperty("name", name); |
| 14291 jsobj.AddProperty("user_name", user_name); | 14353 jsobj.AddProperty("user_name", pretty_name); |
| 14292 if (ref) { | 14354 if (ref) { |
| 14293 return; | 14355 return; |
| 14294 } | 14356 } |
| 14295 jsobj.AddProperty("ref_type", AbstractType::Handle(type())); | 14357 jsobj.AddProperty("ref_type", AbstractType::Handle(type())); |
| 14296 } | 14358 } |
| 14297 | 14359 |
| 14298 | 14360 |
| 14299 void TypeParameter::set_is_finalized() const { | 14361 void TypeParameter::set_is_finalized() const { |
| 14300 ASSERT(!IsFinalized()); | 14362 ASSERT(!IsFinalized()); |
| 14301 set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 14363 set_type_state(RawTypeParameter::kFinalizedUninstantiated); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14496 } | 14558 } |
| 14497 | 14559 |
| 14498 | 14560 |
| 14499 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14561 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 14500 JSONObject jsobj(stream); | 14562 JSONObject jsobj(stream); |
| 14501 PrintSharedInstanceJSON(&jsobj, ref); | 14563 PrintSharedInstanceJSON(&jsobj, ref); |
| 14502 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14564 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14503 const intptr_t id = ring->GetIdForObject(raw()); | 14565 const intptr_t id = ring->GetIdForObject(raw()); |
| 14504 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14566 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14505 const char* name = String::Handle(Name()).ToCString(); | 14567 const char* name = String::Handle(Name()).ToCString(); |
| 14506 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14568 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14507 jsobj.AddProperty("name", name); | 14569 jsobj.AddProperty("name", name); |
| 14508 jsobj.AddProperty("user_name", user_name); | 14570 jsobj.AddProperty("user_name", pretty_name); |
| 14509 const Class& param_cls = Class::Handle(parameterized_class()); | 14571 const Class& param_cls = Class::Handle(parameterized_class()); |
| 14510 jsobj.AddProperty("parameterized_class", param_cls); | 14572 jsobj.AddProperty("parameterized_class", param_cls); |
| 14511 if (ref) { | 14573 if (ref) { |
| 14512 return; | 14574 return; |
| 14513 } | 14575 } |
| 14514 jsobj.AddProperty("index", index()); | 14576 jsobj.AddProperty("index", index()); |
| 14515 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 14577 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
| 14516 jsobj.AddProperty("upper_bound", upper_bound); | 14578 jsobj.AddProperty("upper_bound", upper_bound); |
| 14517 } | 14579 } |
| 14518 | 14580 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14700 } | 14762 } |
| 14701 | 14763 |
| 14702 | 14764 |
| 14703 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14765 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 14704 JSONObject jsobj(stream); | 14766 JSONObject jsobj(stream); |
| 14705 PrintSharedInstanceJSON(&jsobj, ref); | 14767 PrintSharedInstanceJSON(&jsobj, ref); |
| 14706 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14768 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 14707 const intptr_t id = ring->GetIdForObject(raw()); | 14769 const intptr_t id = ring->GetIdForObject(raw()); |
| 14708 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14770 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 14709 const char* name = String::Handle(Name()).ToCString(); | 14771 const char* name = String::Handle(Name()).ToCString(); |
| 14710 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14772 const char* pretty_name = String::Handle(PrettyName()).ToCString(); |
| 14711 jsobj.AddProperty("name", name); | 14773 jsobj.AddProperty("name", name); |
| 14712 jsobj.AddProperty("user_name", user_name); | 14774 jsobj.AddProperty("user_name", pretty_name); |
| 14713 if (ref) { | 14775 if (ref) { |
| 14714 return; | 14776 return; |
| 14715 } | 14777 } |
| 14716 jsobj.AddProperty("bounded_type", AbstractType::Handle(type())); | 14778 jsobj.AddProperty("bounded_type", AbstractType::Handle(type())); |
| 14717 jsobj.AddProperty("upper_bound", AbstractType::Handle(bound())); | 14779 jsobj.AddProperty("upper_bound", AbstractType::Handle(bound())); |
| 14718 } | 14780 } |
| 14719 | 14781 |
| 14720 | 14782 |
| 14721 intptr_t MixinAppType::token_pos() const { | 14783 intptr_t MixinAppType::token_pos() const { |
| 14722 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); | 14784 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(); | 18786 return tag_label.ToCString(); |
| 18725 } | 18787 } |
| 18726 | 18788 |
| 18727 | 18789 |
| 18728 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 18790 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 18729 Instance::PrintJSONImpl(stream, ref); | 18791 Instance::PrintJSONImpl(stream, ref); |
| 18730 } | 18792 } |
| 18731 | 18793 |
| 18732 | 18794 |
| 18733 } // namespace dart | 18795 } // namespace dart |
| OLD | NEW |