30#define FORWARD_DECLARE(Name, Argc) \
31 Address Builtin_##Name(int argc, Address* args, Isolate* isolate);
38struct BuiltinMetadata {
42 struct BytecodeAndScale {
49 static_assert(
sizeof(BytecodeAndScale) <=
sizeof(
Address));
52 union KindSpecificData {
60 constexpr KindSpecificData(
int parameter_count,
72#define DECL_CPP(Name, Argc) \
73 {#Name, Builtins::CPP, {FUNCTION_ADDR(Builtin_##Name)}},
74#define DECL_TSJ(Name, Count, ...) {#Name, Builtins::TSJ, {Count, 0}},
75#define DECL_TFJ(Name, Count, ...) {#Name, Builtins::TFJ, {Count, 0}},
76#define DECL_TSC(Name, ...) {#Name, Builtins::TSC, {}},
77#define DECL_TFC(Name, ...) {#Name, Builtins::TFC, {}},
78#define DECL_TFS(Name, ...) {#Name, Builtins::TFS, {}},
79#define DECL_TFH(Name, ...) {#Name, Builtins::TFH, {}},
80#define DECL_BCH(Name, OperandScale, Bytecode) \
81 {#Name, Builtins::BCH, {Bytecode, OperandScale}},
82#define DECL_ASM(Name, ...) {#Name, Builtins::ASM, {}},
83const BuiltinMetadata builtin_metadata[] = {
124 return name(builtin_ix);
162 return builtin_metadata[
ToInt(builtin)].data.parameter_count;
167 Builtin builtin,
int function_length,
168 int formal_parameter_count_with_receiver) {
180 if (builtin == Builtin::kCompileLazy) {
194#define CASE_OTHER(Name, ...) \
195 case Builtin::k##Name: { \
196 key = Builtin_##Name##_InterfaceDescriptor::key(); \
215 Handle<Code> code = isolate->builtins()->code_handle(builtin);
227 int index =
ToInt(builtin);
229 return builtin_metadata[
index].name;
234#if V8_ENABLE_WEBASSEMBLY
243 case Builtin::kDataViewPrototypeGetBigInt64:
244 return "DataView.prototype.getBigInt64";
245 case Builtin::kDataViewPrototypeGetBigUint64:
246 return "DataView.prototype.getBigUint64";
247 case Builtin::kDataViewPrototypeGetFloat16:
248 return "DataView.prototype.getFloat16";
249 case Builtin::kDataViewPrototypeGetFloat32:
250 return "DataView.prototype.getFloat32";
251 case Builtin::kDataViewPrototypeGetFloat64:
252 return "DataView.prototype.getFloat64";
253 case Builtin::kDataViewPrototypeGetInt8:
254 return "DataView.prototype.getInt8";
255 case Builtin::kDataViewPrototypeGetInt16:
256 return "DataView.prototype.getInt16";
257 case Builtin::kDataViewPrototypeGetInt32:
258 return "DataView.prototype.getInt32";
259 case Builtin::kDataViewPrototypeGetUint8:
260 return "DataView.prototype.getUint8";
261 case Builtin::kDataViewPrototypeGetUint16:
262 return "DataView.prototype.getUint16";
263 case Builtin::kDataViewPrototypeGetUint32:
264 return "DataView.prototype.getUint32";
265 case Builtin::kDataViewPrototypeSetBigInt64:
266 return "DataView.prototype.setBigInt64";
267 case Builtin::kDataViewPrototypeSetBigUint64:
268 return "DataView.prototype.setBigUint64";
269 case Builtin::kDataViewPrototypeSetFloat16:
270 return "DataView.prototype.setFloat16";
271 case Builtin::kDataViewPrototypeSetFloat32:
272 return "DataView.prototype.setFloat32";
273 case Builtin::kDataViewPrototypeSetFloat64:
274 return "DataView.prototype.setFloat64";
275 case Builtin::kDataViewPrototypeSetInt8:
276 return "DataView.prototype.setInt8";
277 case Builtin::kDataViewPrototypeSetInt16:
278 return "DataView.prototype.setInt16";
279 case Builtin::kDataViewPrototypeSetInt32:
280 return "DataView.prototype.setInt32";
281 case Builtin::kDataViewPrototypeSetUint8:
282 return "DataView.prototype.setUint8";
283 case Builtin::kDataViewPrototypeSetUint16:
284 return "DataView.prototype.setUint16";
285 case Builtin::kDataViewPrototypeSetUint32:
286 return "DataView.prototype.setUint32";
287 case Builtin::kDataViewPrototypeGetByteLength:
288 return "get DataView.prototype.byteLength";
289 case Builtin::kThrowDataViewDetachedError:
290 case Builtin::kThrowDataViewOutOfBounds:
291 case Builtin::kThrowDataViewTypeError: {
295 case Builtin::kStringPrototypeToLocaleLowerCase:
296 return "String.toLocaleLowerCase";
297 case Builtin::kStringPrototypeIndexOf:
298 case Builtin::kThrowIndexOfCalledOnNull:
299 return "String.indexOf";
301 case Builtin::kStringPrototypeToLowerCaseIntl:
303 case Builtin::kThrowToLowerCaseCalledOnNull:
304 return "String.toLowerCase";
305 case Builtin::kWasmIntToString:
306 return "Number.toString";
321#ifdef ENABLE_DISASSEMBLER
324 const char* builtin_name =
name(builtin);
330 builtin_code->Disassemble(builtin_name, os,
isolate_);
341 const char* builtin_name =
name(builtin);
344 PrintF(stdout,
"%s Builtin, %s, %d\n",
kind, builtin_name,
345 code->instruction_size());
352 return builtin_metadata[
ToInt(builtin)].data.cpp_entry;
364 if (handle_location < builtins_table)
return false;
366 if (handle_location >= builtins_table_end)
return false;
367 *builtin =
FromInt(
static_cast<int>(handle_location - builtins_table));
373 Builtin builtin = code->builtin_id();
381 IsolateData* isolate_data = isolate->isolate_data();
386 DCHECK(!isolate->builtins()->code(
i)->has_instruction_stream());
402 if (!isolate->IsLoggingCodeCreation())
return;
404 Address* builtins = isolate->builtin_table();
407 for (;
i <
ToInt(Builtin::kFirstBytecodeHandler);
i++) {
410 PROFILE(isolate, CodeCreateEvent(LogEventListener::CodeTag::kBuiltin, code,
419 builtin_metadata[
i].data.bytecode_and_scale.bytecode;
421 builtin_metadata[
i].data.bytecode_and_scale.scale;
424 LogEventListener::CodeTag::kBytecodeHandler, code,
433 DCHECK_NE(0, isolate->embedded_blob_code_size());
436 Builtin::kInterpreterEntryTrampolineForProfiling);
439 desc.
buffer =
reinterpret_cast<uint8_t*
>(code->instruction_start());
441 int instruction_size = code->instruction_size();
442 desc.buffer_size = instruction_size;
443 desc.instr_size = instruction_size;
447 DCHECK_EQ(code->safepoint_table_size(), 0);
448 DCHECK_EQ(code->handler_table_size(), 0);
449 DCHECK_EQ(code->constant_pool_size(), 0);
454 DCHECK_EQ(code->code_comments_size(), 0);
455 DCHECK_EQ(code->unwinding_info_size(), 0);
457 desc.safepoint_table_offset = instruction_size;
458 desc.handler_table_offset = instruction_size;
459 desc.constant_pool_offset = instruction_size;
460 desc.code_comments_offset = instruction_size;
461 desc.builtin_jump_table_info_offset = instruction_size;
473 return builtin_metadata[
ToInt(builtin)].kind;
481 case CPP:
return "CPP";
482 case TSJ:
return "TSJ";
483 case TFJ:
return "TFJ";
484 case TSC:
return "TSC";
485 case TFC:
return "TFC";
486 case TFS:
return "TFS";
487 case TFH:
return "TFH";
488 case BCH:
return "BCH";
489 case ASM:
return "ASM";
507#if V8_ENABLE_DRUMBRAKE
508 if (builtin == Builtin::kGenericJSToWasmInterpreterWrapper) {
510 }
else if (builtin == Builtin::kGenericWasmToJSInterpreterWrapper) {
537 if (
v8_flags.allow_unsafe_function_constructor)
return true;
541 if (responsible_context.
is_null()) {
544 if (*responsible_context == target->context())
return true;
545 return isolate->MayAccess(responsible_context, target_global_proxy);
549 size_t function_pointer_type_id) {
550 switch (function_pointer_type_id) {
551#define FUNCTION_POINTER_ID_CASE(id, name) \
553 return Builtin::k##name;
555#undef FUNCTION_POINTER_ID_CASE
#define BUILTIN_LIST_C(V)
#define IGNORE_BUILTIN(...)
BytecodeAndScale bytecode_and_scale
#define CASE_OTHER(Name,...)
#define DECL_TFJ(Name, Count,...)
#define DECL_ASM(Name,...)
#define DECL_TSC(Name,...)
#define DECL_TFC(Name,...)
#define DECL_TFS(Name,...)
#define FUNCTION_POINTER_ID_CASE(id, name)
interpreter::OperandScale scale
#define DECL_CPP(Name, Argc)
#define DECL_TSJ(Name, Count,...)
#define DECL_BCH(Name, OperandScale, Bytecode)
#define DECL_TFH(Name,...)
#define FORWARD_DECLARE(Name, Argc)
static bool AllowDynamicFunction(Isolate *isolate, DirectHandle< JSFunction > target, DirectHandle< JSObject > target_global_proxy)
static V8_EXPORT_PRIVATE bool IsCpp(Builtin builtin)
static bool IsIsolateIndependentBuiltin(Tagged< Code > code)
static V8_EXPORT_PRIVATE Kind KindOf(Builtin builtin)
V8_EXPORT_PRIVATE Tagged< Code > code(Builtin builtin)
V8_EXPORT_PRIVATE Handle< Code > code_handle(Builtin builtin)
static BytecodeOffset GetContinuationBytecodeOffset(Builtin builtin)
static CallInterfaceDescriptor CallInterfaceDescriptorFor(Builtin builtin)
static constexpr int kBuiltinCount
static constexpr int kLastBytecodeHandlerPlusOne
static Address CppEntryOf(Builtin builtin)
const char * Lookup(Address pc)
static constexpr Builtin kFirst
static int GetFormalParameterCount(Builtin builtin)
static V8_EXPORT_PRIVATE int GetStackParameterCount(Builtin builtin)
static Builtin GetBuiltinFromBytecodeOffset(BytecodeOffset)
FullObjectSlot builtin_slot(Builtin builtin)
FullObjectSlot builtin_tier0_slot(Builtin builtin)
static V8_EXPORT_PRIVATE CodeEntrypointTag EntrypointTagFor(Builtin builtin)
static constexpr bool IsIsolateIndependent(Builtin builtin)
static constexpr int ToInt(Builtin id)
static const char * KindNameOf(Builtin builtin)
static void InitializeIsolateDataTables(Isolate *isolate)
static void EmitCodeCreateEvents(Isolate *isolate)
static V8_EXPORT_PRIVATE const char * NameForStackTrace(Isolate *isolate, Builtin builtin)
static DirectHandle< Code > CreateInterpreterEntryTrampolineForProfiling(Isolate *isolate)
void set_code(Builtin builtin, Tagged< Code > code)
static constexpr bool IsBuiltinId(Builtin builtin)
static constexpr Builtin FromInt(int id)
static constexpr bool IsTier0(Builtin builtin)
static V8_EXPORT_PRIVATE bool HasJSLinkage(Builtin builtin)
static constexpr Builtin kLast
bool IsBuiltinHandle(IndirectHandle< HeapObject > maybe_code, Builtin *index) const
static bool IsBuiltin(const Tagged< Code > code)
static constexpr Builtin kLastTier0
static V8_EXPORT_PRIVATE const char * name(Builtin builtin)
static bool CheckFormalParameterCount(Builtin builtin, int function_length, int formal_parameter_count_with_receiver)
static V8_EXPORT_PRIVATE Callable CallableFor(Isolate *isolate, Builtin builtin)
static const int kFirstBuiltinContinuationId
CodeEntrypointTag tag() const
static void Verify(const CodeDesc *desc)
V8_INLINE bool is_null() const
static V8_INLINE DirectHandle FromSlot(Address *slot)
Address InstructionStartOf(Builtin builtin) const
static EmbeddedData FromBlob()
CodeBuilder & set_builtin(Builtin builtin)
V8_WARN_UNUSED_RESULT Handle< Code > Build()
V8_INLINE Address * location() const
static V8_INLINE constexpr bool HasHeapObjectTag(Address value)
Address * builtin_tier0_table()
Address * builtin_table()
Address * builtin_tier0_entry_table()
Address * builtin_entry_table()
static Builtin TryLookupCode(Isolate *isolate, Address address)
static const char * ToString(Bytecode bytecode)
#define PROFILE(the_isolate, Call)
Vector< const char > CStrVector(const char *data)
constexpr const char * ToString(DeoptimizeKind kind)
void PrintF(const char *format,...)
@ kBytecodeHandlerEntrypointTag
@ kDefaultCodeEntrypointTag
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
bool PassesFilter(base::Vector< const char > name, base::Vector< const char > filter)
V8_EXPORT_PRIVATE FlagValues v8_flags
static constexpr Address kNullAddress
Builtin ExampleBuiltinForTorqueFunctionPointerType(size_t function_pointer_type_id)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_LE(v1, v2)
#define DCHECK_NOT_NULL(val)
#define DCHECK_NE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)