[fastcall] Swap the template arguments in CopyAndConvertArrayToCppBuffer

For CopyAndConvertArrayToCppBuffer<T, type_info>(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<type_info, T>(src, dst, length).

Bug: v8:11739
Change-Id: Ic3a28671cf7576672dad2f21bf6acf87807c3b48
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3023006
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Paolo Severini <paolosev@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#75709}
This commit is contained in:
Paolo Severini 2021-07-12 16:20:10 -07:00 committed by V8 LUCI CQ
parent 1eb8770691
commit 0f9e9e2010
3 changed files with 4 additions and 4 deletions

View File

@ -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 <typename T, const CTypeInfo* type_info>
template <const CTypeInfo* type_info, typename T>
bool CopyAndConvertArrayToCppBuffer(Local<Array> src, T* dst,
uint32_t max_length);

View File

@ -263,7 +263,7 @@ void CopyDoubleElementsToTypedBuffer(T* dst, uint32_t length,
}
}
template <typename T, const CTypeInfo* type_info>
template <const CTypeInfo* type_info, typename T>
bool CopyAndConvertArrayToCppBuffer(Local<Array> src, T* dst,
uint32_t max_length) {
static_assert(

View File

@ -120,7 +120,7 @@ class FastCApiObject {
Type buffer[1024];
bool result =
CopyAndConvertArrayToCppBuffer<Type, &type_info>(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<Type, &type_info>(seq_arg, buffer, 1024);
CopyAndConvertArrayToCppBuffer<&type_info, Type>(seq_arg, buffer, 1024);
if (!result) {
isolate->ThrowError("Array conversion unsuccessful.");
return;