Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b2a3d1c

Browse files
liamappelbecommit-bot@chromium.org
authored andcommitted
Give Field::is_nullable the same consistency check as guarded_cid
Fixes: dart-lang/sdk#36717 Bug: dart-lang/sdk#36717 Change-Id: Ic58b9a004a0bbab91d330c24212ff2d8634c084f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100273 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
1 parent b4611b9 commit b2a3d1c

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Fragment StreamingFlowGraphBuilder::BuildFieldInitializer(
168168
if (H.thread()->IsMutatorThread()) {
169169
field.RecordStore(Object::null_object());
170170
} else {
171-
ASSERT(field.is_nullable());
171+
ASSERT(field.is_nullable(/* silence_assert = */ true));
172172
}
173173
return Fragment();
174174
}

runtime/vm/object.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3452,7 +3452,18 @@ class Field : public Object {
34523452
// Internally we is_nullable_ field contains either kNullCid (nullable) or
34533453
// kInvalidCid (non-nullable) instead of boolean. This is done to simplify
34543454
// guarding sequence in the generated code.
3455-
bool is_nullable() const { return raw_ptr()->is_nullable_ == kNullCid; }
3455+
bool is_nullable(bool silence_assert = false) const {
3456+
#if defined(DEBUG)
3457+
if (!silence_assert) {
3458+
// Same assert as guarded_cid(), because is_nullable() also needs to be
3459+
// consistent for the background compiler.
3460+
Thread* thread = Thread::Current();
3461+
ASSERT(!IsOriginal() || is_static() || thread->IsMutatorThread() ||
3462+
thread->IsAtSafepoint());
3463+
}
3464+
#endif
3465+
return raw_ptr()->is_nullable_ == kNullCid;
3466+
}
34563467
void set_is_nullable(bool val) const {
34573468
ASSERT(Thread::Current()->IsMutatorThread());
34583469
StoreNonPointer(&raw_ptr()->is_nullable_, val ? kNullCid : kIllegalCid);

0 commit comments

Comments
 (0)