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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 other_type_arguments, | 856 other_type_arguments, |
857 bound_error); | 857 bound_error); |
858 } | 858 } |
859 | 859 |
860 // Check if this is the top level class. | 860 // Check if this is the top level class. |
861 bool IsTopLevel() const; | 861 bool IsTopLevel() const; |
862 | 862 |
863 RawArray* fields() const { return raw_ptr()->fields_; } | 863 RawArray* fields() const { return raw_ptr()->fields_; } |
864 void SetFields(const Array& value) const; | 864 void SetFields(const Array& value) const; |
865 | 865 |
| 866 // Returns an array of all fields of this class and its superclasses indexed |
| 867 // by offset in words. |
| 868 RawArray* OffsetToFieldMap() const; |
| 869 |
866 // Returns true if non-static fields are defined. | 870 // Returns true if non-static fields are defined. |
867 bool HasInstanceFields() const; | 871 bool HasInstanceFields() const; |
868 | 872 |
869 RawArray* functions() const { return raw_ptr()->functions_; } | 873 RawArray* functions() const { return raw_ptr()->functions_; } |
870 void SetFunctions(const Array& value) const; | 874 void SetFunctions(const Array& value) const; |
871 void AddFunction(const Function& function) const; | 875 void AddFunction(const Function& function) const; |
872 | 876 |
873 RawGrowableObjectArray* closures() const { | 877 RawGrowableObjectArray* closures() const { |
874 return raw_ptr()->closure_functions_; | 878 return raw_ptr()->closure_functions_; |
875 } | 879 } |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 bool is_nullable() const { | 2121 bool is_nullable() const { |
2118 return raw_ptr()->is_nullable_ == kNullCid; | 2122 return raw_ptr()->is_nullable_ == kNullCid; |
2119 } | 2123 } |
2120 void set_is_nullable(bool val) const { | 2124 void set_is_nullable(bool val) const { |
2121 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; | 2125 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; |
2122 } | 2126 } |
2123 static intptr_t is_nullable_offset() { | 2127 static intptr_t is_nullable_offset() { |
2124 return OFFSET_OF(RawField, is_nullable_); | 2128 return OFFSET_OF(RawField, is_nullable_); |
2125 } | 2129 } |
2126 | 2130 |
2127 // Update guarded class id and nullability of the field to reflect assignment | 2131 // Update guarded cid and guarded length for this field. May trigger |
2128 // of the value with the given class id to this field. May trigger | 2132 // deoptimization of dependent optimized code. |
2129 // deoptimization of dependent code. | 2133 bool UpdateGuardedCidAndLength(const Object& value) const; |
2130 void UpdateCid(intptr_t cid) const; | |
2131 // Update guarded class length of the field to reflect assignment of the | |
2132 // value with the given length. May trigger deoptimization of dependent code. | |
2133 void UpdateLength(intptr_t length) const; | |
2134 | 2134 |
2135 // Return the list of optimized code objects that were optimized under | 2135 // Return the list of optimized code objects that were optimized under |
2136 // assumptions about guarded class id and nullability of this field. | 2136 // assumptions about guarded class id and nullability of this field. |
2137 // These code objects must be deoptimized when field's properties change. | 2137 // These code objects must be deoptimized when field's properties change. |
2138 // Code objects are held weakly via an indirection through WeakProperty. | 2138 // Code objects are held weakly via an indirection through WeakProperty. |
2139 RawArray* dependent_code() const; | 2139 RawArray* dependent_code() const; |
2140 void set_dependent_code(const Array& array) const; | 2140 void set_dependent_code(const Array& array) const; |
2141 | 2141 |
2142 // Add the given code object to the list of dependent ones. | 2142 // Add the given code object to the list of dependent ones. |
2143 void RegisterDependentCode(const Code& code) const; | 2143 void RegisterDependentCode(const Code& code) const; |
(...skipping 18 matching lines...) Expand all Loading... |
2162 kConstBit = 1, | 2162 kConstBit = 1, |
2163 kStaticBit, | 2163 kStaticBit, |
2164 kFinalBit, | 2164 kFinalBit, |
2165 kHasInitializerBit, | 2165 kHasInitializerBit, |
2166 }; | 2166 }; |
2167 class ConstBit : public BitField<bool, kConstBit, 1> {}; | 2167 class ConstBit : public BitField<bool, kConstBit, 1> {}; |
2168 class StaticBit : public BitField<bool, kStaticBit, 1> {}; | 2168 class StaticBit : public BitField<bool, kStaticBit, 1> {}; |
2169 class FinalBit : public BitField<bool, kFinalBit, 1> {}; | 2169 class FinalBit : public BitField<bool, kFinalBit, 1> {}; |
2170 class HasInitializerBit : public BitField<bool, kHasInitializerBit, 1> {}; | 2170 class HasInitializerBit : public BitField<bool, kHasInitializerBit, 1> {}; |
2171 | 2171 |
| 2172 // Update guarded class id and nullability of the field to reflect assignment |
| 2173 // of the value with the given class id to this field. Returns true, if |
| 2174 // deoptimization of dependent code is required. |
| 2175 bool UpdateCid(intptr_t cid) const; |
| 2176 |
| 2177 // Update guarded class length of the field to reflect assignment of the |
| 2178 // value with the given length. Returns true if deoptimization of dependent |
| 2179 // code is required. |
| 2180 bool UpdateLength(intptr_t length) const; |
| 2181 |
2172 void set_name(const String& value) const; | 2182 void set_name(const String& value) const; |
2173 void set_is_static(bool is_static) const { | 2183 void set_is_static(bool is_static) const { |
2174 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_)); | 2184 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_)); |
2175 } | 2185 } |
2176 void set_is_final(bool is_final) const { | 2186 void set_is_final(bool is_final) const { |
2177 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_)); | 2187 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_)); |
2178 } | 2188 } |
2179 void set_is_const(bool value) const { | 2189 void set_is_const(bool value) const { |
2180 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); | 2190 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); |
2181 } | 2191 } |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3821 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const; | 3831 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const; |
3822 | 3832 |
3823 // Returns true if all fields are OK for canonicalization. | 3833 // Returns true if all fields are OK for canonicalization. |
3824 virtual bool CheckAndCanonicalizeFields(const char** error_str) const; | 3834 virtual bool CheckAndCanonicalizeFields(const char** error_str) const; |
3825 | 3835 |
3826 RawObject* GetField(const Field& field) const { | 3836 RawObject* GetField(const Field& field) const { |
3827 return *FieldAddr(field); | 3837 return *FieldAddr(field); |
3828 } | 3838 } |
3829 | 3839 |
3830 void SetField(const Field& field, const Object& value) const { | 3840 void SetField(const Field& field, const Object& value) const { |
| 3841 field.UpdateGuardedCidAndLength(value); |
3831 StorePointer(FieldAddr(field), value.raw()); | 3842 StorePointer(FieldAddr(field), value.raw()); |
3832 } | 3843 } |
3833 | 3844 |
3834 RawType* GetType() const; | 3845 RawType* GetType() const; |
3835 | 3846 |
3836 virtual RawAbstractTypeArguments* GetTypeArguments() const; | 3847 virtual RawAbstractTypeArguments* GetTypeArguments() const; |
3837 virtual void SetTypeArguments(const AbstractTypeArguments& value) const; | 3848 virtual void SetTypeArguments(const AbstractTypeArguments& value) const; |
3838 | 3849 |
3839 // Check if the type of this instance is a subtype of the given type. | 3850 // Check if the type of this instance is a subtype of the given type. |
3840 bool IsInstanceOf(const AbstractType& type, | 3851 bool IsInstanceOf(const AbstractType& type, |
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6294 | 6305 |
6295 | 6306 |
6296 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6307 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6297 intptr_t index) { | 6308 intptr_t index) { |
6298 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6309 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6299 } | 6310 } |
6300 | 6311 |
6301 } // namespace dart | 6312 } // namespace dart |
6302 | 6313 |
6303 #endif // VM_OBJECT_H_ | 6314 #endif // VM_OBJECT_H_ |
OLD | NEW |