Get rid of code duplication by computing int Lub using range Lub.
R=rossberg@chromium.org BUG= Review URL: https://codereview.chromium.org/616563002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24320 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
3eebdc3264
commit
7045592947
32
src/types.cc
32
src/types.cc
@ -274,37 +274,11 @@ TypeImpl<Config>::BitsetType::Lub(double value) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
if (i::IsMinusZero(value)) return kMinusZero;
|
||||
if (std::isnan(value)) return kNaN;
|
||||
if (IsUint32Double(value)) return Lub(FastD2UI(value));
|
||||
if (IsInt32Double(value)) return Lub(FastD2I(value));
|
||||
if (IsUint32Double(value) || IsInt32Double(value)) return Lub(value, value);
|
||||
return kOtherNumber;
|
||||
}
|
||||
|
||||
|
||||
template<class Config>
|
||||
typename TypeImpl<Config>::bitset
|
||||
TypeImpl<Config>::BitsetType::Lub(int32_t value) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
if (value >= 0x40000000) {
|
||||
return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall;
|
||||
}
|
||||
if (value >= 0) return kUnsignedSmall;
|
||||
if (value >= -0x40000000) return kOtherSignedSmall;
|
||||
return i::SmiValuesAre31Bits() ? kOtherSigned32 : kOtherSignedSmall;
|
||||
}
|
||||
|
||||
|
||||
template<class Config>
|
||||
typename TypeImpl<Config>::bitset
|
||||
TypeImpl<Config>::BitsetType::Lub(uint32_t value) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
if (value >= 0x80000000u) return kOtherUnsigned32;
|
||||
if (value >= 0x40000000u) {
|
||||
return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall;
|
||||
}
|
||||
return kUnsignedSmall;
|
||||
}
|
||||
|
||||
|
||||
// Minimum values of regular numeric bitsets when SmiValuesAre31Bits.
|
||||
template<class Config>
|
||||
const typename TypeImpl<Config>::BitsetType::BitsetMin
|
||||
@ -334,10 +308,8 @@ TypeImpl<Config>::BitsetType::BitsetMins32[] = {
|
||||
|
||||
template<class Config>
|
||||
typename TypeImpl<Config>::bitset
|
||||
TypeImpl<Config>::BitsetType::Lub(Limits lim) {
|
||||
TypeImpl<Config>::BitsetType::Lub(double min, double max) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
double min = lim.min->Number();
|
||||
double max = lim.max->Number();
|
||||
int lub = kNone;
|
||||
const BitsetMin* mins = BitsetMins();
|
||||
|
||||
|
@ -598,12 +598,10 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
|
||||
|
||||
static bitset Glb(TypeImpl* type); // greatest lower bound that's a bitset
|
||||
static bitset Lub(TypeImpl* type); // least upper bound that's a bitset
|
||||
static bitset Lub(i::Map* map);
|
||||
static bitset Lub(i::Object* value);
|
||||
static bitset Lub(double value);
|
||||
static bitset Lub(int32_t value);
|
||||
static bitset Lub(uint32_t value);
|
||||
static bitset Lub(i::Map* map);
|
||||
static bitset Lub(Limits lim);
|
||||
static bitset Lub(double min, double max);
|
||||
|
||||
static const char* Name(bitset);
|
||||
static void Print(std::ostream& os, bitset); // NOLINT
|
||||
@ -781,7 +779,8 @@ class TypeImpl<Config>::RangeType : public StructuralType {
|
||||
DCHECK(min->Number() <= max->Number());
|
||||
RangeHandle type = Config::template cast<RangeType>(
|
||||
StructuralType::New(StructuralType::kRangeTag, 3, region));
|
||||
type->Set(0, BitsetType::New(BitsetType::Lub(Limits(min, max)), region));
|
||||
type->Set(0, BitsetType::New(
|
||||
BitsetType::Lub(min->Number(), max->Number()), region));
|
||||
type->SetValue(1, min);
|
||||
type->SetValue(2, max);
|
||||
return type;
|
||||
|
Loading…
Reference in New Issue
Block a user