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

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 a27fae70fb27b4ba1bc890c65b583ed54abdaab5..0f3fd22bc554ce68b7d8428a134ad6450e776651 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1982,11 +1982,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 kUnknownLength the length has not been determined.
+ // 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.
+ // 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::kUnknownLength;
+ 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.
+ return r;
+ }
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
@@ -2003,8 +2025,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.

Powered by Google App Engine
This is Rietveld 408576698