Commit 727c6489 authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[fastcall] Mark test as incompatible with deopt_fuzzer

This CL makes more assumptions in the fast-api-call mjsunit test
explicit and specifies --deopt-every-n-times=0 for it, as it relies
on particular optimization/deoptimization sequences. It also fixes an
inconsistency between the fast/slow path results.

Bug: v8:11620
Change-Id: I385949a04534cd1658236878875efa6622936bc5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2817607Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73905}
parent 15bf8519
......@@ -51,10 +51,10 @@ class FastCApiObject {
HandleScope handle_scope(isolate);
double sum = 0;
if (args.Length() > 1 && args[1]->IsInt32()) {
if (args.Length() > 1 && args[1]->IsNumber()) {
sum += args[1]->Int32Value(isolate->GetCurrentContext()).FromJust();
}
if (args.Length() > 2 && args[2]->IsUint32()) {
if (args.Length() > 2 && args[2]->IsNumber()) {
sum += args[2]->Uint32Value(isolate->GetCurrentContext()).FromJust();
}
if (args.Length() > 3 && args[3]->IsNumber()) {
......@@ -101,10 +101,10 @@ class FastCApiObject {
HandleScope handle_scope(isolate);
double sum = 0;
if (args.Length() > 1 && args[1]->IsInt32()) {
if (args.Length() > 1 && args[1]->IsNumber()) {
sum += args[1]->Int32Value(isolate->GetCurrentContext()).FromJust();
}
if (args.Length() > 2 && args[2]->IsUint32()) {
if (args.Length() > 2 && args[2]->IsNumber()) {
sum += args[2]->Uint32Value(isolate->GetCurrentContext()).FromJust();
}
......
......@@ -9,6 +9,9 @@
// --always-opt is disabled because we rely on particular feedback for
// optimizing to the fastest path.
// Flags: --no-always-opt
// The test relies on optimizing/deoptimizing at predictable moments, so
// it's not suitable for deoptimization fuzzing.
// Flags: --deopt-every-n-times=0
assertThrows(() => d8.test.fast_c_api());
const fast_c_api = new d8.test.fast_c_api();
......@@ -36,24 +39,28 @@ if (fast_c_api.supports_fp_params) {
// Test that regular call hits the fast path.
fast_c_api.reset_counts();
assertEquals(add_all_result, add_all());
assertOptimized(add_all);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(0, fast_c_api.slow_call_count());
// Test fallback to slow path.
fast_c_api.reset_counts();
assertEquals(add_all_result, add_all(true));
assertOptimized(add_all);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(1, fast_c_api.slow_call_count());
// Test that no fallback hits the fast path again.
fast_c_api.reset_counts();
assertEquals(add_all_result, add_all());
assertOptimized(add_all);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(0, fast_c_api.slow_call_count());
} else {
// Test that calling with unsupported types hits the slow path.
fast_c_api.reset_counts();
assertEquals(add_all_result, add_all());
assertOptimized(add_all);
assertEquals(0, fast_c_api.fast_call_count());
assertEquals(1, fast_c_api.slow_call_count());
}
......@@ -71,15 +78,17 @@ const add_all_mismatch_result = add_all_mismatch();
fast_c_api.reset_counts();
assertEquals(add_all_mismatch_result, add_all_mismatch());
assertEquals(1, fast_c_api.slow_call_count());
assertEquals(0, fast_c_api.fast_call_count());
// If the function was ever optimized to the fast path, it should
// have been deoptimized due to the argument types mismatch. If it
// wasn't optimized due to lack of support for FP params, it will
// stay optimized.
if (fast_c_api.supports_fp_params) {
assertUnoptimized(add_all_mismatch);
} else {
assertOptimized(add_all_mismatch);
}
assertEquals(0, fast_c_api.fast_call_count());
assertEquals(1, fast_c_api.slow_call_count());
// ----------- add_32bit_int -----------
// `add_32bit_int` has the following signature:
......@@ -98,18 +107,21 @@ assertEquals(add_32bit_int_result, add_32bit_int());
// Test that regular call hits the fast path.
fast_c_api.reset_counts();
assertEquals(add_32bit_int_result, add_32bit_int());
assertOptimized(add_32bit_int);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(0, fast_c_api.slow_call_count());
// Test fallback to slow path.
fast_c_api.reset_counts();
assertEquals(add_32bit_int_result, add_32bit_int(true));
assertOptimized(add_32bit_int);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(1, fast_c_api.slow_call_count());
// Test that no fallback hits the fast path again.
fast_c_api.reset_counts();
assertEquals(add_32bit_int_result, add_32bit_int());
assertOptimized(add_32bit_int);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(0, fast_c_api.slow_call_count());
......@@ -125,20 +137,25 @@ assertEquals(add_32bit_int_result, add_32bit_int_mismatch(false, -42, 45));
// Test that passing extra argument stays on the fast path.
fast_c_api.reset_counts();
assertEquals(add_32bit_int_result, add_32bit_int_mismatch(false, -42, 45, -42));
assertOptimized(add_32bit_int_mismatch);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(0, fast_c_api.slow_call_count());
%PrepareFunctionForOptimization(add_32bit_int_mismatch);
// Test that passing wrong argument types stays on the fast path.
fast_c_api.reset_counts();
assertEquals(Math.round(-42 + 3.14), add_32bit_int_mismatch(false, -42, 3.14));
let mismatch_result = add_32bit_int_mismatch(false, -42, 3.14);
assertOptimized(add_32bit_int_mismatch);
assertEquals(Math.round(-42 + 3.14), mismatch_result);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(0, fast_c_api.slow_call_count());
// Test that passing arguments non-convertible to number falls down the slow path.
fast_c_api.reset_counts();
assertEquals(0, add_32bit_int_mismatch(false, -4294967296, Symbol()));
assertEquals(1, fast_c_api.slow_call_count());
assertEquals(0, fast_c_api.fast_call_count());
assertUnoptimized(add_32bit_int_mismatch);
assertEquals(0, fast_c_api.fast_call_count());
assertEquals(1, fast_c_api.slow_call_count());
// Optimize again.
%OptimizeFunctionOnNextCall(add_32bit_int_mismatch);
......@@ -149,13 +166,15 @@ assertOptimized(add_32bit_int_mismatch);
// because it's an argument type mismatch (undefined vs. int).
fast_c_api.reset_counts();
assertEquals(-42, add_32bit_int_mismatch(false, -42));
assertEquals(1, fast_c_api.slow_call_count());
assertEquals(0, fast_c_api.fast_call_count());
assertUnoptimized(add_32bit_int_mismatch);
assertEquals(0, fast_c_api.fast_call_count());
assertEquals(1, fast_c_api.slow_call_count());
// Test that the function can be optimized again.
%PrepareFunctionForOptimization(add_32bit_int_mismatch);
%OptimizeFunctionOnNextCall(add_32bit_int_mismatch);
fast_c_api.reset_counts();
assertEquals(add_32bit_int_result, add_32bit_int_mismatch(false, -42, 45));
assertOptimized(add_32bit_int_mismatch);
assertEquals(1, fast_c_api.fast_call_count());
assertEquals(0, fast_c_api.slow_call_count());
......@@ -953,7 +953,6 @@
'deopt-recursive-lazy-once': [SKIP],
'deopt-recursive-soft-once': [SKIP],
'code-coverage-block-opt': [SKIP],
'compiler/fast-api-calls': [SKIP],
'compiler/serializer-apply': [SKIP],
'compiler/serializer-call': [SKIP],
'compiler/serializer-dead-after-jump': [SKIP],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment