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

Unified Diff: src/types.h

Issue 788313002: Reland of "Avoid number range holes in bitset types." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 6 years 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 | « src/compiler/typer.cc ('k') | src/types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index 969a81de1b80677e45097f7da869081f6420540c..e9fc5d6b799b4f088a4cd3d2e249e53b74140f7a 100644
--- a/src/types.h
+++ b/src/types.h
@@ -188,18 +188,20 @@ namespace internal {
V(Untagged, kUntaggedNumber | kUntaggedPointer) \
V(Tagged, kTaggedSigned | kTaggedPointer)
+#define INTERNAL_BITSET_TYPE_LIST(V) \
+ V(OtherUnsigned31, 1u << 1 | REPRESENTATION(kTagged | kUntaggedNumber)) \
+ V(OtherUnsigned32, 1u << 2 | REPRESENTATION(kTagged | kUntaggedNumber)) \
+ V(OtherSigned32, 1u << 3 | REPRESENTATION(kTagged | kUntaggedNumber)) \
+ V(OtherNumber, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber))
+
#define SEMANTIC_BITSET_TYPE_LIST(V) \
- V(Null, 1u << 1 | REPRESENTATION(kTaggedPointer)) \
- V(Undefined, 1u << 2 | REPRESENTATION(kTaggedPointer)) \
- V(Boolean, 1u << 3 | REPRESENTATION(kTaggedPointer)) \
- V(UnsignedSmall, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber)) \
- V(OtherSignedSmall, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
- V(OtherUnsigned31, 1u << 6 | REPRESENTATION(kTagged | kUntaggedNumber)) \
- V(OtherUnsigned32, 1u << 7 | REPRESENTATION(kTagged | kUntaggedNumber)) \
- V(OtherSigned32, 1u << 8 | REPRESENTATION(kTagged | kUntaggedNumber)) \
- V(MinusZero, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \
- V(NaN, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \
- V(OtherNumber, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \
+ V(NegativeSignedSmall, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \
+ V(Null, 1u << 6 | REPRESENTATION(kTaggedPointer)) \
+ V(Undefined, 1u << 7 | REPRESENTATION(kTaggedPointer)) \
+ V(Boolean, 1u << 8 | REPRESENTATION(kTaggedPointer)) \
+ V(UnsignedSmall, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \
+ V(MinusZero, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \
+ V(NaN, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \
V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \
V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPointer)) \
V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPointer)) \
@@ -209,11 +211,14 @@ namespace internal {
V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \
V(Internal, 1u << 19 | REPRESENTATION(kTagged | kUntagged)) \
\
- V(SignedSmall, kUnsignedSmall | kOtherSignedSmall) \
+ V(SignedSmall, kUnsignedSmall | kNegativeSignedSmall) \
V(Signed32, kSignedSmall | kOtherUnsigned31 | kOtherSigned32) \
+ V(NegativeSigned32, kNegativeSignedSmall | kOtherSigned32) \
+ V(NonNegativeSigned32, kUnsignedSmall | kOtherUnsigned31) \
V(Unsigned32, kUnsignedSmall | kOtherUnsigned31 | kOtherUnsigned32) \
V(Integral32, kSigned32 | kUnsigned32) \
- V(OrderedNumber, kIntegral32 | kMinusZero | kOtherNumber) \
+ V(PlainNumber, kIntegral32 | kOtherNumber) \
+ V(OrderedNumber, kPlainNumber | kMinusZero) \
V(Number, kOrderedNumber | kNaN) \
V(String, kInternalizedString | kOtherString) \
V(UniqueName, kSymbol | kInternalizedString) \
@@ -231,6 +236,7 @@ namespace internal {
V(NonNumber, kUnique | kString | kInternal) \
V(Any, 0xfffffffeu)
+
/*
* The following diagrams show how integers (in the mathematical sense) are
* divided among the different atomic numerical types.
@@ -259,9 +265,11 @@ namespace internal {
REPRESENTATION_BITSET_TYPE_LIST(V) \
SEMANTIC_BITSET_TYPE_LIST(V)
-#define BITSET_TYPE_LIST(V) \
- MASK_BITSET_TYPE_LIST(V) \
- PROPER_BITSET_TYPE_LIST(V)
+#define BITSET_TYPE_LIST(V) \
+ MASK_BITSET_TYPE_LIST(V) \
+ REPRESENTATION_BITSET_TYPE_LIST(V) \
+ INTERNAL_BITSET_TYPE_LIST(V) \
+ SEMANTIC_BITSET_TYPE_LIST(V)
// -----------------------------------------------------------------------------
@@ -598,6 +606,20 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
static TypeImpl* New(bitset bits) {
DCHECK(bits == kNone || IsInhabited(bits));
+
+ if (FLAG_enable_slow_asserts) {
+ // Check that the bitset does not contain any holes in number ranges.
+ bitset mask = kSemantic;
+ if (!i::SmiValuesAre31Bits()) {
+ mask &= ~(kOtherUnsigned31 | kOtherSigned32);
+ }
+ bitset number_bits = bits & kPlainNumber & mask;
+ if (number_bits != 0) {
+ bitset lub = Lub(Min(number_bits), Max(number_bits)) & mask;
+ CHECK(lub == number_bits);
+ }
+ }
+
return Config::from_bitset(bits);
}
static TypeHandle New(bitset bits, Region* region) {
« no previous file with comments | « src/compiler/typer.cc ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698