Commit f15d37aa authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

[turbofan] Add fast API calls fallback for floats

This CL ensures that if float parameters are unsupported for fast API
calls (which is currently the case for all platforms except x64), the
call is properly optimized to the regular TurboFan path.

Bug: chromium:1052746
Change-Id: I6dd9892d1db2b8c194c30b5d656d50ff63f03f51
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2450020
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Auto-Submit: Maya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70354}
parent 4f1bf7d1
......@@ -3453,6 +3453,20 @@ Reduction JSCallReducer::ReduceArraySome(Node* node,
return ReplaceWithSubgraph(&a, subgraph);
}
#ifndef V8_ENABLE_FP_PARAMS_IN_C_LINKAGE
namespace {
bool HasFPParamsInSignature(const CFunctionInfo* c_signature) {
for (unsigned int i = 0; i < c_signature->ArgumentCount(); ++i) {
if (c_signature->ArgumentInfo(i).GetType() == CTypeInfo::Type::kFloat32 ||
c_signature->ArgumentInfo(i).GetType() == CTypeInfo::Type::kFloat64) {
return true;
}
}
return false;
}
} // namespace
#endif
Reduction JSCallReducer::ReduceCallApiFunction(
Node* node, const SharedFunctionInfoRef& shared) {
DisallowHeapAccessIf no_heap_access(should_disallow_heap_access());
......@@ -3626,8 +3640,14 @@ Reduction JSCallReducer::ReduceCallApiFunction(
Address c_function = function_template_info.c_function();
if (FLAG_turbo_fast_api_calls && c_function != kNullAddress) {
const CFunctionInfo* c_signature = function_template_info.c_signature();
bool optimize_to_fast_call =
FLAG_turbo_fast_api_calls && c_function != kNullAddress;
const CFunctionInfo* c_signature = function_template_info.c_signature();
#ifndef V8_ENABLE_FP_PARAMS_IN_C_LINKAGE
optimize_to_fast_call =
optimize_to_fast_call && !HasFPParamsInSignature(c_signature);
#endif
if (optimize_to_fast_call) {
FastApiCallReducerAssembler a(this, node, c_function, c_signature,
function_template_info, receiver, holder,
shared, target, argc, effect);
......
......@@ -27712,7 +27712,6 @@ void CheckEqual(T actual, T expected) {
CHECK_EQ(actual, expected);
}
#ifdef V8_ENABLE_FP_PARAMS_IN_C_LINKAGE
template <>
void CheckEqual<float>(float actual, float expected) {
if (std::isnan(expected)) {
......@@ -27734,7 +27733,6 @@ void CheckEqual<double>(double actual, double expected) {
CHECK_EQ(actual, expected);
}
}
#endif
template <typename T>
void CallAndCheck(T expected_value, Behavior expected_behavior,
......@@ -28025,6 +28023,11 @@ TEST(FastApiCalls) {
ApiCheckerResult::kFastCalled, v8_num(3.14));
CallAndCheck<double>(3.14, Behavior::kNoException,
ApiCheckerResult::kFastCalled, v8_num(3.14));
#else
CallAndCheck<float>(3.14f, Behavior::kNoException,
ApiCheckerResult::kSlowCalled, v8_num(3.14));
CallAndCheck<double>(3.14, Behavior::kNoException,
ApiCheckerResult::kSlowCalled, v8_num(3.14));
#endif
// Corner cases (the value is out of bounds or of different type) - int32_t
......
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