Skip to content

Commit 8c5407b

Browse files
alexmarkovCommit Queue
authored and
Commit Queue
committed
[vm/compiler] Fix truncation of class id when it is stored in FieldGuardState
Class id can occupy more than 16 bits, so bit field FieldGuardState::GuardedCidBits is extended. Also added assertion that it has at least target::UntaggedObject::kClassIdTagSize bits. TEST=ci, manually tested repro from b/322790241. Fixes b/322790241 Change-Id: I39d0592a5a1c8e0c83b7af7d30de6f966b358fda Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349082 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 72fdb26 commit 8c5407b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

runtime/vm/compiler/backend/slot.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ const Slot& Slot::GetCanonicalSlot(Thread* thread,
331331

332332
FieldGuardState::FieldGuardState(const Field& field)
333333
: state_(GuardedCidBits::encode(field.guarded_cid()) |
334-
IsNullableBit::encode(field.is_nullable())) {}
334+
IsNullableBit::encode(field.is_nullable())) {
335+
ASSERT(compiler::target::UntaggedObject::kClassIdTagSize <=
336+
GuardedCidBits::bitsize());
337+
}
335338

336339
const Slot& Slot::Get(const Field& field,
337340
const ParsedFunction* parsed_function) {

runtime/vm/compiler/backend/slot.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class FieldGuardState {
241241
bool is_nullable() const { return IsNullableBit::decode(state_); }
242242

243243
private:
244-
using GuardedCidBits = BitField<int32_t, ClassIdTagType, 0, 16>;
244+
using GuardedCidBits = BitField<int32_t, ClassIdTagType, 0, 20>;
245245
using IsNullableBit = BitField<int32_t, bool, GuardedCidBits::kNextBit, 1>;
246246

247247
const int32_t state_;

0 commit comments

Comments
 (0)