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

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

Issue 264743010: Don't remap class/type names in the vm service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include <math.h> 8 #include <math.h>
9 9
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 static const ClassId kClassId = kObjectCid; 490 static const ClassId kClassId = kObjectCid;
491 491
492 // Different kinds of type tests. 492 // Different kinds of type tests.
493 enum TypeTestKind { 493 enum TypeTestKind {
494 kIsSubtypeOf = 0, 494 kIsSubtypeOf = 0,
495 kIsMoreSpecificThan 495 kIsMoreSpecificThan
496 }; 496 };
497 497
498 // Different kinds of name visibility. 498 // Different kinds of name visibility.
499 enum NameVisibility { 499 enum NameVisibility {
500 // Internal names are the true names of classes, fields,
501 // etc. inside the vm. These names include privacy suffixes,
502 // getter prefixes, and trailing dots on unnamed constructors.
503 //
504 // The names of core implementation classes (like _OneByteString)
505 // are preserved as well.
506 //
507 // e.g.
508 // private getter - get:foo@6be832b
509 // private constructor - _MyClass@6b3832b.
510 // private named constructor - _MyClass@6b3832b.named
511 // core impl class name shown - _OneByteString
500 kInternalName = 0, 512 kInternalName = 0,
513
514 // Pretty names drop privacy suffixes, getter prefixes, and
515 // trailing dots on unnamed constructors. These names are used in
516 // the vm service.
517 //
518 // e.g.
519 // get:foo@6be832b -> foo
520 // _MyClass@6b3832b. -> _MyClass
521 // _MyClass@6b3832b.named -> _MyClass.named
522 // _OneByteString -> _OneByteString (not remapped)
523 kPrettyName,
524
525 // User visible names are appropriate for reporting type errors
526 // directly to programmers. The names have been "prettied" and
527 // the names of core implementation classes are remapped to their
528 // public interface names.
529 //
530 // e.g.
531 // get:foo@6be832b -> foo
532 // _MyClass@6b3832b. -> _MyClass
533 // _MyClass@6b3832b.named -> _MyClass.named
534 // _OneByteString -> String (remapped)
501 kUserVisibleName 535 kUserVisibleName
502 }; 536 };
503 537
504 protected: 538 protected:
505 // Used for extracting the C++ vtable during bringup. 539 // Used for extracting the C++ vtable during bringup.
506 Object() : raw_(null_) {} 540 Object() : raw_(null_) {}
507 541
508 uword raw_value() const { 542 uword raw_value() const {
509 return reinterpret_cast<uword>(raw()); 543 return reinterpret_cast<uword>(raw());
510 } 544 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 static bool is_valid_id(intptr_t value) { 734 static bool is_valid_id(intptr_t value) {
701 return RawObject::ClassIdTag::is_valid(value); 735 return RawObject::ClassIdTag::is_valid(value);
702 } 736 }
703 intptr_t id() const { return raw_ptr()->id_; } 737 intptr_t id() const { return raw_ptr()->id_; }
704 void set_id(intptr_t value) const { 738 void set_id(intptr_t value) const {
705 ASSERT(is_valid_id(value)); 739 ASSERT(is_valid_id(value));
706 raw_ptr()->id_ = value; 740 raw_ptr()->id_ = value;
707 } 741 }
708 742
709 RawString* Name() const; 743 RawString* Name() const;
744 RawString* PrettyName() const;
710 RawString* UserVisibleName() const; 745 RawString* UserVisibleName() const;
711 746
712 virtual RawString* DictionaryName() const { return Name(); } 747 virtual RawString* DictionaryName() const { return Name(); }
713 748
714 RawScript* script() const { return raw_ptr()->script_; } 749 RawScript* script() const { return raw_ptr()->script_; }
715 void set_script(const Script& value) const; 750 void set_script(const Script& value) const;
716 751
717 intptr_t token_pos() const { return raw_ptr()->token_pos_; } 752 intptr_t token_pos() const { return raw_ptr()->token_pos_; }
718 void set_token_pos(intptr_t value) const; 753 void set_token_pos(intptr_t value) const;
719 754
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 class PatchBit : public BitField<bool, kPatchBit, 1> {}; 1185 class PatchBit : public BitField<bool, kPatchBit, 1> {};
1151 class SynthesizedClassBit : public BitField<bool, kSynthesizedClassBit, 1> {}; 1186 class SynthesizedClassBit : public BitField<bool, kSynthesizedClassBit, 1> {};
1152 class MarkedForParsingBit : public BitField<bool, kMarkedForParsingBit, 1> {}; 1187 class MarkedForParsingBit : public BitField<bool, kMarkedForParsingBit, 1> {};
1153 class MixinAppAliasBit : public BitField<bool, kMixinAppAliasBit, 1> {}; 1188 class MixinAppAliasBit : public BitField<bool, kMixinAppAliasBit, 1> {};
1154 class MixinTypeAppliedBit : public BitField<bool, kMixinTypeAppliedBit, 1> {}; 1189 class MixinTypeAppliedBit : public BitField<bool, kMixinTypeAppliedBit, 1> {};
1155 class FieldsMarkedNullableBit : public BitField<bool, 1190 class FieldsMarkedNullableBit : public BitField<bool,
1156 kFieldsMarkedNullableBit, 1> {}; // NOLINT 1191 kFieldsMarkedNullableBit, 1> {}; // NOLINT
1157 class CycleFreeBit : public BitField<bool, kCycleFreeBit, 1> {}; 1192 class CycleFreeBit : public BitField<bool, kCycleFreeBit, 1> {};
1158 1193
1159 void set_name(const String& value) const; 1194 void set_name(const String& value) const;
1195 void set_pretty_name(const String& value) const;
1160 void set_user_name(const String& value) const; 1196 void set_user_name(const String& value) const;
1197 RawString* GeneratePrettyName() const;
1161 RawString* GenerateUserVisibleName() const; 1198 RawString* GenerateUserVisibleName() const;
1162 void set_signature_function(const Function& value) const; 1199 void set_signature_function(const Function& value) const;
1163 void set_signature_type(const AbstractType& value) const; 1200 void set_signature_type(const AbstractType& value) const;
1164 void set_state_bits(intptr_t bits) const; 1201 void set_state_bits(intptr_t bits) const;
1165 1202
1166 void set_constants(const Array& value) const; 1203 void set_constants(const Array& value) const;
1167 1204
1168 void set_canonical_types(const Object& value) const; 1205 void set_canonical_types(const Object& value) const;
1169 RawObject* canonical_types() const; 1206 RawObject* canonical_types() const;
1170 1207
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 static intptr_t type_at_offset(intptr_t index) { 1305 static intptr_t type_at_offset(intptr_t index) {
1269 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; 1306 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize;
1270 } 1307 }
1271 void SetTypeAt(intptr_t index, const AbstractType& value) const; 1308 void SetTypeAt(intptr_t index, const AbstractType& value) const;
1272 1309
1273 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". 1310 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>".
1274 RawString* Name() const { 1311 RawString* Name() const {
1275 return SubvectorName(0, Length(), kInternalName); 1312 return SubvectorName(0, Length(), kInternalName);
1276 } 1313 }
1277 1314
1315 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>".
1316 // Names of internal classes are not mapped to their public interfaces.
1317 RawString* PrettyName() const {
1318 return SubvectorName(0, Length(), kPrettyName);
1319 }
1320
1278 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". 1321 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>".
1279 // Names of internal classes are mapped to their public interfaces. 1322 // Names of internal classes are mapped to their public interfaces.
1280 RawString* UserVisibleName() const { 1323 RawString* UserVisibleName() const {
1281 return SubvectorName(0, Length(), kUserVisibleName); 1324 return SubvectorName(0, Length(), kUserVisibleName);
1282 } 1325 }
1283 1326
1284 // Check if the subvector of length 'len' starting at 'from_index' of this 1327 // Check if the subvector of length 'len' starting at 'from_index' of this
1285 // type argument vector consists solely of DynamicType. 1328 // type argument vector consists solely of DynamicType.
1286 bool IsRaw(intptr_t from_index, intptr_t len) const { 1329 bool IsRaw(intptr_t from_index, intptr_t len) const {
1287 return IsDynamicTypes(false, from_index, len); 1330 return IsDynamicTypes(false, from_index, len);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 static RawPatchClass* New(); 1501 static RawPatchClass* New();
1459 1502
1460 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object); 1503 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object);
1461 friend class Class; 1504 friend class Class;
1462 }; 1505 };
1463 1506
1464 1507
1465 class Function : public Object { 1508 class Function : public Object {
1466 public: 1509 public:
1467 RawString* name() const { return raw_ptr()->name_; } 1510 RawString* name() const { return raw_ptr()->name_; }
1511 RawString* PrettyName() const;
1468 RawString* UserVisibleName() const; 1512 RawString* UserVisibleName() const;
1513 RawString* QualifiedPrettyName() const;
1469 RawString* QualifiedUserVisibleName() const; 1514 RawString* QualifiedUserVisibleName() const;
1470 virtual RawString* DictionaryName() const { return name(); } 1515 virtual RawString* DictionaryName() const { return name(); }
1471 1516
1472 RawString* GetSource(); 1517 RawString* GetSource();
1473 1518
1474 // Build a string of the form 'C<T, R>(T, {b: B, c: C}) => R' representing the 1519 // Build a string of the form 'C<T, R>(T, {b: B, c: C}) => R' representing the
1475 // internal signature of the given function. In this example, T and R are 1520 // internal signature of the given function. In this example, T and R are
1476 // type parameters of class C, the owner of the function. 1521 // type parameters of class C, the owner of the function.
1477 RawString* Signature() const { 1522 RawString* Signature() const {
1478 const bool instantiate = false; 1523 const bool instantiate = false;
1479 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle()); 1524 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle());
1480 } 1525 }
1481 1526
1527 RawString* PrettySignature() const {
1528 const bool instantiate = false;
1529 return BuildSignature(
1530 instantiate, kPrettyName, TypeArguments::Handle());
1531 }
1532
1482 // Build a string of the form '(T, {b: B, c: C}) => R' representing the 1533 // Build a string of the form '(T, {b: B, c: C}) => R' representing the
1483 // user visible signature of the given function. In this example, T and R are 1534 // user visible signature of the given function. In this example, T and R are
1484 // type parameters of class C, the owner of the function. 1535 // type parameters of class C, the owner of the function.
1485 // Implicit parameters are hidden, as well as the prefix denoting the 1536 // Implicit parameters are hidden, as well as the prefix denoting the
1486 // signature class and its type parameters. 1537 // signature class and its type parameters.
1487 RawString* UserVisibleSignature() const { 1538 RawString* UserVisibleSignature() const {
1488 const bool instantiate = false; 1539 const bool instantiate = false;
1489 return BuildSignature( 1540 return BuildSignature(
1490 instantiate, kUserVisibleName, TypeArguments::Handle()); 1541 instantiate, kUserVisibleName, TypeArguments::Handle());
1491 } 1542 }
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 FINAL_HEAP_OBJECT_IMPLEMENTATION(RedirectionData, Object); 2141 FINAL_HEAP_OBJECT_IMPLEMENTATION(RedirectionData, Object);
2091 friend class Class; 2142 friend class Class;
2092 friend class Function; 2143 friend class Function;
2093 friend class HeapProfiler; 2144 friend class HeapProfiler;
2094 }; 2145 };
2095 2146
2096 2147
2097 class Field : public Object { 2148 class Field : public Object {
2098 public: 2149 public:
2099 RawString* name() const { return raw_ptr()->name_; } 2150 RawString* name() const { return raw_ptr()->name_; }
2151 RawString* PrettyName() const;
2100 RawString* UserVisibleName() const; 2152 RawString* UserVisibleName() const;
2101 virtual RawString* DictionaryName() const { return name(); } 2153 virtual RawString* DictionaryName() const { return name(); }
2102 2154
2103 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_bits_); } 2155 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_bits_); }
2104 bool is_final() const { return FinalBit::decode(raw_ptr()->kind_bits_); } 2156 bool is_final() const { return FinalBit::decode(raw_ptr()->kind_bits_); }
2105 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_bits_); } 2157 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_bits_); }
2106 2158
2107 inline intptr_t Offset() const; 2159 inline intptr_t Offset() const;
2108 inline void SetOffset(intptr_t value_in_bytes) const; 2160 inline void SetOffset(intptr_t value_in_bytes) const;
2109 2161
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. 3657 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n].
3606 // Returns the maximum id found. 3658 // Returns the maximum id found.
3607 intptr_t ExtractIcDataArraysAtCalls( 3659 intptr_t ExtractIcDataArraysAtCalls(
3608 GrowableArray<intptr_t>* node_ids, 3660 GrowableArray<intptr_t>* node_ids,
3609 const GrowableObjectArray& ic_data_objs) const; 3661 const GrowableObjectArray& ic_data_objs) const;
3610 3662
3611 // Returns an array indexed by deopt id, containing the extracted ICData. 3663 // Returns an array indexed by deopt id, containing the extracted ICData.
3612 RawArray* ExtractTypeFeedbackArray() const; 3664 RawArray* ExtractTypeFeedbackArray() const;
3613 3665
3614 RawString* Name() const; 3666 RawString* Name() const;
3615 RawString* UserName() const; 3667 RawString* PrettyName() const;
3616 3668
3617 int64_t compile_timestamp() const { 3669 int64_t compile_timestamp() const {
3618 return raw_ptr()->compile_timestamp_; 3670 return raw_ptr()->compile_timestamp_;
3619 } 3671 }
3620 3672
3621 private: 3673 private:
3622 void set_state_bits(intptr_t bits) const; 3674 void set_state_bits(intptr_t bits) const;
3623 3675
3624 friend class RawCode; 3676 friend class RawCode;
3625 enum { 3677 enum {
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 // If the trail is null, allocate a trail, add the pair <receiver, buddy> to 4343 // If the trail is null, allocate a trail, add the pair <receiver, buddy> to
4292 // the trail. The receiver may only be added once with its only buddy. 4344 // the trail. The receiver may only be added once with its only buddy.
4293 void AddOnlyBuddyToTrail(GrowableObjectArray** trail, 4345 void AddOnlyBuddyToTrail(GrowableObjectArray** trail,
4294 const Object& buddy) const; 4346 const Object& buddy) const;
4295 4347
4296 // The name of this type, including the names of its type arguments, if any. 4348 // The name of this type, including the names of its type arguments, if any.
4297 virtual RawString* Name() const { 4349 virtual RawString* Name() const {
4298 return BuildName(kInternalName); 4350 return BuildName(kInternalName);
4299 } 4351 }
4300 4352
4353 virtual RawString* PrettyName() const {
4354 return BuildName(kPrettyName);
4355 }
4356
4301 // The name of this type, including the names of its type arguments, if any. 4357 // The name of this type, including the names of its type arguments, if any.
4302 // Names of internal classes are mapped to their public interfaces. 4358 // Names of internal classes are mapped to their public interfaces.
4303 virtual RawString* UserVisibleName() const { 4359 virtual RawString* UserVisibleName() const {
4304 return BuildName(kUserVisibleName); 4360 return BuildName(kUserVisibleName);
4305 } 4361 }
4306 4362
4307 virtual intptr_t Hash() const; 4363 virtual intptr_t Hash() const;
4308 4364
4309 // The name of this type's class, i.e. without the type argument names of this 4365 // The name of this type's class, i.e. without the type argument names of this
4310 // type. 4366 // type.
(...skipping 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after
6984 7040
6985 7041
6986 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7042 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6987 intptr_t index) { 7043 intptr_t index) {
6988 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7044 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6989 } 7045 }
6990 7046
6991 } // namespace dart 7047 } // namespace dart
6992 7048
6993 #endif // VM_OBJECT_H_ 7049 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/disassembler_ia32.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698