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