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

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

Issue 1723733002: Simplify various name flavors in VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 // The names of core implementation classes (like _OneByteString) 584 // The names of core implementation classes (like _OneByteString)
585 // are preserved as well. 585 // are preserved as well.
586 // 586 //
587 // e.g. 587 // e.g.
588 // private getter - get:foo@6be832b 588 // private getter - get:foo@6be832b
589 // private constructor - _MyClass@6b3832b. 589 // private constructor - _MyClass@6b3832b.
590 // private named constructor - _MyClass@6b3832b.named 590 // private named constructor - _MyClass@6b3832b.named
591 // core impl class name shown - _OneByteString 591 // core impl class name shown - _OneByteString
592 kInternalName = 0, 592 kInternalName = 0,
593 593
594 // Pretty names drop privacy suffixes, getter prefixes, and 594 // User visible names drop privacy suffixes, getter prefixes, and
595 // trailing dots on unnamed constructors. These names are used in 595 // trailing dots on unnamed constructors. The names of core
596 // the vm service. 596 // implementation classes are remapped to their public interface names.
597 // These names are used in the vm service and are appropriate for
598 // reporting type errors directly to programmers.
597 // 599 //
598 // e.g. 600 // e.g.
599 // get:foo@6be832b -> foo 601 // get:foo@6be832b -> foo
600 // _MyClass@6b3832b. -> _MyClass
601 // _MyClass@6b3832b.named -> _MyClass.named
602 // _OneByteString -> _OneByteString (not remapped)
603 kPrettyName,
604
605 // User visible names are appropriate for reporting type errors
606 // directly to programmers. The names have been "prettied" and
607 // the names of core implementation classes are remapped to their
608 // public interface names.
609 //
610 // e.g.
611 // get:foo@6be832b -> foo
612 // _MyClass@6b3832b. -> _MyClass 602 // _MyClass@6b3832b. -> _MyClass
613 // _MyClass@6b3832b.named -> _MyClass.named 603 // _MyClass@6b3832b.named -> _MyClass.named
614 // _OneByteString -> String (remapped) 604 // _OneByteString -> String (remapped)
615 kUserVisibleName 605 kUserVisibleName
616 }; 606 };
617 607
618 protected: 608 protected:
619 // Used for extracting the C++ vtable during bringup. 609 // Used for extracting the C++ vtable during bringup.
620 Object() : raw_(null_) {} 610 Object() : raw_(null_) {}
621 611
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 static bool is_valid_id(intptr_t value) { 936 static bool is_valid_id(intptr_t value) {
947 return RawObject::ClassIdTag::is_valid(value); 937 return RawObject::ClassIdTag::is_valid(value);
948 } 938 }
949 intptr_t id() const { return raw_ptr()->id_; } 939 intptr_t id() const { return raw_ptr()->id_; }
950 void set_id(intptr_t value) const { 940 void set_id(intptr_t value) const {
951 ASSERT(is_valid_id(value)); 941 ASSERT(is_valid_id(value));
952 StoreNonPointer(&raw_ptr()->id_, value); 942 StoreNonPointer(&raw_ptr()->id_, value);
953 } 943 }
954 944
955 RawString* Name() const; 945 RawString* Name() const;
956 RawString* PrettyName() const;
957 RawString* UserVisibleName() const; 946 RawString* UserVisibleName() const;
947
948 // The scrubbed name is identical to the UserVisibleName, but without the
949 // remapping to the public interface name. It is only used for VM debugging.
950 RawString* ScrubbedName() const;
951
958 bool IsInFullSnapshot() const; 952 bool IsInFullSnapshot() const;
959 953
960 virtual RawString* DictionaryName() const { return Name(); } 954 virtual RawString* DictionaryName() const { return Name(); }
961 955
962 RawScript* script() const { return raw_ptr()->script_; } 956 RawScript* script() const { return raw_ptr()->script_; }
963 void set_script(const Script& value) const; 957 void set_script(const Script& value) const;
964 958
965 TokenPosition token_pos() const { return raw_ptr()->token_pos_; } 959 TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
966 void set_token_pos(TokenPosition value) const; 960 void set_token_pos(TokenPosition value) const;
967 961
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 public BitField<uint16_t, bool, kMixinAppAliasBit, 1> {}; 1404 public BitField<uint16_t, bool, kMixinAppAliasBit, 1> {};
1411 class MixinTypeAppliedBit : 1405 class MixinTypeAppliedBit :
1412 public BitField<uint16_t, bool, kMixinTypeAppliedBit, 1> {}; 1406 public BitField<uint16_t, bool, kMixinTypeAppliedBit, 1> {};
1413 class FieldsMarkedNullableBit : 1407 class FieldsMarkedNullableBit :
1414 public BitField<uint16_t, bool, kFieldsMarkedNullableBit, 1> {}; 1408 public BitField<uint16_t, bool, kFieldsMarkedNullableBit, 1> {};
1415 class CycleFreeBit : public BitField<uint16_t, bool, kCycleFreeBit, 1> {}; 1409 class CycleFreeBit : public BitField<uint16_t, bool, kCycleFreeBit, 1> {};
1416 class EnumBit : public BitField<uint16_t, bool, kEnumBit, 1> {}; 1410 class EnumBit : public BitField<uint16_t, bool, kEnumBit, 1> {};
1417 class IsAllocatedBit : public BitField<uint16_t, bool, kIsAllocatedBit, 1> {}; 1411 class IsAllocatedBit : public BitField<uint16_t, bool, kIsAllocatedBit, 1> {};
1418 1412
1419 void set_name(const String& value) const; 1413 void set_name(const String& value) const;
1420 void set_pretty_name(const String& value) const;
1421 void set_user_name(const String& value) const; 1414 void set_user_name(const String& value) const;
1422 RawString* GeneratePrettyName() const;
1423 RawString* GenerateUserVisibleName() const; 1415 RawString* GenerateUserVisibleName() const;
1424 void set_state_bits(intptr_t bits) const; 1416 void set_state_bits(intptr_t bits) const;
1425 1417
1426 void set_constants(const Array& value) const; 1418 void set_constants(const Array& value) const;
1427 1419
1428 void set_canonical_types(const Object& value) const; 1420 void set_canonical_types(const Object& value) const;
1429 RawObject* canonical_types() const; 1421 RawObject* canonical_types() const;
1430 1422
1431 RawArray* invocation_dispatcher_cache() const; 1423 RawArray* invocation_dispatcher_cache() const;
1432 void set_invocation_dispatcher_cache(const Array& cache) const; 1424 void set_invocation_dispatcher_cache(const Array& cache) const;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 return OFFSET_OF_RETURNED_VALUE( 1534 return OFFSET_OF_RETURNED_VALUE(
1543 RawTypeArguments, types) + index * kWordSize; 1535 RawTypeArguments, types) + index * kWordSize;
1544 } 1536 }
1545 void SetTypeAt(intptr_t index, const AbstractType& value) const; 1537 void SetTypeAt(intptr_t index, const AbstractType& value) const;
1546 1538
1547 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". 1539 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>".
1548 RawString* Name() const { 1540 RawString* Name() const {
1549 return SubvectorName(0, Length(), kInternalName); 1541 return SubvectorName(0, Length(), kInternalName);
1550 } 1542 }
1551 1543
1552 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>".
1553 // Names of internal classes are not mapped to their public interfaces.
1554 RawString* PrettyName() const {
1555 return SubvectorName(0, Length(), kPrettyName);
1556 }
1557
1558 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". 1544 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>".
1559 // Names of internal classes are mapped to their public interfaces. 1545 // Names of internal classes are mapped to their public interfaces.
1560 RawString* UserVisibleName() const { 1546 RawString* UserVisibleName() const {
1561 return SubvectorName(0, Length(), kUserVisibleName); 1547 return SubvectorName(0, Length(), kUserVisibleName);
1562 } 1548 }
1563 1549
1564 // Check if the subvector of length 'len' starting at 'from_index' of this 1550 // Check if the subvector of length 'len' starting at 'from_index' of this
1565 // type argument vector consists solely of DynamicType. 1551 // type argument vector consists solely of DynamicType.
1566 bool IsRaw(intptr_t from_index, intptr_t len) const { 1552 bool IsRaw(intptr_t from_index, intptr_t len) const {
1567 return IsDynamicTypes(false, from_index, len); 1553 return IsDynamicTypes(false, from_index, len);
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 2087
2102 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object); 2088 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object);
2103 friend class Class; 2089 friend class Class;
2104 friend class SnapshotWriter; 2090 friend class SnapshotWriter;
2105 }; 2091 };
2106 2092
2107 2093
2108 class Function : public Object { 2094 class Function : public Object {
2109 public: 2095 public:
2110 RawString* name() const { return raw_ptr()->name_; } 2096 RawString* name() const { return raw_ptr()->name_; }
2111 RawString* PrettyName() const;
2112 RawString* UserVisibleName() const; 2097 RawString* UserVisibleName() const;
2113 RawString* QualifiedPrettyName() const;
2114 RawString* QualifiedUserVisibleName() const; 2098 RawString* QualifiedUserVisibleName() const;
2115 const char* QualifiedUserVisibleNameCString() const;
2116 virtual RawString* DictionaryName() const { return name(); } 2099 virtual RawString* DictionaryName() const { return name(); }
2117 2100
2118 RawString* GetSource() const; 2101 RawString* GetSource() const;
2119 2102
2120 // Return the type of this function's signature. It may not be canonical yet. 2103 // Return the type of this function's signature. It may not be canonical yet.
2121 // For example, if this function has a signature of the form 2104 // For example, if this function has a signature of the form
2122 // '(T, [b: B, c: C]) => R', where 'T' and 'R' are type parameters of the 2105 // '(T, [b: B, c: C]) => R', where 'T' and 'R' are type parameters of the
2123 // owner class of this function, then its signature type is a parameterized 2106 // owner class of this function, then its signature type is a parameterized
2124 // FunctionType with uninstantiated type arguments 'T' and 'R' as elements of 2107 // FunctionType with uninstantiated type arguments 'T' and 'R' as elements of
2125 // its type argument vector. 2108 // its type argument vector.
2126 RawFunctionType* SignatureType() const; 2109 RawFunctionType* SignatureType() const;
2127 2110
2128 // Update the signature type (with a canonical version). 2111 // Update the signature type (with a canonical version).
2129 void SetSignatureType(const FunctionType& value) const; 2112 void SetSignatureType(const FunctionType& value) const;
2130 2113
2131 // Build a string of the form 'C<T, R>(T, {b: B, c: C}) => R' representing the 2114 // Build a string of the form 'C<T, R>(T, {b: B, c: C}) => R' representing the
2132 // internal signature of the given function. In this example, T and R are 2115 // internal signature of the given function. In this example, T and R are
2133 // type parameters of class C, the owner of the function. 2116 // type parameters of class C, the owner of the function.
2134 RawString* Signature() const { 2117 RawString* Signature() const {
2135 const bool instantiate = false; 2118 const bool instantiate = false;
2136 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle()); 2119 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle());
2137 } 2120 }
2138 2121
2139 RawString* PrettySignature() const {
2140 const bool instantiate = false;
2141 return BuildSignature(
2142 instantiate, kPrettyName, TypeArguments::Handle());
2143 }
2144
2145 // Build a string of the form '(T, {b: B, c: C}) => R' representing the 2122 // Build a string of the form '(T, {b: B, c: C}) => R' representing the
2146 // user visible signature of the given function. In this example, T and R are 2123 // user visible signature of the given function. In this example, T and R are
2147 // type parameters of class C, the owner of the function, also called the 2124 // type parameters of class C, the owner of the function, also called the
2148 // scope class of the function type. 2125 // scope class of the function type.
2149 // Implicit parameters are hidden, as well as the prefix denoting the 2126 // Implicit parameters are hidden, as well as the prefix denoting the
2150 // scope class and its type parameters. 2127 // scope class and its type parameters.
2151 RawString* UserVisibleSignature() const { 2128 RawString* UserVisibleSignature() const {
2152 const bool instantiate = false; 2129 const bool instantiate = false;
2153 return BuildSignature( 2130 return BuildSignature(
2154 instantiate, kUserVisibleName, TypeArguments::Handle()); 2131 instantiate, kUserVisibleName, TypeArguments::Handle());
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 FINAL_HEAP_OBJECT_IMPLEMENTATION(RedirectionData, Object); 2862 FINAL_HEAP_OBJECT_IMPLEMENTATION(RedirectionData, Object);
2886 friend class Class; 2863 friend class Class;
2887 friend class Function; 2864 friend class Function;
2888 friend class HeapProfiler; 2865 friend class HeapProfiler;
2889 }; 2866 };
2890 2867
2891 2868
2892 class Field : public Object { 2869 class Field : public Object {
2893 public: 2870 public:
2894 RawString* name() const { return raw_ptr()->name_; } 2871 RawString* name() const { return raw_ptr()->name_; }
2895 RawString* PrettyName() const;
2896 RawString* UserVisibleName() const; 2872 RawString* UserVisibleName() const;
2897 virtual RawString* DictionaryName() const { return name(); } 2873 virtual RawString* DictionaryName() const { return name(); }
2898 2874
2899 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_bits_); } 2875 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_bits_); }
2900 bool is_final() const { return FinalBit::decode(raw_ptr()->kind_bits_); } 2876 bool is_final() const { return FinalBit::decode(raw_ptr()->kind_bits_); }
2901 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_bits_); } 2877 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_bits_); }
2902 bool is_reflectable() const { 2878 bool is_reflectable() const {
2903 return ReflectableBit::decode(raw_ptr()->kind_bits_); 2879 return ReflectableBit::decode(raw_ptr()->kind_bits_);
2904 } 2880 }
2905 void set_is_reflectable(bool value) const { 2881 void set_is_reflectable(bool value) const {
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
4512 kInvalidPc = -1 4488 kInvalidPc = -1
4513 }; 4489 };
4514 4490
4515 uword GetLazyDeoptPc() const; 4491 uword GetLazyDeoptPc() const;
4516 4492
4517 // Find pc, return 0 if not found. 4493 // Find pc, return 0 if not found.
4518 uword GetPcForDeoptId(intptr_t deopt_id, RawPcDescriptors::Kind kind) const; 4494 uword GetPcForDeoptId(intptr_t deopt_id, RawPcDescriptors::Kind kind) const;
4519 intptr_t GetDeoptIdForOsr(uword pc) const; 4495 intptr_t GetDeoptIdForOsr(uword pc) const;
4520 4496
4521 RawString* Name() const; 4497 RawString* Name() const;
4522 RawString* PrettyName() const; 4498 RawString* UserVisibleName() const;
4523 4499
4524 int64_t compile_timestamp() const { 4500 int64_t compile_timestamp() const {
4525 return raw_ptr()->compile_timestamp_; 4501 return raw_ptr()->compile_timestamp_;
4526 } 4502 }
4527 4503
4528 intptr_t lazy_deopt_pc_offset() const { 4504 intptr_t lazy_deopt_pc_offset() const {
4529 return raw_ptr()->lazy_deopt_pc_offset_; 4505 return raw_ptr()->lazy_deopt_pc_offset_;
4530 } 4506 }
4531 void set_lazy_deopt_pc_offset(intptr_t pc) const { 4507 void set_lazy_deopt_pc_offset(intptr_t pc) const {
4532 StoreNonPointer(&raw_ptr()->lazy_deopt_pc_offset_, pc); 4508 StoreNonPointer(&raw_ptr()->lazy_deopt_pc_offset_, pc);
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
5312 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver, 5288 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver,
5313 // buddy> to the trail and return false. 5289 // buddy> to the trail and return false.
5314 // The receiver may be added several times, each time with a different buddy. 5290 // The receiver may be added several times, each time with a different buddy.
5315 bool TestAndAddBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const; 5291 bool TestAndAddBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const;
5316 5292
5317 // The name of this type, including the names of its type arguments, if any. 5293 // The name of this type, including the names of its type arguments, if any.
5318 virtual RawString* Name() const { 5294 virtual RawString* Name() const {
5319 return BuildName(kInternalName); 5295 return BuildName(kInternalName);
5320 } 5296 }
5321 5297
5322 virtual RawString* PrettyName() const {
5323 return BuildName(kPrettyName);
5324 }
5325
5326 // The name of this type, including the names of its type arguments, if any. 5298 // The name of this type, including the names of its type arguments, if any.
5327 // Names of internal classes are mapped to their public interfaces. 5299 // Names of internal classes are mapped to their public interfaces.
5328 virtual RawString* UserVisibleName() const { 5300 virtual RawString* UserVisibleName() const {
5329 return BuildName(kUserVisibleName); 5301 return BuildName(kUserVisibleName);
5330 } 5302 }
5331 5303
5332 virtual intptr_t Hash() const; 5304 virtual intptr_t Hash() const;
5333 5305
5334 // The name of this type's class, i.e. without the type argument names of this 5306 // The name of this type's class, i.e. without the type argument names of this
5335 // type. 5307 // type.
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
6513 6485
6514 static RawString* Transform(int32_t (*mapping)(int32_t ch), 6486 static RawString* Transform(int32_t (*mapping)(int32_t ch),
6515 const String& str, 6487 const String& str,
6516 Heap::Space space = Heap::kNew); 6488 Heap::Space space = Heap::kNew);
6517 6489
6518 static RawString* ToUpperCase(const String& str, 6490 static RawString* ToUpperCase(const String& str,
6519 Heap::Space space = Heap::kNew); 6491 Heap::Space space = Heap::kNew);
6520 static RawString* ToLowerCase(const String& str, 6492 static RawString* ToLowerCase(const String& str,
6521 Heap::Space space = Heap::kNew); 6493 Heap::Space space = Heap::kNew);
6522 6494
6523 static RawString* IdentifierPrettyName(const String& name); 6495 static RawString* ScrubName(const String& name);
6524 static RawString* IdentifierPrettyNameRetainPrivate(const String& name); 6496 static RawString* ScrubNameRetainPrivate(const String& name);
6525 6497
6526 static bool EqualsIgnoringPrivateKey(const String& str1, 6498 static bool EqualsIgnoringPrivateKey(const String& str1,
6527 const String& str2); 6499 const String& str2);
6528 6500
6529 static RawString* NewFormatted(const char* format, ...) 6501 static RawString* NewFormatted(const char* format, ...)
6530 PRINTF_ATTRIBUTE(1, 2); 6502 PRINTF_ATTRIBUTE(1, 2);
6531 static RawString* NewFormatted(Heap::Space space, const char* format, ...) 6503 static RawString* NewFormatted(Heap::Space space, const char* format, ...)
6532 PRINTF_ATTRIBUTE(2, 3); 6504 PRINTF_ATTRIBUTE(2, 3);
6533 static RawString* NewFormattedV(const char* format, va_list args, 6505 static RawString* NewFormattedV(const char* format, va_list args,
6534 Heap::Space space = Heap::kNew); 6506 Heap::Space space = Heap::kNew);
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
8427 8399
8428 8400
8429 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 8401 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
8430 intptr_t index) { 8402 intptr_t index) {
8431 return array.At((index * kEntryLength) + kTargetFunctionIndex); 8403 return array.At((index * kEntryLength) + kTargetFunctionIndex);
8432 } 8404 }
8433 8405
8434 } // namespace dart 8406 } // namespace dart
8435 8407
8436 #endif // VM_OBJECT_H_ 8408 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698