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

Unified Diff: src/types.cc

Issue 759013003: Avoid number range holes in bitset types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Another 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/types.h ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.cc
diff --git a/src/types.cc b/src/types.cc
index b423beea0833e4be55865ff0e7d9fa463226afc4..786948d6705a7308c06bc802302fa3484b606655 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -283,30 +283,28 @@ TypeImpl<Config>::BitsetType::Lub(double value) {
// Minimum values of regular numeric bitsets when SmiValuesAre31Bits.
-template<class Config>
+template <class Config>
const typename TypeImpl<Config>::BitsetType::BitsetMin
-TypeImpl<Config>::BitsetType::BitsetMins31[] = {
- {kOtherNumber, -V8_INFINITY},
- {kOtherSigned32, kMinInt},
- {kOtherSignedSmall, -0x40000000},
- {kUnsignedSmall, 0},
- {kOtherUnsigned31, 0x40000000},
- {kOtherUnsigned32, 0x80000000},
- {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}
-};
+ TypeImpl<Config>::BitsetType::BitsetMins31[] = {
+ {kOtherNumber, -V8_INFINITY},
+ {kOtherSigned32, kMinInt},
+ {kNegativeSignedSmall, -0x40000000},
+ {kUnsignedSmall, 0},
+ {kOtherUnsigned31, 0x40000000},
+ {kOtherUnsigned32, 0x80000000},
+ {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}};
// Minimum values of regular numeric bitsets when SmiValuesAre32Bits.
// OtherSigned32 and OtherUnsigned31 are empty (see the diagrams in types.h).
-template<class Config>
+template <class Config>
const typename TypeImpl<Config>::BitsetType::BitsetMin
-TypeImpl<Config>::BitsetType::BitsetMins32[] = {
- {kOtherNumber, -V8_INFINITY},
- {kOtherSignedSmall, kMinInt},
- {kUnsignedSmall, 0},
- {kOtherUnsigned32, 0x80000000},
- {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}
-};
+ TypeImpl<Config>::BitsetType::BitsetMins32[] = {
+ {kOtherNumber, -V8_INFINITY},
+ {kNegativeSignedSmall, kMinInt},
+ {kUnsignedSmall, 0},
+ {kOtherUnsigned32, 0x80000000},
+ {kOtherNumber, static_cast<double>(kMaxUInt32) + 1}};
template<class Config>
@@ -316,6 +314,11 @@ TypeImpl<Config>::BitsetType::Lub(double min, double max) {
int lub = kNone;
const BitsetMin* mins = BitsetMins();
+ // Make sure the min-max range touches 0, so we are guaranteed no holes
+ // in unions of valid bitsets.
+ if (max < -1) max = -1;
+ if (min > 0) min = 0;
+
for (size_t i = 1; i < BitsetMinsSize(); ++i) {
if (min < mins[i].min) {
lub |= mins[i-1].bits;
@@ -986,6 +989,7 @@ void TypeImpl<Config>::BitsetType::Print(std::ostream& os, // NOLINT
#undef BITSET_CONSTANT
#define BITSET_CONSTANT(type, value) SEMANTIC(k##type),
+ INTERNAL_BITSET_TYPE_LIST(BITSET_CONSTANT)
SEMANTIC_BITSET_TYPE_LIST(BITSET_CONSTANT)
#undef BITSET_CONSTANT
};
« no previous file with comments | « src/types.h ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698