5#ifndef V8_TORQUE_INSTRUCTIONS_H_
6#define V8_TORQUE_INSTRUCTIONS_H_
20class ControlFlowGraph;
23class NamespaceConstant;
27#define TORQUE_BACKEND_AGNOSTIC_INSTRUCTION_LIST(V) \
30 V(DeleteRangeInstruction)
33#define TORQUE_BACKEND_DEPENDENT_INSTRUCTION_LIST(V) \
34 V(PushUninitializedInstruction) \
35 V(PushBuiltinPointerInstruction) \
36 V(LoadReferenceInstruction) \
37 V(StoreReferenceInstruction) \
38 V(LoadBitFieldInstruction) \
39 V(StoreBitFieldInstruction) \
40 V(CallCsaMacroInstruction) \
41 V(CallIntrinsicInstruction) \
42 V(NamespaceConstantInstruction) \
43 V(CallCsaMacroAndBranchInstruction) \
44 V(CallBuiltinInstruction) \
45 V(CallRuntimeInstruction) \
46 V(CallBuiltinPointerInstruction) \
47 V(BranchInstruction) \
48 V(ConstexprBranchInstruction) \
50 V(GotoExternalInstruction) \
51 V(MakeLazyNodeInstruction) \
52 V(ReturnInstruction) \
53 V(PrintErrorInstruction) \
55 V(UnsafeCastInstruction)
57#define TORQUE_INSTRUCTION_LIST(V) \
58 TORQUE_BACKEND_AGNOSTIC_INSTRUCTION_LIST(V) \
59 TORQUE_BACKEND_DEPENDENT_INSTRUCTION_LIST(V)
61#define TORQUE_INSTRUCTION_BOILERPLATE() \
62 static const InstructionKind kKind; \
63 std::unique_ptr<InstructionBase> Clone() const override; \
64 void Assign(const InstructionBase& other) override; \
65 void TypeInstruction(Stack<const Type*>* stack, ControlFlowGraph* cfg) \
67 void RecomputeDefinitionLocations(Stack<DefinitionLocation>* locations, \
68 Worklist<Block*>* worklist) \
72#define ENUM_ITEM(name) k##name,
77struct InstructionBase;
99 std::size_t index = 0) {
139 if (
kind_ != other.kind_)
return false;
140 if (
location_ != other.location_)
return false;
141 return index_ == other.index_;
149 if (
kind_ != other.kind_) {
150 return static_cast<int>(
kind_) <
static_cast<int>(other.kind_);
155 return index_ < other.index_;
171 return stream <<
"DefinitionLocation::Invalid()";
173 return stream <<
"DefinitionLocation::Parameter("
176 return stream <<
"DefinitionLocation::Phi(" << std::hex
180 return stream <<
"DefinitionLocation::Instruction(" << std::hex
188 virtual std::unique_ptr<InstructionBase>
Clone()
const = 0;
213 return static_cast<T&
>(*instruction_);
219 return static_cast<const T&
>(*instruction_);
224 return kind_ == T::kKind;
240 :
kind_(other.kind_),
243 if (
kind_ == other.kind_) {
255#define ENUM_ITEM(name) \
256 case InstructionKind::k##name: \
269 instruction_->RecomputeDefinitionLocations(locations, worklist);
292 os <<
"Peek " << instruction.slot;
293 if (instruction.widened_type) {
294 os <<
", " << **instruction.widened_type;
311 os <<
"Poke " << instruction.slot;
312 if (instruction.widened_type) {
313 os <<
", " << **instruction.widened_type;
329 return os <<
"DeleteRange " << instruction.range;
343 return os <<
"PushUninitialized " << *instruction.type;
350 DCHECK(type->IsBuiltinPointerType());
361 return os <<
"PushBuiltinPointer "
363 << *instruction.type;
369 : constant(constant) {}
394 return os <<
"LoadReference " << *instruction.type;
405 return os <<
"StoreReference " << *instruction.type;
423 return os <<
"LoadBitField " << *instruction.bit_field_struct_type <<
", "
424 << instruction.bit_field.name_and_type.name;
447 os <<
"StoreBitField " << *instruction.bit_field_struct_type <<
", "
448 << instruction.bit_field.name_and_type.name;
449 if (instruction.starts_as_zero) {
450 os <<
", starts_as_zero";
521 std::size_t index)
const;
597 os <<
"CallBuiltinPointer " << *instruction.type
598 <<
", argc: " << instruction.argc;
599 if (instruction.is_tailcall) {
600 os <<
", is_tailcall";
636 block_list->push_back(
if_true);
654 block_list->push_back(
if_true);
699 os <<
"GotoExternal " << instruction.destination;
700 for (
const std::string& name : instruction.variable_names) {
716 return os <<
"Return count: " << instruction.count;
722 : message(
std::move(message)) {}
729 return os <<
"PrintConstantString "
742 return "kDebugBreak";
744 return "kUnreachable";
746 return "kAssertionFailure";
772 return os <<
"UnsafeCast " << *instruction.destination_type;
bool operator==(const DefinitionLocation &other) const
std::size_t GetPhiIndex() const
std::size_t GetParameterIndex() const
bool IsPhiFromBlock(const Block *block) const
bool operator<(const DefinitionLocation &other) const
static DefinitionLocation Instruction(const InstructionBase *instruction, std::size_t index=0)
const Block * GetPhiBlock() const
bool operator!=(const DefinitionLocation &other) const
std::size_t GetInstructionIndex() const
static DefinitionLocation Parameter(std::size_t index)
static DefinitionLocation Phi(const Block *block, std::size_t index)
const InstructionBase * GetInstruction() const
DefinitionLocation(Kind kind, const void *location, std::size_t index)
bool IsInstruction() const
InstructionBase * operator->()
std::unique_ptr< InstructionBase > instruction_
Instruction & operator=(const Instruction &other) V8_NOEXCEPT
void RecomputeDefinitionLocations(Stack< DefinitionLocation > *locations, Worklist< Block * > *worklist) const
const InstructionBase * operator->() const
const T * DynamicCast() const
void TypeInstruction(Stack< const Type * > *stack, ControlFlowGraph *cfg) const
const char * Mnemonic() const
Instruction(const Instruction &other) V8_NOEXCEPT
InstructionKind kind() const
#define TORQUE_INSTRUCTION_LIST(V)
#define TORQUE_INSTRUCTION_BOILERPLATE()
V8_INLINE const Operation & Get(const Graph &graph, OpIndex index)
std::ostream & operator<<(std::ostream &os, Identifier *id)
std::string StringLiteralQuote(const std::string &s)
std::vector< const Type * > TypeVector
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
#define DCHECK(condition)
static const char * KindToString(Kind kind)
AbortInstruction(Kind kind, std::string message="")
bool IsBlockTerminator() const override
BranchInstruction(Block *if_true, Block *if_false)
void AppendSuccessorBlocks(std::vector< Block * > *block_list) const override
bool IsBlockTerminator() const override
std::optional< DefinitionLocation > GetExceptionObjectDefinition() const
void AppendSuccessorBlocks(std::vector< Block * > *block_list) const override
bool IsBlockTerminator() const override
std::size_t GetValueDefinitionCount() const
DefinitionLocation GetValueDefinition(std::size_t index) const
std::optional< Block * > catch_block
CallBuiltinInstruction(bool is_tailcall, Builtin *builtin, size_t argc, std::optional< Block * > catch_block)
CallBuiltinPointerInstruction(bool is_tailcall, const BuiltinPointerType *type, size_t argc)
const BuiltinPointerType * type
DefinitionLocation GetValueDefinition(std::size_t index) const
std::size_t GetValueDefinitionCount() const
bool IsBlockTerminator() const override
void AppendSuccessorBlocks(std::vector< Block * > *block_list) const override
std::size_t GetLabelCount() const
std::vector< Block * > label_blocks
std::vector< std::string > constexpr_arguments
DefinitionLocation GetValueDefinition(std::size_t index) const
std::optional< DefinitionLocation > GetExceptionObjectDefinition() const
std::optional< Block * > return_continuation
DefinitionLocation GetLabelValueDefinition(std::size_t label, std::size_t index) const
std::optional< Block * > catch_block
std::size_t GetValueDefinitionCount() const
std::size_t GetLabelValueDefinitionCount(std::size_t label) const
bool IsBlockTerminator() const override
std::optional< DefinitionLocation > GetExceptionObjectDefinition() const
DefinitionLocation GetValueDefinition(std::size_t index) const
void AppendSuccessorBlocks(std::vector< Block * > *block_list) const override
std::optional< Block * > catch_block
std::vector< std::string > constexpr_arguments
std::size_t GetValueDefinitionCount() const
std::size_t GetValueDefinitionCount() const
std::vector< std::string > constexpr_arguments
DefinitionLocation GetValueDefinition(std::size_t index) const
TypeVector specialization_types
CallRuntimeInstruction(bool is_tailcall, RuntimeFunction *runtime_function, size_t argc, std::optional< Block * > catch_block)
DefinitionLocation GetValueDefinition(std::size_t index) const
std::optional< DefinitionLocation > GetExceptionObjectDefinition() const
bool IsBlockTerminator() const override
std::optional< Block * > catch_block
void AppendSuccessorBlocks(std::vector< Block * > *block_list) const override
std::size_t GetValueDefinitionCount() const
RuntimeFunction * runtime_function
void AppendSuccessorBlocks(std::vector< Block * > *block_list) const override
bool IsBlockTerminator() const override
ConstexprBranchInstruction(std::string condition, Block *if_true, Block *if_false)
std::vector< std::string > variable_names
bool IsBlockTerminator() const override
GotoExternalInstruction(std::string destination, std::vector< std::string > variable_names)
void AppendSuccessorBlocks(std::vector< Block * > *block_list) const override
GotoInstruction(Block *destination)
bool IsBlockTerminator() const override
virtual void RecomputeDefinitionLocations(Stack< DefinitionLocation > *locations, Worklist< Block * > *worklist) const =0
void InvalidateTransientTypes(Stack< const Type * > *stack) const
virtual void Assign(const InstructionBase &other)=0
virtual void TypeInstruction(Stack< const Type * > *stack, ControlFlowGraph *cfg) const =0
virtual ~InstructionBase()=default
virtual std::unique_ptr< InstructionBase > Clone() const =0
virtual bool IsBlockTerminator() const
virtual void AppendSuccessorBlocks(std::vector< Block * > *block_list) const
DefinitionLocation GetValueDefinition() const
const Type * bit_field_struct_type
FieldSynchronization synchronization
DefinitionLocation GetValueDefinition() const
std::vector< std::string > constexpr_arguments
DefinitionLocation GetValueDefinition() const
NamespaceConstant * constant
std::size_t GetValueDefinitionCount() const
DefinitionLocation GetValueDefinition(std::size_t index) const
std::optional< const Type * > widened_type
std::optional< const Type * > widened_type
DefinitionLocation GetValueDefinition() const
std::string external_name
DefinitionLocation GetValueDefinition() const
bool IsBlockTerminator() const override
DefinitionLocation GetValueDefinition() const
const Type * bit_field_struct_type
const Type * destination_type
DefinitionLocation GetValueDefinition() const