719d6c1d58
For bound functions on the right-hand side of instanceof we can constant-fold to the actual [[BoundTargetFunction]], actually instance OrdinaryHasInstance. Move the Function.prototype[@@hasInstance] reduction up to the JSCallReducer to allow this optimization to become effective (and also enable other optimizations). BUG=v8:5267 R=jarin@chromium.org Review-Url: https://codereview.chromium.org/2537763002 Cr-Commit-Position: refs/heads/master@{#41352}
18 lines
545 B
JavaScript
18 lines
545 B
JavaScript
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
function Bar() {}
|
|
var Foo = Bar.bind(null);
|
|
|
|
// TurboFan will optimize this to false via constant-folding the
|
|
// OrdinaryHasInstance call inside Function.prototype[@@hasInstance].
|
|
function foo() { return 1 instanceof Foo; }
|
|
|
|
assertEquals(false, foo());
|
|
assertEquals(false, foo());
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertEquals(false, foo());
|