Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: runtime/vm/object.cc

Issue 1723733002: Simplify various name flavors in VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address what was discussed in meeting Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // The trailing . on the default constructor name is dropped: 209 // The trailing . on the default constructor name is dropped:
210 // 210 //
211 // List. -> List 211 // List. -> List
212 // 212 //
213 // And so forth: 213 // And so forth:
214 // 214 //
215 // get:foo@6328321 -> foo 215 // get:foo@6328321 -> foo
216 // _MyClass@6328321. -> _MyClass 216 // _MyClass@6328321. -> _MyClass
217 // _MyClass@6328321.named -> _MyClass.named 217 // _MyClass@6328321.named -> _MyClass.named
218 // 218 //
219 RawString* String::IdentifierPrettyName(const String& name) { 219 RawString* String::ScrubName(const String& name) {
220 Zone* zone = Thread::Current()->zone(); 220 Zone* zone = Thread::Current()->zone();
221
222 #if !defined(PRODUCT)
Cutch 2016/02/25 00:10:07 NOT_IN_PRODUCT( .... );
regis 2016/02/25 17:47:27 Done.
221 if (name.Equals(Symbols::TopLevel())) { 223 if (name.Equals(Symbols::TopLevel())) {
222 // Name of invisible top-level class. 224 // Name of invisible top-level class.
223 return Symbols::Empty().raw(); 225 return Symbols::Empty().raw();
224 } 226 }
227 #endif // !defined(PRODUCT)
225 228
226 const char* cname = name.ToCString(); 229 const char* cname = name.ToCString();
227 ASSERT(strlen(cname) == static_cast<size_t>(name.Length())); 230 ASSERT(strlen(cname) == static_cast<size_t>(name.Length()));
228 const intptr_t name_len = name.Length(); 231 const intptr_t name_len = name.Length();
229 // First remove all private name mangling. 232 // First remove all private name mangling.
230 intptr_t start_pos = 0; 233 intptr_t start_pos = 0;
231 GrowableArray<const char*> unmangled_segments; 234 GrowableArray<const char*> unmangled_segments;
232 intptr_t sum_segment_len = 0; 235 intptr_t sum_segment_len = 0;
233 for (intptr_t i = 0; i < name_len; i++) { 236 for (intptr_t i = 0; i < name_len; i++) {
234 if ((cname[i] == '@') && ((i + 1) < name_len) && 237 if ((cname[i] == '@') && ((i + 1) < name_len) &&
(...skipping 24 matching lines...) Expand all
259 // Append the last segment. 262 // Append the last segment.
260 const intptr_t segment_len = name.Length() - start_pos; 263 const intptr_t segment_len = name.Length() - start_pos;
261 sum_segment_len += segment_len; 264 sum_segment_len += segment_len;
262 AppendSubString(zone, &unmangled_segments, cname, start_pos, segment_len); 265 AppendSubString(zone, &unmangled_segments, cname, start_pos, segment_len);
263 } 266 }
264 if (unmangled_name == NULL) { 267 if (unmangled_name == NULL) {
265 // Merge unmangled_segments. 268 // Merge unmangled_segments.
266 unmangled_name = MergeSubStrings(zone, unmangled_segments, sum_segment_len); 269 unmangled_name = MergeSubStrings(zone, unmangled_segments, sum_segment_len);
267 } 270 }
268 271
272 #if !defined(PRODUCT)
Cutch 2016/02/25 00:10:07 NOT_IN_PRODUCT( .... );
regis 2016/02/25 17:47:27 Done.
269 intptr_t len = sum_segment_len; 273 intptr_t len = sum_segment_len;
270 intptr_t start = 0; 274 intptr_t start = 0;
271 intptr_t dot_pos = -1; // Position of '.' in the name, if any. 275 intptr_t dot_pos = -1; // Position of '.' in the name, if any.
272 bool is_setter = false; 276 bool is_setter = false;
273 for (intptr_t i = start; i < len; i++) { 277 for (intptr_t i = start; i < len; i++) {
274 if (unmangled_name[i] == ':') { 278 if (unmangled_name[i] == ':') {
275 if (start != 0) { 279 if (start != 0) {
276 // Reset and break. 280 // Reset and break.
277 start = 0; 281 start = 0;
278 dot_pos = -1; 282 dot_pos = -1;
(...skipping 28 matching lines...) Expand all
307 intptr_t final_len = end - start; 311 intptr_t final_len = end - start;
308 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len); 312 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len);
309 if (is_setter) { 313 if (is_setter) {
310 const char* equals = Symbols::Equals().ToCString(); 314 const char* equals = Symbols::Equals().ToCString();
311 const intptr_t equals_len = strlen(equals); 315 const intptr_t equals_len = strlen(equals);
312 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len); 316 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len);
313 final_len += equals_len; 317 final_len += equals_len;
314 } 318 }
315 319
316 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len); 320 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len);
321 #endif // !defined(PRODUCT)
317 322
318 return Symbols::New(unmangled_name); 323 return Symbols::New(unmangled_name);
319 } 324 }
320 325
321 326
322 RawString* String::IdentifierPrettyNameRetainPrivate(const String& name) { 327 RawString* String::ScrubNameRetainPrivate(const String& name) {
328 #if defined(PRODUCT)
329 return name.raw();
330 #else // defined(PRODUCT)
323 intptr_t len = name.Length(); 331 intptr_t len = name.Length();
324 intptr_t start = 0; 332 intptr_t start = 0;
325 intptr_t at_pos = -1; // Position of '@' in the name, if any. 333 intptr_t at_pos = -1; // Position of '@' in the name, if any.
326 bool is_setter = false; 334 bool is_setter = false;
327 335
328 for (intptr_t i = start; i < len; i++) { 336 for (intptr_t i = start; i < len; i++) {
329 if (name.CharAt(i) == ':') { 337 if (name.CharAt(i) == ':') {
330 ASSERT(start == 0); // Only one : is possible in getters or setters. 338 ASSERT(start == 0); // Only one : is possible in getters or setters.
331 if (name.CharAt(0) == 's') { 339 if (name.CharAt(0) == 's') {
332 is_setter = true; 340 is_setter = true;
(...skipping 22 matching lines...) Expand all
355 const String& pre_at = 363 const String& pre_at =
356 String::Handle(String::SubString(result, 0, at_pos - 4)); 364 String::Handle(String::SubString(result, 0, at_pos - 4));
357 const String& post_at = 365 const String& post_at =
358 String::Handle(String::SubString(name, at_pos, len - at_pos)); 366 String::Handle(String::SubString(name, at_pos, len - at_pos));
359 result = String::Concat(pre_at, Symbols::Equals()); 367 result = String::Concat(pre_at, Symbols::Equals());
360 result = String::Concat(result, post_at); 368 result = String::Concat(result, post_at);
361 } 369 }
362 } 370 }
363 371
364 return result.raw(); 372 return result.raw();
373 #endif // defined(PRODUCT)
365 } 374 }
366 375
367 376
368 template<typename type> 377 template<typename type>
369 static bool IsSpecialCharacter(type value) { 378 static bool IsSpecialCharacter(type value) {
370 return ((value == '"') || 379 return ((value == '"') ||
371 (value == '\n') || 380 (value == '\n') ||
372 (value == '\f') || 381 (value == '\f') ||
373 (value == '\b') || 382 (value == '\b') ||
374 (value == '\t') || 383 (value == '\t') ||
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 1919
1911 1920
1912 RawString* Class::Name() const { 1921 RawString* Class::Name() const {
1913 // TODO(turnidge): This assert fails for the fake kFreeListElement class. 1922 // TODO(turnidge): This assert fails for the fake kFreeListElement class.
1914 // Fix this. 1923 // Fix this.
1915 ASSERT(raw_ptr()->name_ != String::null()); 1924 ASSERT(raw_ptr()->name_ != String::null());
1916 return raw_ptr()->name_; 1925 return raw_ptr()->name_;
1917 } 1926 }
1918 1927
1919 1928
1920 RawString* Class::PrettyName() const { 1929 RawString* Class::ScrubbedName() const {
1921 return GeneratePrettyName(); 1930 return String::ScrubName(String::Handle(Name()));
1922 } 1931 }
1923 1932
1924 1933
1925 RawString* Class::UserVisibleName() const { 1934 RawString* Class::UserVisibleName() const {
1926 #if defined(PRODUCT) 1935 #if defined(PRODUCT)
1927 return raw_ptr()->name_; 1936 return GenerateUserVisibleName();
1928 #else // defined(PRODUCT) 1937 #else // defined(PRODUCT)
1929 ASSERT(raw_ptr()->user_name_ != String::null()); 1938 ASSERT(raw_ptr()->user_name_ != String::null());
1930 return raw_ptr()->user_name_; 1939 return raw_ptr()->user_name_;
1931 #endif // defined(PRODUCT) 1940 #endif // defined(PRODUCT)
1932 } 1941 }
1933 1942
1934 1943
1935 bool Class::IsInFullSnapshot() const { 1944 bool Class::IsInFullSnapshot() const {
1936 NoSafepointScope no_safepoint; 1945 NoSafepointScope no_safepoint;
1937 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_; 1946 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_;
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 intptr_t instance_size = ExternalTypedData::InstanceSize(); 3163 intptr_t instance_size = ExternalTypedData::InstanceSize();
3155 Class& result = Class::Handle(New<ExternalTypedData>(class_id)); 3164 Class& result = Class::Handle(New<ExternalTypedData>(class_id));
3156 result.set_instance_size(instance_size); 3165 result.set_instance_size(instance_size);
3157 result.set_next_field_offset(ExternalTypedData::NextFieldOffset()); 3166 result.set_next_field_offset(ExternalTypedData::NextFieldOffset());
3158 result.set_is_prefinalized(); 3167 result.set_is_prefinalized();
3159 return result.raw(); 3168 return result.raw();
3160 } 3169 }
3161 3170
3162 3171
3163 void Class::set_name(const String& value) const { 3172 void Class::set_name(const String& value) const {
3173 ASSERT(raw_ptr()->name_ == String::null());
3164 ASSERT(value.IsSymbol()); 3174 ASSERT(value.IsSymbol());
3165 StorePointer(&raw_ptr()->name_, value.raw()); 3175 StorePointer(&raw_ptr()->name_, value.raw());
3166 NOT_IN_PRODUCT( 3176 NOT_IN_PRODUCT(
3167 if (raw_ptr()->user_name_ == String::null()) { 3177 if (raw_ptr()->user_name_ == String::null()) {
3168 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes, 3178 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes,
3169 // lazily set user name for the other classes. 3179 // lazily set user name for the other classes.
3170 // Generate and set user_name. 3180 // Generate and set user_name.
3171 const String& user_name = String::Handle(GenerateUserVisibleName()); 3181 const String& user_name = String::Handle(GenerateUserVisibleName());
3172 set_user_name(user_name); 3182 set_user_name(user_name);
3173 } 3183 }
3174 ) 3184 )
3175 } 3185 }
3176 3186
3177 3187
3178 NOT_IN_PRODUCT( 3188 NOT_IN_PRODUCT(
3179 void Class::set_user_name(const String& value) const { 3189 void Class::set_user_name(const String& value) const {
3180 StorePointer(&raw_ptr()->user_name_, value.raw()); 3190 StorePointer(&raw_ptr()->user_name_, value.raw());
3181 } 3191 }
3182 ) 3192 )
3183 3193
3184 3194
3185 RawString* Class::GeneratePrettyName() const {
3186 const String& name = String::Handle(Name());
3187 return String::IdentifierPrettyName(name);
3188 }
3189
3190
3191 RawString* Class::GenerateUserVisibleName() const { 3195 RawString* Class::GenerateUserVisibleName() const {
3192 if (FLAG_show_internal_names) { 3196 if (FLAG_show_internal_names) {
3193 return Name(); 3197 return Name();
3194 } 3198 }
3199 #if !defined(PRODUCT)
Cutch 2016/02/25 00:10:07 NOT_IN_PRODUCT( .... );
regis 2016/02/25 17:47:27 Done.
3195 switch (id()) { 3200 switch (id()) {
3196 case kNullCid: 3201 case kNullCid:
3197 return Symbols::Null().raw(); 3202 return Symbols::Null().raw();
3198 case kDynamicCid: 3203 case kDynamicCid:
3199 return Symbols::Dynamic().raw(); 3204 return Symbols::Dynamic().raw();
3200 case kVoidCid: 3205 case kVoidCid:
3201 return Symbols::Void().raw(); 3206 return Symbols::Void().raw();
3202 case kClassCid: 3207 case kClassCid:
3203 return Symbols::Class().raw(); 3208 return Symbols::Class().raw();
3204 case kUnresolvedClassCid: 3209 case kUnresolvedClassCid:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 return Symbols::Float32x4List().raw(); 3321 return Symbols::Float32x4List().raw();
3317 case kTypedDataFloat64x2ArrayCid: 3322 case kTypedDataFloat64x2ArrayCid:
3318 case kExternalTypedDataFloat64x2ArrayCid: 3323 case kExternalTypedDataFloat64x2ArrayCid:
3319 return Symbols::Float64x2List().raw(); 3324 return Symbols::Float64x2List().raw();
3320 case kTypedDataFloat32ArrayCid: 3325 case kTypedDataFloat32ArrayCid:
3321 case kExternalTypedDataFloat32ArrayCid: 3326 case kExternalTypedDataFloat32ArrayCid:
3322 return Symbols::Float32List().raw(); 3327 return Symbols::Float32List().raw();
3323 case kTypedDataFloat64ArrayCid: 3328 case kTypedDataFloat64ArrayCid:
3324 case kExternalTypedDataFloat64ArrayCid: 3329 case kExternalTypedDataFloat64ArrayCid:
3325 return Symbols::Float64List().raw(); 3330 return Symbols::Float64List().raw();
3331 #endif // !defined(PRODUCT)
Ivan Posva 2016/02/25 00:22:14 I don't think this will compile in PRODUCT, becaus
regis 2016/02/25 00:34:12 Indeed, it does not compile. A debug build does no
3326 default: 3332 default:
3327 const String& name = String::Handle(Name()); 3333 const String& name = String::Handle(Name());
3328 return String::IdentifierPrettyName(name); 3334 return String::ScrubName(name);
3329 } 3335 }
3330 UNREACHABLE(); 3336 UNREACHABLE();
3331 } 3337 }
3332 3338
3333 3339
3334 void Class::set_script(const Script& value) const { 3340 void Class::set_script(const Script& value) const {
3335 StorePointer(&raw_ptr()->script_, value.raw()); 3341 StorePointer(&raw_ptr()->script_, value.raw());
3336 } 3342 }
3337 3343
3338 3344
(...skipping 3309 matching lines...) Expand 10 before | Expand all | Expand 10 after
6648 ASSERT(obj.IsPatchClass()); 6654 ASSERT(obj.IsPatchClass());
6649 return PatchClass::Cast(obj).script(); 6655 return PatchClass::Cast(obj).script();
6650 } 6656 }
6651 6657
6652 6658
6653 bool Function::HasOptimizedCode() const { 6659 bool Function::HasOptimizedCode() const {
6654 return HasCode() && Code::Handle(CurrentCode()).is_optimized(); 6660 return HasCode() && Code::Handle(CurrentCode()).is_optimized();
6655 } 6661 }
6656 6662
6657 6663
6658 RawString* Function::PrettyName() const { 6664 RawString* Function::ScrubbedName() const {
6659 const String& str = String::Handle(name()); 6665 if (FLAG_show_internal_names) {
6660 return String::IdentifierPrettyName(str); 6666 return name();
6667 }
6668 return String::ScrubName(String::Handle(name()));
6661 } 6669 }
6662 6670
6663 6671
6664 const char* Function::QualifiedUserVisibleNameCString() const { 6672 RawString* Function::QualifiedName(NameVisibility name_visibility) const {
6665 const String& str = String::Handle(QualifiedUserVisibleName()); 6673 ASSERT(name_visibility != kInternalName); // We never request it.
6666 return str.ToCString(); 6674 // A function's scrubbed name and its user visible name are identical.
6675 String& result = String::Handle(ScrubbedName());
6676 if (IsClosureFunction()) {
6677 Function& fun = Function::Handle(raw());
6678 while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) {
6679 fun = fun.parent_function();
6680 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
6681 result = String::Concat(
6682 String::Handle(fun.ScrubbedName()), result, Heap::kOld);
6683 }
6684 }
6685 const Class& cls = Class::Handle(Owner());
6686 if (!cls.IsTopLevel()) {
6687 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
6688 const String& cls_name = String::Handle(
6689 name_visibility == kScrubbedName ? cls.ScrubbedName()
6690 : cls.UserVisibleName());
6691 result = String::Concat(cls_name, result, Heap::kOld);
6692 }
6693 return result.raw();
6667 } 6694 }
6668 6695
6669 6696
6670 RawString* Function::UserVisibleName() const {
6671 return PrettyName();
6672 }
6673
6674
6675 RawString* Function::QualifiedPrettyName() const {
6676 String& tmp = String::Handle();
6677 const Class& cls = Class::Handle(Owner());
6678
6679 if (IsClosureFunction()) {
6680 if (IsLocalFunction() && !IsImplicitClosureFunction()) {
6681 const Function& parent = Function::Handle(parent_function());
6682 tmp = parent.QualifiedPrettyName();
6683 } else {
6684 return PrettyName();
6685 }
6686 } else {
6687 if (cls.IsTopLevel()) {
6688 return PrettyName();
6689 } else {
6690 tmp = cls.PrettyName();
6691 }
6692 }
6693 tmp = String::Concat(tmp, Symbols::Dot(), Heap::kOld);
6694 const String& suffix = String::Handle(PrettyName());
6695 return String::Concat(tmp, suffix, Heap::kOld);
6696 }
6697
6698
6699 RawString* Function::QualifiedUserVisibleName() const {
6700 String& tmp = String::Handle();
6701 const Class& cls = Class::Handle(Owner());
6702
6703 if (IsClosureFunction()) {
6704 if (IsLocalFunction() && !IsImplicitClosureFunction()) {
6705 const Function& parent = Function::Handle(parent_function());
6706 tmp = parent.QualifiedUserVisibleName();
6707 } else {
6708 return UserVisibleName();
6709 }
6710 } else {
6711 if (cls.IsTopLevel()) {
6712 return UserVisibleName();
6713 } else {
6714 tmp = cls.UserVisibleName();
6715 }
6716 }
6717 tmp = String::Concat(tmp, Symbols::Dot());
6718 const String& suffix = String::Handle(UserVisibleName());
6719 return String::Concat(tmp, suffix);
6720 }
6721
6722
6723 RawString* Function::GetSource() const { 6697 RawString* Function::GetSource() const {
6724 if (IsImplicitConstructor() || IsSignatureFunction()) { 6698 if (IsImplicitConstructor() || IsSignatureFunction()) {
6725 // We may need to handle more cases when the restrictions on mixins are 6699 // We may need to handle more cases when the restrictions on mixins are
6726 // relaxed. In particular we might start associating some source with the 6700 // relaxed. In particular we might start associating some source with the
6727 // forwarding constructors when it becomes possible to specify a particular 6701 // forwarding constructors when it becomes possible to specify a particular
6728 // constructor from the mixin to use. 6702 // constructor from the mixin to use.
6729 return String::null(); 6703 return String::null();
6730 } 6704 }
6731 const Script& func_script = Script::Handle(script()); 6705 const Script& func_script = Script::Handle(script());
6732 const TokenStream& stream = TokenStream::Handle(func_script.tokens()); 6706 const TokenStream& stream = TokenStream::Handle(func_script.tokens());
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
7201 if (new_owner.NumTypeParameters() > 0) { 7175 if (new_owner.NumTypeParameters() > 0) {
7202 // Adjust the field type to refer to type parameters of the new owner. 7176 // Adjust the field type to refer to type parameters of the new owner.
7203 AbstractType& type = AbstractType::Handle(clone.type()); 7177 AbstractType& type = AbstractType::Handle(clone.type());
7204 type ^= type.CloneUninstantiated(new_owner); 7178 type ^= type.CloneUninstantiated(new_owner);
7205 clone.SetFieldType(type); 7179 clone.SetFieldType(type);
7206 } 7180 }
7207 return clone.raw(); 7181 return clone.raw();
7208 } 7182 }
7209 7183
7210 7184
7211 RawString* Field::PrettyName() const { 7185 RawString* Field::ScrubbedName() const {
7212 const String& str = String::Handle(name()); 7186 if (FLAG_show_internal_names) {
7213 return String::IdentifierPrettyName(str); 7187 return name();
7188 }
7189 return String::ScrubName(String::Handle(name()));
7214 } 7190 }
7215 7191
7216 7192
7217 RawString* Field::UserVisibleName() const {
7218 return PrettyName();
7219 }
7220
7221
7222 intptr_t Field::guarded_list_length() const { 7193 intptr_t Field::guarded_list_length() const {
7223 return Smi::Value(raw_ptr()->guarded_list_length_); 7194 return Smi::Value(raw_ptr()->guarded_list_length_);
7224 } 7195 }
7225 7196
7226 7197
7227 void Field::set_guarded_list_length(intptr_t list_length) const { 7198 void Field::set_guarded_list_length(intptr_t list_length) const {
7228 ASSERT(Thread::Current()->IsMutatorThread()); 7199 ASSERT(Thread::Current()->IsMutatorThread());
7229 StoreSmi(&raw_ptr()->guarded_list_length_, Smi::New(list_length)); 7200 StoreSmi(&raw_ptr()->guarded_list_length_, Smi::New(list_length));
7230 } 7201 }
7231 7202
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
8965 return Symbols::FromConcatAll(pieces); 8936 return Symbols::FromConcatAll(pieces);
8966 } 8937 }
8967 8938
8968 8939
8969 static RawString* MakeFunctionMetaName(const Function& func) { 8940 static RawString* MakeFunctionMetaName(const Function& func) {
8970 const String& cname = 8941 const String& cname =
8971 String::Handle(MakeClassMetaName(Class::Handle(func.origin()))); 8942 String::Handle(MakeClassMetaName(Class::Handle(func.origin())));
8972 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 8943 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
8973 pieces.Add(cname); 8944 pieces.Add(cname);
8974 pieces.Add(Symbols::At()); 8945 pieces.Add(Symbols::At());
8975 pieces.Add(String::Handle(func.QualifiedPrettyName())); 8946 pieces.Add(String::Handle(func.QualifiedScrubbedName()));
8976 return Symbols::FromConcatAll(pieces); 8947 return Symbols::FromConcatAll(pieces);
8977 } 8948 }
8978 8949
8979 8950
8980 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) { 8951 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) {
8981 const String& cname = String::Handle( 8952 const String& cname = String::Handle(
8982 MakeClassMetaName(Class::Handle(param.parameterized_class()))); 8953 MakeClassMetaName(Class::Handle(param.parameterized_class())));
8983 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 8954 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
8984 pieces.Add(cname); 8955 pieces.Add(cname);
8985 pieces.Add(Symbols::At()); 8956 pieces.Add(Symbols::At());
(...skipping 4039 matching lines...) Expand 10 before | Expand all | Expand 10 after
13025 Zone* zone = Thread::Current()->zone(); 12996 Zone* zone = Thread::Current()->zone();
13026 if (IsStubCode()) { 12997 if (IsStubCode()) {
13027 const char* name = StubCode::NameOfStub(EntryPoint()); 12998 const char* name = StubCode::NameOfStub(EntryPoint());
13028 return zone->PrintToString("[stub: %s]", name); 12999 return zone->PrintToString("[stub: %s]", name);
13029 } else { 13000 } else {
13030 return zone->PrintToString("Code entry:%" Px, EntryPoint()); 13001 return zone->PrintToString("Code entry:%" Px, EntryPoint());
13031 } 13002 }
13032 } 13003 }
13033 13004
13034 13005
13035 // Called by disassembler.
13036 RawString* Code::Name() const { 13006 RawString* Code::Name() const {
13037 const Object& obj = Object::Handle(owner()); 13007 const Object& obj = Object::Handle(owner());
13038 if (obj.IsNull()) { 13008 if (obj.IsNull()) {
13039 // Regular stub. 13009 // Regular stub.
13040 const char* name = StubCode::NameOfStub(EntryPoint()); 13010 const char* name = StubCode::NameOfStub(EntryPoint());
13041 ASSERT(name != NULL); 13011 ASSERT(name != NULL);
13042 const String& stub_name = String::Handle(Symbols::New(name)); 13012 const String& stub_name = String::Handle(Symbols::New(name));
13043 return Symbols::FromConcat(Symbols::StubPrefix(), stub_name); 13013 return Symbols::FromConcat(Symbols::StubPrefix(), stub_name);
13044 } else if (obj.IsClass()) { 13014 } else if (obj.IsClass()) {
13045 // Allocation stub. 13015 // Allocation stub.
13046 const Class& cls = Class::Cast(obj); 13016 const Class& cls = Class::Cast(obj);
13047 String& cls_name = String::Handle(cls.Name()); 13017 String& cls_name = String::Handle(cls.ScrubbedName());
13048 ASSERT(!cls_name.IsNull()); 13018 ASSERT(!cls_name.IsNull());
13049 return Symbols::FromConcat(Symbols::AllocationStubFor(), cls_name); 13019 return Symbols::FromConcat(Symbols::AllocationStubFor(), cls_name);
13050 } else { 13020 } else {
13051 ASSERT(obj.IsFunction()); 13021 ASSERT(obj.IsFunction());
13052 // Dart function. 13022 // Dart function.
13053 return Function::Cast(obj).name(); 13023 return Function::Cast(obj).ScrubbedName();
13054 } 13024 }
13055 } 13025 }
13056 13026
13057 13027
13058 RawString* Code::PrettyName() const { 13028 RawString* Code::QualifiedName() const {
13059 const Object& obj = Object::Handle(owner()); 13029 const Object& obj = Object::Handle(owner());
13060 if (obj.IsNull()) { 13030 if (obj.IsFunction()) {
13061 // Regular stub. 13031 return Function::Cast(obj).QualifiedScrubbedName();
13062 const char* name = StubCode::NameOfStub(EntryPoint());
13063 ASSERT(name != NULL);
13064 const String& stub_name = String::Handle(String::New(name));
13065 return String::Concat(Symbols::StubPrefix(), stub_name);
13066 } else if (obj.IsClass()) {
13067 // Allocation stub.
13068 const Class& cls = Class::Cast(obj);
13069 String& cls_name = String::Handle(cls.Name());
13070 ASSERT(!cls_name.IsNull());
13071 return String::Concat(Symbols::AllocationStubFor(), cls_name);
13072 } else {
13073 ASSERT(obj.IsFunction());
13074 // Dart function.
13075 return Function::Cast(obj).QualifiedPrettyName();
13076 } 13032 }
13033 return Name();
13077 } 13034 }
13078 13035
13079 13036
13080 bool Code::IsAllocationStubCode() const { 13037 bool Code::IsAllocationStubCode() const {
13081 const Object& obj = Object::Handle(owner()); 13038 const Object& obj = Object::Handle(owner());
13082 return obj.IsClass(); 13039 return obj.IsClass();
13083 } 13040 }
13084 13041
13085 13042
13086 bool Code::IsStubCode() const { 13043 bool Code::IsStubCode() const {
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
14778 } 14735 }
14779 } 14736 }
14780 } 14737 }
14781 (*trail)->Add(*this); 14738 (*trail)->Add(*this);
14782 (*trail)->Add(buddy); 14739 (*trail)->Add(buddy);
14783 return false; 14740 return false;
14784 } 14741 }
14785 14742
14786 14743
14787 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { 14744 RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
14745 ASSERT(name_visibility != kScrubbedName);
14788 Zone* zone = Thread::Current()->zone(); 14746 Zone* zone = Thread::Current()->zone();
14789 if (IsBoundedType()) { 14747 if (IsBoundedType()) {
14790 const AbstractType& type = AbstractType::Handle( 14748 const AbstractType& type = AbstractType::Handle(
14791 BoundedType::Cast(*this).type()); 14749 BoundedType::Cast(*this).type());
14792 if (name_visibility == kPrettyName) { 14750 if (name_visibility == kUserVisibleName) {
14793 return type.BuildName(kPrettyName);
14794 } else if (name_visibility == kUserVisibleName) {
14795 return type.BuildName(kUserVisibleName); 14751 return type.BuildName(kUserVisibleName);
14796 } 14752 }
14797 GrowableHandlePtrArray<const String> pieces(zone, 5); 14753 GrowableHandlePtrArray<const String> pieces(zone, 5);
14798 String& type_name = String::Handle(zone, type.BuildName(kInternalName)); 14754 String& type_name = String::Handle(zone, type.BuildName(kInternalName));
14799 pieces.Add(type_name); 14755 pieces.Add(type_name);
14800 pieces.Add(Symbols::SpaceExtendsSpace()); 14756 pieces.Add(Symbols::SpaceExtendsSpace());
14801 // Build the bound name without causing divergence. 14757 // Build the bound name without causing divergence.
14802 const AbstractType& bound = AbstractType::Handle( 14758 const AbstractType& bound = AbstractType::Handle(
14803 zone, BoundedType::Cast(*this).bound()); 14759 zone, BoundedType::Cast(*this).bound());
14804 String& bound_name = String::Handle(zone); 14760 String& bound_name = String::Handle(zone);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
14854 if (IsResolved() || !cls.IsMixinApplication()) { 14810 if (IsResolved() || !cls.IsMixinApplication()) {
14855 // Do not print the full vector, but only the declared type parameters. 14811 // Do not print the full vector, but only the declared type parameters.
14856 num_type_params = cls.NumTypeParameters(); 14812 num_type_params = cls.NumTypeParameters();
14857 } else { 14813 } else {
14858 // Do not print the type parameters of an unresolved mixin application, 14814 // Do not print the type parameters of an unresolved mixin application,
14859 // since it would prematurely trigger the application of the mixin type. 14815 // since it would prematurely trigger the application of the mixin type.
14860 num_type_params = 0; 14816 num_type_params = 0;
14861 } 14817 }
14862 if (name_visibility == kInternalName) { 14818 if (name_visibility == kInternalName) {
14863 class_name = cls.Name(); 14819 class_name = cls.Name();
14864 } else if (name_visibility == kPrettyName) {
14865 class_name = cls.PrettyName();
14866 } else { 14820 } else {
14867 ASSERT(name_visibility == kUserVisibleName); 14821 ASSERT(name_visibility == kUserVisibleName);
14868 // Map internal types to their corresponding public interfaces. 14822 // Map internal types to their corresponding public interfaces.
14869 class_name = cls.UserVisibleName(); 14823 class_name = cls.UserVisibleName();
14870 } 14824 }
14871 if (num_type_params > num_args) { 14825 if (num_type_params > num_args) {
14872 first_type_param_index = 0; 14826 first_type_param_index = 0;
14873 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { 14827 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) {
14874 // Most probably a malformed type. Do not fill up with "dynamic", 14828 // Most probably a malformed type. Do not fill up with "dynamic",
14875 // but use actual vector. 14829 // but use actual vector.
(...skipping 6595 matching lines...) Expand 10 before | Expand all | Expand 10 after
21471 return UserTag::null(); 21425 return UserTag::null();
21472 } 21426 }
21473 21427
21474 21428
21475 const char* UserTag::ToCString() const { 21429 const char* UserTag::ToCString() const {
21476 const String& tag_label = String::Handle(label()); 21430 const String& tag_label = String::Handle(label());
21477 return tag_label.ToCString(); 21431 return tag_label.ToCString();
21478 } 21432 }
21479 21433
21480 } // namespace dart 21434 } // namespace dart
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/object_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698