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

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 comments Created 4 years, 9 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // The trailing . on the default constructor name is dropped: 206 // The trailing . on the default constructor name is dropped:
207 // 207 //
208 // List. -> List 208 // List. -> List
209 // 209 //
210 // And so forth: 210 // And so forth:
211 // 211 //
212 // get:foo@6328321 -> foo 212 // get:foo@6328321 -> foo
213 // _MyClass@6328321. -> _MyClass 213 // _MyClass@6328321. -> _MyClass
214 // _MyClass@6328321.named -> _MyClass.named 214 // _MyClass@6328321.named -> _MyClass.named
215 // 215 //
216 RawString* String::IdentifierPrettyName(const String& name) { 216 RawString* String::ScrubName(const String& name) {
217 Zone* zone = Thread::Current()->zone(); 217 Zone* zone = Thread::Current()->zone();
218
219 NOT_IN_PRODUCT(
218 if (name.Equals(Symbols::TopLevel())) { 220 if (name.Equals(Symbols::TopLevel())) {
219 // Name of invisible top-level class. 221 // Name of invisible top-level class.
220 return Symbols::Empty().raw(); 222 return Symbols::Empty().raw();
221 } 223 }
224 )
222 225
223 const char* cname = name.ToCString(); 226 const char* cname = name.ToCString();
224 ASSERT(strlen(cname) == static_cast<size_t>(name.Length())); 227 ASSERT(strlen(cname) == static_cast<size_t>(name.Length()));
225 const intptr_t name_len = name.Length(); 228 const intptr_t name_len = name.Length();
226 // First remove all private name mangling. 229 // First remove all private name mangling.
227 intptr_t start_pos = 0; 230 intptr_t start_pos = 0;
228 GrowableArray<const char*> unmangled_segments; 231 GrowableArray<const char*> unmangled_segments;
229 intptr_t sum_segment_len = 0; 232 intptr_t sum_segment_len = 0;
230 for (intptr_t i = 0; i < name_len; i++) { 233 for (intptr_t i = 0; i < name_len; i++) {
231 if ((cname[i] == '@') && ((i + 1) < name_len) && 234 if ((cname[i] == '@') && ((i + 1) < name_len) &&
(...skipping 24 matching lines...) Expand all
256 // Append the last segment. 259 // Append the last segment.
257 const intptr_t segment_len = name.Length() - start_pos; 260 const intptr_t segment_len = name.Length() - start_pos;
258 sum_segment_len += segment_len; 261 sum_segment_len += segment_len;
259 AppendSubString(zone, &unmangled_segments, cname, start_pos, segment_len); 262 AppendSubString(zone, &unmangled_segments, cname, start_pos, segment_len);
260 } 263 }
261 if (unmangled_name == NULL) { 264 if (unmangled_name == NULL) {
262 // Merge unmangled_segments. 265 // Merge unmangled_segments.
263 unmangled_name = MergeSubStrings(zone, unmangled_segments, sum_segment_len); 266 unmangled_name = MergeSubStrings(zone, unmangled_segments, sum_segment_len);
264 } 267 }
265 268
269 NOT_IN_PRODUCT(
266 intptr_t len = sum_segment_len; 270 intptr_t len = sum_segment_len;
267 intptr_t start = 0; 271 intptr_t start = 0;
268 intptr_t dot_pos = -1; // Position of '.' in the name, if any. 272 intptr_t dot_pos = -1; // Position of '.' in the name, if any.
269 bool is_setter = false; 273 bool is_setter = false;
270 for (intptr_t i = start; i < len; i++) { 274 for (intptr_t i = start; i < len; i++) {
271 if (unmangled_name[i] == ':') { 275 if (unmangled_name[i] == ':') {
272 if (start != 0) { 276 if (start != 0) {
273 // Reset and break. 277 // Reset and break.
274 start = 0; 278 start = 0;
275 dot_pos = -1; 279 dot_pos = -1;
(...skipping 28 matching lines...) Expand all
304 intptr_t final_len = end - start; 308 intptr_t final_len = end - start;
305 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len); 309 AppendSubString(zone, &unmangled_segments, unmangled_name, start, final_len);
306 if (is_setter) { 310 if (is_setter) {
307 const char* equals = Symbols::Equals().ToCString(); 311 const char* equals = Symbols::Equals().ToCString();
308 const intptr_t equals_len = strlen(equals); 312 const intptr_t equals_len = strlen(equals);
309 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len); 313 AppendSubString(zone, &unmangled_segments, equals, 0, equals_len);
310 final_len += equals_len; 314 final_len += equals_len;
311 } 315 }
312 316
313 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len); 317 unmangled_name = MergeSubStrings(zone, unmangled_segments, final_len);
318 )
314 319
315 return Symbols::New(unmangled_name); 320 return Symbols::New(unmangled_name);
316 } 321 }
317 322
318 323
319 RawString* String::IdentifierPrettyNameRetainPrivate(const String& name) { 324 RawString* String::ScrubNameRetainPrivate(const String& name) {
325 NOT_IN_PRODUCT(
320 intptr_t len = name.Length(); 326 intptr_t len = name.Length();
321 intptr_t start = 0; 327 intptr_t start = 0;
322 intptr_t at_pos = -1; // Position of '@' in the name, if any. 328 intptr_t at_pos = -1; // Position of '@' in the name, if any.
323 bool is_setter = false; 329 bool is_setter = false;
324 330
325 for (intptr_t i = start; i < len; i++) { 331 for (intptr_t i = start; i < len; i++) {
326 if (name.CharAt(i) == ':') { 332 if (name.CharAt(i) == ':') {
327 ASSERT(start == 0); // Only one : is possible in getters or setters. 333 ASSERT(start == 0); // Only one : is possible in getters or setters.
328 if (name.CharAt(0) == 's') { 334 if (name.CharAt(0) == 's') {
329 is_setter = true; 335 is_setter = true;
(...skipping 22 matching lines...) Expand all
352 const String& pre_at = 358 const String& pre_at =
353 String::Handle(String::SubString(result, 0, at_pos - 4)); 359 String::Handle(String::SubString(result, 0, at_pos - 4));
354 const String& post_at = 360 const String& post_at =
355 String::Handle(String::SubString(name, at_pos, len - at_pos)); 361 String::Handle(String::SubString(name, at_pos, len - at_pos));
356 result = String::Concat(pre_at, Symbols::Equals()); 362 result = String::Concat(pre_at, Symbols::Equals());
357 result = String::Concat(result, post_at); 363 result = String::Concat(result, post_at);
358 } 364 }
359 } 365 }
360 366
361 return result.raw(); 367 return result.raw();
368 )
369 return name.raw(); // In PRODUCT, return argument unchanged.
362 } 370 }
363 371
364 372
365 template<typename type> 373 template<typename type>
366 static bool IsSpecialCharacter(type value) { 374 static bool IsSpecialCharacter(type value) {
367 return ((value == '"') || 375 return ((value == '"') ||
368 (value == '\n') || 376 (value == '\n') ||
369 (value == '\f') || 377 (value == '\f') ||
370 (value == '\b') || 378 (value == '\b') ||
371 (value == '\t') || 379 (value == '\t') ||
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 str = lib.PrivateName(public_class_name); 1095 str = lib.PrivateName(public_class_name);
1088 cls.set_name(str); 1096 cls.set_name(str);
1089 lib.AddClass(cls); 1097 lib.AddClass(cls);
1090 } 1098 }
1091 1099
1092 1100
1093 RawError* Object::Init(Isolate* isolate) { 1101 RawError* Object::Init(Isolate* isolate) {
1094 Thread* thread = Thread::Current(); 1102 Thread* thread = Thread::Current();
1095 Zone* zone = thread->zone(); 1103 Zone* zone = thread->zone();
1096 ASSERT(isolate == thread->isolate()); 1104 ASSERT(isolate == thread->isolate());
1097 #ifndef PRODUCT 1105 NOT_IN_PRODUCT(
1098 TimelineDurationScope tds(thread, 1106 TimelineDurationScope tds(thread,
1099 isolate->GetIsolateStream(), 1107 isolate->GetIsolateStream(),
1100 "Object::Init"); 1108 "Object::Init");
1101 #endif 1109 )
1102 1110
1103 #if defined(DART_NO_SNAPSHOT) 1111 #if defined(DART_NO_SNAPSHOT)
1104 // Object::Init version when we are running in a version of dart that does 1112 // Object::Init version when we are running in a version of dart that does
1105 // not have a full snapshot linked in. 1113 // not have a full snapshot linked in.
1106 ObjectStore* object_store = isolate->object_store(); 1114 ObjectStore* object_store = isolate->object_store();
1107 1115
1108 Class& cls = Class::Handle(zone); 1116 Class& cls = Class::Handle(zone);
1109 Type& type = Type::Handle(zone); 1117 Type& type = Type::Handle(zone);
1110 Array& array = Array::Handle(zone); 1118 Array& array = Array::Handle(zone);
1111 Library& lib = Library::Handle(zone); 1119 Library& lib = Library::Handle(zone);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 if (lib.IsNull()) { 1373 if (lib.IsNull()) {
1366 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true); 1374 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true);
1367 lib.SetLoadRequested(); 1375 lib.SetLoadRequested();
1368 lib.Register(); 1376 lib.Register();
1369 object_store->set_bootstrap_library(ObjectStore::kMirrors, lib); 1377 object_store->set_bootstrap_library(ObjectStore::kMirrors, lib);
1370 } 1378 }
1371 ASSERT(!lib.IsNull()); 1379 ASSERT(!lib.IsNull());
1372 ASSERT(lib.raw() == Library::MirrorsLibrary()); 1380 ASSERT(lib.raw() == Library::MirrorsLibrary());
1373 1381
1374 cls = Class::New<MirrorReference>(); 1382 cls = Class::New<MirrorReference>();
1375 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib)); 1383 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib);
1384 )
1376 1385
1377 // Pre-register the collection library so we can place the vm class 1386 // Pre-register the collection library so we can place the vm class
1378 // LinkedHashMap there rather than the core library. 1387 // LinkedHashMap there rather than the core library.
1379 lib = Library::LookupLibrary(Symbols::DartCollection()); 1388 lib = Library::LookupLibrary(Symbols::DartCollection());
1380 if (lib.IsNull()) { 1389 if (lib.IsNull()) {
1381 lib = Library::NewLibraryHelper(Symbols::DartCollection(), true); 1390 lib = Library::NewLibraryHelper(Symbols::DartCollection(), true);
1382 lib.SetLoadRequested(); 1391 lib.SetLoadRequested();
1383 lib.Register(); 1392 lib.Register();
1384 object_store->set_bootstrap_library(ObjectStore::kCollection, lib); 1393 object_store->set_bootstrap_library(ObjectStore::kCollection, lib);
1385 } 1394 }
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 1916
1908 1917
1909 RawString* Class::Name() const { 1918 RawString* Class::Name() const {
1910 // TODO(turnidge): This assert fails for the fake kFreeListElement class. 1919 // TODO(turnidge): This assert fails for the fake kFreeListElement class.
1911 // Fix this. 1920 // Fix this.
1912 ASSERT(raw_ptr()->name_ != String::null()); 1921 ASSERT(raw_ptr()->name_ != String::null());
1913 return raw_ptr()->name_; 1922 return raw_ptr()->name_;
1914 } 1923 }
1915 1924
1916 1925
1917 RawString* Class::PrettyName() const { 1926 RawString* Class::ScrubbedName() const {
1918 return GeneratePrettyName(); 1927 return String::ScrubName(String::Handle(Name()));
1919 } 1928 }
1920 1929
1921 1930
1922 RawString* Class::UserVisibleName() const { 1931 RawString* Class::UserVisibleName() const {
1923 #if defined(PRODUCT) 1932 NOT_IN_PRODUCT(
1924 return raw_ptr()->name_;
1925 #else // defined(PRODUCT)
1926 ASSERT(raw_ptr()->user_name_ != String::null()); 1933 ASSERT(raw_ptr()->user_name_ != String::null());
1927 return raw_ptr()->user_name_; 1934 return raw_ptr()->user_name_;
1928 #endif // defined(PRODUCT) 1935 )
1936 return GenerateUserVisibleName(); // No caching in PRODUCT, regenerate.
1929 } 1937 }
1930 1938
1931 1939
1932 bool Class::IsInFullSnapshot() const { 1940 bool Class::IsInFullSnapshot() const {
1933 NoSafepointScope no_safepoint; 1941 NoSafepointScope no_safepoint;
1934 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_; 1942 return raw_ptr()->library_->ptr()->is_in_fullsnapshot_;
1935 } 1943 }
1936 1944
1937 1945
1938 RawAbstractType* Class::RareType() const { 1946 RawAbstractType* Class::RareType() const {
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 intptr_t instance_size = ExternalTypedData::InstanceSize(); 3159 intptr_t instance_size = ExternalTypedData::InstanceSize();
3152 Class& result = Class::Handle(New<ExternalTypedData>(class_id)); 3160 Class& result = Class::Handle(New<ExternalTypedData>(class_id));
3153 result.set_instance_size(instance_size); 3161 result.set_instance_size(instance_size);
3154 result.set_next_field_offset(ExternalTypedData::NextFieldOffset()); 3162 result.set_next_field_offset(ExternalTypedData::NextFieldOffset());
3155 result.set_is_prefinalized(); 3163 result.set_is_prefinalized();
3156 return result.raw(); 3164 return result.raw();
3157 } 3165 }
3158 3166
3159 3167
3160 void Class::set_name(const String& value) const { 3168 void Class::set_name(const String& value) const {
3169 ASSERT(raw_ptr()->name_ == String::null());
3161 ASSERT(value.IsSymbol()); 3170 ASSERT(value.IsSymbol());
3162 StorePointer(&raw_ptr()->name_, value.raw()); 3171 StorePointer(&raw_ptr()->name_, value.raw());
3163 NOT_IN_PRODUCT( 3172 NOT_IN_PRODUCT(
3164 if (raw_ptr()->user_name_ == String::null()) { 3173 if (raw_ptr()->user_name_ == String::null()) {
3165 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes, 3174 // TODO(johnmccutchan): Eagerly set user name for VM isolate classes,
3166 // lazily set user name for the other classes. 3175 // lazily set user name for the other classes.
3167 // Generate and set user_name. 3176 // Generate and set user_name.
3168 const String& user_name = String::Handle(GenerateUserVisibleName()); 3177 const String& user_name = String::Handle(GenerateUserVisibleName());
3169 set_user_name(user_name); 3178 set_user_name(user_name);
3170 } 3179 }
3171 ) 3180 )
3172 } 3181 }
3173 3182
3174 3183
3175 NOT_IN_PRODUCT( 3184 NOT_IN_PRODUCT(
3176 void Class::set_user_name(const String& value) const { 3185 void Class::set_user_name(const String& value) const {
3177 StorePointer(&raw_ptr()->user_name_, value.raw()); 3186 StorePointer(&raw_ptr()->user_name_, value.raw());
3178 } 3187 }
3179 ) 3188 )
3180 3189
3181 3190
3182 RawString* Class::GeneratePrettyName() const {
3183 const String& name = String::Handle(Name());
3184 return String::IdentifierPrettyName(name);
3185 }
3186
3187
3188 RawString* Class::GenerateUserVisibleName() const { 3191 RawString* Class::GenerateUserVisibleName() const {
3189 if (FLAG_show_internal_names) { 3192 if (FLAG_show_internal_names) {
3190 return Name(); 3193 return Name();
3191 } 3194 }
3195 NOT_IN_PRODUCT(
3192 switch (id()) { 3196 switch (id()) {
3193 case kNullCid: 3197 case kNullCid:
3194 return Symbols::Null().raw(); 3198 return Symbols::Null().raw();
3195 case kDynamicCid: 3199 case kDynamicCid:
3196 return Symbols::Dynamic().raw(); 3200 return Symbols::Dynamic().raw();
3197 case kVoidCid: 3201 case kVoidCid:
3198 return Symbols::Void().raw(); 3202 return Symbols::Void().raw();
3199 case kClassCid: 3203 case kClassCid:
3200 return Symbols::Class().raw(); 3204 return Symbols::Class().raw();
3201 case kUnresolvedClassCid: 3205 case kUnresolvedClassCid:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 return Symbols::Float32x4List().raw(); 3317 return Symbols::Float32x4List().raw();
3314 case kTypedDataFloat64x2ArrayCid: 3318 case kTypedDataFloat64x2ArrayCid:
3315 case kExternalTypedDataFloat64x2ArrayCid: 3319 case kExternalTypedDataFloat64x2ArrayCid:
3316 return Symbols::Float64x2List().raw(); 3320 return Symbols::Float64x2List().raw();
3317 case kTypedDataFloat32ArrayCid: 3321 case kTypedDataFloat32ArrayCid:
3318 case kExternalTypedDataFloat32ArrayCid: 3322 case kExternalTypedDataFloat32ArrayCid:
3319 return Symbols::Float32List().raw(); 3323 return Symbols::Float32List().raw();
3320 case kTypedDataFloat64ArrayCid: 3324 case kTypedDataFloat64ArrayCid:
3321 case kExternalTypedDataFloat64ArrayCid: 3325 case kExternalTypedDataFloat64ArrayCid:
3322 return Symbols::Float64List().raw(); 3326 return Symbols::Float64List().raw();
3323 default:
3324 const String& name = String::Handle(Name());
3325 return String::IdentifierPrettyName(name);
3326 } 3327 }
3327 UNREACHABLE(); 3328 )
3329 const String& name = String::Handle(Name());
3330 return String::ScrubName(name);
3328 } 3331 }
3329 3332
3330 3333
3331 void Class::set_script(const Script& value) const { 3334 void Class::set_script(const Script& value) const {
3332 StorePointer(&raw_ptr()->script_, value.raw()); 3335 StorePointer(&raw_ptr()->script_, value.raw());
3333 } 3336 }
3334 3337
3335 3338
3336 void Class::set_token_pos(TokenPosition token_pos) const { 3339 void Class::set_token_pos(TokenPosition token_pos) const {
3337 ASSERT(!token_pos.IsClassifying()); 3340 ASSERT(!token_pos.IsClassifying());
(...skipping 3307 matching lines...) Expand 10 before | Expand all | Expand 10 after
6645 ASSERT(obj.IsPatchClass()); 6648 ASSERT(obj.IsPatchClass());
6646 return PatchClass::Cast(obj).script(); 6649 return PatchClass::Cast(obj).script();
6647 } 6650 }
6648 6651
6649 6652
6650 bool Function::HasOptimizedCode() const { 6653 bool Function::HasOptimizedCode() const {
6651 return HasCode() && Code::Handle(CurrentCode()).is_optimized(); 6654 return HasCode() && Code::Handle(CurrentCode()).is_optimized();
6652 } 6655 }
6653 6656
6654 6657
6655 RawString* Function::PrettyName() const {
6656 const String& str = String::Handle(name());
6657 return String::IdentifierPrettyName(str);
6658 }
6659
6660
6661 const char* Function::QualifiedUserVisibleNameCString() const {
6662 const String& str = String::Handle(QualifiedUserVisibleName());
6663 return str.ToCString();
6664 }
6665
6666
6667 RawString* Function::UserVisibleName() const { 6658 RawString* Function::UserVisibleName() const {
6668 return PrettyName(); 6659 if (FLAG_show_internal_names) {
6660 return name();
6661 }
6662 return String::ScrubName(String::Handle(name()));
6669 } 6663 }
6670 6664
6671 6665
6672 RawString* Function::QualifiedPrettyName() const { 6666 RawString* Function::QualifiedName(NameVisibility name_visibility) const {
6673 String& tmp = String::Handle(); 6667 ASSERT(name_visibility != kInternalName); // We never request it.
6674 const Class& cls = Class::Handle(Owner()); 6668 // A function's scrubbed name and its user visible name are identical.
6675 6669 String& result = String::Handle(UserVisibleName());
6676 if (IsClosureFunction()) { 6670 if (IsClosureFunction()) {
6677 if (IsLocalFunction() && !IsImplicitClosureFunction()) { 6671 Function& fun = Function::Handle(raw());
6678 const Function& parent = Function::Handle(parent_function()); 6672 while (fun.IsLocalFunction() && !fun.IsImplicitClosureFunction()) {
6679 tmp = parent.QualifiedPrettyName(); 6673 fun = fun.parent_function();
6680 } else { 6674 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
6681 return PrettyName(); 6675 result = String::Concat(
6682 } 6676 String::Handle(fun.UserVisibleName()), result, Heap::kOld);
6683 } else {
6684 if (cls.IsTopLevel()) {
6685 return PrettyName();
6686 } else {
6687 tmp = cls.PrettyName();
6688 } 6677 }
6689 } 6678 }
6690 tmp = String::Concat(tmp, Symbols::Dot(), Heap::kOld); 6679 const Class& cls = Class::Handle(Owner());
6691 const String& suffix = String::Handle(PrettyName()); 6680 if (!cls.IsTopLevel()) {
6692 return String::Concat(tmp, suffix, Heap::kOld); 6681 result = String::Concat(Symbols::Dot(), result, Heap::kOld);
6682 const String& cls_name = String::Handle(
6683 name_visibility == kScrubbedName ? cls.ScrubbedName()
6684 : cls.UserVisibleName());
6685 result = String::Concat(cls_name, result, Heap::kOld);
6686 }
6687 return result.raw();
6693 } 6688 }
6694 6689
6695 6690
6696 RawString* Function::QualifiedUserVisibleName() const {
6697 String& tmp = String::Handle();
6698 const Class& cls = Class::Handle(Owner());
6699
6700 if (IsClosureFunction()) {
6701 if (IsLocalFunction() && !IsImplicitClosureFunction()) {
6702 const Function& parent = Function::Handle(parent_function());
6703 tmp = parent.QualifiedUserVisibleName();
6704 } else {
6705 return UserVisibleName();
6706 }
6707 } else {
6708 if (cls.IsTopLevel()) {
6709 return UserVisibleName();
6710 } else {
6711 tmp = cls.UserVisibleName();
6712 }
6713 }
6714 tmp = String::Concat(tmp, Symbols::Dot());
6715 const String& suffix = String::Handle(UserVisibleName());
6716 return String::Concat(tmp, suffix);
6717 }
6718
6719
6720 RawString* Function::GetSource() const { 6691 RawString* Function::GetSource() const {
6721 if (IsImplicitConstructor() || IsSignatureFunction()) { 6692 if (IsImplicitConstructor() || IsSignatureFunction()) {
6722 // We may need to handle more cases when the restrictions on mixins are 6693 // We may need to handle more cases when the restrictions on mixins are
6723 // relaxed. In particular we might start associating some source with the 6694 // relaxed. In particular we might start associating some source with the
6724 // forwarding constructors when it becomes possible to specify a particular 6695 // forwarding constructors when it becomes possible to specify a particular
6725 // constructor from the mixin to use. 6696 // constructor from the mixin to use.
6726 return String::null(); 6697 return String::null();
6727 } 6698 }
6728 const Script& func_script = Script::Handle(script()); 6699 const Script& func_script = Script::Handle(script());
6729 const TokenStream& stream = TokenStream::Handle(func_script.tokens()); 6700 const TokenStream& stream = TokenStream::Handle(func_script.tokens());
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
7198 if (new_owner.NumTypeParameters() > 0) { 7169 if (new_owner.NumTypeParameters() > 0) {
7199 // Adjust the field type to refer to type parameters of the new owner. 7170 // Adjust the field type to refer to type parameters of the new owner.
7200 AbstractType& type = AbstractType::Handle(clone.type()); 7171 AbstractType& type = AbstractType::Handle(clone.type());
7201 type ^= type.CloneUninstantiated(new_owner); 7172 type ^= type.CloneUninstantiated(new_owner);
7202 clone.SetFieldType(type); 7173 clone.SetFieldType(type);
7203 } 7174 }
7204 return clone.raw(); 7175 return clone.raw();
7205 } 7176 }
7206 7177
7207 7178
7208 RawString* Field::PrettyName() const {
7209 const String& str = String::Handle(name());
7210 return String::IdentifierPrettyName(str);
7211 }
7212
7213
7214 RawString* Field::UserVisibleName() const { 7179 RawString* Field::UserVisibleName() const {
7215 return PrettyName(); 7180 if (FLAG_show_internal_names) {
7181 return name();
7182 }
7183 return String::ScrubName(String::Handle(name()));
7216 } 7184 }
7217 7185
7218 7186
7219 intptr_t Field::guarded_list_length() const { 7187 intptr_t Field::guarded_list_length() const {
7220 return Smi::Value(raw_ptr()->guarded_list_length_); 7188 return Smi::Value(raw_ptr()->guarded_list_length_);
7221 } 7189 }
7222 7190
7223 7191
7224 void Field::set_guarded_list_length(intptr_t list_length) const { 7192 void Field::set_guarded_list_length(intptr_t list_length) const {
7225 ASSERT(Thread::Current()->IsMutatorThread()); 7193 ASSERT(Thread::Current()->IsMutatorThread());
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after
8962 return Symbols::FromConcatAll(pieces); 8930 return Symbols::FromConcatAll(pieces);
8963 } 8931 }
8964 8932
8965 8933
8966 static RawString* MakeFunctionMetaName(const Function& func) { 8934 static RawString* MakeFunctionMetaName(const Function& func) {
8967 const String& cname = 8935 const String& cname =
8968 String::Handle(MakeClassMetaName(Class::Handle(func.origin()))); 8936 String::Handle(MakeClassMetaName(Class::Handle(func.origin())));
8969 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 8937 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
8970 pieces.Add(cname); 8938 pieces.Add(cname);
8971 pieces.Add(Symbols::At()); 8939 pieces.Add(Symbols::At());
8972 pieces.Add(String::Handle(func.QualifiedPrettyName())); 8940 pieces.Add(String::Handle(func.QualifiedScrubbedName()));
8973 return Symbols::FromConcatAll(pieces); 8941 return Symbols::FromConcatAll(pieces);
8974 } 8942 }
8975 8943
8976 8944
8977 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) { 8945 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) {
8978 const String& cname = String::Handle( 8946 const String& cname = String::Handle(
8979 MakeClassMetaName(Class::Handle(param.parameterized_class()))); 8947 MakeClassMetaName(Class::Handle(param.parameterized_class())));
8980 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); 8948 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3);
8981 pieces.Add(cname); 8949 pieces.Add(cname);
8982 pieces.Add(Symbols::At()); 8950 pieces.Add(Symbols::At());
(...skipping 4039 matching lines...) Expand 10 before | Expand all | Expand 10 after
13022 Zone* zone = Thread::Current()->zone(); 12990 Zone* zone = Thread::Current()->zone();
13023 if (IsStubCode()) { 12991 if (IsStubCode()) {
13024 const char* name = StubCode::NameOfStub(EntryPoint()); 12992 const char* name = StubCode::NameOfStub(EntryPoint());
13025 return zone->PrintToString("[stub: %s]", name); 12993 return zone->PrintToString("[stub: %s]", name);
13026 } else { 12994 } else {
13027 return zone->PrintToString("Code entry:%" Px, EntryPoint()); 12995 return zone->PrintToString("Code entry:%" Px, EntryPoint());
13028 } 12996 }
13029 } 12997 }
13030 12998
13031 12999
13032 // Called by disassembler.
13033 RawString* Code::Name() const { 13000 RawString* Code::Name() const {
13034 const Object& obj = Object::Handle(owner()); 13001 const Object& obj = Object::Handle(owner());
13035 if (obj.IsNull()) { 13002 if (obj.IsNull()) {
13036 // Regular stub. 13003 // Regular stub.
13037 const char* name = StubCode::NameOfStub(EntryPoint()); 13004 const char* name = StubCode::NameOfStub(EntryPoint());
13038 ASSERT(name != NULL); 13005 ASSERT(name != NULL);
13039 const String& stub_name = String::Handle(Symbols::New(name)); 13006 const String& stub_name = String::Handle(Symbols::New(name));
13040 return Symbols::FromConcat(Symbols::StubPrefix(), stub_name); 13007 return Symbols::FromConcat(Symbols::StubPrefix(), stub_name);
13041 } else if (obj.IsClass()) { 13008 } else if (obj.IsClass()) {
13042 // Allocation stub. 13009 // Allocation stub.
13043 const Class& cls = Class::Cast(obj); 13010 const Class& cls = Class::Cast(obj);
13044 String& cls_name = String::Handle(cls.Name()); 13011 String& cls_name = String::Handle(cls.ScrubbedName());
13045 ASSERT(!cls_name.IsNull()); 13012 ASSERT(!cls_name.IsNull());
13046 return Symbols::FromConcat(Symbols::AllocationStubFor(), cls_name); 13013 return Symbols::FromConcat(Symbols::AllocationStubFor(), cls_name);
13047 } else { 13014 } else {
13048 ASSERT(obj.IsFunction()); 13015 ASSERT(obj.IsFunction());
13049 // Dart function. 13016 // Dart function.
13050 return Function::Cast(obj).name(); 13017 return Function::Cast(obj).UserVisibleName(); // Same as scrubbed name.
13051 } 13018 }
13052 } 13019 }
13053 13020
13054 13021
13055 RawString* Code::PrettyName() const { 13022 RawString* Code::QualifiedName() const {
13056 const Object& obj = Object::Handle(owner()); 13023 const Object& obj = Object::Handle(owner());
13057 if (obj.IsNull()) { 13024 if (obj.IsFunction()) {
13058 // Regular stub. 13025 return Function::Cast(obj).QualifiedScrubbedName();
13059 const char* name = StubCode::NameOfStub(EntryPoint());
13060 ASSERT(name != NULL);
13061 const String& stub_name = String::Handle(String::New(name));
13062 return String::Concat(Symbols::StubPrefix(), stub_name);
13063 } else if (obj.IsClass()) {
13064 // Allocation stub.
13065 const Class& cls = Class::Cast(obj);
13066 String& cls_name = String::Handle(cls.Name());
13067 ASSERT(!cls_name.IsNull());
13068 return String::Concat(Symbols::AllocationStubFor(), cls_name);
13069 } else {
13070 ASSERT(obj.IsFunction());
13071 // Dart function.
13072 return Function::Cast(obj).QualifiedPrettyName();
13073 } 13026 }
13027 return Name();
13074 } 13028 }
13075 13029
13076 13030
13077 bool Code::IsAllocationStubCode() const { 13031 bool Code::IsAllocationStubCode() const {
13078 const Object& obj = Object::Handle(owner()); 13032 const Object& obj = Object::Handle(owner());
13079 return obj.IsClass(); 13033 return obj.IsClass();
13080 } 13034 }
13081 13035
13082 13036
13083 bool Code::IsStubCode() const { 13037 bool Code::IsStubCode() const {
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
14775 } 14729 }
14776 } 14730 }
14777 } 14731 }
14778 (*trail)->Add(*this); 14732 (*trail)->Add(*this);
14779 (*trail)->Add(buddy); 14733 (*trail)->Add(buddy);
14780 return false; 14734 return false;
14781 } 14735 }
14782 14736
14783 14737
14784 RawString* AbstractType::BuildName(NameVisibility name_visibility) const { 14738 RawString* AbstractType::BuildName(NameVisibility name_visibility) const {
14739 ASSERT(name_visibility != kScrubbedName);
14785 Zone* zone = Thread::Current()->zone(); 14740 Zone* zone = Thread::Current()->zone();
14786 if (IsBoundedType()) { 14741 if (IsBoundedType()) {
14787 const AbstractType& type = AbstractType::Handle( 14742 const AbstractType& type = AbstractType::Handle(
14788 BoundedType::Cast(*this).type()); 14743 BoundedType::Cast(*this).type());
14789 if (name_visibility == kPrettyName) { 14744 if (name_visibility == kUserVisibleName) {
14790 return type.BuildName(kPrettyName);
14791 } else if (name_visibility == kUserVisibleName) {
14792 return type.BuildName(kUserVisibleName); 14745 return type.BuildName(kUserVisibleName);
14793 } 14746 }
14794 GrowableHandlePtrArray<const String> pieces(zone, 5); 14747 GrowableHandlePtrArray<const String> pieces(zone, 5);
14795 String& type_name = String::Handle(zone, type.BuildName(kInternalName)); 14748 String& type_name = String::Handle(zone, type.BuildName(kInternalName));
14796 pieces.Add(type_name); 14749 pieces.Add(type_name);
14797 pieces.Add(Symbols::SpaceExtendsSpace()); 14750 pieces.Add(Symbols::SpaceExtendsSpace());
14798 // Build the bound name without causing divergence. 14751 // Build the bound name without causing divergence.
14799 const AbstractType& bound = AbstractType::Handle( 14752 const AbstractType& bound = AbstractType::Handle(
14800 zone, BoundedType::Cast(*this).bound()); 14753 zone, BoundedType::Cast(*this).bound());
14801 String& bound_name = String::Handle(zone); 14754 String& bound_name = String::Handle(zone);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
14851 if (IsResolved() || !cls.IsMixinApplication()) { 14804 if (IsResolved() || !cls.IsMixinApplication()) {
14852 // Do not print the full vector, but only the declared type parameters. 14805 // Do not print the full vector, but only the declared type parameters.
14853 num_type_params = cls.NumTypeParameters(); 14806 num_type_params = cls.NumTypeParameters();
14854 } else { 14807 } else {
14855 // Do not print the type parameters of an unresolved mixin application, 14808 // Do not print the type parameters of an unresolved mixin application,
14856 // since it would prematurely trigger the application of the mixin type. 14809 // since it would prematurely trigger the application of the mixin type.
14857 num_type_params = 0; 14810 num_type_params = 0;
14858 } 14811 }
14859 if (name_visibility == kInternalName) { 14812 if (name_visibility == kInternalName) {
14860 class_name = cls.Name(); 14813 class_name = cls.Name();
14861 } else if (name_visibility == kPrettyName) {
14862 class_name = cls.PrettyName();
14863 } else { 14814 } else {
14864 ASSERT(name_visibility == kUserVisibleName); 14815 ASSERT(name_visibility == kUserVisibleName);
14865 // Map internal types to their corresponding public interfaces. 14816 // Map internal types to their corresponding public interfaces.
14866 class_name = cls.UserVisibleName(); 14817 class_name = cls.UserVisibleName();
14867 } 14818 }
14868 if (num_type_params > num_args) { 14819 if (num_type_params > num_args) {
14869 first_type_param_index = 0; 14820 first_type_param_index = 0;
14870 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) { 14821 if (!IsFinalized() || IsBeingFinalized() || IsMalformed()) {
14871 // Most probably a malformed type. Do not fill up with "dynamic", 14822 // Most probably a malformed type. Do not fill up with "dynamic",
14872 // but use actual vector. 14823 // but use actual vector.
(...skipping 6598 matching lines...) Expand 10 before | Expand all | Expand 10 after
21471 return UserTag::null(); 21422 return UserTag::null();
21472 } 21423 }
21473 21424
21474 21425
21475 const char* UserTag::ToCString() const { 21426 const char* UserTag::ToCString() const {
21476 const String& tag_label = String::Handle(label()); 21427 const String& tag_label = String::Handle(label());
21477 return tag_label.ToCString(); 21428 return tag_label.ToCString();
21478 } 21429 }
21479 21430
21480 } // namespace dart 21431 } // namespace dart
OLDNEW
« no previous file with comments | « 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