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>
275 "TypedArrays are not supported directly anymore."),
276 // is void
277 kIsArrayBuffer // ArrayBuffer
278 };
279
280 enum class Flags : uint8_t {
281 kNone = 0,
282 kAllowSharedBit = 1 << 0, // Must be an ArrayBuffer or TypedArray
283 kEnforceRangeBit = 1 << 1, // T must be integral
284 kClampBit = 1 << 2, // T must be integral
285 kIsRestrictedBit = 1 << 3, // T must be float or double
286 };
287
288 explicit constexpr CTypeInfo(
289 Type type, SequenceType sequence_type = SequenceType::kScalar,
290 Flags flags = Flags::kNone)
291 : type_(type), sequence_type_(sequence_type), flags_(flags) {}
292
293 typedef uint32_t Identifier;
294 explicit constexpr CTypeInfo(Identifier identifier)
295 : CTypeInfo(static_cast<Type>(identifier >> 16),
296 static_cast<SequenceType>((identifier >> 8) & 255),
297 static_cast<Flags>(identifier & 255)) {}
298 constexpr Identifier GetId() const {
299 return static_cast<uint8_t>(type_) << 16 |
300 static_cast<uint8_t>(sequence_type_) << 8 |
301 static_cast<uint8_t>(flags_);
302 }
303
304 constexpr Type GetType() const { return type_; }
305 constexpr SequenceType GetSequenceType() const { return sequence_type_; }
306 constexpr Flags GetFlags() const { return flags_; }
307
308 static constexpr bool IsIntegralType(Type type) {
309 return type == Type::kUint8 || type == Type::kInt32 ||
310 type == Type::kUint32 || type == Type::kInt64 ||
311 type == Type::kUint64;
312 }
313
314 static constexpr bool IsFloatingPointType(Type type) {
315 return type == Type::kFloat32 || type == Type::kFloat64;
316 }
317
318 static constexpr bool IsPrimitive(Type type) {
319 return IsIntegralType(type) || IsFloatingPointType(type) ||
320 type == Type::kBool;
321 }
322
323 private:
324 Type type_;
325 SequenceType sequence_type_;
326 Flags flags_;
327};
328
330 "With the removal of FastApiTypedArray this type is not needed "
331 "anymore.") FastApiTypedArrayBase {
332 public:
333 // Returns the length in number of elements.
334 size_t V8_EXPORT length() const { return length_; }
335 // Checks whether the given index is within the bounds of the collection.
336 void V8_EXPORT ValidateIndex(size_t index) const;
337
338 protected:
339 size_t length_ = 0;
340};
341
342struct V8_DEPRECATED("This API is dead within V8") FastApiArrayBufferView {
343 void* data;
345};
346
347struct V8_DEPRECATED("This API is dead within V8") FastApiArrayBuffer {
348 void* data;
350};
351
353 const char* data;
354 uint32_t length;
355};
356
358 public:
359 enum class Int64Representation : uint8_t {
360 kNumber = 0, // Use numbers to represent 64 bit integers.
361 kBigInt = 1, // Use BigInts to represent 64 bit integers.
362 };
363
364 // Construct a struct to hold a CFunction's type information.
365 // |return_info| describes the function's return type.
366 // |arg_info| is an array of |arg_count| CTypeInfos describing the
367 // arguments. Only the last argument may be of the special type
368 // CTypeInfo::kCallbackOptionsType.
369 CFunctionInfo(const CTypeInfo& return_info, unsigned int arg_count,
370 const CTypeInfo* arg_info,
371 Int64Representation repr = Int64Representation::kNumber);
372
373 const CTypeInfo& ReturnInfo() const { return return_info_; }
374
375 // The argument count, not including the v8::FastApiCallbackOptions
376 // if present.
377 unsigned int ArgumentCount() const {
378 return HasOptions() ? arg_count_ - 1 : arg_count_;
379 }
380
382
383 // |index| must be less than ArgumentCount().
384 // Note: if the last argument passed on construction of CFunctionInfo
385 // has type CTypeInfo::kCallbackOptionsType, it is not included in
386 // ArgumentCount().
387 const CTypeInfo& ArgumentInfo(unsigned int index) const;
388
389 bool HasOptions() const {
390 // The options arg is always the last one.
391 return arg_count_ > 0 && arg_info_[arg_count_ - 1].GetType() ==
392 CTypeInfo::kCallbackOptionsType;
393 }
394
395 private:
396 const CTypeInfo return_info_;
397 const Int64Representation repr_;
398 const unsigned int arg_count_;
399 const CTypeInfo* arg_info_;
400};
401
402struct FastApiCallbackOptions;
403
404// Provided for testing.
406 AnyCType() : int64_value(0) {}
407
408#if defined(V8_ENABLE_LOCAL_OFF_STACK_CHECK) && V8_HAS_ATTRIBUTE_TRIVIAL_ABI
409 // In this case, Local<T> is not trivially copyable and the implicit
410 // copy constructor and copy assignment for the union are deleted.
411 AnyCType(const AnyCType& other) : int64_value(other.int64_value) {}
412 AnyCType& operator=(const AnyCType& other) {
413 int64_value = other.int64_value;
414 return *this;
415 }
416#endif
417
419 int32_t int32_value;
420 uint32_t uint32_value;
421 int64_t int64_value;
422 uint64_t uint64_value;
430};
431
432static_assert(
433 sizeof(AnyCType) == 8,
434 "The union AnyCType should have size == 64 bits, as this is assumed "
435 "by EffectControlLinearizer.");
436
438 public:
439 constexpr CFunction() : address_(nullptr), type_info_(nullptr) {}
440
441 const CTypeInfo& ReturnInfo() const { return type_info_->ReturnInfo(); }
442
443 const CTypeInfo& ArgumentInfo(unsigned int index) const {
444 return type_info_->ArgumentInfo(index);
445 }
446
447 unsigned int ArgumentCount() const { return type_info_->ArgumentCount(); }
448
449 const void* GetAddress() const { return address_; }
451 return type_info_->GetInt64Representation();
452 }
453 const CFunctionInfo* GetTypeInfo() const { return type_info_; }
454
455 enum class OverloadResolution { kImpossible, kAtRuntime, kAtCompileTime };
456
457 // Returns whether an overload between this and the given CFunction can
458 // be resolved at runtime by the RTTI available for the arguments or at
459 // compile time for functions with different number of arguments.
461 "Overload resolution is only based on the parameter count. If the "
462 "parameter count is different, overload resolution is possible and "
463 "happens at compile time. Otherwise overload resolution is impossible.")
464 OverloadResolution GetOverloadResolution(const CFunction* other) {
465 // Runtime overload resolution can only deal with functions with the
466 // same number of arguments. Functions with different arity are handled
467 // by compile time overload resolution though.
468 if (ArgumentCount() != other->ArgumentCount()) {
469 return OverloadResolution::kAtCompileTime;
470 }
471
472 // The functions can only differ by a single argument position.
473 int diff_index = -1;
474 for (unsigned int i = 0; i < ArgumentCount(); ++i) {
475 if (ArgumentInfo(i).GetSequenceType() !=
476 other->ArgumentInfo(i).GetSequenceType()) {
477 if (diff_index >= 0) {
478 return OverloadResolution::kImpossible;
479 }
480 diff_index = i;
481
482 // We only support overload resolution between sequence types.
483 if (ArgumentInfo(i).GetSequenceType() ==
484 CTypeInfo::SequenceType::kScalar ||
485 other->ArgumentInfo(i).GetSequenceType() ==
486 CTypeInfo::SequenceType::kScalar) {
487 return OverloadResolution::kImpossible;
488 }
489 }
490 }
491
492 return OverloadResolution::kAtRuntime;
493 }
494
495 template <typename F>
496 static CFunction Make(F* func,
498 CFunctionInfo::Int64Representation::kNumber) {
499 CFunction result = ArgUnwrap<F*>::Make(func, int64_rep);
500 result.GetInt64Representation();
501 return result;
502 }
503
504 // Provided for testing purposes.
505 template <typename R, typename... Args, typename R_Patch,
506 typename... Args_Patch>
507 static CFunction Make(R (*func)(Args...),
508 R_Patch (*patching_func)(Args_Patch...),
510 CFunctionInfo::Int64Representation::kNumber) {
511 CFunction c_func = ArgUnwrap<R (*)(Args...)>::Make(func, int64_rep);
512 static_assert(
513 sizeof...(Args_Patch) == sizeof...(Args),
514 "The patching function must have the same number of arguments.");
515 c_func.address_ = reinterpret_cast<void*>(patching_func);
516 return c_func;
517 }
518
519 CFunction(const void* address, const CFunctionInfo* type_info);
520
521 private:
522 const void* address_;
523 const CFunctionInfo* type_info_;
524
525 template <typename F>
526 class ArgUnwrap {
527 static_assert(sizeof(F) != sizeof(F),
528 "CFunction must be created from a function pointer.");
529 };
530
531 template <typename R, typename... Args>
532 class ArgUnwrap<R (*)(Args...)> {
533 public:
534 static CFunction Make(R (*func)(Args...),
536 CFunctionInfo::Int64Representation::kNumber);
537 };
538};
539
552 return {};
553 }
554
556
561};
562
563namespace internal {
564
565// Helper to count the number of occurances of `T` in `List`
566template <typename T, typename... List>
567struct count : std::integral_constant<int, 0> {};
568template <typename T, typename... Args>
569struct count<T, T, Args...>
570 : std::integral_constant<std::size_t, 1 + count<T, Args...>::value> {};
571template <typename T, typename U, typename... Args>
572struct count<T, U, Args...> : count<T, Args...> {};
573
574template <CFunctionInfo::Int64Representation Representation,
575 typename RetBuilder, typename... ArgBuilders>
577 static constexpr int kOptionsArgCount =
578 count<FastApiCallbackOptions&, ArgBuilders...>();
579 static constexpr int kReceiverCount = 1;
580
581 static_assert(kOptionsArgCount == 0 || kOptionsArgCount == 1,
582 "Only one options parameter is supported.");
583
584 static_assert(sizeof...(ArgBuilders) >= kOptionsArgCount + kReceiverCount,
585 "The receiver or the options argument is missing.");
586
587 public:
589 : CFunctionInfo(RetBuilder::Build(), sizeof...(ArgBuilders),
590 arg_info_storage_, Representation),
591 arg_info_storage_{ArgBuilders::Build()...} {
592 constexpr CTypeInfo::Type kReturnType = RetBuilder::Build().GetType();
593 static_assert(kReturnType == CTypeInfo::Type::kVoid ||
594 kReturnType == CTypeInfo::Type::kBool ||
595 kReturnType == CTypeInfo::Type::kInt32 ||
596 kReturnType == CTypeInfo::Type::kUint32 ||
597 kReturnType == CTypeInfo::Type::kInt64 ||
598 kReturnType == CTypeInfo::Type::kUint64 ||
599 kReturnType == CTypeInfo::Type::kFloat32 ||
600 kReturnType == CTypeInfo::Type::kFloat64 ||
601 kReturnType == CTypeInfo::Type::kPointer ||
602 kReturnType == CTypeInfo::Type::kAny,
603 "String and api object values are not currently "
604 "supported return types.");
605 }
606
607 private:
608 const CTypeInfo arg_info_storage_[sizeof...(ArgBuilders)];
609};
610
611template <typename T>
613 static_assert(sizeof(T) != sizeof(T), "This type is not supported");
614};
615
616#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR(T, Enum) \
617 template <> \
618 struct TypeInfoHelper<T> { \
619 static constexpr CTypeInfo::Flags Flags() { \
620 return CTypeInfo::Flags::kNone; \
621 } \
622 \
623 static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \
624 static constexpr CTypeInfo::SequenceType SequenceType() { \
625 return CTypeInfo::SequenceType::kScalar; \
626 } \
627 };
628
629template <CTypeInfo::Type type>
631
632#define DEFINE_TYPE_INFO_TRAITS(CType, Enum) \
633 template <> \
634 struct CTypeInfoTraits<CTypeInfo::Type::Enum> { \
635 using ctype = CType; \
636 };
637
638#define PRIMITIVE_C_TYPES(V) \
639 V(bool, kBool) \
640 V(uint8_t, kUint8) \
641 V(int32_t, kInt32) \
642 V(uint32_t, kUint32) \
643 V(int64_t, kInt64) \
644 V(uint64_t, kUint64) \
645 V(float, kFloat32) \
646 V(double, kFloat64) \
647 V(void*, kPointer)
648
649// Same as above, but includes deprecated types for compatibility.
650#define ALL_C_TYPES(V) \
651 PRIMITIVE_C_TYPES(V) \
652 V(void, kVoid) \
653 V(v8::Local<v8::Value>, kV8Value) \
654 V(v8::Local<v8::Object>, kV8Value) \
655 V(AnyCType, kAny)
656
657// ApiObject was a temporary solution to wrap the pointer to the v8::Value.
658// Please use v8::Local<v8::Value> in new code for the arguments and
659// v8::Local<v8::Object> for the receiver, as ApiObject will be deprecated.
660
663
664#undef PRIMITIVE_C_TYPES
665#undef ALL_C_TYPES
666
667#undef TYPED_ARRAY_C_TYPES
669template <>
670struct TypeInfoHelper<v8::Local<v8::Array>> {
671 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
672
673 static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kVoid; }
674 static constexpr CTypeInfo::SequenceType SequenceType() {
676 }
678
679template <>
681 "TypedArrays are not supported directly anymore. Use Local<Value> instead.")
682 TypeInfoHelper<v8::Local<v8::Uint32Array>> {
683 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
684
685 static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kUint32; }
686 static constexpr CTypeInfo::SequenceType SequenceType() {
687 return CTypeInfo::SequenceType::kIsTypedArray;
688 }
691template <>
693 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
694
695 static constexpr CTypeInfo::Type Type() {
697 }
698 static constexpr CTypeInfo::SequenceType SequenceType() {
700 }
703template <>
705 static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
706
707 static constexpr CTypeInfo::Type Type() {
709 }
710 static constexpr CTypeInfo::SequenceType SequenceType() {
713};
714
715#define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG) \
716 static_assert(((COND) == 0) || (ASSERTION), MSG)
717
718} // namespace internal
719
720template <typename T, CTypeInfo::Flags... Flags>
722 public:
723 using BaseType = T;
724
726 static constexpr CTypeInfo Build() {
727 constexpr CTypeInfo::Flags kFlags =
728 MergeFlags(internal::TypeInfoHelper<T>::Flags(), Flags...);
730 constexpr CTypeInfo::SequenceType kSequenceType =
732
734 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kAllowSharedBit),
735 (kSequenceType == CTypeInfo::SequenceType::kIsTypedArray ||
736 kSequenceType == CTypeInfo::SequenceType::kIsArrayBuffer),
737 "kAllowSharedBit is only allowed for TypedArrays and ArrayBuffers.");
739 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kEnforceRangeBit),
740 CTypeInfo::IsIntegralType(kType),
741 "kEnforceRangeBit is only allowed for integral types.");
743 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kClampBit),
744 CTypeInfo::IsIntegralType(kType),
745 "kClampBit is only allowed for integral types.");
747 uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kIsRestrictedBit),
748 CTypeInfo::IsFloatingPointType(kType),
749 "kIsRestrictedBit is only allowed for floating point types.");
750 STATIC_ASSERT_IMPLIES(kSequenceType == CTypeInfo::SequenceType::kIsSequence,
751 kType == CTypeInfo::Type::kVoid,
752 "Sequences are only supported from void type.");
754 kSequenceType == CTypeInfo::SequenceType::kIsTypedArray,
755 CTypeInfo::IsPrimitive(kType) || kType == CTypeInfo::Type::kVoid,
756 "TypedArrays are only supported from primitive types or void.");
757
758 // Return the same type with the merged flags.
761 }
763
764 private:
765 template <typename... Rest>
766 static constexpr CTypeInfo::Flags MergeFlags(CTypeInfo::Flags flags,
767 Rest... rest) {
768 return CTypeInfo::Flags(uint8_t(flags) | uint8_t(MergeFlags(rest...)));
769 }
770 static constexpr CTypeInfo::Flags MergeFlags() { return CTypeInfo::Flags(0); }
771};
773namespace internal {
774template <typename RetBuilder, typename... ArgBuilders>
776 public:
777 explicit constexpr CFunctionBuilderWithFunction(const void* fn) : fn_(fn) {}
778
779 template <CTypeInfo::Flags... Flags>
780 constexpr auto Ret() {
782 CTypeInfoBuilder<typename RetBuilder::BaseType, Flags...>,
783 ArgBuilders...>(fn_);
785
786 template <unsigned int N, CTypeInfo::Flags... Flags>
787 constexpr auto Arg() {
788 // Return a copy of the builder with the Nth arg builder merged with
789 // template parameter pack Flags.
790 return ArgImpl<N, Flags...>(
791 std::make_index_sequence<sizeof...(ArgBuilders)>());
792 }
794 // Provided for testing purposes.
795 template <typename Ret, typename... Args>
796 auto Patch(Ret (*patching_func)(Args...)) {
797 static_assert(
798 sizeof...(Args) == sizeof...(ArgBuilders),
799 "The patching function must have the same number of arguments.");
800 fn_ = reinterpret_cast<void*>(patching_func);
801 return *this;
802 }
804 template <CFunctionInfo::Int64Representation Representation =
806 auto Build() {
807 static CFunctionInfoImpl<Representation, RetBuilder, ArgBuilders...>
808 instance;
809 return CFunction(fn_, &instance);
810 }
811
812 private:
813 template <bool Merge, unsigned int N, CTypeInfo::Flags... Flags>
814 struct GetArgBuilder;
815
816 // Returns the same ArgBuilder as the one at index N, including its flags.
817 // Flags in the template parameter pack are ignored.
818 template <unsigned int N, CTypeInfo::Flags... Flags>
819 struct GetArgBuilder<false, N, Flags...> {
820 using type =
821 typename std::tuple_element<N, std::tuple<ArgBuilders...>>::type;
822 };
823
824 // Returns an ArgBuilder with the same base type as the one at index N,
825 // but merges the flags with the flags in the template parameter pack.
826 template <unsigned int N, CTypeInfo::Flags... Flags>
827 struct GetArgBuilder<true, N, Flags...> {
828 using type = CTypeInfoBuilder<
829 typename std::tuple_element<N,
830 std::tuple<ArgBuilders...>>::type::BaseType,
831 std::tuple_element<N, std::tuple<ArgBuilders...>>::type::Build()
832 .GetFlags(),
833 Flags...>;
834 };
835
836 // Return a copy of the CFunctionBuilder, but merges the Flags on
837 // ArgBuilder index N with the new Flags passed in the template parameter
838 // pack.
839 template <unsigned int N, CTypeInfo::Flags... Flags, size_t... I>
840 constexpr auto ArgImpl(std::index_sequence<I...>) {
841 return CFunctionBuilderWithFunction<
842 RetBuilder, typename GetArgBuilder<N == I, I, Flags...>::type...>(fn_);
843 }
844
845 const void* fn_;
846};
848class CFunctionBuilder {
849 public:
850 constexpr CFunctionBuilder() {}
851
852 template <typename R, typename... Args>
853 constexpr auto Fn(R (*fn)(Args...)) {
856 reinterpret_cast<const void*>(fn));
857 }
858};
859
860} // namespace internal
861
862// static
863template <typename R, typename... Args>
864CFunction CFunction::ArgUnwrap<R (*)(Args...)>::Make(
865 R (*func)(Args...), CFunctionInfo::Int64Representation int64_rep) {
867 return internal::CFunctionBuilder().Fn(func).Build();
868 }
869 return internal::CFunctionBuilder()
870 .Fn(func)
871 .template Build<CFunctionInfo::Int64Representation::kBigInt>();
872}
873
874using CFunctionBuilder = internal::CFunctionBuilder;
875
876static constexpr CTypeInfo kTypeInfoInt32 = CTypeInfo(CTypeInfo::Type::kInt32);
877static constexpr CTypeInfo kTypeInfoFloat64 =
878 CTypeInfo(CTypeInfo::Type::kFloat64);
879
892template <CTypeInfo::Identifier type_info_id, typename T>
894 Local<Array> src, T* dst, uint32_t max_length);
895
896template <>
898TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<int32_t>::Build().GetId(),
899 int32_t>(Local<Array> src, int32_t* dst,
900 uint32_t max_length);
901
902template <>
904TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<uint32_t>::Build().GetId(),
905 uint32_t>(Local<Array> src, uint32_t* dst,
906 uint32_t max_length);
907
908template <>
910TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<float>::Build().GetId(),
911 float>(Local<Array> src, float* dst,
912 uint32_t max_length);
913
914template <>
916TryToCopyAndConvertArrayToCppBuffer<CTypeInfoBuilder<double>::Build().GetId(),
917 double>(Local<Array> src, double* dst,
918 uint32_t max_length);
919
920} // namespace v8
921
922#endif // INCLUDE_V8_FAST_API_CALLS_H_
Definition: v8-fast-api-calls.h:357
Int64Representation GetInt64Representation() const
Definition: v8-fast-api-calls.h:381
Int64Representation
Definition: v8-fast-api-calls.h:359
const CTypeInfo & ReturnInfo() const
Definition: v8-fast-api-calls.h:373
const CTypeInfo & ArgumentInfo(unsigned int index) const
bool HasOptions() const
Definition: v8-fast-api-calls.h:389
unsigned int ArgumentCount() const
Definition: v8-fast-api-calls.h:377
CFunctionInfo(const CTypeInfo &return_info, unsigned int arg_count, const CTypeInfo *arg_info, Int64Representation repr=Int64Representation::kNumber)
Definition: v8-fast-api-calls.h:437
const CTypeInfo & ReturnInfo() const
Definition: v8-fast-api-calls.h:441
constexpr CFunction()
Definition: v8-fast-api-calls.h:439
const CTypeInfo & ArgumentInfo(unsigned int index) const
Definition: v8-fast-api-calls.h:443
unsigned int ArgumentCount() const
Definition: v8-fast-api-calls.h:447
CFunctionInfo::Int64Representation GetInt64Representation() const
Definition: v8-fast-api-calls.h:450
CFunction(const void *address, const CFunctionInfo *type_info)
static CFunction Make(R(*func)(Args...), R_Patch(*patching_func)(Args_Patch...), CFunctionInfo::Int64Representation int64_rep=CFunctionInfo::Int64Representation::kNumber)
Definition: v8-fast-api-calls.h:507
const void * GetAddress() const
Definition: v8-fast-api-calls.h:449
OverloadResolution
Definition: v8-fast-api-calls.h:455
const CFunctionInfo * GetTypeInfo() const
Definition: v8-fast-api-calls.h:453
static CFunction Make(F *func, CFunctionInfo::Int64Representation int64_rep=CFunctionInfo::Int64Representation::kNumber)
Definition: v8-fast-api-calls.h:496
Definition: v8-fast-api-calls.h:718
static constexpr CTypeInfo Build()
Definition: v8-fast-api-calls.h:723
T BaseType
Definition: v8-fast-api-calls.h:720
Definition: v8-fast-api-calls.h:238
Flags
Definition: v8-fast-api-calls.h:280
constexpr CTypeInfo(Type type, SequenceType sequence_type=SequenceType::kScalar, Flags flags=Flags::kNone)
Definition: v8-fast-api-calls.h:288
static constexpr bool IsFloatingPointType(Type type)
Definition: v8-fast-api-calls.h:314
static constexpr bool IsPrimitive(Type type)
Definition: v8-fast-api-calls.h:318
static constexpr Type kCallbackOptionsType
Definition: v8-fast-api-calls.h:269
static constexpr bool IsIntegralType(Type type)
Definition: v8-fast-api-calls.h:308
SequenceType
Definition: v8-fast-api-calls.h:271
constexpr Identifier GetId() const
Definition: v8-fast-api-calls.h:298
constexpr Type GetType() const
Definition: v8-fast-api-calls.h:304
constexpr Flags GetFlags() const
Definition: v8-fast-api-calls.h:306
Type
Definition: v8-fast-api-calls.h:240
uint32_t Identifier
Definition: v8-fast-api-calls.h:293
constexpr CTypeInfo(Identifier identifier)
Definition: v8-fast-api-calls.h:294
constexpr SequenceType GetSequenceType() const
Definition: v8-fast-api-calls.h:305
Definition: v8-isolate.h:212
Definition: v8-local-handle.h:266
Definition: v8-fast-api-calls.h:772
auto Build()
Definition: v8-fast-api-calls.h:803
constexpr auto Ret()
Definition: v8-fast-api-calls.h:777
constexpr auto Arg()
Definition: v8-fast-api-calls.h:784
auto Patch(Ret(*patching_func)(Args...))
Definition: v8-fast-api-calls.h:793
Definition: v8-fast-api-calls.h:845
constexpr CFunctionBuilder()
Definition: v8-fast-api-calls.h:847
constexpr auto Fn(R(*fn)(Args...))
Definition: v8-fast-api-calls.h:850
Definition: v8-fast-api-calls.h:576
constexpr CFunctionInfoImpl()
Definition: v8-fast-api-calls.h:588
Definition: libplatform.h:15
bool TryToCopyAndConvertArrayToCppBuffer(Local< Array > src, T *dst, uint32_t max_length)
internal::CFunctionBuilder CFunctionBuilder
Definition: v8-fast-api-calls.h:871
Definition: v8-fast-api-calls.h:342
size_t byte_length
Definition: v8-fast-api-calls.h:344
void * data
Definition: v8-fast-api-calls.h:343
Definition: v8-fast-api-calls.h:347
void * data
Definition: v8-fast-api-calls.h:348
size_t byte_length
Definition: v8-fast-api-calls.h:349
Definition: v8-fast-api-calls.h:546
v8::Isolate * isolate
Definition: v8-fast-api-calls.h:555
v8::Local< v8::Value > data
Definition: v8-fast-api-calls.h:560
static FastApiCallbackOptions CreateForTesting(Isolate *isolate)
Definition: v8-fast-api-calls.h:551
Definition: v8-fast-api-calls.h:331
size_t length() const
Definition: v8-fast-api-calls.h:334
void ValidateIndex(size_t index) const
Definition: v8-fast-api-calls.h:352
const char * data
Definition: v8-fast-api-calls.h:353
uint32_t length
Definition: v8-fast-api-calls.h:354
Definition: v8-fast-api-calls.h:630
Definition: v8-fast-api-calls.h:612
Definition: v8-fast-api-calls.h:567
Definition: v8-fast-api-calls.h:405
FastApiCallbackOptions * options_value
Definition: v8-fast-api-calls.h:429
AnyCType()
Definition: v8-fast-api-calls.h:406
const FastOneByteString * string_value
Definition: v8-fast-api-calls.h:428
Local< Array > sequence_value
Definition: v8-fast-api-calls.h:427
Local< Object > object_value
Definition: v8-fast-api-calls.h:426
double double_value
Definition: v8-fast-api-calls.h:424
void * pointer_value
Definition: v8-fast-api-calls.h:425
uint32_t uint32_value
Definition: v8-fast-api-calls.h:420
bool bool_value
Definition: v8-fast-api-calls.h:418
float float_value
Definition: v8-fast-api-calls.h:423
uint64_t uint64_value
Definition: v8-fast-api-calls.h:422
int32_t int32_value
Definition: v8-fast-api-calls.h:419
int64_t int64_value
Definition: v8-fast-api-calls.h:421
#define DEFINE_TYPE_INFO_TRAITS(CType, Enum)
Definition: v8-fast-api-calls.h:632
#define PRIMITIVE_C_TYPES(V)
Definition: v8-fast-api-calls.h:638
#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR(T, Enum)
Definition: v8-fast-api-calls.h:616
#define ALL_C_TYPES(V)
Definition: v8-fast-api-calls.h:650
#define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG)
Definition: v8-fast-api-calls.h:712
#define V8_EXPORT
Definition: v8config.h:793
#define V8_DEPRECATED(message)
Definition: v8config.h:595
#define END_ALLOW_USE_DEPRECATED()
Definition: v8config.h:623
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:660
#define V8_TRIVIAL_ABI
Definition: v8config.h:743
#define START_ALLOW_USE_DEPRECATED()
Definition: v8config.h:622