| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index ba6d5a339dc88f3ed31fc8126292b44c62c0b929..d7d0f57fc9047bcd9332ff99cffb6da290482a82 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -1331,11 +1331,30 @@ Reduction JSTypedLowering::ReduceJSOrdinaryHasInstance(Node* node) {
|
| Node* constructor = NodeProperties::GetValueInput(node, 0);
|
| Type* constructor_type = NodeProperties::GetType(constructor);
|
| Node* object = NodeProperties::GetValueInput(node, 1);
|
| + Type* object_type = NodeProperties::GetType(object);
|
| Node* context = NodeProperties::GetContextInput(node);
|
| Node* frame_state = NodeProperties::GetFrameStateInput(node);
|
| Node* effect = NodeProperties::GetEffectInput(node);
|
| Node* control = NodeProperties::GetControlInput(node);
|
|
|
| + // Check if the {constructor} cannot be callable.
|
| + // See ES6 section 7.3.19 OrdinaryHasInstance ( C, O ) step 1.
|
| + if (!constructor_type->Maybe(Type::Callable())) {
|
| + Node* value = jsgraph()->FalseConstant();
|
| + ReplaceWithValue(node, value, effect, control);
|
| + return Replace(value);
|
| + }
|
| +
|
| + // If the {constructor} cannot be a JSBoundFunction and then {object}
|
| + // cannot be a JSReceiver, then this can be constant-folded to false.
|
| + // See ES6 section 7.3.19 OrdinaryHasInstance ( C, O ) step 2 and 3.
|
| + if (!object_type->Maybe(Type::Receiver()) &&
|
| + !constructor_type->Maybe(Type::BoundFunction())) {
|
| + Node* value = jsgraph()->FalseConstant();
|
| + ReplaceWithValue(node, value, effect, control);
|
| + return Replace(value);
|
| + }
|
| +
|
| // Check if the {constructor} is a (known) JSFunction.
|
| if (!constructor_type->IsHeapConstant() ||
|
| !constructor_type->AsHeapConstant()->Value()->IsJSFunction()) {
|
|
|