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

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
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 2c543b5041fde5f2a6c86bd2b653f1b80dc0f50b..20c508bee71380a29fc043910f66a69a2612638e 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1987,11 +1987,33 @@ 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 kUnknownFixedLength the length has not
+ // been determined. If length is kNoFixedLength 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_);
+ }
+ bool needs_length_check() const {
+ const bool r = guarded_list_length() >= Field::kUnknownFixedLength;
+ ASSERT(!r || is_final());
+ return r;
+ }
static bool IsExternalizableCid(intptr_t cid) {
return (cid == kOneByteStringCid) || (cid == kTwoByteStringCid);
}
+ enum {
+ kUnknownFixedLength = -1,
+ kNoFixedLength = -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
@@ -2008,8 +2030,12 @@ class Field : public Object {
}
// Update guarded class id and nullability of the field to reflect assignment
- // of the value with the given class id to this field.
+ // of the value with the given class id to this field. May trigger
+ // deoptimization of dependent code.
void UpdateCid(intptr_t cid) const;
+ // Update guarded class length of the field to reflect assignment of the
+ // value with the given length. May trigger deoptimization of dependent code.
+ 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.
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698