Added static assert to BitField to ensure the contents fit within the field

Fixed ExtraICStateField which used 1 bits more than were available
BUG=

Review-Url: https://codereview.chromium.org/2258473002
Cr-Commit-Position: refs/heads/master@{#38697}
This commit is contained in:
heimbuef 2016-08-18 01:05:36 -07:00 committed by Commit bot
parent f9763eb275
commit 3cbb5e4806
2 changed files with 6 additions and 4 deletions

View File

@ -5475,9 +5475,10 @@ class Code: public HeapObject {
: public BitField<CacheHolderFlag, HasUnwindingInfoField::kNext, 2> {};
class KindField : public BitField<Kind, CacheHolderField::kNext, 5> {};
STATIC_ASSERT(NUMBER_OF_KINDS <= KindField::kMax);
class ExtraICStateField : public BitField<ExtraICState, KindField::kNext,
PlatformSmiTagging::kSmiValueSize -
KindField::kNext + 1> {};
class ExtraICStateField
: public BitField<ExtraICState, KindField::kNext,
PlatformSmiTagging::kSmiValueSize - KindField::kNext> {
};
// KindSpecificFlags1 layout (STUB, BUILTIN and OPTIMIZED_FUNCTION)
static const int kStackSlotsFirstBit = 0;

View File

@ -305,8 +305,9 @@ class BitFieldBase {
static T decode(U value) {
return static_cast<T>((value & kMask) >> shift);
}
};
STATIC_ASSERT((kNext - 1) / 8 < sizeof(U));
};
template <class T, int shift, int size>
class BitField8 : public BitFieldBase<T, shift, size, uint8_t> {};