diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc index 0ddd788153..0fc2f21138 100644 --- a/src/crankshaft/hydrogen.cc +++ b/src/crankshaft/hydrogen.cc @@ -8381,6 +8381,13 @@ bool HOptimizedGraphBuilder::TryInline(Handle target, } } + // Unsupported variable references present. + if (function->scope()->this_function_var() != nullptr || + function->scope()->new_target_var() != nullptr) { + TraceInline(target, caller, "target uses new target or this function"); + return false; + } + // All declarations must be inlineable. ZoneList* decls = target_info.scope()->declarations(); int decl_count = decls->length(); diff --git a/test/mjsunit/es6/regress/regress-inlined-new-target.js b/test/mjsunit/es6/regress/regress-inlined-new-target.js new file mode 100644 index 0000000000..59932f6b4c --- /dev/null +++ b/test/mjsunit/es6/regress/regress-inlined-new-target.js @@ -0,0 +1,13 @@ +// Copyright 2015 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 g() { return { val: new.target }; } +function f() { return (new g()).val; } + +assertEquals(g, f()); +assertEquals(g, f()); +%OptimizeFunctionOnNextCall(f); +assertEquals(g, f());