10#include "builtins-generated/bytecodes-builtins-list.h"
29namespace interpreter {
36 std::vector<FunctionLiteral*>* eager_inner_literals,
51 template <
typename IsolateT>
55 template <
typename IsolateT>
67 interpreter_entry_trampoline_instruction_start_(
kNullAddress) {
76 static const int kBytecodeCount =
static_cast<int>(
Bytecode::kLast) + 1;
78 new uintptr_t[kBytecodeCount * kBytecodeCount]);
80 sizeof(uintptr_t) * kBytecodeCount * kBytecodeCount);
87 int index =
static_cast<int>(
bytecode);
88 if (operand_scale == OperandScale::kSingle) {
98 uint8_t
offset = kWideBytecodeToBuiltinsMapping[
index];
100 return Builtin::kIllegalHandler;
102 index = kNumberOfBytecodeHandlers +
offset;
103 if (operand_scale == OperandScale::kQuadruple) {
104 index += kNumberOfWideBytecodeHandlers;
116 Builtin builtin = BuiltinIndexFromBytecode(bytecode, operand_scale);
123 DCHECK(!handler->has_instruction_stream());
124 DCHECK(handler->kind() == CodeKind::BYTECODE_HANDLER);
132 static const size_t kEntriesPerOperandScale = 1u <<
kBitsPerByte;
133 size_t index =
static_cast<size_t>(
bytecode);
135 kEntriesPerOperandScale;
146 os <<
"[generating bytecode for function: " << name.get() <<
"]" << std::endl;
148 os <<
"--- AST ---" << std::endl
150 .PrintProgram(compilation_info->
literal())
156 if (!
v8_flags.print_bytecode)
return false;
159 if (shared->is_toplevel()) {
162 return filter.empty() || (filter.length() == 1 && filter[0] ==
'*');
164 return shared->PassesFilter(
v8_flags.print_bytecode_filter);
173 std::vector<FunctionLiteral*>* eager_inner_literals,
181 parse_info->ast_string_constants(), eager_inner_literals,
186 RuntimeCallCounterId::kCompileIgnition,
187 RuntimeCallStats::kThreadSpecific);
208template <
typename IsolateT>
212 int first_mismatch =
generator()->CheckBytecodeMatches(*bytecode);
213 if (first_mismatch >= 0) {
220 std::cerr <<
"Bytecode mismatch";
222 std::cerr <<
" found for function: ";
226 if (maybe_name.
ToHandle(&name) && name->length() != 0) {
227 name->PrintUC16(std::cerr);
229 std::cerr <<
"anonymous";
232 if (IsString(script_name)) {
238 std::cerr <<
"\nOriginal bytecode:\n";
239 bytecode->Disassemble(std::cerr);
240 std::cerr <<
"\nNew bytecode:\n";
241 new_bytecode->Disassemble(std::cerr);
242 FATAL(
"Bytecode mismatch at offset %d\n", first_mismatch);
250 RuntimeCallCounterId::kCompileIgnitionFinalization);
252 "V8.CompileIgnitionFinalization");
258 RCS_SCOPE(isolate, RuntimeCallCounterId::kCompileIgnitionFinalization,
259 RuntimeCallStats::kThreadSpecific);
261 "V8.CompileIgnitionFinalization");
265template <
typename IsolateT>
269 if (bytecodes.is_null()) {
282 bytecodes->set_source_position_table(*source_position_table,
kReleaseStore);
285 if (ShouldPrintBytecode(shared_info)) {
287 std::unique_ptr<char[]> name =
289 os <<
"[generated bytecode for function: " << name.get() <<
" ("
290 << shared_info <<
")]" << std::endl;
291 os <<
"Bytecode length: " << bytecodes->length() << std::endl;
292 bytecodes->Disassemble(os);
311 std::vector<FunctionLiteral*>* eager_inner_literals,
313 return std::make_unique<InterpreterCompilationJob>(
314 parse_info,
literal, script, allocator, eager_inner_literals,
318std::unique_ptr<UnoptimizedCompilationJob>
323 auto job = std::make_unique<InterpreterCompilationJob>(
325 job->compilation_info()->SetBytecodeArray(existing_bytecode);
332#define VALUE(Name, _) OperandScale::k##Name,
350 DCHECK(builtins->is_initialized());
351 DCHECK(!code->has_instruction_stream());
356 Builtin builtin = BuiltinIndexFromBytecode(bytecode, operand_scale);
361 std::string expected_name =
383 "Dispatch counters require building with "
384 "v8_enable_ignition_dispatch_counting");
interpreter::Bytecode bytecode
#define BUILTIN_CODE(isolate, name)
#define OPERAND_SCALE_LIST(V)
void Internalize(IsolateT *isolate)
V8_EXPORT_PRIVATE Tagged< Code > code(Builtin builtin)
static constexpr Builtin FromInt(int id)
static V8_EXPORT_PRIVATE const char * name(Builtin builtin)
static V8_EXPORT_PRIVATE void AllocateScopeInfos(ParseInfo *info, DirectHandle< Script > script, IsolateT *isolate)
DirectHandle< Number > NewNumberFromSize(size_t value)
Handle< JSObject > NewJSObjectWithNullProto()
MaybeHandle< String > GetName(IsolateT *isolate) const
int start_position() const
std::unique_ptr< char[]> GetDebugName() const
void set_shared_function_info(Handle< SharedFunctionInfo > shared_function_info)
v8::internal::Factory * factory()
static V8_EXPORT_PRIVATE void AddProperty(Isolate *isolate, DirectHandle< JSObject > object, DirectHandle< Name > name, DirectHandle< Object > value, PropertyAttributes attributes)
V8_INLINE void ParkIfOnBackgroundAndExecute(Callback callback)
V8_WARN_UNUSED_RESULT V8_INLINE bool ToHandle(DirectHandle< S > *out) const
FunctionLiteral * literal() const
uintptr_t stack_limit() const
AstValueFactory * ast_value_factory() const
@ RECORD_SOURCE_POSITIONS
void SetBytecodeArray(Handle< BytecodeArray > bytecode_array)
FunctionLiteral * literal() const
Handle< BytecodeArray > bytecode_array() const
ParseInfo * parse_info() const
uintptr_t stack_limit() const
UnoptimizedCompilationInfo * compilation_info() const
void GenerateBytecode(uintptr_t stack_limit)
DirectHandle< TrustedByteArray > FinalizeSourcePositionTable(IsolateT *isolate)
Handle< BytecodeArray > FinalizeBytecode(IsolateT *isolate, Handle< Script > script)
static constexpr int OperandScaleAsIndex(OperandScale operand_scale)
static Bytecode FromByte(uint8_t value)
static const int kBytecodeCount
static uint8_t ToByte(Bytecode bytecode)
static constexpr bool IsShortStar(Bytecode bytecode)
static const char * ToString(Bytecode bytecode)
static bool BytecodeHasHandler(Bytecode bytecode, OperandScale operand_scale)
static const int kShortStarCount
InterpreterCompilationJob & operator=(const InterpreterCompilationJob &)=delete
LocalIsolate * local_isolate_
Status ExecuteJobImpl() final
Status FinalizeJobImpl(DirectHandle< SharedFunctionInfo > shared_info, Isolate *isolate) final
UnoptimizedCompilationInfo compilation_info_
InterpreterCompilationJob(ParseInfo *parse_info, FunctionLiteral *literal, Handle< Script > script, AccountingAllocator *allocator, std::vector< FunctionLiteral * > *eager_inner_literals, LocalIsolate *local_isolate)
InterpreterCompilationJob(const InterpreterCompilationJob &)=delete
BytecodeGenerator generator_
Status DoFinalizeJobImpl(DirectHandle< SharedFunctionInfo > shared_info, IsolateT *isolate)
void CheckAndPrintBytecodeMismatch(IsolateT *isolate, Handle< Script > script, DirectHandle< BytecodeArray > bytecode)
BytecodeGenerator * generator()
static std::unique_ptr< UnoptimizedCompilationJob > NewSourcePositionCollectionJob(ParseInfo *parse_info, FunctionLiteral *literal, Handle< BytecodeArray > existing_bytecode, AccountingAllocator *allocator, LocalIsolate *local_isolate)
V8_EXPORT_PRIVATE void InitDispatchCounters()
void ForEachBytecode(const std::function< void(Bytecode, OperandScale)> &f)
void SetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale, Tagged< Code > handler)
Address interpreter_entry_trampoline_instruction_start_
static size_t GetDispatchTableIndex(Bytecode bytecode, OperandScale operand_scale)
static const int kNumberOfBytecodes
V8_EXPORT_PRIVATE DirectHandle< JSObject > GetDispatchCountersObject()
Address dispatch_table_[kDispatchTableSize]
static std::unique_ptr< UnoptimizedCompilationJob > NewCompilationJob(ParseInfo *parse_info, FunctionLiteral *literal, Handle< Script > script, AccountingAllocator *allocator, std::vector< FunctionLiteral * > *eager_inner_literals, LocalIsolate *local_isolate)
std::unique_ptr< uintptr_t[]> bytecode_dispatch_counters_table_
V8_EXPORT_PRIVATE Tagged< Code > GetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale)
bool IsDispatchTableInitialized() const
V8_EXPORT_PRIVATE uintptr_t GetDispatchCounter(Bytecode from, Bytecode to) const
Interpreter(Isolate *isolate)
#define V8_IGNITION_DISPATCH_COUNTING_BOOL
std::unique_ptr< icu::DateTimePatternGenerator > generator_
FunctionLiteral * literal
LocalIsolate * local_isolate_
Vector< const char > CStrVector(const char *data)
const int kIllegalBytecodeHandlerEncoding
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
constexpr int kBitsPerByte
V8_INLINE IndirectHandle< T > indirect_handle(DirectHandle< T > handle)
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
V8_EXPORT_PRIVATE FlagValues v8_flags
static constexpr Address kNullAddress
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
static constexpr ReleaseStoreTag kReleaseStore
#define CHECK_WITH_MSG(condition, message)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define TRACE_EVENT0(category_group, name)
#define TRACE_DISABLED_BY_DEFAULT(name)