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

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

Issue 12210127: First stab at mixins in VM compiler (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | 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 "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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 // The super type of this class, Object type if not explicitly specified. 654 // The super type of this class, Object type if not explicitly specified.
655 RawType* super_type() const { return raw_ptr()->super_type_; } 655 RawType* super_type() const { return raw_ptr()->super_type_; }
656 void set_super_type(const Type& value) const; 656 void set_super_type(const Type& value) const;
657 static intptr_t super_type_offset() { 657 static intptr_t super_type_offset() {
658 return OFFSET_OF(RawClass, super_type_); 658 return OFFSET_OF(RawClass, super_type_);
659 } 659 }
660 660
661 // Asserts that the class of the super type has been resolved. 661 // Asserts that the class of the super type has been resolved.
662 RawClass* SuperClass() const; 662 RawClass* SuperClass() const;
663 663
664 RawType* mixin() const { return raw_ptr()->mixin_; }
665 void set_mixin(const Type& value) const;
666
664 // Interfaces is an array of Types. 667 // Interfaces is an array of Types.
665 RawArray* interfaces() const { return raw_ptr()->interfaces_; } 668 RawArray* interfaces() const { return raw_ptr()->interfaces_; }
666 void set_interfaces(const Array& value) const; 669 void set_interfaces(const Array& value) const;
667 static intptr_t interfaces_offset() { 670 static intptr_t interfaces_offset() {
668 return OFFSET_OF(RawClass, interfaces_); 671 return OFFSET_OF(RawClass, interfaces_);
669 } 672 }
670 673
671 // Returns the list of classes having this class as direct superclass. 674 // Returns the list of classes having this class as direct superclass.
672 RawGrowableObjectArray* direct_subclasses() const { 675 RawGrowableObjectArray* direct_subclasses() const {
673 return raw_ptr()->direct_subclasses_; 676 return raw_ptr()->direct_subclasses_;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 NameVisibility name_visibility) const { 1193 NameVisibility name_visibility) const {
1191 const bool instantiate = true; 1194 const bool instantiate = true;
1192 return BuildSignature(instantiate, name_visibility, instantiator); 1195 return BuildSignature(instantiate, name_visibility, instantiator);
1193 } 1196 }
1194 1197
1195 // Returns true if the signature of this function is instantiated, i.e. if it 1198 // Returns true if the signature of this function is instantiated, i.e. if it
1196 // does not involve generic parameter types or generic result type. 1199 // does not involve generic parameter types or generic result type.
1197 bool HasInstantiatedSignature() const; 1200 bool HasInstantiatedSignature() const;
1198 1201
1199 RawClass* Owner() const; 1202 RawClass* Owner() const;
1200 1203 RawClass* origin() const;
siva 2013/02/13 01:34:37 Our function naming style seems in consistent. I a
hausner 2013/02/13 19:58:14 I noticed that too. Technically, according to our
1201 RawScript* script() const; 1204 RawScript* script() const;
1202 1205
1203 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } 1206 RawAbstractType* result_type() const { return raw_ptr()->result_type_; }
1204 void set_result_type(const AbstractType& value) const; 1207 void set_result_type(const AbstractType& value) const;
1205 1208
1206 RawAbstractType* ParameterTypeAt(intptr_t index) const; 1209 RawAbstractType* ParameterTypeAt(intptr_t index) const;
1207 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; 1210 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const;
1211 RawArray* parameter_types() const { return raw_ptr()->parameter_types_; }
1208 void set_parameter_types(const Array& value) const; 1212 void set_parameter_types(const Array& value) const;
1209 1213
1210 // Parameter names are valid for all valid parameter indices, and are not 1214 // Parameter names are valid for all valid parameter indices, and are not
1211 // limited to named optional parameters. 1215 // limited to named optional parameters.
1212 RawString* ParameterNameAt(intptr_t index) const; 1216 RawString* ParameterNameAt(intptr_t index) const;
1213 void SetParameterNameAt(intptr_t index, const String& value) const; 1217 void SetParameterNameAt(intptr_t index, const String& value) const;
1218 RawArray* parameter_names() const { return raw_ptr()->parameter_names_; }
1214 void set_parameter_names(const Array& value) const; 1219 void set_parameter_names(const Array& value) const;
1215 1220
1216 // Sets function's code and code's function. 1221 // Sets function's code and code's function.
1217 void SetCode(const Code& value) const; 1222 void SetCode(const Code& value) const;
1218 1223
1219 // Disables optimized code and switches to unoptimized code. 1224 // Disables optimized code and switches to unoptimized code.
1220 void SwitchToUnoptimizedCode() const; 1225 void SwitchToUnoptimizedCode() const;
1221 1226
1222 // Return the most recently compiled and installed code for this function. 1227 // Return the most recently compiled and installed code for this function.
1223 // It is not the only Code object that points to this function. 1228 // It is not the only Code object that points to this function.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 RawFunction::Kind kind() const { 1282 RawFunction::Kind kind() const {
1278 return KindBits::decode(raw_ptr()->kind_tag_); 1283 return KindBits::decode(raw_ptr()->kind_tag_);
1279 } 1284 }
1280 1285
1281 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_tag_); } 1286 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_tag_); }
1282 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_tag_); } 1287 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_tag_); }
1283 bool is_external() const { return ExternalBit::decode(raw_ptr()->kind_tag_); } 1288 bool is_external() const { return ExternalBit::decode(raw_ptr()->kind_tag_); }
1284 bool IsConstructor() const { 1289 bool IsConstructor() const {
1285 return (kind() == RawFunction::kConstructor) && !is_static(); 1290 return (kind() == RawFunction::kConstructor) && !is_static();
1286 } 1291 }
1292 bool IsImplicitConstructor() const;
1287 bool IsFactory() const { 1293 bool IsFactory() const {
1288 return (kind() == RawFunction::kConstructor) && is_static(); 1294 return (kind() == RawFunction::kConstructor) && is_static();
1289 } 1295 }
1290 bool IsDynamicFunction() const { 1296 bool IsDynamicFunction() const {
1291 if (is_static() || is_abstract()) { 1297 if (is_static() || is_abstract()) {
1292 return false; 1298 return false;
1293 } 1299 }
1294 switch (kind()) { 1300 switch (kind()) {
1295 case RawFunction::kRegularFunction: 1301 case RawFunction::kRegularFunction:
1296 case RawFunction::kGetterFunction: 1302 case RawFunction::kGetterFunction:
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 intptr_t token_pos); 1560 intptr_t token_pos);
1555 1561
1556 // Allocates a new Function object representing a closure function, as well as 1562 // Allocates a new Function object representing a closure function, as well as
1557 // a new associated Class object representing the signature class of the 1563 // a new associated Class object representing the signature class of the
1558 // function. 1564 // function.
1559 // The function and the class share the same given name. 1565 // The function and the class share the same given name.
1560 static RawFunction* NewClosureFunction(const String& name, 1566 static RawFunction* NewClosureFunction(const String& name,
1561 const Function& parent, 1567 const Function& parent,
1562 intptr_t token_pos); 1568 intptr_t token_pos);
1563 1569
1570 // Allocate new function object, clone values from this function. The
1571 // owner of the clone is new_owner.
1572 RawFunction* Clone(const Class& new_owner) const;
1573
1564 // Slow function, use in asserts to track changes in important library 1574 // Slow function, use in asserts to track changes in important library
1565 // functions. 1575 // functions.
1566 int32_t SourceFingerprint() const; 1576 int32_t SourceFingerprint() const;
1567 1577
1568 // Return false and report an error if the fingerprint does not match. 1578 // Return false and report an error if the fingerprint does not match.
1569 bool CheckSourceFingerprint(intptr_t fp) const; 1579 bool CheckSourceFingerprint(intptr_t fp) const;
1570 1580
1571 static const int kCtorPhaseInit = 1 << 0; 1581 static const int kCtorPhaseInit = 1 << 0;
1572 static const int kCtorPhaseBody = 1 << 1; 1582 static const int kCtorPhaseBody = 1 << 1;
1573 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody); 1583 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_bits_); } 1726 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_bits_); }
1717 bool is_final() const { return FinalBit::decode(raw_ptr()->kind_bits_); } 1727 bool is_final() const { return FinalBit::decode(raw_ptr()->kind_bits_); }
1718 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_bits_); } 1728 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_bits_); }
1719 1729
1720 inline intptr_t Offset() const; 1730 inline intptr_t Offset() const;
1721 inline void SetOffset(intptr_t value_in_bytes) const; 1731 inline void SetOffset(intptr_t value_in_bytes) const;
1722 1732
1723 RawInstance* value() const; 1733 RawInstance* value() const;
1724 void set_value(const Instance& value) const; 1734 void set_value(const Instance& value) const;
1725 1735
1726 RawClass* owner() const { return raw_ptr()->owner_; } 1736 RawClass* owner() const;
1737 RawClass* origin() const; // Either mixin class, or same as owner().
1727 1738
1728 RawAbstractType* type() const { return raw_ptr()->type_; } 1739 RawAbstractType* type() const { return raw_ptr()->type_; }
1729 void set_type(const AbstractType& value) const; 1740 void set_type(const AbstractType& value) const;
1730 1741
1731 static intptr_t InstanceSize() { 1742 static intptr_t InstanceSize() {
1732 return RoundedAllocationSize(sizeof(RawField)); 1743 return RoundedAllocationSize(sizeof(RawField));
1733 } 1744 }
1734 1745
1735 static RawField* New(const String& name, 1746 static RawField* New(const String& name,
1736 bool is_static, 1747 bool is_static,
1737 bool is_final, 1748 bool is_final,
1738 bool is_const, 1749 bool is_const,
1739 const Class& owner, 1750 const Class& owner,
1740 intptr_t token_pos); 1751 intptr_t token_pos);
1741 1752
1753 // Allocate new field object, clone values from this field. The
1754 // owner of the clone is new_owner.
1755 RawField* Clone(const Class& new_owner) const;
1756
1742 static intptr_t value_offset() { return OFFSET_OF(RawField, value_); } 1757 static intptr_t value_offset() { return OFFSET_OF(RawField, value_); }
1743 1758
1744 intptr_t token_pos() const { return raw_ptr()->token_pos_; } 1759 intptr_t token_pos() const { return raw_ptr()->token_pos_; }
1745 1760
1746 bool has_initializer() const { 1761 bool has_initializer() const {
1747 return HasInitializerBit::decode(raw_ptr()->kind_bits_); 1762 return HasInitializerBit::decode(raw_ptr()->kind_bits_);
1748 } 1763 }
1749 void set_has_initializer(bool has_initializer) const { 1764 void set_has_initializer(bool has_initializer) const {
1750 set_kind_bits(HasInitializerBit::update(has_initializer, 1765 set_kind_bits(HasInitializerBit::update(has_initializer,
1751 raw_ptr()->kind_bits_)); 1766 raw_ptr()->kind_bits_));
(...skipping 24 matching lines...) Expand all
1776 void set_name(const String& value) const; 1791 void set_name(const String& value) const;
1777 void set_is_static(bool is_static) const { 1792 void set_is_static(bool is_static) const {
1778 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_)); 1793 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_));
1779 } 1794 }
1780 void set_is_final(bool is_final) const { 1795 void set_is_final(bool is_final) const {
1781 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_)); 1796 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_));
1782 } 1797 }
1783 void set_is_const(bool value) const { 1798 void set_is_const(bool value) const {
1784 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); 1799 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_));
1785 } 1800 }
1786 void set_owner(const Class& value) const { 1801 void set_owner(const Object& value) const {
1787 StorePointer(&raw_ptr()->owner_, value.raw()); 1802 StorePointer(&raw_ptr()->owner_, value.raw());
1788 } 1803 }
1789 void set_token_pos(intptr_t token_pos) const { 1804 void set_token_pos(intptr_t token_pos) const {
1790 raw_ptr()->token_pos_ = token_pos; 1805 raw_ptr()->token_pos_ = token_pos;
1791 } 1806 }
1792 void set_kind_bits(intptr_t value) const { 1807 void set_kind_bits(intptr_t value) const {
1793 raw_ptr()->kind_bits_ = static_cast<uint8_t>(value); 1808 raw_ptr()->kind_bits_ = static_cast<uint8_t>(value);
1794 } 1809 }
1795 static RawField* New(); 1810 static RawField* New();
1796 1811
(...skipping 4538 matching lines...) Expand 10 before | Expand all | Expand 10 after
6335 6350
6336 6351
6337 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6352 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6338 intptr_t index) { 6353 intptr_t index) {
6339 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6354 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6340 } 6355 }
6341 6356
6342 } // namespace dart 6357 } // namespace dart
6343 6358
6344 #endif // VM_OBJECT_H_ 6359 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698