Commit 8a91be5b authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Benedikt Meurer

[turbofan] Remove the unused ToBooleanHints.

The ToBooleanHints were used to represent the ToBoolean feedback
collected by Fullcodegen. But Ignition doesn't collect this feedback
and also TurboFan doesn't make use of the hints, so we should remove
this for now.

Bug: v8:7101
Change-Id: Ifc97d3ebb7494029b33ad79fc8bafdf3c08fb871
Reviewed-on: https://chromium-review.googlesource.com/778163Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49470}
parent aae52f6b
......@@ -2297,8 +2297,8 @@ void BytecodeGraphBuilder::VisitLogicalNot() {
}
void BytecodeGraphBuilder::VisitToBooleanLogicalNot() {
Node* value = NewNode(simplified()->ToBoolean(ToBooleanHint::kAny),
environment()->LookupAccumulator());
Node* value =
NewNode(simplified()->ToBoolean(), environment()->LookupAccumulator());
Node* node = NewNode(simplified()->BooleanNot(), value);
environment()->BindAccumulator(node);
}
......@@ -2955,15 +2955,13 @@ void BytecodeGraphBuilder::BuildJumpIfTrue() {
void BytecodeGraphBuilder::BuildJumpIfToBooleanTrue() {
Node* accumulator = environment()->LookupAccumulator();
Node* condition =
NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), accumulator);
Node* condition = NewNode(simplified()->ToBoolean(), accumulator);
BuildJumpIf(condition);
}
void BytecodeGraphBuilder::BuildJumpIfToBooleanFalse() {
Node* accumulator = environment()->LookupAccumulator();
Node* condition =
NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), accumulator);
Node* condition = NewNode(simplified()->ToBoolean(), accumulator);
BuildJumpIfNot(condition);
}
......
......@@ -142,7 +142,7 @@ Reduction JSCallReducer::ReduceBooleanConstructor(Node* node) {
DCHECK_LE(2u, p.arity());
Node* value = (p.arity() == 2) ? jsgraph()->UndefinedConstant()
: NodeProperties::GetValueInput(node, 2);
value = graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), value);
value = graph()->NewNode(simplified()->ToBoolean(), value);
ReplaceWithValue(node, value);
return Replace(value);
}
......@@ -1447,8 +1447,8 @@ Node* JSCallReducer::DoFilterPostCallbackWork(ElementsKind kind, Node** control,
Node** effect, Node* a, Node* to,
Node* element,
Node* callback_value) {
Node* boolean_result = graph()->NewNode(
simplified()->ToBoolean(ToBooleanHint::kAny), callback_value);
Node* boolean_result =
graph()->NewNode(simplified()->ToBoolean(), callback_value);
Node* check_boolean_result =
graph()->NewNode(simplified()->ReferenceEqual(), boolean_result,
......
......@@ -269,8 +269,7 @@ Reduction JSNativeContextSpecialization::ReduceJSInstanceOf(Node* node) {
ConvertReceiverMode::kNotNullOrUndefined));
// Rewire the value uses of {node} to ToBoolean conversion of the result.
Node* value =
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), node);
Node* value = graph()->NewNode(simplified()->ToBoolean(), node);
for (Edge edge : node->use_edges()) {
if (NodeProperties::IsValueEdge(edge) && edge.from() != value) {
edge.UpdateTo(value);
......
......@@ -102,11 +102,6 @@ std::ostream& operator<<(std::ostream& os, ElementAccess const& access) {
return os;
}
ToBooleanHints ToBooleanHintsOf(Operator const* op) {
DCHECK_EQ(IrOpcode::kToBoolean, op->opcode());
return OpParameter<ToBooleanHints>(op);
}
const FieldAccess& FieldAccessOf(const Operator* op) {
DCHECK_NOT_NULL(op);
DCHECK(op->opcode() == IrOpcode::kLoadField ||
......@@ -636,7 +631,8 @@ DeoptimizeReason DeoptimizeReasonOf(const Operator* op) {
V(ReferenceEqual, Operator::kCommutative, 2, 0) \
V(StringEqual, Operator::kCommutative, 2, 0) \
V(StringLessThan, Operator::kNoProperties, 2, 0) \
V(StringLessThanOrEqual, Operator::kNoProperties, 2, 0)
V(StringLessThanOrEqual, Operator::kNoProperties, 2, 0) \
V(ToBoolean, Operator::kNoProperties, 1, 0)
#define SPECULATIVE_NUMBER_BINOP_LIST(V) \
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
......@@ -1118,15 +1114,6 @@ const Operator* SimplifiedOperatorBuilder::TransitionElementsKind(
transition); // parameter
}
const Operator* SimplifiedOperatorBuilder::ToBoolean(ToBooleanHints hints) {
// TODO(turbofan): Cache most important versions of this operator.
return new (zone()) Operator1<ToBooleanHints>( //--
IrOpcode::kToBoolean, Operator::kPure, // opcode
"ToBoolean", // name
1, 0, 0, 1, 0, 0, // inputs/outputs
hints); // parameter
}
namespace {
struct ArgumentsLengthParameters {
......
......@@ -199,9 +199,6 @@ std::ostream& operator<<(std::ostream&, GrowFastElementsMode);
GrowFastElementsMode GrowFastElementsModeOf(const Operator*) WARN_UNUSED_RESULT;
// The ToBooleanHints are used as parameter by ToBoolean operators.
ToBooleanHints ToBooleanHintsOf(Operator const* op);
// A descriptor for elements kind transitions.
class ElementsTransition final {
public:
......@@ -397,7 +394,7 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
const Operator* TypeOf();
const Operator* ClassOf();
const Operator* ToBoolean(ToBooleanHints hints);
const Operator* ToBoolean();
const Operator* StringEqual();
const Operator* StringLessThan();
......
......@@ -67,93 +67,6 @@ std::ostream& operator<<(std::ostream& os, ForInHint hint) {
UNREACHABLE();
}
std::ostream& operator<<(std::ostream& os, ToBooleanHint hint) {
switch (hint) {
case ToBooleanHint::kNone:
return os << "None";
case ToBooleanHint::kUndefined:
return os << "Undefined";
case ToBooleanHint::kBoolean:
return os << "Boolean";
case ToBooleanHint::kNull:
return os << "Null";
case ToBooleanHint::kSmallInteger:
return os << "SmallInteger";
case ToBooleanHint::kReceiver:
return os << "Receiver";
case ToBooleanHint::kString:
return os << "String";
case ToBooleanHint::kSymbol:
return os << "Symbol";
case ToBooleanHint::kHeapNumber:
return os << "HeapNumber";
case ToBooleanHint::kAny:
return os << "Any";
case ToBooleanHint::kNeedsMap:
return os << "NeedsMap";
}
UNREACHABLE();
}
std::string ToString(ToBooleanHint hint) {
switch (hint) {
case ToBooleanHint::kNone:
return "None";
case ToBooleanHint::kUndefined:
return "Undefined";
case ToBooleanHint::kBoolean:
return "Boolean";
case ToBooleanHint::kNull:
return "Null";
case ToBooleanHint::kSmallInteger:
return "SmallInteger";
case ToBooleanHint::kReceiver:
return "Receiver";
case ToBooleanHint::kString:
return "String";
case ToBooleanHint::kSymbol:
return "Symbol";
case ToBooleanHint::kHeapNumber:
return "HeapNumber";
case ToBooleanHint::kAny:
return "Any";
case ToBooleanHint::kNeedsMap:
return "NeedsMap";
}
UNREACHABLE();
}
std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) {
if (hints == ToBooleanHint::kAny) return os << "Any";
if (hints == ToBooleanHint::kNone) return os << "None";
bool first = true;
for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * 8; ++i) {
ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i);
if (hints & hint) {
if (!first) os << "|";
first = false;
os << hint;
}
}
return os;
}
std::string ToString(ToBooleanHints hints) {
if (hints == ToBooleanHint::kAny) return "Any";
if (hints == ToBooleanHint::kNone) return "None";
std::string ret;
bool first = true;
for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * 8; ++i) {
ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i);
if (hints & hint) {
if (!first) ret += "|";
first = false;
ret += ToString(hint);
}
}
return ret;
}
std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags) {
switch (flags) {
case STRING_ADD_CHECK_NONE:
......
......@@ -58,33 +58,6 @@ enum class ForInHint : uint8_t {
std::ostream& operator<<(std::ostream&, ForInHint);
// Type hints for the ToBoolean type conversion.
enum class ToBooleanHint : uint16_t {
kNone = 0u,
kUndefined = 1u << 0,
kBoolean = 1u << 1,
kNull = 1u << 2,
kSmallInteger = 1u << 3,
kReceiver = 1u << 4,
kString = 1u << 5,
kSymbol = 1u << 6,
kHeapNumber = 1u << 7,
kAny = kUndefined | kBoolean | kNull | kSmallInteger | kReceiver | kString |
kSymbol | kHeapNumber,
kNeedsMap = kReceiver | kString | kSymbol | kHeapNumber,
kCanBeUndetectable = kReceiver,
};
std::ostream& operator<<(std::ostream&, ToBooleanHint);
std::string ToString(ToBooleanHint);
typedef base::Flags<ToBooleanHint, uint16_t> ToBooleanHints;
std::ostream& operator<<(std::ostream&, ToBooleanHints);
std::string ToString(ToBooleanHints);
DEFINE_OPERATORS_FOR_FLAGS(ToBooleanHints)
enum StringAddFlags {
// Omit both parameter checks.
STRING_ADD_CHECK_NONE = 0,
......
......@@ -193,8 +193,7 @@ TEST_F(TypedOptimizationTest, ToBooleanWithFalsish) {
zone()),
zone()),
0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFalseConstant());
}
......@@ -206,32 +205,28 @@ TEST_F(TypedOptimizationTest, ToBooleanWithTruish) {
Type::Union(Type::DetectableReceiver(), Type::Symbol(), zone()),
zone()),
0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsTrueConstant());
}
TEST_F(TypedOptimizationTest, ToBooleanWithNonZeroPlainNumber) {
Node* input = Parameter(Type::Range(1, V8_INFINITY, zone()), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsTrueConstant());
}
TEST_F(TypedOptimizationTest, ToBooleanWithBoolean) {
Node* input = Parameter(Type::Boolean(), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(input, r.replacement());
}
TEST_F(TypedOptimizationTest, ToBooleanWithOrderedNumber) {
Node* input = Parameter(Type::OrderedNumber(), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsBooleanNot(IsNumberEqual(input, IsNumberConstant(0.0))));
......@@ -239,16 +234,14 @@ TEST_F(TypedOptimizationTest, ToBooleanWithOrderedNumber) {
TEST_F(TypedOptimizationTest, ToBooleanWithNumber) {
Node* input = Parameter(Type::Number(), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsNumberToBoolean(input));
}
TEST_F(TypedOptimizationTest, ToBooleanWithDetectableReceiverOrNull) {
Node* input = Parameter(Type::DetectableReceiverOrNull(), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsBooleanNot(IsReferenceEqual(input, IsNullConstant())));
......@@ -256,16 +249,14 @@ TEST_F(TypedOptimizationTest, ToBooleanWithDetectableReceiverOrNull) {
TEST_F(TypedOptimizationTest, ToBooleanWithReceiverOrNullOrUndefined) {
Node* input = Parameter(Type::ReceiverOrNullOrUndefined(), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsBooleanNot(IsObjectIsUndetectable(input)));
}
TEST_F(TypedOptimizationTest, ToBooleanWithString) {
Node* input = Parameter(Type::String(), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsBooleanNot(IsReferenceEqual(
......@@ -274,8 +265,7 @@ TEST_F(TypedOptimizationTest, ToBooleanWithString) {
TEST_F(TypedOptimizationTest, ToBooleanWithAny) {
Node* input = Parameter(Type::Any(), 0);
Reduction r = Reduce(
graph()->NewNode(simplified()->ToBoolean(ToBooleanHint::kAny), input));
Reduction r = Reduce(graph()->NewNode(simplified()->ToBoolean(), input));
ASSERT_FALSE(r.Changed());
}
......
......@@ -492,13 +492,6 @@ TEST_MONOTONICITY(ObjectIsSymbol)
TEST_MONOTONICITY(ObjectIsUndetectable)
TEST_MONOTONICITY(TypeOf)
TEST_MONOTONICITY(ClassOf)
#undef TEST_MONOTONICITY
// SIMPLIFIED UNOPs with ToBooleanHint
#define TEST_MONOTONICITY(name) \
TEST_F(TyperTest, Monotonicity_##name) { \
TestUnaryMonotonicity(simplified_.name(ToBooleanHint())); \
}
TEST_MONOTONICITY(ToBoolean)
#undef TEST_MONOTONICITY
......
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