| 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 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 // to have or kDynamicCid if such class id is not known. | 1980 // to have or kDynamicCid if such class id is not known. |
| 1981 // Stores to this field must update this information hence the name. | 1981 // Stores to this field must update this information hence the name. |
| 1982 intptr_t guarded_cid() const { return raw_ptr()->guarded_cid_; } | 1982 intptr_t guarded_cid() const { return raw_ptr()->guarded_cid_; } |
| 1983 | 1983 |
| 1984 void set_guarded_cid(intptr_t cid) const { | 1984 void set_guarded_cid(intptr_t cid) const { |
| 1985 raw_ptr()->guarded_cid_ = cid; | 1985 raw_ptr()->guarded_cid_ = cid; |
| 1986 } | 1986 } |
| 1987 static intptr_t guarded_cid_offset() { | 1987 static intptr_t guarded_cid_offset() { |
| 1988 return OFFSET_OF(RawField, guarded_cid_); | 1988 return OFFSET_OF(RawField, guarded_cid_); |
| 1989 } | 1989 } |
| 1990 // Return the list length that any list stored in this field is guaranteed |
| 1991 // to have. If length is kUnknownFixedLength the length has not |
| 1992 // been determined. If length is kNoFixedLength this field has multiple |
| 1993 // list lengths associated with it and cannot be predicted. |
| 1994 intptr_t guarded_list_length() const { |
| 1995 return raw_ptr()->guarded_list_length_; |
| 1996 } |
| 1997 void set_guarded_list_length(intptr_t list_length) const { |
| 1998 raw_ptr()->guarded_list_length_ = list_length; |
| 1999 } |
| 2000 static intptr_t guarded_list_length_offset() { |
| 2001 return OFFSET_OF(RawField, guarded_list_length_); |
| 2002 } |
| 2003 bool needs_length_check() const { |
| 2004 const bool r = guarded_list_length() >= Field::kUnknownFixedLength; |
| 2005 ASSERT(!r || is_final()); |
| 2006 return r; |
| 2007 } |
| 1990 | 2008 |
| 1991 static bool IsExternalizableCid(intptr_t cid) { | 2009 static bool IsExternalizableCid(intptr_t cid) { |
| 1992 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid); | 2010 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid); |
| 1993 } | 2011 } |
| 1994 | 2012 |
| 2013 enum { |
| 2014 kUnknownFixedLength = -1, |
| 2015 kNoFixedLength = -2, |
| 2016 }; |
| 1995 // Returns false if any value read from this field is guaranteed to be | 2017 // Returns false if any value read from this field is guaranteed to be |
| 1996 // not null. | 2018 // not null. |
| 1997 // Internally we is_nullable_ field contains either kNullCid (nullable) or | 2019 // Internally we is_nullable_ field contains either kNullCid (nullable) or |
| 1998 // any other value (non-nullable) instead of boolean. This is done to simplify | 2020 // any other value (non-nullable) instead of boolean. This is done to simplify |
| 1999 // guarding sequence in the generated code. | 2021 // guarding sequence in the generated code. |
| 2000 bool is_nullable() const { | 2022 bool is_nullable() const { |
| 2001 return raw_ptr()->is_nullable_ == kNullCid; | 2023 return raw_ptr()->is_nullable_ == kNullCid; |
| 2002 } | 2024 } |
| 2003 void set_is_nullable(bool val) const { | 2025 void set_is_nullable(bool val) const { |
| 2004 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; | 2026 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; |
| 2005 } | 2027 } |
| 2006 static intptr_t is_nullable_offset() { | 2028 static intptr_t is_nullable_offset() { |
| 2007 return OFFSET_OF(RawField, is_nullable_); | 2029 return OFFSET_OF(RawField, is_nullable_); |
| 2008 } | 2030 } |
| 2009 | 2031 |
| 2010 // Update guarded class id and nullability of the field to reflect assignment | 2032 // Update guarded class id and nullability of the field to reflect assignment |
| 2011 // of the value with the given class id to this field. | 2033 // of the value with the given class id to this field. May trigger |
| 2034 // deoptimization of dependent code. |
| 2012 void UpdateCid(intptr_t cid) const; | 2035 void UpdateCid(intptr_t cid) const; |
| 2036 // Update guarded class length of the field to reflect assignment of the |
| 2037 // value with the given length. May trigger deoptimization of dependent code. |
| 2038 void UpdateLength(intptr_t length) const; |
| 2013 | 2039 |
| 2014 // Return the list of optimized code objects that were optimized under | 2040 // Return the list of optimized code objects that were optimized under |
| 2015 // assumptions about guarded class id and nullability of this field. | 2041 // assumptions about guarded class id and nullability of this field. |
| 2016 // These code objects must be deoptimized when field's properties change. | 2042 // These code objects must be deoptimized when field's properties change. |
| 2017 // Code objects are held weakly via an indirection through WeakProperty. | 2043 // Code objects are held weakly via an indirection through WeakProperty. |
| 2018 RawArray* dependent_code() const; | 2044 RawArray* dependent_code() const; |
| 2019 void set_dependent_code(const Array& array) const; | 2045 void set_dependent_code(const Array& array) const; |
| 2020 | 2046 |
| 2021 // Add the given code object to the list of dependent ones. | 2047 // Add the given code object to the list of dependent ones. |
| 2022 void RegisterDependentCode(const Code& code) const; | 2048 void RegisterDependentCode(const Code& code) const; |
| (...skipping 4056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6079 | 6105 |
| 6080 | 6106 |
| 6081 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6107 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6082 intptr_t index) { | 6108 intptr_t index) { |
| 6083 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6109 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6084 } | 6110 } |
| 6085 | 6111 |
| 6086 } // namespace dart | 6112 } // namespace dart |
| 6087 | 6113 |
| 6088 #endif // VM_OBJECT_H_ | 6114 #endif // VM_OBJECT_H_ |
| OLD | NEW |