| 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 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1768 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 1768 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 1769 | 1769 |
| 1770 bool has_initializer() const { | 1770 bool has_initializer() const { |
| 1771 return HasInitializerBit::decode(raw_ptr()->kind_bits_); | 1771 return HasInitializerBit::decode(raw_ptr()->kind_bits_); |
| 1772 } | 1772 } |
| 1773 void set_has_initializer(bool has_initializer) const { | 1773 void set_has_initializer(bool has_initializer) const { |
| 1774 set_kind_bits(HasInitializerBit::update(has_initializer, | 1774 set_kind_bits(HasInitializerBit::update(has_initializer, |
| 1775 raw_ptr()->kind_bits_)); | 1775 raw_ptr()->kind_bits_)); |
| 1776 } | 1776 } |
| 1777 | 1777 |
| 1778 // Return class id that any non-null value read from this field is guaranteed |
| 1779 // to have or kDynamicCid if such class id is not known. |
| 1780 // Stores to this field must update this information hence the name. |
| 1781 intptr_t guarded_cid() const { return raw_ptr()->guarded_cid_; } |
| 1782 void set_guarded_cid(intptr_t cid) const { |
| 1783 raw_ptr()->guarded_cid_ = cid; |
| 1784 } |
| 1785 static intptr_t guarded_cid_offset() { |
| 1786 return OFFSET_OF(RawField, guarded_cid_); |
| 1787 } |
| 1788 |
| 1789 // Returns false if any value read from this field is guaranteed to be |
| 1790 // not null. |
| 1791 // Internally we is_nullable_ field contains either kNullCid (nullable) or |
| 1792 // kIllegalCid (non-nullable) instead of boolean. This is done to simplify |
| 1793 // guarding sequence in the generated code. |
| 1794 bool is_nullable() const { |
| 1795 return raw_ptr()->is_nullable_ == kNullCid; |
| 1796 } |
| 1797 void set_is_nullable(bool val) const { |
| 1798 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; |
| 1799 } |
| 1800 static intptr_t is_nullable_offset() { |
| 1801 return OFFSET_OF(RawField, is_nullable_); |
| 1802 } |
| 1803 |
| 1804 // Update guarded class id and nullability of the field to reflect assignment |
| 1805 // of the value with the given class id to this field. |
| 1806 void UpdateCid(intptr_t cid) const; |
| 1807 |
| 1808 // Return the list of optimized code objects that were optimized under |
| 1809 // assumptions about guarded class id and nullability of this field. |
| 1810 // These code objects must be deoptimized when field's properties change. |
| 1811 // Code objects are held weakly via an indirection through WeakProperty. |
| 1812 RawArray* dependent_code() const; |
| 1813 void set_dependent_code(const Array& array) const; |
| 1814 |
| 1815 // Add the given code object to the list of dependent ones. |
| 1816 void RegisterDependentCode(const Code& code) const; |
| 1817 |
| 1818 // Deoptimize all dependent code objects. |
| 1819 void DeoptimizeDependentCode() const; |
| 1820 |
| 1778 // Constructs getter and setter names for fields and vice versa. | 1821 // Constructs getter and setter names for fields and vice versa. |
| 1779 static RawString* GetterName(const String& field_name); | 1822 static RawString* GetterName(const String& field_name); |
| 1780 static RawString* GetterSymbol(const String& field_name); | 1823 static RawString* GetterSymbol(const String& field_name); |
| 1781 static RawString* SetterName(const String& field_name); | 1824 static RawString* SetterName(const String& field_name); |
| 1782 static RawString* SetterSymbol(const String& field_name); | 1825 static RawString* SetterSymbol(const String& field_name); |
| 1783 static RawString* NameFromGetter(const String& getter_name); | 1826 static RawString* NameFromGetter(const String& getter_name); |
| 1784 static RawString* NameFromSetter(const String& setter_name); | 1827 static RawString* NameFromSetter(const String& setter_name); |
| 1785 static bool IsGetterName(const String& function_name); | 1828 static bool IsGetterName(const String& function_name); |
| 1786 static bool IsSetterName(const String& function_name); | 1829 static bool IsSetterName(const String& function_name); |
| 1787 | 1830 |
| (...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4643 | 4686 |
| 4644 | 4687 |
| 4645 class Array : public Instance { | 4688 class Array : public Instance { |
| 4646 public: | 4689 public: |
| 4647 intptr_t Length() const { | 4690 intptr_t Length() const { |
| 4648 ASSERT(!IsNull()); | 4691 ASSERT(!IsNull()); |
| 4649 return Smi::Value(raw_ptr()->length_); | 4692 return Smi::Value(raw_ptr()->length_); |
| 4650 } | 4693 } |
| 4651 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } | 4694 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } |
| 4652 static intptr_t data_offset() { return length_offset() + kWordSize; } | 4695 static intptr_t data_offset() { return length_offset() + kWordSize; } |
| 4696 static intptr_t element_offset(intptr_t index) { |
| 4697 return data_offset() + kWordSize * index; |
| 4698 } |
| 4653 | 4699 |
| 4654 RawObject* At(intptr_t index) const { | 4700 RawObject* At(intptr_t index) const { |
| 4655 return *ObjectAddr(index); | 4701 return *ObjectAddr(index); |
| 4656 } | 4702 } |
| 4657 void SetAt(intptr_t index, const Object& value) const { | 4703 void SetAt(intptr_t index, const Object& value) const { |
| 4658 // TODO(iposva): Add storing NoGCScope. | 4704 // TODO(iposva): Add storing NoGCScope. |
| 4659 StorePointer(ObjectAddr(index), value.raw()); | 4705 StorePointer(ObjectAddr(index), value.raw()); |
| 4660 } | 4706 } |
| 4661 | 4707 |
| 4662 virtual RawAbstractTypeArguments* GetTypeArguments() const { | 4708 virtual RawAbstractTypeArguments* GetTypeArguments() const { |
| (...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6824 | 6870 |
| 6825 | 6871 |
| 6826 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6872 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6827 intptr_t index) { | 6873 intptr_t index) { |
| 6828 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6874 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6829 } | 6875 } |
| 6830 | 6876 |
| 6831 } // namespace dart | 6877 } // namespace dart |
| 6832 | 6878 |
| 6833 #endif // VM_OBJECT_H_ | 6879 #endif // VM_OBJECT_H_ |
| OLD | NEW |