5 #ifndef V8_BUILTINS_BUILTINS_H_ 6 #define V8_BUILTINS_BUILTINS_H_ 8 #include "src/base/flags.h" 9 #include "src/builtins/builtins-definitions.h" 10 #include "src/globals.h" 24 enum class InterpreterPushArgsMode :
unsigned;
26 class CodeAssemblerState;
30 static constexpr T FirstFromVarArgs(T x, ...) noexcept {
35 #define BUILTIN_CODE(isolate, name) \ 36 (isolate)->builtins()->builtin_handle(Builtins::k##name) 48 #define DEF_ENUM(Name, ...) k##Name, 49 BUILTIN_LIST(DEF_ENUM, DEF_ENUM, DEF_ENUM, DEF_ENUM, DEF_ENUM, DEF_ENUM,
54 #define EXTRACT_NAME(Name, ...) k##Name, 56 kFirstBytecodeHandler =
57 FirstFromVarArgs(BUILTIN_LIST_BYTECODE_HANDLERS(EXTRACT_NAME) 0)
61 static const int32_t kNoBuiltinId = -1;
63 static constexpr
bool IsBuiltinId(
int maybe_id) {
64 return 0 <= maybe_id && maybe_id < builtin_count;
68 enum Kind { CPP, API, TFJ, TFC, TFS, TFH, BCH, ASM };
70 static BailoutId GetContinuationBailoutId(Name name);
71 static Name GetBuiltinFromBailoutId(
BailoutId);
74 Handle<Code> CallFunction(ConvertReceiverMode = ConvertReceiverMode::kAny);
77 ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
78 Handle<Code> OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint);
79 Handle<Code> InterpreterPushArgsThenCall(ConvertReceiverMode receiver_mode,
80 InterpreterPushArgsMode mode);
81 Handle<Code> InterpreterPushArgsThenConstruct(InterpreterPushArgsMode mode);
86 void set_builtin(
int index,
Code builtin);
88 Code builtin(
int index);
89 V8_EXPORT_PRIVATE
Handle<Code> builtin_handle(
int index);
91 V8_EXPORT_PRIVATE
static Callable CallableFor(
Isolate* isolate, Name name);
93 static int GetStackParameterCount(Name name);
95 static const char* name(
int index);
98 void PrintBuiltinCode();
99 void PrintBuiltinSize();
103 static Address CppEntryOf(
int index);
105 static Kind KindOf(
int index);
106 static const char* KindNameOf(
int index);
108 static bool IsCpp(
int index);
109 static bool HasCppImplementation(
int index);
113 static bool IsBuiltin(
const Code code);
120 static bool IsIsolateIndependentBuiltin(
const Code code);
122 static constexpr
int kFirstWideBytecodeHandler =
123 kFirstBytecodeHandler + kNumberOfBytecodeHandlers;
124 static constexpr
int kFirstExtraWideBytecodeHandler =
125 kFirstWideBytecodeHandler + kNumberOfWideBytecodeHandlers;
126 STATIC_ASSERT(kFirstExtraWideBytecodeHandler +
127 kNumberOfWideBytecodeHandlers ==
132 static bool IsIsolateIndependent(
int index) {
return true; }
137 static bool IsWasmRuntimeStub(
int index);
139 bool is_initialized()
const {
return initialized_; }
142 void MarkInitialized() {
143 DCHECK(!initialized_);
152 enum ExitFrameType { EXIT, BUILTIN_EXIT };
155 ExitFrameType exit_frame_type);
157 static void Generate_CEntry(
MacroAssembler* masm,
int result_size,
158 SaveFPRegsMode save_doubles, ArgvMode argv_mode,
159 bool builtin_exit_frame);
176 ConvertReceiverMode mode);
180 static void Generate_Call(
MacroAssembler* masm, ConvertReceiverMode mode);
182 enum class CallOrConstructMode { kCall, kConstruct };
185 static void Generate_CallOrConstructForwardVarargs(
MacroAssembler* masm,
186 CallOrConstructMode mode,
189 static void Generate_InterpreterPushArgsThenCallImpl(
191 InterpreterPushArgsMode mode);
193 static void Generate_InterpreterPushArgsThenConstructImpl(
196 #define DECLARE_ASM(Name, ...) \ 197 static void Generate_##Name(MacroAssembler* masm); 198 #define DECLARE_TF(Name, ...) \ 199 static void Generate_##Name(compiler::CodeAssemblerState* state); 201 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TF, DECLARE_TF,
202 DECLARE_TF, DECLARE_TF, IGNORE_BUILTIN, DECLARE_ASM)
208 bool initialized_ =
false;
215 Builtins::Name ExampleBuiltinForTorqueFunctionPointerType(
216 size_t function_pointer_type_id);
221 #endif // V8_BUILTINS_BUILTINS_H_