v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtins-descriptors.h
Go to the documentation of this file.
1// Copyright 2017 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
5#ifndef V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
6#define V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
7
10#include "src/common/globals.h"
11
12namespace v8 {
13namespace internal {
14
15#ifdef V8_JS_LINKAGE_INCLUDES_DISPATCH_HANDLE
16#define DEFINE_TFJ_PARAMETER_INDICES(...) \
17 enum ParameterIndices { \
18 kJSTarget = kJSCallClosureParameterIndex, \
19 ##__VA_ARGS__, \
20 kJSNewTarget, \
21 kJSActualArgumentsCount, \
22 kJSDispatchHandle, \
23 kContext, \
24 kParameterCount, \
25 };
26constexpr size_t kJSBuiltinBaseParameterCount = 4;
27#else
28#define DEFINE_TFJ_PARAMETER_INDICES(...) \
29 enum ParameterIndices { \
30 kJSTarget = kJSCallClosureParameterIndex, \
31 ##__VA_ARGS__, \
32 kJSNewTarget, \
33 kJSActualArgumentsCount, \
34 kContext, \
35 kParameterCount, \
36 };
37constexpr size_t kJSBuiltinBaseParameterCount = 3;
38#endif
39
40// Define interface descriptors for builtins with JS linkage.
41#define DEFINE_TFJ_INTERFACE_DESCRIPTOR(Name, Argc, ...) \
42 struct Builtin_##Name##_InterfaceDescriptor { \
43 DEFINE_TFJ_PARAMETER_INDICES(__VA_ARGS__) \
44 static_assert(kParameterCount == kJSBuiltinBaseParameterCount + (Argc)); \
45 static_assert((Argc) == \
46 static_cast<uint16_t>(kParameterCount - \
47 kJSBuiltinBaseParameterCount), \
48 "Inconsistent set of arguments"); \
49 static_assert(kParameterCount - (Argc) == \
50 JSTrampolineDescriptor::kParameterCount, \
51 "Interface descriptors for JS builtins must be compatible " \
52 "with the general JS calling convention"); \
53 static_assert(kJSTarget == -1, "Unexpected kJSTarget index value"); \
54 };
55
56#define DEFINE_TSJ_INTERFACE_DESCRIPTOR(...) \
57 DEFINE_TFJ_INTERFACE_DESCRIPTOR(__VA_ARGS__)
58
59#define DEFINE_TSC_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
60 using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
61
62// Define interface descriptors for builtins with StubCall linkage.
63#define DEFINE_TFC_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
64 using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
65
66#define DEFINE_TFS_INTERFACE_DESCRIPTOR(Name, ...) \
67 using Builtin_##Name##_InterfaceDescriptor = Name##Descriptor;
68
69// Define interface descriptors for IC handlers/dispatchers.
70#define DEFINE_TFH_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
71 using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
72
73#define DEFINE_ASM_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
74 using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
75
81
82#undef DEFINE_TFJ_INTERFACE_DESCRIPTOR
83#undef DEFINE_TSJ_INTERFACE_DESCRIPTOR
84#undef DEFINE_TSC_INTERFACE_DESCRIPTOR
85#undef DEFINE_TFC_INTERFACE_DESCRIPTOR
86#undef DEFINE_TFS_INTERFACE_DESCRIPTOR
87#undef DEFINE_TFH_INTERFACE_DESCRIPTOR
88#undef DEFINE_ASM_INTERFACE_DESCRIPTOR
89
90} // namespace internal
91} // namespace v8
92
93#endif // V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
#define IGNORE_BUILTIN(...)
#define DEFINE_ASM_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor)
#define DEFINE_TSJ_INTERFACE_DESCRIPTOR(...)
#define DEFINE_TFS_INTERFACE_DESCRIPTOR(Name,...)
#define DEFINE_TFC_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor)
#define DEFINE_TFH_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor)
#define DEFINE_TSC_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor)
#define DEFINE_TFJ_INTERFACE_DESCRIPTOR(Name, Argc,...)
constexpr size_t kJSBuiltinBaseParameterCount