| 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 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 // to have or kDynamicCid if such class id is not known. | 1975 // to have or kDynamicCid if such class id is not known. |
| 1976 // Stores to this field must update this information hence the name. | 1976 // Stores to this field must update this information hence the name. |
| 1977 intptr_t guarded_cid() const { return raw_ptr()->guarded_cid_; } | 1977 intptr_t guarded_cid() const { return raw_ptr()->guarded_cid_; } |
| 1978 | 1978 |
| 1979 void set_guarded_cid(intptr_t cid) const { | 1979 void set_guarded_cid(intptr_t cid) const { |
| 1980 raw_ptr()->guarded_cid_ = cid; | 1980 raw_ptr()->guarded_cid_ = cid; |
| 1981 } | 1981 } |
| 1982 static intptr_t guarded_cid_offset() { | 1982 static intptr_t guarded_cid_offset() { |
| 1983 return OFFSET_OF(RawField, guarded_cid_); | 1983 return OFFSET_OF(RawField, guarded_cid_); |
| 1984 } | 1984 } |
| 1985 // Return the list length that any list stored in this field is guaranteed |
| 1986 // to have. If length is kUnknownLength the length has not been determined. |
| 1987 // If length is kVariableLength this field has multiple list lengths |
| 1988 // associated with it and cannot be predicted. |
| 1989 intptr_t guarded_list_length() const { |
| 1990 return raw_ptr()->guarded_list_length_; |
| 1991 } |
| 1992 void set_guarded_list_length(intptr_t list_length) const { |
| 1993 raw_ptr()->guarded_list_length_ = list_length; |
| 1994 } |
| 1995 static intptr_t guarded_list_length_offset() { |
| 1996 return OFFSET_OF(RawField, guarded_list_length_); |
| 1997 } |
| 1985 | 1998 |
| 1986 static bool IsExternalizableCid(intptr_t cid) { | 1999 static bool IsExternalizableCid(intptr_t cid) { |
| 1987 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid); | 2000 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid); |
| 1988 } | 2001 } |
| 1989 | 2002 |
| 2003 enum { |
| 2004 kUnknownLength = -1, |
| 2005 kNoLength = -2, |
| 2006 }; |
| 1990 // Returns false if any value read from this field is guaranteed to be | 2007 // Returns false if any value read from this field is guaranteed to be |
| 1991 // not null. | 2008 // not null. |
| 1992 // Internally we is_nullable_ field contains either kNullCid (nullable) or | 2009 // Internally we is_nullable_ field contains either kNullCid (nullable) or |
| 1993 // any other value (non-nullable) instead of boolean. This is done to simplify | 2010 // any other value (non-nullable) instead of boolean. This is done to simplify |
| 1994 // guarding sequence in the generated code. | 2011 // guarding sequence in the generated code. |
| 1995 bool is_nullable() const { | 2012 bool is_nullable() const { |
| 1996 return raw_ptr()->is_nullable_ == kNullCid; | 2013 return raw_ptr()->is_nullable_ == kNullCid; |
| 1997 } | 2014 } |
| 1998 void set_is_nullable(bool val) const { | 2015 void set_is_nullable(bool val) const { |
| 1999 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; | 2016 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; |
| 2000 } | 2017 } |
| 2001 static intptr_t is_nullable_offset() { | 2018 static intptr_t is_nullable_offset() { |
| 2002 return OFFSET_OF(RawField, is_nullable_); | 2019 return OFFSET_OF(RawField, is_nullable_); |
| 2003 } | 2020 } |
| 2004 | 2021 |
| 2005 // Update guarded class id and nullability of the field to reflect assignment | 2022 // Update guarded class id, nullability, to reflect assignment of the |
| 2006 // of the value with the given class id to this field. | 2023 // value with the given class id to this field. |
| 2007 void UpdateCid(intptr_t cid) const; | 2024 void UpdateCid(intptr_t cid) const; |
| 2025 void UpdateLength(intptr_t length) const; |
| 2008 | 2026 |
| 2009 // Return the list of optimized code objects that were optimized under | 2027 // Return the list of optimized code objects that were optimized under |
| 2010 // assumptions about guarded class id and nullability of this field. | 2028 // assumptions about guarded class id and nullability of this field. |
| 2011 // These code objects must be deoptimized when field's properties change. | 2029 // These code objects must be deoptimized when field's properties change. |
| 2012 // Code objects are held weakly via an indirection through WeakProperty. | 2030 // Code objects are held weakly via an indirection through WeakProperty. |
| 2013 RawArray* dependent_code() const; | 2031 RawArray* dependent_code() const; |
| 2014 void set_dependent_code(const Array& array) const; | 2032 void set_dependent_code(const Array& array) const; |
| 2015 | 2033 |
| 2016 // Add the given code object to the list of dependent ones. | 2034 // Add the given code object to the list of dependent ones. |
| 2017 void RegisterDependentCode(const Code& code) const; | 2035 void RegisterDependentCode(const Code& code) const; |
| (...skipping 4031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6049 | 6067 |
| 6050 | 6068 |
| 6051 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6069 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6052 intptr_t index) { | 6070 intptr_t index) { |
| 6053 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6071 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6054 } | 6072 } |
| 6055 | 6073 |
| 6056 } // namespace dart | 6074 } // namespace dart |
| 6057 | 6075 |
| 6058 #endif // VM_OBJECT_H_ | 6076 #endif // VM_OBJECT_H_ |
| OLD | NEW |