Index: src/compiler/js-typed-lowering.cc |
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc |
index 3ad838c33198f8bc4b03c4bb37b378530d60c087..f03d0309db177317dcab3818944363e7c4cb867b 100644 |
--- a/src/compiler/js-typed-lowering.cc |
+++ b/src/compiler/js-typed-lowering.cc |
@@ -1000,7 +1000,6 @@ Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { |
return Replace(input); |
} else if (input_type->Is(Type::OrderedNumber())) { |
// JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) |
- RelaxEffectsAndControls(node); |
node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input, |
jsgraph()->ZeroConstant())); |
node->TrimInputCount(1); |
@@ -1008,10 +1007,25 @@ Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { |
return Changed(node); |
} else if (input_type->Is(Type::Number())) { |
// JSToBoolean(x:number) => NumberToBoolean(x) |
- RelaxEffectsAndControls(node); |
node->TrimInputCount(1); |
NodeProperties::ChangeOp(node, simplified()->NumberToBoolean()); |
return Changed(node); |
+ } else if (input_type->Is(Type::DetectableReceiverOrNull())) { |
+ // JSToBoolean(x:detectable receiver \/ null) |
+ // => BooleanNot(ReferenceEqual(x,#null)) |
+ node->ReplaceInput(0, graph()->NewNode(simplified()->ReferenceEqual(), |
+ input, jsgraph()->NullConstant())); |
+ node->TrimInputCount(1); |
+ NodeProperties::ChangeOp(node, simplified()->BooleanNot()); |
+ return Changed(node); |
+ } else if (input_type->Is(Type::ReceiverOrNullOrUndefined())) { |
+ // JSToBoolean(x:receiver \/ null \/ undefined) |
+ // => BooleanNot(ObjectIsUndetectable(x)) |
+ node->ReplaceInput( |
+ 0, graph()->NewNode(simplified()->ObjectIsUndetectable(), input)); |
+ node->TrimInputCount(1); |
+ NodeProperties::ChangeOp(node, simplified()->BooleanNot()); |
+ return Changed(node); |
} |
return NoChange(); |
} |