5#ifndef V8_INTERPRETER_BYTECODE_GENERATOR_H_
6#define V8_INTERPRETER_BYTECODE_GENERATOR_H_
19class AstNodeSourceRanges;
20class AstStringConstants;
22class UnoptimizedCompilationInfo;
25namespace interpreter {
27class TopLevelDeclarationsBuilder;
29class BlockCoverageBuilder;
30class BytecodeJumpTable;
45 std::vector<FunctionLiteral*>* eager_inner_literals,
49 template <
typename IsolateT>
52 template <
typename IsolateT>
57 return hint1 == (hint1 | hint2);
68#define DECLARE_VISIT(type) void Visit##type(type* node);
79 class AccumulatorPreservingScope;
82 class ControlScopeForBreakable;
83 class ControlScopeForDerivedConstructor;
84 class ControlScopeForIteration;
85 class ControlScopeForTopLevel;
86 class ControlScopeForTryCatch;
87 class ControlScopeForTryFinally;
89 class EffectResultScope;
90 class ExpressionResultScope;
91 class FeedbackSlotCache;
92 class HoleCheckElisionScope;
93 class HoleCheckElisionMergeScope;
95 class MultipleEntryBlockContextScope;
98 class NaryCodeCoverageSlots;
99 class OptionalChainNullLabelScope;
100 class RegisterAllocationScope;
101 class TestResultScope;
102 class TopLevelDeclarationsBuilder;
103 class DisposablesStackScope;
104 class ValueResultScope;
211 template <
typename IsolateT>
333 Register iteration_continuation_token);
402 int right_coverage_slot);
447 template <
typename TryBodyFunc,
typename CatchBodyFunc>
448 void BuildTryCatch(TryBodyFunc try_body_func, CatchBodyFunc catch_body_func,
451 template <
typename TryBodyFunc,
typename FinallyBodyFunc>
453 FinallyBodyFunc finally_body_func,
456 template <
typename WrappedFunc>
459 template <
typename ExpressionFunc>
486 template <
typename T>
523 return type_hint == TypeHint::kBoolean ? ToBooleanMode::kAlreadyBoolean
524 : ToBooleanMode::kConvertToBoolean;
#define DECLARE_VISIT(type)
#define SBXCHECK(condition)
base::ThreadedList< Declaration > List
BytecodeRegisterAllocator * register_allocator()
Expression * object_expr() const
AssignmentLhsData(AssignType assign_type, Expression *expr, RegisterList super_property_args, Register object, Register key, Expression *object_expr, const AstRawString *name)
static AssignmentLhsData PrivateMethodOrAccessor(AssignType type, Property *property, Register object, Register key)
const AstRawString * name_
AssignType assign_type() const
static AssignmentLhsData NamedProperty(Expression *object_expr, Register object, const AstRawString *name)
RegisterList super_property_args_
bool is_private_assign_type() const
Expression * expr() const
static AssignmentLhsData PrivateDebugEvaluate(AssignType type, Property *property, Register object)
Expression * object_expr_
RegisterList super_property_args() const
static AssignmentLhsData NonProperty(Expression *expr)
static AssignmentLhsData KeyedSuperProperty(RegisterList super_property_args)
const AstRawString * name() const
static AssignmentLhsData NamedSuperProperty(RegisterList super_property_args)
static AssignmentLhsData KeyedProperty(Register object, Register key)
SharedFeedbackSlot dummy_feedback_slot_
void BuildAsyncReturn(int source_position)
void VisitNot(UnaryOperation *expr)
void GenerateDerivedConstructorBody()
ForInScope * current_for_in_scope() const
void BuildVariableLoadForAccumulatorValue(Variable *variable, HoleCheckMode hole_check_mode, TypeofMode typeof_mode=TypeofMode::kNotInside)
void SetVariableInRegister(Variable *var, Register reg)
Runtime::FunctionId StoreKeyedToSuperRuntimeId()
void VisitCommaExpression(BinaryOperation *binop)
void BuildHoleCheckForVariableAssignment(Variable *variable, Token::Value op)
void BuildFillArrayWithIterator(IteratorRecord iterator, Register array, Register index, Register value, FeedbackSlot next_value_slot, FeedbackSlot next_done_slot, FeedbackSlot index_slot, FeedbackSlot element_slot)
void VisitBlockMaybeDispose(Block *stmt)
UnoptimizedCompilationInfo * info() const
void BuildDisposeScope(WrappedFunc wrapped_func, bool has_await_using)
ContextScope * execution_context() const
void BuildCreateObjectLiteral(Register literal, uint8_t flags, size_t entry)
void GenerateBytecode(uintptr_t stack_limit)
void BuildPrivateBrandInitialization(Register receiver, Variable *brand)
Variable::HoleCheckBitmap hole_check_bitmap_
void VisitGlobalDeclarations(Declaration::List *declarations)
void AllocateTopLevelRegisters()
DirectHandle< TrustedByteArray > FinalizeSourcePositionTable(IsolateT *isolate)
void GenerateBodyStatements(int start=0)
BlockCoverageBuilder * block_coverage_builder_
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS()
void VisitNullishExpression(BinaryOperation *binop)
void VisitIterationBody(IterationStatement *stmt, LoopBuilder *loop_builder)
void GenerateBaseConstructorBody()
Register current_disposables_stack() const
FeedbackSlot GetCachedStoreICSlot(const Expression *expr, const AstRawString *name)
ZoneVector< std::pair< Call *, Scope * > > eval_calls_
TypeHint GetTypeHintForLocalVariable(Variable *variable)
DeclarationScope * closure_scope_
ZoneVector< Variable * > vars_in_hole_check_bitmap_
ZoneVector< std::pair< ObjectLiteralBoilerplateBuilder *, size_t > > object_literals_
int feedback_index(FeedbackSlot slot) const
void VisitArguments(const ZonePtrList< Expression > *args, RegisterList *arg_regs)
void BuildClassProperty(ClassLiteral::Property *property)
ZoneVector< std::pair< ClassLiteral *, size_t > > class_literals_
Variable * GetPotentialVariableInAccumulator()
ControlScope * execution_control_
void VisitLogicalTestSubExpression(Token::Value token, Expression *expr, BytecodeLabels *then_labels, BytecodeLabels *else_labels, int coverage_slot)
void set_current_for_in_scope(ForInScope *for_in_scope)
void BuildTryCatch(TryBodyFunc try_body_func, CatchBodyFunc catch_body_func, HandlerTable::CatchPrediction catch_prediction, TryCatchStatement *stmt_for_coverage=nullptr)
void BuildDestructuringArrayAssignment(ArrayLiteral *pattern, Token::Value op, LookupHoistingMode lookup_hoisting_mode)
void BuildCreateArrayLiteral(const ZonePtrList< Expression > *elements, ArrayLiteral *expr)
void BuildTest(ToBooleanMode mode, BytecodeLabels *then_labels, BytecodeLabels *else_labels, TestFallthrough fallthrough)
void VisitBlockDeclarationsAndStatements(Block *stmt)
V8_WARN_UNUSED_RESULT Register VisitForRegisterValue(Expression *expr)
void set_catch_prediction(HandlerTable::CatchPrediction value)
void VisitNaryCommaExpression(NaryOperation *expr)
void set_current_disposables_stack(Register disposables_stack)
IteratorRecord BuildGetIteratorRecord(Register iterator_next, Register iterator_object, IteratorType hint)
void VisitCallSuper(Call *call)
FunctionKind function_kind() const
void BuildNewLocalWithContext(Scope *scope)
void BuildLoadNamedProperty(const Expression *object_expr, Register object, const AstRawString *name)
int AllocateConditionalChainBlockCoverageSlotIfEnabled(ConditionalChain *node, SourceRangeKind kind, size_t index)
void VisitForAccumulatorValueOrTheHole(Expression *expr)
Register GetRegisterForLocalVariable(Variable *variable)
static bool IsSameOrSubTypeHint(TypeHint hint1, TypeHint hint2)
void VisitNaryArithmeticExpression(NaryOperation *expr)
void BuildLocalActivationContextInitialization()
const AstStringConstants * ast_string_constants() const
void BuildCallIteratorMethod(Register iterator, const AstRawString *method, RegisterList receiver_and_args, BytecodeLabel *if_called, BytecodeLabels *if_notcalled)
BytecodeJumpTable * generator_jump_table_
void BuildLiteralCompareNil(Token::Value compare_op, BytecodeArrayBuilder::NilValue nil)
void BuildAwait(Expression *await_expr)
void VisitPropertyLoad(Register obj, Property *expr)
void VisitLogicalTest(Token::Value token, Expression *left, Expression *right, int right_coverage_slot)
ControlScope * execution_control() const
void VisitInHoleCheckElisionScope(T *node)
ZoneVector< std::pair< FunctionLiteral *, size_t > > function_literals_
void BuildGetIterator(IteratorType hint)
void VisitForNullishTest(Expression *expr, BytecodeLabels *then_labels, BytecodeLabels *test_next_labels, BytecodeLabels *else_labels)
void BuildTryFinally(TryBodyFunc try_body_func, FinallyBodyFunc finally_body_func, HandlerTable::CatchPrediction catch_prediction, TryFinallyStatement *stmt_for_coverage=nullptr)
void VisitLiteralAccessor(LiteralProperty *property, Register value_out)
bool VisitLogicalOrSubExpression(Expression *expr, BytecodeLabels *end_labels, int coverage_slot)
TypeHint VisitForAccumulatorValue(Expression *expr)
void VisitLogicalOrExpression(BinaryOperation *binop)
void GenerateBodyPrologue()
void VisitNaryLogicalOrExpression(NaryOperation *expr)
void VisitKeyedSuperPropertyLoad(Property *property, Register opt_receiver_out)
void VisitIterationBodyInHoleCheckElisionScope(IterationStatement *stmt, LoopBuilder *loop_builder)
Register incoming_new_target_or_generator_
BytecodeLabels * optional_chaining_null_labels_
void BuildGetAndCheckSuperConstructor(Register this_function, Register new_target, Register constructor, BytecodeLabel *super_ctor_call_done)
void VisitTypeOf(UnaryOperation *expr)
void BuildLoadPropertyKey(LiteralProperty *property, Register out_reg)
FeedbackSlot GetCachedLoadICSlot(const Expression *expr, const AstRawString *name)
int AllocateBlockCoverageSlotIfEnabled(AstNode *node, SourceRangeKind kind)
void VisitArithmeticExpression(BinaryOperation *binop)
void BuildDeclareCall(Runtime::FunctionId id)
void VisitForTest(Expression *expr, BytecodeLabels *then_labels, BytecodeLabels *else_labels, TestFallthrough fallthrough)
void BuildAwait(int position=kNoSourcePosition)
void set_execution_context(ContextScope *context)
Scope * current_scope() const
void VisitRestArgumentsArray(Variable *rest)
void GenerateBytecodeBody()
void VisitNaryNullishExpression(NaryOperation *expr)
ExpressionResultScope * execution_result_
FeedbackSlot GetCachedLoadSuperICSlot(const AstRawString *name)
void BuildVariableLoad(Variable *variable, HoleCheckMode hole_check_mode, TypeofMode typeof_mode=TypeofMode::kNotInside)
bool IsLocalVariableWithInternalizedStringHint(Expression *expr)
void VisitModuleNamespaceImports()
void BuildPrivateMethods(ClassLiteral *expr, bool is_static, Register home_object)
void BuildPrivateBrandCheck(Property *property, Register object)
void VisitCondition(Expression *expr)
int GetCachedCreateClosureSlot(FunctionLiteral *literal)
void GenerateAsyncGeneratorFunctionBody()
LocalIsolate * local_isolate_
void BuildIteratorClose(const IteratorRecord &iterator, Expression *expr=nullptr)
void BuildAssignment(const AssignmentLhsData &data, Token::Value op, LookupHoistingMode lookup_hoisting_mode)
TopLevelDeclarationsBuilder * top_level_builder()
void VisitClassLiteral(ClassLiteral *expr, Register name)
BytecodeArrayBuilder builder_
void AddToEagerLiteralsIfEager(FunctionLiteral *literal)
void GenerateAsyncFunctionBody()
void BuildSetNamedProperty(const Expression *object_expr, Register object, const AstRawString *name)
void set_execution_control(ControlScope *scope)
FeedbackSlot GetCachedLoadGlobalICSlot(TypeofMode typeof_mode, Variable *variable)
void BuildVariableAssignment(Variable *variable, Token::Value op, HoleCheckMode hole_check_mode, LookupHoistingMode lookup_hoisting_mode=LookupHoistingMode::kNormal)
void BuildSuspendPoint(int position)
void RememberHoleCheckInCurrentBlock(Variable *variable)
void BuildPrivateDebugDynamicSet(Property *property, Register obj, Register value)
void BuildNewLocalActivationContext()
void set_current_scope(Scope *scope)
LanguageMode language_mode() const
Register current_disposables_stack_
void BuildIncrementBlockCoverageCounterIfEnabled(AstNode *node, SourceRangeKind kind)
void BuildInstanceMemberInitialization(Register constructor, Register instance)
Register generator_object() const
void VisitAndPushIntoRegisterList(Expression *expr, RegisterList *reg_list)
void BuildOptionalChain(ExpressionFunc expression_func)
const AstStringConstants * ast_string_constants_
void BuildInstanceInitializationAfterSuperCall(Register this_function, Register instance)
void set_execution_result(ExpressionResultScope *execution_result)
void BuildPushUndefinedIntoRegisterList(RegisterList *reg_list)
void BuildNewLocalCatchContext(Scope *scope)
FeedbackSlotCache * feedback_slot_cache()
HandlerTable::CatchPrediction catch_prediction() const
BytecodeGenerator(LocalIsolate *local_isolate, Zone *zone, UnoptimizedCompilationInfo *info, const AstStringConstants *ast_string_constants, std::vector< FunctionLiteral * > *eager_inner_literals, Handle< Script > script)
bool IsVariableInRegister(Variable *var, Register reg)
ExpressionResultScope * execution_result() const
void BuildSuperCallOptimization(Register this_function, Register new_target, Register constructor_then_instance, BytecodeLabel *super_ctor_call_done)
void BuildStoreGlobal(Variable *variable)
bool VisitNullishSubExpression(Expression *expr, BytecodeLabels *end_labels, int coverage_slot)
Expression * GetDestructuringDefaultValue(Expression **target)
void VisitDelete(UnaryOperation *expr)
bool VariableNeedsHoleCheckInCurrentBlockForAssignment(Variable *variable, Token::Value op, HoleCheckMode hole_check_mode)
static constexpr ToBooleanMode ToBooleanModeFromTypeHint(TypeHint type_hint)
void BuildAsyncGeneratorReturn()
std::vector< FunctionLiteral * > * eager_inner_literals_
void VisitNaryLogicalAndExpression(NaryOperation *expr)
void set_current_loop_scope(LoopScope *loop_scope)
bool VariableNeedsHoleCheckInCurrentBlock(Variable *variable, HoleCheckMode hole_check_mode)
void BuildPrivateMethodIn(Variable *private_name, Expression *object_expression)
void BuildIteratorNext(const IteratorRecord &iterator, Register next_result)
int AllocateNaryBlockCoverageSlotIfEnabled(NaryOperation *node, size_t index)
void BuildGeneratorObjectVariableInitialization()
void BuildDestructuringObjectAssignment(ObjectLiteral *pattern, Token::Value op, LookupHoistingMode lookup_hoisting_mode)
void VisitPropertyLoadForRegister(Register obj, Property *expr, Register destination)
LoopScope * current_loop_scope_
UnoptimizedCompilationInfo * info_
FeedbackSlot GetDummyCompareICSlot()
BytecodeArrayBuilder * builder()
void BuildReturn(int source_position)
FeedbackVectorSpec * feedback_spec()
void BuildThisVariableLoad()
void BuildPrivateGetterAccess(Register obj, Register access_pair)
AccumulatorPreservingMode
void BuildClassLiteral(ClassLiteral *expr, Register name)
void VisitNewTargetVariable(Variable *variable)
FeedbackSlot GetCachedStoreGlobalICSlot(LanguageMode language_mode, Variable *variable)
void BuildPrivateDebugDynamicGet(Property *property, Register obj)
void VisitModuleDeclarations(Declaration::List *declarations)
BytecodeRegisterAllocator * register_allocator()
void VisitNamedSuperPropertyLoad(Property *property, Register opt_receiver_out)
void GenerateBodyStatementsWithoutImplicitFinalReturn(int start=0)
ZoneVector< std::pair< GetTemplateObject *, size_t > > template_objects_
HandlerTable::CatchPrediction catch_prediction_
void VisitArgumentsObject(Variable *variable)
ZoneVector< std::pair< NativeFunctionLiteral *, size_t > > native_function_literals_
void VisitLogicalAndExpression(BinaryOperation *binop)
Register incoming_new_target() const
void VisitDeclarations(Declaration::List *declarations)
AssignmentLhsData PrepareAssignmentLhs(Expression *lhs, AccumulatorPreservingMode accumulator_preserving_mode=AccumulatorPreservingMode::kNone)
void VisitInScope(Statement *stmt, Scope *scope)
void BuildFinalizeIteration(IteratorRecord iterator, Register done, Register iteration_continuation_token)
void VisitStatements(const ZonePtrList< Statement > *statments, int start=0)
void BuildLiteralStrictCompareBoolean(Literal *literal)
void BuildLoadKeyedProperty(Register object, FeedbackSlot slot)
TypeHint VisitInHoleCheckElisionScopeForAccumulatorValue(Expression *expr)
DeclarationScope * closure_scope() const
ForInScope * current_for_in_scope_
ZoneVector< std::pair< ArrayLiteralBoilerplateBuilder *, size_t > > array_literals_
void BuildThrowIfHole(Variable *variable)
void BuildGeneratorPrologue()
void VisitVoid(UnaryOperation *expr)
void BuildInvalidPropertyAccess(MessageTemplate tmpl, Property *property)
FeedbackSlotCache * feedback_slot_cache_
Handle< BytecodeArray > FinalizeBytecode(IsolateT *isolate, Handle< Script > script)
void VisitForInAssignment(Expression *expr)
void VisitInSameTestExecutionScope(Expression *expr)
void AllocateDeferredConstants(IsolateT *isolate, Handle< Script > script)
void BuildNewLocalBlockContext(Scope *scope)
void VisitForEffect(Expression *expr)
TopLevelDeclarationsBuilder * top_level_builder_
void BuildPrivateSetterAccess(Register obj, Register access_pair, Register value)
static bool IsStringTypeHint(TypeHint hint)
bool VisitLogicalAndSubExpression(Expression *expr, BytecodeLabels *end_labels, int coverage_slot)
void VisitNaryLogicalTest(Token::Value token, NaryOperation *expr, const NaryCodeCoverageSlots *coverage_slots)
ContextScope * execution_context_
void VisitForTypeOfValue(Expression *expr)
Runtime::FunctionId StoreToSuperRuntimeId()
void VisitThisFunctionVariable(Variable *variable)
LoopScope * current_loop_scope() const
constexpr bool is_valid() const
base::Vector< const DirectHandle< Object > > args
DirectHandle< Object > new_target
FunctionLiteral * literal
InstructionOperand destination
constexpr int kNoSourcePosition
@ PRIVATE_GETTER_AND_SETTER
ZoneList< T * > ZonePtrList
TorqueStructIteratorRecord IteratorRecord
#define DCHECK_NOT_NULL(val)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define V8_WARN_UNUSED_RESULT