Commit a10c69f0 authored by mvstanton's avatar mvstanton Committed by Commit bot

Revert "[turbofan] Cleanup: Type only has a semantic dimension."

Reverted for stability reasons.

BUG=chromium:649967
TBR=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2366313002
Cr-Commit-Position: refs/heads/master@{#39716}
parent 3218ef30
......@@ -196,7 +196,7 @@ Node* RepresentationChanger::GetTaggedSignedRepresentationFor(
}
// Select the correct X -> Tagged operator.
const Operator* op;
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->Constant(0);
......@@ -293,7 +293,7 @@ Node* RepresentationChanger::GetTaggedPointerRepresentationFor(
break;
}
// Select the correct X -> Tagged operator.
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->TheHoleConstant();
......@@ -338,7 +338,7 @@ Node* RepresentationChanger::GetTaggedRepresentationFor(
}
// Select the correct X -> Tagged operator.
const Operator* op;
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->TheHoleConstant();
......@@ -420,7 +420,7 @@ Node* RepresentationChanger::GetFloat32RepresentationFor(
}
// Select the correct X -> Float32 operator.
const Operator* op = nullptr;
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->Float32Constant(0.0f);
......@@ -490,7 +490,7 @@ Node* RepresentationChanger::GetFloat64RepresentationFor(
}
// Select the correct X -> Float64 operator.
const Operator* op = nullptr;
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->Float64Constant(0.0);
......@@ -576,7 +576,7 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
// Select the correct X -> Word32 operator.
const Operator* op = nullptr;
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->Int32Constant(0);
......@@ -698,7 +698,7 @@ Node* RepresentationChanger::GetBitRepresentationFor(
}
// Select the correct X -> Bit operator.
const Operator* op;
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->Int32Constant(0);
......@@ -737,7 +737,7 @@ Node* RepresentationChanger::GetBitRepresentationFor(
Node* RepresentationChanger::GetWord64RepresentationFor(
Node* node, MachineRepresentation output_rep, Type* output_type) {
if (output_type->Is(Type::None())) {
if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
// This is an impossible value; it should not be used at runtime.
// We just provide a dummy value here.
return jsgraph()->Int64Constant(0);
......
This diff is collapsed.
......@@ -22,7 +22,13 @@ namespace compiler {
// can express class types (a.k.a. specific maps) and singleton types (i.e.,
// concrete constants).
//
// The following equations and inequations hold:
// Types consist of two dimensions: semantic (value range) and representation.
// Both are related through subtyping.
//
//
// SEMANTIC DIMENSION
//
// The following equations and inequations hold for the semantic axis:
//
// None <= T
// T <= Any
......@@ -34,6 +40,7 @@ namespace compiler {
// InternalizedString < String
//
// Receiver = Object \/ Proxy
// RegExp < Object
// OtherUndetectable < Object
// DetectableReceiver = Receiver - OtherUndetectable
//
......@@ -96,13 +103,18 @@ namespace compiler {
// clang-format off
#define MASK_BITSET_TYPE_LIST(V) \
V(Semantic, 0xfffffffeu)
#define SEMANTIC(k) ((k) & BitsetType::kSemantic)
#define INTERNAL_BITSET_TYPE_LIST(V) \
V(OtherUnsigned31, 1u << 1) \
V(OtherUnsigned32, 1u << 2) \
V(OtherSigned32, 1u << 3) \
V(OtherNumber, 1u << 4) \
#define PROPER_BITSET_TYPE_LIST(V) \
#define SEMANTIC_BITSET_TYPE_LIST(V) \
V(None, 0u) \
V(Negative31, 1u << 5) \
V(Null, 1u << 6) \
......@@ -181,9 +193,12 @@ namespace compiler {
* occur as part of PlainNumber.
*/
#define PROPER_BITSET_TYPE_LIST(V) SEMANTIC_BITSET_TYPE_LIST(V)
#define BITSET_TYPE_LIST(V) \
MASK_BITSET_TYPE_LIST(V) \
INTERNAL_BITSET_TYPE_LIST(V) \
PROPER_BITSET_TYPE_LIST(V)
SEMANTIC_BITSET_TYPE_LIST(V)
class Type;
......@@ -208,7 +223,11 @@ class BitsetType {
return static_cast<bitset>(reinterpret_cast<uintptr_t>(this) ^ 1u);
}
static bool IsInhabited(bitset bits) { return bits != kNone; }
static bool IsInhabited(bitset bits) { return SemanticIsInhabited(bits); }
static bool SemanticIsInhabited(bitset bits) {
return SEMANTIC(bits) != kNone;
}
static bool Is(bitset bits1, bitset bits2) {
return (bits1 | bits2) == bits2;
......@@ -351,7 +370,7 @@ class RangeType : public TypeBase {
static Type* New(Limits lim, Zone* zone) {
DCHECK(IsInteger(lim.min) && IsInteger(lim.max));
DCHECK(lim.min <= lim.max);
BitsetType::bitset bits = BitsetType::Lub(lim.min, lim.max);
BitsetType::bitset bits = SEMANTIC(BitsetType::Lub(lim.min, lim.max));
return AsType(new (zone->New(sizeof(RangeType))) RangeType(bits, lim));
}
......@@ -506,6 +525,9 @@ class Type {
}
static Type* For(i::Handle<i::Map> map) { return For(*map); }
// Extraction of components.
static Type* Semantic(Type* t, Zone* zone);
// Predicates.
bool IsInhabited() { return BitsetType::IsInhabited(this->BitsetLub()); }
......@@ -604,10 +626,14 @@ class Type {
}
UnionType* AsUnion() { return UnionType::cast(this); }
// Auxiliary functions.
bool SemanticMaybe(Type* that);
bitset BitsetGlb() { return BitsetType::Glb(this); }
bitset BitsetLub() { return BitsetType::Lub(this); }
bool SlowIs(Type* that);
bool SemanticIs(Type* that);
static bool Overlap(RangeType* lhs, RangeType* rhs);
static bool Contains(RangeType* lhs, RangeType* rhs);
......
......@@ -108,6 +108,9 @@ class Types {
PROPER_BITSET_TYPE_LIST(DECLARE_TYPE)
#undef DECLARE_TYPE
#define DECLARE_TYPE(name, value) Type* Mask##name##ForTesting;
MASK_BITSET_TYPE_LIST(DECLARE_TYPE)
#undef DECLARE_TYPE
Type* SignedSmall;
Type* UnsignedSmall;
......@@ -139,6 +142,8 @@ class Types {
Type* Intersect(Type* t1, Type* t2) { return Type::Intersect(t1, t2, zone_); }
Type* Semantic(Type* t) { return Type::Semantic(t, zone_); }
Type* Random() {
return types[rng_->NextInt(static_cast<int>(types.size()))];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment