Chromium Code Reviews| 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 | |
|
srdjan
2013/08/16 22:26:01
kVariableLength?
Cutch
2013/08/19 21:52:01
Done.
| |
| 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 } | |
| 1998 bool needs_length_check() const { | |
| 1999 const bool r = guarded_list_length() >= Field::kUnknownLength; | |
| 2000 ASSERT((r && is_final()) || !r); | |
|
srdjan
2013/08/16 22:26:01
This can be simpler: !r || is_final()
Cutch
2013/08/19 21:52:01
Done.
| |
| 2001 return r; | |
| 2002 } | |
| 1985 | 2003 |
| 1986 static bool IsExternalizableCid(intptr_t cid) { | 2004 static bool IsExternalizableCid(intptr_t cid) { |
| 1987 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid); | 2005 return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid); |
| 1988 } | 2006 } |
| 1989 | 2007 |
| 2008 enum { | |
| 2009 kUnknownLength = -1, | |
| 2010 kNoLength = -2, | |
| 2011 }; | |
| 1990 // Returns false if any value read from this field is guaranteed to be | 2012 // Returns false if any value read from this field is guaranteed to be |
| 1991 // not null. | 2013 // not null. |
| 1992 // Internally we is_nullable_ field contains either kNullCid (nullable) or | 2014 // Internally we is_nullable_ field contains either kNullCid (nullable) or |
| 1993 // any other value (non-nullable) instead of boolean. This is done to simplify | 2015 // any other value (non-nullable) instead of boolean. This is done to simplify |
| 1994 // guarding sequence in the generated code. | 2016 // guarding sequence in the generated code. |
| 1995 bool is_nullable() const { | 2017 bool is_nullable() const { |
| 1996 return raw_ptr()->is_nullable_ == kNullCid; | 2018 return raw_ptr()->is_nullable_ == kNullCid; |
| 1997 } | 2019 } |
| 1998 void set_is_nullable(bool val) const { | 2020 void set_is_nullable(bool val) const { |
| 1999 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; | 2021 raw_ptr()->is_nullable_ = val ? kNullCid : kIllegalCid; |
| 2000 } | 2022 } |
| 2001 static intptr_t is_nullable_offset() { | 2023 static intptr_t is_nullable_offset() { |
| 2002 return OFFSET_OF(RawField, is_nullable_); | 2024 return OFFSET_OF(RawField, is_nullable_); |
| 2003 } | 2025 } |
| 2004 | 2026 |
| 2005 // Update guarded class id and nullability of the field to reflect assignment | 2027 // Update guarded class id and nullability of the field to reflect assignment |
| 2006 // of the value with the given class id to this field. | 2028 // of the value with the given class id to this field. May trigger |
| 2029 // deoptimization of dependent code. | |
| 2007 void UpdateCid(intptr_t cid) const; | 2030 void UpdateCid(intptr_t cid) const; |
| 2031 // Update guarded class length of the field to reflect assignment of the | |
| 2032 // value with the given length. May trigger deoptimization of dependent code. | |
| 2033 void UpdateLength(intptr_t length) const; | |
| 2008 | 2034 |
| 2009 // Return the list of optimized code objects that were optimized under | 2035 // Return the list of optimized code objects that were optimized under |
| 2010 // assumptions about guarded class id and nullability of this field. | 2036 // assumptions about guarded class id and nullability of this field. |
| 2011 // These code objects must be deoptimized when field's properties change. | 2037 // These code objects must be deoptimized when field's properties change. |
| 2012 // Code objects are held weakly via an indirection through WeakProperty. | 2038 // Code objects are held weakly via an indirection through WeakProperty. |
| 2013 RawArray* dependent_code() const; | 2039 RawArray* dependent_code() const; |
| 2014 void set_dependent_code(const Array& array) const; | 2040 void set_dependent_code(const Array& array) const; |
| 2015 | 2041 |
| 2016 // Add the given code object to the list of dependent ones. | 2042 // Add the given code object to the list of dependent ones. |
| 2017 void RegisterDependentCode(const Code& code) const; | 2043 void RegisterDependentCode(const Code& code) const; |
| (...skipping 4051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6069 | 6095 |
| 6070 | 6096 |
| 6071 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6097 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6072 intptr_t index) { | 6098 intptr_t index) { |
| 6073 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6099 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6074 } | 6100 } |
| 6075 | 6101 |
| 6076 } // namespace dart | 6102 } // namespace dart |
| 6077 | 6103 |
| 6078 #endif // VM_OBJECT_H_ | 6104 #endif // VM_OBJECT_H_ |
| OLD | NEW |