Skip to content

Commit 7ecb124

Browse files
MayaLekovaCommit Bot
authored andcommitted
[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}
1 parent 69fa5f7 commit 7ecb124

4 files changed

Lines changed: 69 additions & 1 deletion

File tree

src/compiler/serializer-for-background-compilation.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,11 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
23742374
constant, base::nullopt, new_arguments, speculation_mode,
23752375
kMissingArgumentsAreUnknown, result_hints);
23762376
}
2377+
for (auto const& virtual_closure : arguments[0].virtual_closures()) {
2378+
ProcessCalleeForCallOrConstruct(
2379+
Callee(virtual_closure), base::nullopt, new_arguments,
2380+
speculation_mode, kMissingArgumentsAreUnknown, result_hints);
2381+
}
23772382
}
23782383
break;
23792384
case Builtins::kPromiseConstructor:
@@ -2390,7 +2395,7 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
23902395
SpeculationMode::kDisallowSpeculation,
23912396
kMissingArgumentsAreUnknown, result_hints);
23922397
}
2393-
for (auto virtual_closure : arguments[0].virtual_closures()) {
2398+
for (auto const& virtual_closure : arguments[0].virtual_closures()) {
23942399
ProcessCalleeForCallOrConstruct(
23952400
Callee(virtual_closure), base::nullopt, new_arguments,
23962401
SpeculationMode::kDisallowSpeculation,
@@ -2407,6 +2412,11 @@ void SerializerForBackgroundCompilation::ProcessBuiltinCall(
24072412
new_arguments, speculation_mode,
24082413
padding, result_hints);
24092414
}
2415+
for (auto const& virtual_closure : arguments[0].virtual_closures()) {
2416+
ProcessCalleeForCallOrConstruct(
2417+
Callee(virtual_closure), base::nullopt, new_arguments,
2418+
speculation_mode, padding, result_hints);
2419+
}
24102420
}
24112421
break;
24122422
case Builtins::kReflectApply:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2019 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax --opt --no-always-opt
6+
7+
function apply(arg) {
8+
"use strict";
9+
return arg.apply(this, arguments);
10+
}
11+
12+
function bar() {
13+
function foo(self, arg) {
14+
%TurbofanStaticAssert(arg === 42);
15+
return %IsBeingInterpreted();
16+
}
17+
%PrepareFunctionForOptimization(foo);
18+
19+
return apply(foo, 42);
20+
}
21+
22+
%PrepareFunctionForOptimization(bar);
23+
%PrepareFunctionForOptimization(apply);
24+
assertTrue(bar());
25+
assertTrue(bar());
26+
%OptimizeFunctionOnNextCall(bar);
27+
assertFalse(bar());
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2019 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax --opt --no-always-opt
6+
7+
function call(cb) {
8+
return cb.call(this, 42);
9+
}
10+
11+
function bar() {
12+
function foo(arg) {
13+
%TurbofanStaticAssert(arg === 42);
14+
return %IsBeingInterpreted();
15+
}
16+
%PrepareFunctionForOptimization(foo);
17+
18+
return call(foo);
19+
}
20+
21+
22+
%PrepareFunctionForOptimization(bar);
23+
%PrepareFunctionForOptimization(call);
24+
assertTrue(bar());
25+
assertTrue(bar());
26+
%OptimizeFunctionOnNextCall(bar);
27+
assertFalse(bar());

test/mjsunit/mjsunit.status

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@
407407
# Tests that depend on optimization (beyond doing assertOptimized).
408408
'compiler/is-being-interpreted-*': [SKIP],
409409
'compiler/serializer-accessors': [SKIP],
410+
'compiler/serializer-apply': [SKIP],
411+
'compiler/serializer-call': [SKIP],
410412
'compiler/serializer-transition-propagation': [SKIP],
411413

412414
# These tests check that we can trace the compiler.
@@ -1094,6 +1096,8 @@
10941096
'compiler/is-being-interpreted-*': [SKIP],
10951097
'compiler/load-elimination-const-field': [SKIP],
10961098
'compiler/serializer-accessors': [SKIP],
1099+
'compiler/serializer-apply': [SKIP],
1100+
'compiler/serializer-call': [SKIP],
10971101
'compiler/serializer-feedback-propagation-*': [SKIP],
10981102
'compiler/serializer-transition-propagation': [SKIP],
10991103

0 commit comments

Comments
 (0)