[turbofan] Add missing data for Function.apply and .call

Add serialization of the virtual closures for Function.ptototype.apply
and Function.prototype.call. Also add tests for those.

Bug: v8:7790
Change-Id: I26374009c09958943ef36eae283a270875234e40
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1943155
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Auto-Submit: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65298}
This commit is contained in:
Maya Lekova 2019-12-02 17:03:32 +01:00 committed by Commit Bot
parent 69fa5f794f
commit 7ecb124a67
4 changed files with 69 additions and 1 deletions

View File

@ -2374,6 +2374,11 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
constant, base::nullopt, new_arguments, speculation_mode,
kMissingArgumentsAreUnknown, result_hints);
}
for (auto const& virtual_closure : arguments[0].virtual_closures()) {
ProcessCalleeForCallOrConstruct(
Callee(virtual_closure), base::nullopt, new_arguments,
speculation_mode, kMissingArgumentsAreUnknown, result_hints);
}
}
break;
case Builtins::kPromiseConstructor:
@ -2390,7 +2395,7 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
SpeculationMode::kDisallowSpeculation,
kMissingArgumentsAreUnknown, result_hints);
}
for (auto virtual_closure : arguments[0].virtual_closures()) {
for (auto const& virtual_closure : arguments[0].virtual_closures()) {
ProcessCalleeForCallOrConstruct(
Callee(virtual_closure), base::nullopt, new_arguments,
SpeculationMode::kDisallowSpeculation,
@ -2407,6 +2412,11 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
new_arguments, speculation_mode,
padding, result_hints);
}
for (auto const& virtual_closure : arguments[0].virtual_closures()) {
ProcessCalleeForCallOrConstruct(
Callee(virtual_closure), base::nullopt, new_arguments,
speculation_mode, padding, result_hints);
}
}
break;
case Builtins::kReflectApply:

View File

@ -0,0 +1,27 @@
// Copyright 2019 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 --opt --no-always-opt
function apply(arg) {
"use strict";
return arg.apply(this, arguments);
}
function bar() {
function foo(self, arg) {
%TurbofanStaticAssert(arg === 42);
return %IsBeingInterpreted();
}
%PrepareFunctionForOptimization(foo);
return apply(foo, 42);
}
%PrepareFunctionForOptimization(bar);
%PrepareFunctionForOptimization(apply);
assertTrue(bar());
assertTrue(bar());
%OptimizeFunctionOnNextCall(bar);
assertFalse(bar());

View File

@ -0,0 +1,27 @@
// Copyright 2019 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 --opt --no-always-opt
function call(cb) {
return cb.call(this, 42);
}
function bar() {
function foo(arg) {
%TurbofanStaticAssert(arg === 42);
return %IsBeingInterpreted();
}
%PrepareFunctionForOptimization(foo);
return call(foo);
}
%PrepareFunctionForOptimization(bar);
%PrepareFunctionForOptimization(call);
assertTrue(bar());
assertTrue(bar());
%OptimizeFunctionOnNextCall(bar);
assertFalse(bar());

View File

@ -407,6 +407,8 @@
# Tests that depend on optimization (beyond doing assertOptimized).
'compiler/is-being-interpreted-*': [SKIP],
'compiler/serializer-accessors': [SKIP],
'compiler/serializer-apply': [SKIP],
'compiler/serializer-call': [SKIP],
'compiler/serializer-transition-propagation': [SKIP],
# These tests check that we can trace the compiler.
@ -1094,6 +1096,8 @@
'compiler/is-being-interpreted-*': [SKIP],
'compiler/load-elimination-const-field': [SKIP],
'compiler/serializer-accessors': [SKIP],
'compiler/serializer-apply': [SKIP],
'compiler/serializer-call': [SKIP],
'compiler/serializer-feedback-propagation-*': [SKIP],
'compiler/serializer-transition-propagation': [SKIP],