From 0f9e9e2010c7fcb0efbec1b7760d76811565b9aa Mon Sep 17 00:00:00 2001 From: Paolo Severini Date: Mon, 12 Jul 2021 16:20:10 -0700 Subject: [PATCH] [fastcall] Swap the template arguments in CopyAndConvertArrayToCppBuffer For CopyAndConvertArrayToCppBuffer(src, dst, length), type `T` can be deducible from `dst`, but `type_info` cannot be deducible so it's better to rewrite it as CopyAndConvertArrayToCppBuffer(src, dst, length). Bug: v8:11739 Change-Id: Ic3a28671cf7576672dad2f21bf6acf87807c3b48 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3023006 Reviewed-by: Maya Lekova Reviewed-by: Camillo Bruni Commit-Queue: Paolo Severini Cr-Commit-Position: refs/heads/master@{#75709} --- include/v8-fast-api-calls.h | 2 +- src/api/api-inl.h | 2 +- src/d8/d8-test.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/v8-fast-api-calls.h b/include/v8-fast-api-calls.h index 0cb765431b..7568ac9f30 100644 --- a/include/v8-fast-api-calls.h +++ b/include/v8-fast-api-calls.h @@ -782,7 +782,7 @@ using CFunctionBuilder = internal::CFunctionBuilder; * to the requested destination type, is considered unsupported. The operation * returns true on success. `type_info` will be used for conversions. */ -template +template bool CopyAndConvertArrayToCppBuffer(Local src, T* dst, uint32_t max_length); diff --git a/src/api/api-inl.h b/src/api/api-inl.h index 6ba3b6b525..9bd266395e 100644 --- a/src/api/api-inl.h +++ b/src/api/api-inl.h @@ -263,7 +263,7 @@ void CopyDoubleElementsToTypedBuffer(T* dst, uint32_t length, } } -template +template bool CopyAndConvertArrayToCppBuffer(Local src, T* dst, uint32_t max_length) { static_assert( diff --git a/src/d8/d8-test.cc b/src/d8/d8-test.cc index 395fc61c34..dced0b9424 100644 --- a/src/d8/d8-test.cc +++ b/src/d8/d8-test.cc @@ -120,7 +120,7 @@ class FastCApiObject { Type buffer[1024]; bool result = - CopyAndConvertArrayToCppBuffer(seq_arg, buffer, 1024); + CopyAndConvertArrayToCppBuffer<&type_info, Type>(seq_arg, buffer, 1024); if (!result) { options.fallback = 1; return 0; @@ -168,7 +168,7 @@ class FastCApiObject { } Type buffer[1024]; bool result = - CopyAndConvertArrayToCppBuffer(seq_arg, buffer, 1024); + CopyAndConvertArrayToCppBuffer<&type_info, Type>(seq_arg, buffer, 1024); if (!result) { isolate->ThrowError("Array conversion unsuccessful."); return;