v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-fast-api-calls.h
Go to the documentation of this file.
1// Copyright 2020 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
219#ifndef INCLUDE_V8_FAST_API_CALLS_H_
220#define INCLUDE_V8_FAST_API_CALLS_H_
221
222#include <stddef.h>
223#include <stdint.h>
224
225#include <tuple>
226#include <type_traits>
227
228#include "v8-internal.h" // NOLINT(build/include_directory)
229#include "v8-local-handle.h" // NOLINT(build/include_directory)
230#include "v8-typed-array.h" // NOLINT(build/include_directory)
231#include "v8-value.h" // NOLINT(build/include_directory)
232#include "v8config.h" // NOLINT(build/include_directory)
233
234namespace v8 {
235
236class Isolate;
237
239 public:
240 enum class Type : uint8_t {
241 kVoid,
242 kBool,
243 kUint8,
244 kInt32,
245 kUint32,
246 kInt64,
247 kUint64,
248 kFloat32,
249 kFloat64,
250 kPointer,
251 kV8Value,
253 kApiObject, // This will be deprecated once all users have
254 // migrated from v8::ApiObject to v8::Local<v8::Value>.
255 kAny, // This is added to enable untyped representation of fast
256 // call arguments for test purposes. It can represent any of
257 // the other types stored in the same memory as a union
258 // (see AnyCType declared below). This allows for
259 // uniform passing of arguments w.r.t. their location
260 // (in a register or on the stack), independent of their
261 // actual type. It's currently used by the arm64 simulator
262 // and can be added to the other simulators as well when fast
263 // calls having both GP and FP params need to be supported.
264 };
265
266 // kCallbackOptionsType is not part of the Type enum
267 // because it is only used internally. Use value 255 that is larger
268 // than any valid Type enum.
269 static constexpr Type kCallbackOptionsType = Type(255);
270
271 enum class SequenceType : uint8_t {
272 kScalar,
273 kIsSequence, // sequence<T>
274 kIsTypedArray, // TypedArray of T or any ArrayBufferView if T
275 // is void
276 kIsArrayBuffer // ArrayBuffer
277 };
278
279 enum class Flags : uint8_t {
280 kNone = 0,
281 kAllowSharedBit = 1 << 0, // Must be an ArrayBuffer or TypedArray
282 kEnforceRangeBit = 1 << 1, // T must be integral
283 kClampBit = 1 << 2, // T must be integral
284 kIsRestrictedBit = 1 << 3, // T must be float or double
285 };
286
287 explicit constexpr CTypeInfo(
288 Type type, SequenceType sequence_type = SequenceType::kScalar,
289 Flags flags = Flags::kNone)
290 : type_(type), sequence_type_(sequence_type), flags_(flags) {}
291
292 typedef uint32_t Identifier;
293 explicit constexpr CTypeInfo(Identifier identifier)
294 : CTypeInfo(static_cast<Type>(identifier >> 16),
295 static_cast<SequenceType>((identifier >> 8) & 255),
296 static_cast<Flags>(identifier & 255)) {}
297 constexpr Identifier GetId() const {
298 return static_cast<uint8_t>(type_) << 16 |
299 static_cast<uint8_t>(sequence_type_) << 8 |
300 static_cast<uint8_t>(flags_);
301 }
302
303 constexpr Type GetType() const { return type_; }
304 constexpr SequenceType GetSequenceType() const { return sequence_type_; }
305 constexpr Flags GetFlags() const { return flags_; }
306
307 static constexpr bool IsIntegralType(Type type) {
308 return type == Type::kUint8 || type == Type::kInt32 ||
309 type == Type::kUint32 || type == Type::kInt64 ||
310 type == Type::kUint64;
311 }
312
313 static constexpr bool IsFloatingPointType(Type type) {
314 return type == Type::kFloat32 || type == Type::kFloat64;
315 }
316
317 static constexpr bool IsPrimitive(Type type) {
318 return IsIntegralType(type) || IsFloatingPointType(type) ||
319 type == Type::kBool;
320 }
321
322 private:
323 Type type_;
324 SequenceType sequence_type_;
325 Flags flags_;
326};
327
329 public:
330 // Returns the length in number of elements.
331 size_t V8_EXPORT length() const { return length_; }
332 // Checks whether the given index is within the bounds of the collection.
333 void V8_EXPORT ValidateIndex(size_t index) const;
334
335 protected:
336 size_t length_ = 0;
337};
338
339template <typename T>
341 public:
342 V8_INLINE T get(size_t index) const {
343#ifdef DEBUG
344 ValidateIndex(index);
345#endif // DEBUG
346 T tmp;
347 memcpy(&tmp, static_cast<void*>(reinterpret_cast<T*>(data_) + index),
348 sizeof(T));
349 return tmp;
350 }
351
352 bool getStorageIfAligned(T** elements) const {
353 if (reinterpret_cast<uintptr_t>(data_) % alignof(T) != 0) {
354 return false;
355 }
356 *elements = reinterpret_cast<T*>(data_);
357 return true;
358 }
359
360 private:
361 // This pointer should include the typed array offset applied.
362 // It's not guaranteed that it's aligned to sizeof(T), it's only
363 // guaranteed that it's 4-byte aligned, so for 8-byte types we need to
364 // provide a special implementation for reading from it, which hides
365 // the possibly unaligned read in the `get` method.
366 void* data_;
367};
368
369// Any TypedArray. It uses kTypedArrayBit with base type void
370// Overloaded args of ArrayBufferView and TypedArray are not supported
371// (for now) because the generic “any” ArrayBufferView doesn’t have its
372// own instance type. It could be supported if we specify that
373// TypedArray<T> always has precedence over the generic ArrayBufferView,
374// but this complicates overload resolution.
376 void* data;
378};
379
381 void* data;
383};
384
386 const char* data;
387 uint32_t length;
388};
389
391 public:
392 enum class Int64Representation : uint8_t {
393 kNumber = 0, // Use numbers to represent 64 bit integers.
394 kBigInt = 1, // Use BigInts to represent 64 bit integers.
395 };
396
397 // Construct a struct to hold a CFunction's type information.
398 // |return_info| describes the function's return type.
399 // |arg_info| is an array of |arg_count| CTypeInfos describing the
400 // arguments. Only the last argument may be of the special type
401 // CTypeInfo::kCallbackOptionsType.
402 CFunctionInfo(const CTypeInfo& return_info, unsigned int arg_count,
403 const CTypeInfo* arg_info,
404 Int64Representation repr = Int64Representation::kNumber);
405
406 const CTypeInfo& ReturnInfo() const { return return_info_; }
407
408 // The argument count, not including the v8::FastApiCallbackOptions
409 // if present.
410 unsigned int ArgumentCount() const {
411 return HasOptions() ? arg_count_ - 1 : arg_count_;
412 }
413
415
416 // |index| must be less than ArgumentCount().
417 // Note: if the last argument passed on construction of CFunctionInfo
418 // has type CTypeInfo::kCallbackOptionsType, it is not included in
419 // ArgumentCount().
420 const CTypeInfo& ArgumentInfo(unsigned int index) const;
421
422 bool HasOptions() const {
423 // The options arg is always the last one.
424 return arg_count_ > 0 && arg_info_[arg_count_ - 1].GetType() ==
425 CTypeInfo::kCallbackOptionsType;
426 }
427
428 private:
429 const CTypeInfo return_info_;
430 const Int64Representation repr_;
431 const unsigned int arg_count_;
432 const CTypeInfo* arg_info_;
433};
434
435struct FastApiCallbackOptions;
436
437// Provided for testing.
439 AnyCType() : int64_value(0) {}
440
441#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
442 // In this case, Local<T> is not trivially copyable and the implicit
443 // copy constructor and copy assignment for the union are deleted.
444 AnyCType(const AnyCType& other) : int64_value(other.int64_value) {}
445 AnyCType& operator=(const AnyCType& other) {
446 int64_value = other.int64_value;
447 return *this;
448 }
449#endif
450
452 int32_t int32_value;
453 uint32_t uint32_value;
454 int64_t int64_value;
455 uint64_t uint64_value;
470};
471
472static_assert(
473 sizeof(AnyCType) == 8,
474 "The union AnyCType should have size == 64 bits, as this is assumed "
475 "by EffectControlLinearizer.");
476
478 public:
479 constexpr CFunction() : address_(nullptr), type_info_(nullptr) {}
480
481 const CTypeInfo& ReturnInfo() const { return type_info_->ReturnInfo(); }
482
483 const CTypeInfo& ArgumentInfo(unsigned int index) const {
484 return type_info_->ArgumentInfo(index);
485 }
486
487 unsigned int ArgumentCount() const { return type_info_->ArgumentCount(); }
488
489 const void* GetAddress() const { return address_; }
491 return type_info_->GetInt64Representation();
492 }
493 const CFunctionInfo* GetTypeInfo() const { return type_info_; }
494
495 enum class OverloadResolution { kImpossible, kAtRuntime, kAtCompileTime };
496
497 // Returns whether an overload between this and the given CFunction can
498 // be resolved at runtime by the RTTI available for the arguments or at
499 // compile time for functions with different number of arguments.
501 // Runtime overload resolution can only deal with functions with the
502 // same number of arguments. Functions with different arity are handled
503 // by compile time overload resolution though.
504 if (ArgumentCount() != other->ArgumentCount()) {
505 return OverloadResolution::kAtCompileTime;
506 }
507
508 // The functions can only differ by a single argument position.
509 int diff_index = -1;
510 for (unsigned int i = 0; i < ArgumentCount(); ++i) {
511 if (ArgumentInfo(i).GetSequenceType() !=
512 other->ArgumentInfo(i).GetSequenceType()) {
513 if (diff_index >= 0) {
514 return OverloadResolution::kImpossible;
515 }
516 diff_index = i;
517
518 // We only support overload resolution between sequence types.
519 if (ArgumentInfo(i).GetSequenceType() ==
520 CTypeInfo::SequenceType::kScalar ||
521 other->ArgumentInfo(i).GetSequenceType() ==
522 CTypeInfo::SequenceType::kScalar) {
523 return OverloadResolution::kImpossible;
524 }
525 }
526 }
527
528 return OverloadResolution::kAtRuntime;
529 }
530
531 template <typename F>
532 static CFunction Make(F* func) {
533 return ArgUnwrap<F*>::Make(func);
534 }
535
536 // Provided for testing purposes.
537 template <typename R, typename... Args, typename R_Patch,
538 typename... Args_Patch>
539 static CFunction Make(R (*func)(Args...),
540 R_Patch (*patching_func)(Args_Patch...)) {
541 CFunction c_func = ArgUnwrap<R (*)(Args...)>::Make(func);
542 static_assert(
543 sizeof...(Args_Patch) == sizeof...(Args),
544 "The patching function must have the same number of arguments.");
545 c_func.address_ = reinterpret_cast<void*>(patching_func);
546 return c_func;
547 }
548
549 CFunction(const void* address, const CFunctionInfo* type_info);
550
551 private:
552 const void* address_;
553 const CFunctionInfo* type_info_;
554
555 template <typename F>
556 class ArgUnwrap {
557 static_assert(sizeof(F) != sizeof(F),
558 "CFunction must be created from a function pointer.");
559 };
560
561 template <typename R, typename... Args>
562 class ArgUnwrap<R (*)(Args...)> {
563 public:
564 static CFunction Make(R (*func)(Args...));
565 };
566};
567
580 return {false, {0}, nullptr};
581 }
582
595
600 union {
601 uintptr_t data_ptr;
603 };
604
609};
610
611namespace internal {
612
613// Helper to count the number of occurances of `T` in `List`
614template <typename T, typename... List>
615struct count : std::integral_constant<int, 0> {};
616template <typename T, typename... Args>
617struct count<T, T, Args...>
618 : std::integral_constant<std::size_t, 1 + count<T, Args...>::value> {};
619template <typename T, typename U, typename... Args>
620struct count<T, U, Args...> : count<T, Args...> {};
621
622template <CFunctionInfo::Int64Representation Representation,
623 typename RetBuilder, typename... ArgBuilders>
625 static constexpr int kOptionsArgCount =
626 count<FastApiCallbackOptions&, ArgBuilders...>();
627 static constexpr int kReceiverCount = 1;
628
629 static_assert(kOptionsArgCount == 0 || kOptionsArgCount == 1,
630 "Only one options parameter is supported.");
631
632 static_assert(sizeof...(ArgBuilders) >= kOptionsArgCount + kReceiverCount,
633 "The receiver or the options argument is missing.");
634
635 public:
637 : CFunctionInfo(RetBuilder::Build(), sizeof...(ArgBuilders),
638 arg_info_storage_, Representation),
639 arg_info_storage_{ArgBuilders::Build()...} {
640 constexpr CTypeInfo::Type kReturnType = RetBuilder::Build().GetType();
641 static_assert(kReturnType == CTypeInfo::Type::kVoid ||
642 kReturnType == CTypeInfo::Type::kBool ||
643 kReturnType == CTypeInfo::Type::kInt32 ||
644 kReturnType == CTypeInfo::Type::kUint32 ||
645 kReturnType == CTypeInfo::Type::kInt64 ||
646 kReturnType == CTypeInfo::Type::kUint64 ||
647 kReturnType == CTypeInfo::Type::kFloat32 ||
648 kReturnType == CTypeInfo::Type::kFloat64 ||
649 kReturnType == CTypeInfo::Type::kPointer ||
650 kReturnType == CTypeInfo::Type::kAny,
651 "String and api object values are not currently "
652 "supported return types.");
653 }
654
655 private:
656 const CTypeInfo arg_info_storage_[sizeof...(ArgBuilders)];
657};
658
659template <typename T>
661 static_assert(sizeof(T) != sizeof(T), "This type is not supported");
662};
663
664#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR(T, Enum) \
665 template <> \
666 struct TypeInfoHelper<T> { \
667 static constexpr CTypeInfo::Flags Flags() { \
668 return CTypeInfo::Flags::kNone; \
669 } \
670 \
671 static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \
672 static constexpr CTypeInfo::SequenceType SequenceType() { \
673 return CTypeInfo::SequenceType::kScalar; \
674 } \
675 };
676
677template <CTypeInfo::Type type>
679
680#define DEFINE_TYPE_INFO_TRAITS(CType, Enum) \
681 template <> \
682 struct CTypeInfoTraits<CTypeInfo::Type::Enum> { \
683 using ctype = CType; \
684 };
685
686#define PRIMITIVE_C_TYPES(V) \
687 V(bool, kBool) \
688 V(uint8_t, kUint8) \
689 V(int32_t, kInt32) \
690 V(uint32_t, kUint32) \
691 V(int64_t, kInt64) \
692 V(uint64_t, kUint64) \
693 V(float, kFloat32) \
694 V(double, kFloat64) \
695 V(void*, kPointer)
696
697// Same as above, but includes deprecated types for compatibility.
698#define ALL_C_TYPES(V) \
699 PRIMITIVE_C_TYPES(V) \
700 V(void, kVoid) \
701 V(v8::Local<v8::Value>, kV8Value) \
702 V(v8::Local<v8::Object>, kV8Value) \
703 V(AnyCType, kAny)
704
705// ApiObject was a temporary solution to wrap the pointer to the v8::Value.
706// Please use v8::Local<v8::Value> in new code for the arguments and
707// v8::Local<v8::Object> for the receiver, as ApiObject will be deprecated.
708
711
712#undef PRIMITIVE_C_TYPES
713#undef ALL_C_TYPES
714
715#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR_TA(T, Enum) \
716 template <> \
717 struct TypeInfoHelper<const FastApiTypedArray<T>&> { \
718 static constexpr CTypeInfo::Flags Flags() { \
719 return CTypeInfo::Flags::kNone; \
720 } \
721 \
722 static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \
723 static constexpr CTypeInfo::SequenceType SequenceType() { \
724 return CTypeInfo::SequenceType::kIsTypedArray; \
725 } \
726 };
727
728#define TYPED_ARRAY_C_TYPES(V) \
729 V(uint8_t, kUint8) \
730 V(int32_t, kInt32) \
731 V(uint32_t, kUint32) \
732 V(int64_t, kInt64) \
733 V(uint64_t, kUint64) \
734 V(float, kFloat32) \
735 V(double, kFloat64)
736
738
739#undef TYPED_ARRAY_C_TYPES
740
741template <>
742struct TypeInfoHelper<v8::Local<v8::Array>> {
743 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
744
745 static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kVoid; }
748 }
749};
750
751template <>
752struct TypeInfoHelper<v8::Local<v8::Uint32Array>> {
753 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
754
755 static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kUint32; }
758 }
759};
760
761template <>
763 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
764
765 static constexpr CTypeInfo::Type Type() {
767 }
770 }
771};
772
773template <>
775 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
776
777 static constexpr CTypeInfo::Type Type() {
779 }
782 }
783};
784
785#define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG) \
786 static_assert(((COND) == 0) || (ASSERTION), MSG)
787
788} // namespace internal
789
790template <typename T, CTypeInfo::Flags... Flags>
792 public:
793 using BaseType = T;
794
795 static constexpr CTypeInfo Build() {
796 constexpr CTypeInfo::Flags kFlags =
797 MergeFlags(internal::TypeInfoHelper<T>::Flags(), Flags...);
799 constexpr CTypeInfo::SequenceType kSequenceType =
801
803 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kAllowSharedBit),
804 (kSequenceType == CTypeInfo::SequenceType::kIsTypedArray ||
805 kSequenceType == CTypeInfo::SequenceType::kIsArrayBuffer),
806 "kAllowSharedBit is only allowed for TypedArrays and ArrayBuffers.");
808 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kEnforceRangeBit),
809 CTypeInfo::IsIntegralType(kType),
810 "kEnforceRangeBit is only allowed for integral types.");
812 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kClampBit),
813 CTypeInfo::IsIntegralType(kType),
814 "kClampBit is only allowed for integral types.");
816 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kIsRestrictedBit),
817 CTypeInfo::IsFloatingPointType(kType),
818 "kIsRestrictedBit is only allowed for floating point types.");
819 STATIC_ASSERT_IMPLIES(kSequenceType == CTypeInfo::SequenceType::kIsSequence,
820 kType == CTypeInfo::Type::kVoid,
821 "Sequences are only supported from void type.");
823 kSequenceType == CTypeInfo::SequenceType::kIsTypedArray,
824 CTypeInfo::IsPrimitive(kType) || kType == CTypeInfo::Type::kVoid,
825 "TypedArrays are only supported from primitive types or void.");
826
827 // Return the same type with the merged flags.
830 }
831
832 private:
833 template <typename... Rest>
834 static constexpr CTypeInfo::Flags MergeFlags(CTypeInfo::Flags flags,
835 Rest... rest) {
836 return CTypeInfo::Flags(uint8_t(flags) | uint8_t(MergeFlags(rest...)));
837 }
838 static constexpr CTypeInfo::Flags MergeFlags() { return CTypeInfo::Flags(0); }
839};
840
841namespace internal {
842template <typename RetBuilder, typename... ArgBuilders>
844 public:
845 explicit constexpr CFunctionBuilderWithFunction(const void* fn) : fn_(fn) {}
846
847 template <CTypeInfo::Flags... Flags>
848 constexpr auto Ret() {
850 CTypeInfoBuilder<typename RetBuilder::BaseType, Flags...>,
851 ArgBuilders...>(fn_);
852 }
853
854 template <unsigned int N, CTypeInfo::Flags... Flags>
855 constexpr auto Arg() {
856 // Return a copy of the builder with the Nth arg builder merged with
857 // template parameter pack Flags.
858 return ArgImpl<N, Flags...>(
859 std::make_index_sequence<sizeof...(ArgBuilders)>());
860 }
861
862 // Provided for testing purposes.
863 template <typename Ret, typename... Args>
864 auto Patch(Ret (*patching_func)(Args...)) {
865 static_assert(
866 sizeof...(Args) == sizeof...(ArgBuilders),
867 "The patching function must have the same number of arguments.");
868 fn_ = reinterpret_cast<void*>(patching_func);
869 return *this;
870 }
871
872 template <CFunctionInfo::Int64Representation Representation =
874 auto Build() {
875 static CFunctionInfoImpl<Representation, RetBuilder, ArgBuilders...>
876 instance;
877 return CFunction(fn_, &instance);
878 }
879
880 private:
881 template <bool Merge, unsigned int N, CTypeInfo::Flags... Flags>
882 struct GetArgBuilder;
883
884 // Returns the same ArgBuilder as the one at index N, including its flags.
885 // Flags in the template parameter pack are ignored.
886 template <unsigned int N, CTypeInfo::Flags... Flags>
887 struct GetArgBuilder<false, N, Flags...> {
888 using type =
889 typename std::tuple_element<N, std::tuple<ArgBuilders...>>::type;
890 };
891
892 // Returns an ArgBuilder with the same base type as the one at index N,
893 // but merges the flags with the flags in the template parameter pack.
894 template <unsigned int N, CTypeInfo::Flags... Flags>
895 struct GetArgBuilder<true, N, Flags...> {
896 using type = CTypeInfoBuilder<
897 typename std::tuple_element<N,
898 std::tuple<ArgBuilders...>>::type::BaseType,
899 std::tuple_element<N, std::tuple<ArgBuilders...>>::type::Build()
900 .GetFlags(),
901 Flags...>;
902 };
903
904 // Return a copy of the CFunctionBuilder, but merges the Flags on
905 // ArgBuilder index N with the new Flags passed in the template parameter
906 // pack.
907 template <unsigned int N, CTypeInfo::Flags... Flags, size_t... I>
908 constexpr auto ArgImpl(std::index_sequence<I...>) {
909 return CFunctionBuilderWithFunction<
910 RetBuilder, typename GetArgBuilder<N == I, I, Flags...>::type...>(fn_);
911 }
912
913 const void* fn_;
914};
915
917 public:
918 constexpr CFunctionBuilder() {}
919
920 template <typename R, typename... Args>
921 constexpr auto Fn(R (*fn)(Args...)) {
924 reinterpret_cast<const void*>(fn));
925 }
926};
927
928} // namespace internal
929
930// static
931template <typename R, typename... Args>
932CFunction CFunction::ArgUnwrap<R (*)(Args...)>::Make(R (*func)(Args...)) {
933 return internal::CFunctionBuilder().Fn(func).Build();
934}
935
937
938static constexpr CTypeInfo kTypeInfoInt32 = CTypeInfo(CTypeInfo::Type::kInt32);
939static constexpr CTypeInfo kTypeInfoFloat64 =
941
954template <CTypeInfo::Identifier type_info_id, typename T>
956 Local<Array> src, T* dst, uint32_t max_length);
957
958template <>
960TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<int32_t>::Build().GetId(),
961 int32_t>(Local<Array> src, int32_t* dst,
962 uint32_t max_length);
963
964template <>
966TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<uint32_t>::Build().GetId(),
967 uint32_t>(Local<Array> src, uint32_t* dst,
968 uint32_t max_length);
969
970template <>
972TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<float>::Build().GetId(),
973 float>(Local<Array> src, float* dst,
974 uint32_t max_length);
975
976template <>
978TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<double>::Build().GetId(),
979 double>(Local<Array> src, double* dst,
980 uint32_t max_length);
981
982} // namespace v8
983
984#endif // INCLUDE_V8_FAST_API_CALLS_H_
constexpr CFunction()
CFunction(const void *address, const CFunctionInfo *type_info)
static CFunction Make(R(*func)(Args...), R_Patch(*patching_func)(Args_Patch...))
const CTypeInfo & ArgumentInfo(unsigned int index) const
CFunctionInfo::Int64Representation GetInt64Representation() const
OverloadResolution GetOverloadResolution(const CFunction *other)
const void * GetAddress() const
const CFunctionInfo * GetTypeInfo() const
unsigned int ArgumentCount() const
const CTypeInfo & ReturnInfo() const
static CFunction Make(F *func)
Int64Representation GetInt64Representation() const
const CTypeInfo & ArgumentInfo(unsigned int index) const
unsigned int ArgumentCount() const
CFunctionInfo(const CTypeInfo &return_info, unsigned int arg_count, const CTypeInfo *arg_info, Int64Representation repr=Int64Representation::kNumber)
const CTypeInfo & ReturnInfo() const
static constexpr CTypeInfo Build()
constexpr Identifier GetId() const
constexpr SequenceType GetSequenceType() const
static constexpr Type kCallbackOptionsType
static constexpr bool IsIntegralType(Type type)
constexpr CTypeInfo(Identifier identifier)
constexpr CTypeInfo(Type type, SequenceType sequence_type=SequenceType::kScalar, Flags flags=Flags::kNone)
constexpr Flags GetFlags() const
static constexpr bool IsFloatingPointType(Type type)
constexpr Type GetType() const
static constexpr bool IsPrimitive(Type type)
constexpr auto Fn(R(*fn)(Args...))
constexpr CFunctionBuilderWithFunction(const void *fn)
auto Patch(Ret(*patching_func)(Args...))
bool V8_EXPORT V8_WARN_UNUSED_RESULT TryToCopyAndConvertArrayToCppBuffer(Local< Array > src, T *dst, uint32_t max_length)
FastApiTypedArray< uint8_t > *const wasm_memory
static FastApiCallbackOptions CreateForTesting(Isolate *isolate)
v8::Local< v8::Value > data
void V8_EXPORT ValidateIndex(size_t index) const
size_t V8_EXPORT length() const
V8_INLINE T get(size_t index) const
bool getStorageIfAligned(T **elements) const
static constexpr CTypeInfo::SequenceType SequenceType()
static constexpr CTypeInfo::SequenceType SequenceType()
static constexpr CTypeInfo::SequenceType SequenceType()
static constexpr CTypeInfo::SequenceType SequenceType()
const FastOneByteString * string_value
const FastApiTypedArray< int32_t > * int32_ta_value
const FastApiTypedArray< uint8_t > * uint8_ta_value
const FastApiTypedArray< uint32_t > * uint32_ta_value
FastApiCallbackOptions * options_value
const FastApiTypedArray< float > * float_ta_value
const FastApiTypedArray< double > * double_ta_value
Local< Object > object_value
Local< Array > sequence_value
const FastApiTypedArray< int64_t > * int64_ta_value
const FastApiTypedArray< uint64_t > * uint64_ta_value
#define DEFINE_TYPE_INFO_TRAITS(CType, Enum)
#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR_TA(T, Enum)
#define PRIMITIVE_C_TYPES(V)
#define TYPED_ARRAY_C_TYPES(V)
#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR(T, Enum)
#define ALL_C_TYPES(V)
#define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG)
#define V8_EXPORT
Definition v8config.h:753
#define V8_INLINE
Definition v8config.h:477
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:628
#define V8_TRIVIAL_ABI
Definition v8config.h:703