| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index cbcd32e229a2a8be1035f17b31ce2c6dac01f517..809953367e95512557863ee8877da2c509ab43f1 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -1066,10 +1066,7 @@ Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) {
|
| Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0);
|
|
|
| // If deoptimization is disabled, we cannot optimize.
|
| - if (!(flags() & kDeoptimizationEnabled) ||
|
| - (flags() & kDisableBinaryOpReduction)) {
|
| - return NoChange();
|
| - }
|
| + if (!(flags() & kDeoptimizationEnabled)) return NoChange();
|
|
|
| // If we are in a try block, don't optimize since the runtime call
|
| // in the proxy case can throw.
|
| @@ -1088,15 +1085,21 @@ Reduction JSTypedLowering::ReduceJSInstanceOf(Node* node) {
|
| Handle<JSFunction>::cast(r.right_type()->AsConstant()->Value());
|
| Handle<SharedFunctionInfo> shared(function->shared(), isolate());
|
|
|
| - if (!function->IsConstructor() ||
|
| - function->map()->has_non_instance_prototype()) {
|
| + // Make sure the prototype of {function} is the %FunctionPrototype%, and it
|
| + // already has a meaningful initial map (i.e. we constructed at least one
|
| + // instance using the constructor {function}).
|
| + if (function->map()->prototype() != function->native_context()->closure() ||
|
| + function->map()->has_non_instance_prototype() ||
|
| + !function->has_initial_map()) {
|
| return NoChange();
|
| }
|
|
|
| - JSFunction::EnsureHasInitialMap(function);
|
| - DCHECK(function->has_initial_map());
|
| + // We can only use the fast case if @@hasInstance was not used so far.
|
| + if (!isolate()->IsHasInstanceLookupChainIntact()) return NoChange();
|
| + dependencies()->AssumePropertyCell(factory()->has_instance_protector());
|
| +
|
| Handle<Map> initial_map(function->initial_map(), isolate());
|
| - this->dependencies()->AssumeInitialMapCantChange(initial_map);
|
| + dependencies()->AssumeInitialMapCantChange(initial_map);
|
| Node* prototype =
|
| jsgraph()->Constant(handle(initial_map->prototype(), isolate()));
|
|
|
|
|