Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 1980483003: [es6] Reintroduce the instanceof operator in the backends. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Igors comments. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-intrinsic-lowering.cc ('k') | src/contexts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
« no previous file with comments | « src/compiler/js-intrinsic-lowering.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698