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

Unified Diff: src/types.h

Issue 1343933002: Fix type Intersection and Maybe (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months 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 f4cc1f992bd5da4d0eeef0a963cf36ebba8d2b86..3acd5cc842db8e5d451756a5d28c4e7304db6b12 100644
--- a/src/types.h
+++ b/src/types.h
@@ -257,6 +257,11 @@ namespace internal {
* -2^31 -2^30 0 2^30 2^31 2^32
*
* E.g., OtherUnsigned32 (OU32) covers all integers from 2^31 to 2^32-1.
+ *
+ * Some of the atomic numerical bitsets are internal only (see
+ * INTERNAL_BITSET_TYPE_LIST). To a types user, they should only occur in
+ * union with certain other bitsets. For instance, OtherNumber should only
+ * occur as part of PlainNumber.
*/
#define PROPER_BITSET_TYPE_LIST(V) \
@@ -436,10 +441,12 @@ class TypeImpl : public Config::Base {
static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg);
static TypeHandle Of(double value, Region* region) {
- return Config::from_bitset(BitsetType::Lub(value), region);
+ return Config::from_bitset(BitsetType::ExpandInternals(
+ BitsetType::Lub(value)), region);
}
static TypeHandle Of(i::Object* value, Region* region) {
- return Config::from_bitset(BitsetType::Lub(value), region);
+ return Config::from_bitset(BitsetType::ExpandInternals(
+ BitsetType::Lub(value)), region);
}
static TypeHandle Of(i::Handle<i::Object> value, Region* region) {
return Of(*value, region);
@@ -657,11 +664,9 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
bitset Bitset() { return Config::as_bitset(this); }
static TypeImpl* New(bitset bits) {
- if (FLAG_enable_slow_asserts) CheckNumberBits(bits);
return Config::from_bitset(bits);
}
static TypeHandle New(bitset bits, Region* region) {
- if (FLAG_enable_slow_asserts) CheckNumberBits(bits);
return Config::from_bitset(bits, region);
}
@@ -687,6 +692,7 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
static bitset Lub(i::Object* value);
static bitset Lub(double value);
static bitset Lub(double min, double max);
+ static bitset ExpandInternals(bitset bits);
static const char* Name(bitset);
static void Print(std::ostream& os, bitset); // NOLINT
@@ -698,14 +704,13 @@ class TypeImpl<Config>::BitsetType : public TypeImpl<Config> {
private:
struct Boundary {
- bitset bits;
+ bitset internal;
+ bitset external;
double min;
};
static const Boundary BoundariesArray[];
static inline const Boundary* Boundaries();
static inline size_t BoundariesSize();
-
- static void CheckNumberBits(bitset bits);
};
@@ -790,11 +795,6 @@ class TypeImpl<Config>::UnionType : public StructuralType {
template<class Config>
class TypeImpl<Config>::ClassType : public StructuralType {
public:
- TypeHandle Bound(Region* region) {
- return Config::is_class(this) ?
- BitsetType::New(BitsetType::Lub(*Config::as_class(this)), region) :
- this->Get(0);
- }
i::Handle<i::Map> Map() {
return Config::is_class(this) ? Config::as_class(this) :
this->template GetValue<i::Map>(1);
@@ -816,6 +816,14 @@ class TypeImpl<Config>::ClassType : public StructuralType {
DCHECK(type->IsClass());
return static_cast<ClassType*>(type);
}
+
+ private:
+ template<class> friend class TypeImpl;
+ bitset Lub() {
+ return Config::is_class(this) ?
+ BitsetType::Lub(*Config::as_class(this)) :
+ this->Get(0)->AsBitset();
+ }
};
@@ -825,7 +833,6 @@ class TypeImpl<Config>::ClassType : public StructuralType {
template<class Config>
class TypeImpl<Config>::ConstantType : public StructuralType {
public:
- TypeHandle Bound() { return this->Get(0); }
i::Handle<i::Object> Value() { return this->template GetValue<i::Object>(1); }
static ConstantHandle New(i::Handle<i::Object> value, Region* region) {
@@ -840,6 +847,10 @@ class TypeImpl<Config>::ConstantType : public StructuralType {
DCHECK(type->IsConstant());
return static_cast<ConstantType*>(type);
}
+
+ private:
+ template<class> friend class TypeImpl;
+ bitset Lub() { return this->Get(0)->AsBitset(); }
};
// TODO(neis): Also cache value if numerical.
// TODO(neis): Allow restricting the representation.
@@ -851,7 +862,6 @@ class TypeImpl<Config>::ConstantType : public StructuralType {
template <class Config>
class TypeImpl<Config>::RangeType : public TypeImpl<Config> {
public:
- bitset Bound() { return Config::range_get_bitset(Config::as_range(this)); }
double Min() { return Config::range_get_double(Config::as_range(this), 0); }
double Max() { return Config::range_get_double(Config::as_range(this), 1); }
@@ -881,8 +891,13 @@ class TypeImpl<Config>::RangeType : public TypeImpl<Config> {
DCHECK(type->IsRange());
return static_cast<RangeType*>(type);
}
+
+ private:
+ template<class> friend class TypeImpl;
+ bitset Lub() {
+ return Config::range_get_bitset(Config::as_range(this));
+ }
};
-// TODO(neis): Also cache min and max values.
// -----------------------------------------------------------------------------
« 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