Commit b5f60820 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Nuke the context types.

Those have been effectively unused for quite a while now, and we
don't see any use in having them around. Actually it'd be way more
consistent and simpler to just use OtherInternal as type for contexts
instead.

R=mvstanton@chromium.org
BUG=v8:5267,v8:5270

Review-Url: https://codereview.chromium.org/2305383002
Cr-Commit-Position: refs/heads/master@{#39166}
parent 43a39127
...@@ -227,7 +227,6 @@ class Typer::Visitor : public Reducer { ...@@ -227,7 +227,6 @@ class Typer::Visitor : public Reducer {
return TypeOrNone(operand_node); return TypeOrNone(operand_node);
} }
Type* WrapContextTypeForInput(Node* node);
Type* Weaken(Node* node, Type* current_type, Type* previous_type); Type* Weaken(Node* node, Type* current_type, Type* previous_type);
Zone* zone() { return typer_->zone(); } Zone* zone() { return typer_->zone(); }
...@@ -1227,11 +1226,15 @@ Type* Typer::Visitor::TypeJSInstanceOf(Node* node) { return Type::Boolean(); } ...@@ -1227,11 +1226,15 @@ Type* Typer::Visitor::TypeJSInstanceOf(Node* node) { return Type::Boolean(); }
Type* Typer::Visitor::TypeJSLoadContext(Node* node) { Type* Typer::Visitor::TypeJSLoadContext(Node* node) {
ContextAccess const& access = ContextAccessOf(node->op()); ContextAccess const& access = ContextAccessOf(node->op());
if (access.index() == Context::EXTENSION_INDEX) { switch (access.index()) {
return Type::TaggedPointer(); case Context::PREVIOUS_INDEX:
case Context::NATIVE_CONTEXT_INDEX:
return Type::OtherInternal();
case Context::CLOSURE_INDEX:
return Type::Function();
default:
return Type::Any();
} }
// Since contexts are mutable, we just return the top.
return Type::Any();
} }
...@@ -1241,42 +1244,26 @@ Type* Typer::Visitor::TypeJSStoreContext(Node* node) { ...@@ -1241,42 +1244,26 @@ Type* Typer::Visitor::TypeJSStoreContext(Node* node) {
} }
Type* Typer::Visitor::WrapContextTypeForInput(Node* node) {
Type* outer = TypeOrNone(NodeProperties::GetContextInput(node));
if (outer->Is(Type::None())) {
return Type::None();
} else {
DCHECK(outer->Maybe(Type::OtherInternal()));
return Type::Context(outer, zone());
}
}
Type* Typer::Visitor::TypeJSCreateFunctionContext(Node* node) { Type* Typer::Visitor::TypeJSCreateFunctionContext(Node* node) {
return WrapContextTypeForInput(node); return Type::OtherInternal();
} }
Type* Typer::Visitor::TypeJSCreateCatchContext(Node* node) { Type* Typer::Visitor::TypeJSCreateCatchContext(Node* node) {
return WrapContextTypeForInput(node); return Type::OtherInternal();
} }
Type* Typer::Visitor::TypeJSCreateWithContext(Node* node) { Type* Typer::Visitor::TypeJSCreateWithContext(Node* node) {
return WrapContextTypeForInput(node); return Type::OtherInternal();
} }
Type* Typer::Visitor::TypeJSCreateBlockContext(Node* node) { Type* Typer::Visitor::TypeJSCreateBlockContext(Node* node) {
return WrapContextTypeForInput(node); return Type::OtherInternal();
} }
Type* Typer::Visitor::TypeJSCreateScriptContext(Node* node) { Type* Typer::Visitor::TypeJSCreateScriptContext(Node* node) {
return WrapContextTypeForInput(node); return Type::OtherInternal();
} }
// JS other operators. // JS other operators.
......
...@@ -610,10 +610,10 @@ void Verifier::Visitor::Check(Node* node) { ...@@ -610,10 +610,10 @@ void Verifier::Visitor::Check(Node* node) {
case IrOpcode::kJSCreateScriptContext: { case IrOpcode::kJSCreateScriptContext: {
// Type is Context, and operand is Internal. // Type is Context, and operand is Internal.
Node* context = NodeProperties::GetContextInput(node); Node* context = NodeProperties::GetContextInput(node);
// TODO(rossberg): This should really be Is(Internal), but the typer // TODO(bmeurer): This should say CheckTypeIs, but we don't have type
// currently can't do backwards propagation. // OtherInternal on certain contexts, i.e. those from OsrValue inputs.
CheckTypeMaybe(context, Type::Internal()); CheckTypeMaybe(context, Type::OtherInternal());
if (typing == TYPED) CHECK(NodeProperties::GetType(node)->IsContext()); CheckTypeIs(node, Type::OtherInternal());
break; break;
} }
......
...@@ -146,7 +146,6 @@ Type::bitset BitsetType::Lub(Type* type) { ...@@ -146,7 +146,6 @@ Type::bitset BitsetType::Lub(Type* type) {
} }
if (type->IsConstant()) return type->AsConstant()->Lub(); if (type->IsConstant()) return type->AsConstant()->Lub();
if (type->IsRange()) return type->AsRange()->Lub(); if (type->IsRange()) return type->AsRange()->Lub();
if (type->IsContext()) return kOtherInternal & kTaggedPointer;
if (type->IsArray()) return kOtherObject; if (type->IsArray()) return kOtherObject;
if (type->IsFunction()) return kFunction; if (type->IsFunction()) return kFunction;
if (type->IsTuple()) return kOtherInternal; if (type->IsTuple()) return kOtherInternal;
...@@ -412,10 +411,6 @@ bool Type::SimplyEquals(Type* that) { ...@@ -412,10 +411,6 @@ bool Type::SimplyEquals(Type* that) {
return that->IsConstant() return that->IsConstant()
&& *this->AsConstant()->Value() == *that->AsConstant()->Value(); && *this->AsConstant()->Value() == *that->AsConstant()->Value();
} }
if (this->IsContext()) {
return that->IsContext()
&& this->AsContext()->Outer()->Equals(that->AsContext()->Outer());
}
if (this->IsArray()) { if (this->IsArray()) {
return that->IsArray() return that->IsArray()
&& this->AsArray()->Element()->Equals(that->AsArray()->Element()); && this->AsArray()->Element()->Equals(that->AsArray()->Element());
...@@ -1107,10 +1102,6 @@ void Type::PrintTo(std::ostream& os, PrintDimension dim) { ...@@ -1107,10 +1102,6 @@ void Type::PrintTo(std::ostream& os, PrintDimension dim) {
<< ")"; << ")";
os.flags(saved_flags); os.flags(saved_flags);
os.precision(saved_precision); os.precision(saved_precision);
} else if (this->IsContext()) {
os << "Context(";
this->AsContext()->Outer()->PrintTo(os, dim);
os << ")";
} else if (this->IsUnion()) { } else if (this->IsUnion()) {
os << "("; os << "(";
for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) { for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
......
...@@ -48,12 +48,11 @@ namespace internal { ...@@ -48,12 +48,11 @@ namespace internal {
// Constant(x) < T iff instance_type(map(x)) < T // Constant(x) < T iff instance_type(map(x)) < T
// Array(T) < Array // Array(T) < Array
// Function(R, S, T0, T1, ...) < Function // Function(R, S, T0, T1, ...) < Function
// Context(T) < Internal
// //
// Both structural Array and Function types are invariant in all parameters; // Both structural Array and Function types are invariant in all parameters;
// relaxing this would make Union and Intersect operations more involved. // relaxing this would make Union and Intersect operations more involved.
// There is no subtyping relation between Array, Function, or Context types // There is no subtyping relation between Array or Function types and
// and respective Constant types, since these types cannot be reconstructed // respective Constant types, since these types cannot be reconstructed
// for arbitrary heap values. // for arbitrary heap values.
// //
// //
...@@ -349,7 +348,6 @@ class TypeBase { ...@@ -349,7 +348,6 @@ class TypeBase {
enum Kind { enum Kind {
kConstant, kConstant,
kContext,
kArray, kArray,
kFunction, kFunction,
kTuple, kTuple,
...@@ -466,30 +464,6 @@ class RangeType : public TypeBase { ...@@ -466,30 +464,6 @@ class RangeType : public TypeBase {
Limits limits_; Limits limits_;
}; };
// -----------------------------------------------------------------------------
// Context types.
class ContextType : public TypeBase {
public:
Type* Outer() { return outer_; }
private:
friend class Type;
static Type* New(Type* outer, Zone* zone) {
return AsType(new (zone->New(sizeof(ContextType))) ContextType(outer));
}
static ContextType* cast(Type* type) {
DCHECK(IsKind(type, kContext));
return static_cast<ContextType*>(FromType(type));
}
explicit ContextType(Type* outer) : TypeBase(kContext), outer_(outer) {}
Type* outer_;
};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Array types. // Array types.
...@@ -658,9 +632,6 @@ class Type { ...@@ -658,9 +632,6 @@ class Type {
BitsetType::kUntaggedNumber), BitsetType::kUntaggedNumber),
zone); zone);
} }
static Type* Context(Type* outer, Zone* zone) {
return ContextType::New(outer, zone);
}
static Type* Array(Type* element, Zone* zone) { static Type* Array(Type* element, Zone* zone) {
return ArrayType::New(element, zone); return ArrayType::New(element, zone);
} }
...@@ -740,14 +711,12 @@ class Type { ...@@ -740,14 +711,12 @@ class Type {
// Inspection. // Inspection.
bool IsRange() { return IsKind(TypeBase::kRange); } bool IsRange() { return IsKind(TypeBase::kRange); }
bool IsConstant() { return IsKind(TypeBase::kConstant); } bool IsConstant() { return IsKind(TypeBase::kConstant); }
bool IsContext() { return IsKind(TypeBase::kContext); }
bool IsArray() { return IsKind(TypeBase::kArray); } bool IsArray() { return IsKind(TypeBase::kArray); }
bool IsFunction() { return IsKind(TypeBase::kFunction); } bool IsFunction() { return IsKind(TypeBase::kFunction); }
bool IsTuple() { return IsKind(TypeBase::kTuple); } bool IsTuple() { return IsKind(TypeBase::kTuple); }
ConstantType* AsConstant() { return ConstantType::cast(this); } ConstantType* AsConstant() { return ConstantType::cast(this); }
RangeType* AsRange() { return RangeType::cast(this); } RangeType* AsRange() { return RangeType::cast(this); }
ContextType* AsContext() { return ContextType::cast(this); }
ArrayType* AsArray() { return ArrayType::cast(this); } ArrayType* AsArray() { return ArrayType::cast(this); }
FunctionType* AsFunction() { return FunctionType::cast(this); } FunctionType* AsFunction() { return FunctionType::cast(this); }
TupleType* AsTuple() { return TupleType::cast(this); } TupleType* AsTuple() { return TupleType::cast(this); }
......
...@@ -113,8 +113,7 @@ struct Tests { ...@@ -113,8 +113,7 @@ struct Tests {
Type* t = *it; Type* t = *it;
CHECK(1 == CHECK(1 ==
this->IsBitset(t) + t->IsConstant() + t->IsRange() + this->IsBitset(t) + t->IsConstant() + t->IsRange() +
this->IsUnion(t) + t->IsArray() + t->IsFunction() + this->IsUnion(t) + t->IsArray() + t->IsFunction());
t->IsContext());
} }
} }
...@@ -379,33 +378,6 @@ struct Tests { ...@@ -379,33 +378,6 @@ struct Tests {
} }
} }
void Context() {
// Constructor
for (int i = 0; i < 20; ++i) {
Type* type = T.Random();
Type* context = T.Context(type);
CHECK(context->IsContext());
}
// Attributes
for (int i = 0; i < 20; ++i) {
Type* type = T.Random();
Type* context = T.Context(type);
CheckEqual(type, context->AsContext()->Outer());
}
// Functionality & Injectivity: Context(T1) = Context(T2) iff T1 = T2
for (int i = 0; i < 20; ++i) {
for (int j = 0; j < 20; ++j) {
Type* type1 = T.Random();
Type* type2 = T.Random();
Type* context1 = T.Context(type1);
Type* context2 = T.Context(type2);
CHECK(Equal(context1, context2) == Equal(type1, type2));
}
}
}
void Array() { void Array() {
// Constructor // Constructor
for (int i = 0; i < 20; ++i) { for (int i = 0; i < 20; ++i) {
...@@ -714,7 +686,6 @@ struct Tests { ...@@ -714,7 +686,6 @@ struct Tests {
(type1->IsConstant() && type2->IsRange()) || (type1->IsConstant() && type2->IsRange()) ||
(this->IsBitset(type1) && type2->IsRange()) || (this->IsBitset(type1) && type2->IsRange()) ||
(type1->IsRange() && type2->IsRange()) || (type1->IsRange() && type2->IsRange()) ||
(type1->IsContext() && type2->IsContext()) ||
(type1->IsArray() && type2->IsArray()) || (type1->IsArray() && type2->IsArray()) ||
(type1->IsFunction() && type2->IsFunction()) || (type1->IsFunction() && type2->IsFunction()) ||
!type1->IsInhabited()); !type1->IsInhabited());
...@@ -757,17 +728,6 @@ struct Tests { ...@@ -757,17 +728,6 @@ struct Tests {
} }
} }
// Context(T1)->Is(Context(T2)) iff T1 = T2
for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
Type* outer1 = *it1;
Type* outer2 = *it2;
Type* type1 = T.Context(outer1);
Type* type2 = T.Context(outer2);
CHECK(type1->Is(type2) == outer1->Equals(outer2));
}
}
// Array(T1)->Is(Array(T2)) iff T1 = T2 // Array(T1)->Is(Array(T2)) iff T1 = T2
for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
......
...@@ -155,8 +155,6 @@ class Types { ...@@ -155,8 +155,6 @@ class Types {
Type* Range(double min, double max) { return Type::Range(min, max, zone_); } Type* Range(double min, double max) { return Type::Range(min, max, zone_); }
Type* Context(Type* outer) { return Type::Context(outer, zone_); }
Type* Array1(Type* element) { return Type::Array(element, zone_); } Type* Array1(Type* element) { return Type::Array(element, zone_); }
Type* Function0(Type* result, Type* receiver) { Type* Function0(Type* result, Type* receiver) {
...@@ -222,18 +220,12 @@ class Types { ...@@ -222,18 +220,12 @@ class Types {
if (min > max) std::swap(min, max); if (min > max) std::swap(min, max);
return Type::Range(min, max, zone_); return Type::Range(min, max, zone_);
} }
case 3: { // context case 3: { // array
int depth = rng_->NextInt(3);
Type* type = Type::Internal();
for (int i = 0; i < depth; ++i) type = Type::Context(type, zone_);
return type;
}
case 4: { // array
Type* element = Fuzz(depth / 2); Type* element = Fuzz(depth / 2);
return Type::Array(element, zone_); return Type::Array(element, zone_);
} }
case 5: case 4:
case 6: { // function case 5: { // function
Type* result = Fuzz(depth / 2); Type* result = Fuzz(depth / 2);
Type* receiver = Fuzz(depth / 2); Type* receiver = Fuzz(depth / 2);
int arity = rng_->NextInt(3); int arity = rng_->NextInt(3);
......
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