• 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                                                   kJSArgcReceiverSlots), \
29                   "Inconsistent set of arguments");                      \
30     static_assert(kJSTarget == -1, "Unexpected kJSTarget index value");  \
31   };
32 
33 // Define interface descriptors for builtins with StubCall linkage.
34 #define DEFINE_TFC_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
35   using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
36 
37 #define DEFINE_TFS_INTERFACE_DESCRIPTOR(Name, ...) \
38   using Builtin_##Name##_InterfaceDescriptor = Name##Descriptor;
39 
40 // Define interface descriptors for IC handlers/dispatchers.
41 #define DEFINE_TFH_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
42   using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
43 
44 #define DEFINE_ASM_INTERFACE_DESCRIPTOR(Name, InterfaceDescriptor) \
45   using Builtin_##Name##_InterfaceDescriptor = InterfaceDescriptor##Descriptor;
46 
47 BUILTIN_LIST(IGNORE_BUILTIN, DEFINE_TFJ_INTERFACE_DESCRIPTOR,
48              DEFINE_TFC_INTERFACE_DESCRIPTOR, DEFINE_TFS_INTERFACE_DESCRIPTOR,
49              DEFINE_TFH_INTERFACE_DESCRIPTOR, IGNORE_BUILTIN,
50              DEFINE_ASM_INTERFACE_DESCRIPTOR)
51 
52 #undef DEFINE_TFJ_INTERFACE_DESCRIPTOR
53 #undef DEFINE_TFC_INTERFACE_DESCRIPTOR
54 #undef DEFINE_TFS_INTERFACE_DESCRIPTOR
55 #undef DEFINE_TFH_INTERFACE_DESCRIPTOR
56 #undef DEFINE_ASM_INTERFACE_DESCRIPTOR
57 
58 }  // namespace internal
59 }  // namespace v8
60 
61 #endif  // V8_BUILTINS_BUILTINS_DESCRIPTORS_H_
62