• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #include "src/builtins/builtins.h"
9 #include "src/codegen/interface-descriptors.h"
10 #include "src/compiler/code-assembler.h"
11 #include "src/objects/shared-function-info.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 // Define interface descriptors for builtins with JS linkage.
17 #define DEFINE_TFJ_INTERFACE_DESCRIPTOR(Name, Argc, ...)                \
18   struct Builtin_##Name##_InterfaceDescriptor {                         \
19     enum ParameterIndices {                                             \
20       kJSTarget = compiler::CodeAssembler::kTargetParameterIndex,       \
21       ##__VA_ARGS__,                                                    \
22       kJSNewTarget,                                                     \
23       kJSActualArgumentsCount,                                          \
24       kContext,                                                         \
25       kParameterCount,                                                  \
26     };                                                                  \
27     static_assert((Argc) == static_cast<uint16_t>(kParameterCount - 4), \
28                   "Inconsistent set of arguments");                     \
29     static_assert(kJSTarget == -1, "Unexpected kJSTarget index value"); \
30   };
31 
32 // Define interface descriptors for builtins with StubCall linkage.
33 #define DEFINE_TFC_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
34   using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
35 
36 #define DEFINE_TFS_INTERFACE_DESCRIPTOR(Name, ...) \
37   using Builtin_##Name##_InterfaceDescriptor = Name##Descriptor;
38 
39 // Define interface descriptors for IC handlers/dispatchers.
40 #define DEFINE_TFH_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
41   using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
42 
43 #define DEFINE_ASM_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
44   using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
45 
46 BUILTIN_LIST(IGNORE_BUILTIN, DEFINE_TFJ_INTERFACE_DESCRIPTOR,
47              DEFINE_TFC_INTERFACE_DESCRIPTOR, DEFINE_TFS_INTERFACE_DESCRIPTOR,
48              DEFINE_TFH_INTERFACE_DESCRIPTOR, IGNORE_BUILTIN,
49              DEFINE_ASM_INTERFACE_DESCRIPTOR)
50 
51 #undef DEFINE_TFJ_INTERFACE_DESCRIPTOR
52 #undef DEFINE_TFC_INTERFACE_DESCRIPTOR
53 #undef DEFINE_TFS_INTERFACE_DESCRIPTOR
54 #undef DEFINE_TFH_INTERFACE_DESCRIPTOR
55 #undef DEFINE_ASM_INTERFACE_DESCRIPTOR
56 
57 }  // namespace internal
58 }  // namespace v8
59 
60 #endif  // V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
61