Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Unified Diff: runtime/vm/object.h

Issue 22851003: Initial support for length guards on final fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 73afd054c7fa37a863986fbb9305d8fbce35183f..027fa176ee2715021c8f3d6066a149e8bbb341e7 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1982,11 +1982,28 @@ class Field : public Object {
static intptr_t guarded_cid_offset() {
return OFFSET_OF(RawField, guarded_cid_);
}
+ // Return the list length that any list stored in this field is guaranteed
+ // to have. If length is kUnknownLength the length has not been determined.
+ // If length is kVariableLength this field has multiple list lengths
+ // associated with it and cannot be predicted.
+ intptr_t guarded_list_length() const {
+ return raw_ptr()->guarded_list_length_;
+ }
+ void set_guarded_list_length(intptr_t list_length) const {
+ raw_ptr()->guarded_list_length_ = list_length;
+ }
+ static intptr_t guarded_list_length_offset() {
+ return OFFSET_OF(RawField, guarded_list_length_);
+ }
static bool IsExternalizableCid(intptr_t cid) {
return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid);
}
+ enum {
+ kUnknownLength = -1,
+ kNoLength = -2,
+ };
// Returns false if any value read from this field is guaranteed to be
// not null.
// Internally we is_nullable_ field contains either kNullCid (nullable) or
@@ -2002,9 +2019,10 @@ class Field : public Object {
return OFFSET_OF(RawField, is_nullable_);
}
- // Update guarded class id and nullability of the field to reflect assignment
- // of the value with the given class id to this field.
+ // Update guarded class id, nullability, to reflect assignment of the
+ // value with the given class id to this field.
void UpdateCid(intptr_t cid) const;
+ void UpdateLength(intptr_t length) const;
// Return the list of optimized code objects that were optimized under
// assumptions about guarded class id and nullability of this field.

Powered by Google App Engine
This is Rietveld 408576698