5#ifndef V8_MAGLEV_MAGLEV_PRE_REGALLOC_CODEGEN_PROCESSORS_H_
6#define V8_MAGLEV_MAGLEV_PRE_REGALLOC_CODEGEN_PROCESSORS_H_
27#define DEF_PROCESS_NODE(NAME) \
28 ProcessResult Process(NAME* node, const ProcessingState& state) { \
29 node->InitTemporaries(); \
30 node->SetValueLocationConstraints(); \
31 return ProcessResult::kContinue; \
34#undef DEF_PROCESS_NODE
47 template <
typename NodeT>
49#ifdef V8_COMPRESS_POINTERS
50 node->MarkTaggedInputsAsDecompressing();
69 template <
typename NodeT>
71 if constexpr (NodeT::kProperties.is_call() ||
72 NodeT::kProperties.needs_register_snapshot()) {
73 int node_stack_args = node->MaxCallStackArgs();
74 if constexpr (NodeT::kProperties.needs_register_snapshot()) {
82 if constexpr (NodeT::kProperties.can_eager_deopt()) {
85 if constexpr (NodeT::kProperties.can_lazy_deopt()) {
98 frame_size = deopt_frame->
as_interpreted().unit().max_arguments() *
104 deopt_frame = deopt_frame->
parent();
105 }
while (deopt_frame !=
nullptr);
109 switch (deopt_frame->
type()) {
114 return info.frame_size_in_bytes();
135 return info.frame_size_in_bytes();
159 if (block->state()->is_loop()) {
167 template <
typename NodeT>
171 if (loop_used_nodes && node->properties().is_call() &&
182 template <
typename NodeT>
187 node->ForAllInputsInRegallocAssignmentOrder(
189 MarkUse(input->node(), node->id(), input, loop_used_nodes);
191 if constexpr (NodeT::kProperties.can_eager_deopt()) {
195 if constexpr (NodeT::kProperties.can_lazy_deopt()) {
210 int predecessor_id = state.block()->predecessor_id();
212 uint32_t use = node->
id();
220 if (target->has_phi()) {
221 for (
Phi* phi : *target->phis()) {
224 MarkUse(input, use, &phi->input(predecessor_id), outer_loop_used_nodes);
241 (p.second.first_register_use <= loop_used_nodes.
first_call &&
242 p.second.last_register_use > loop_used_nodes.
last_call))) {
249 p.second.first_register_use > loop_used_nodes.
first_call &&
250 p.second.last_register_use <= loop_used_nodes.
last_call)) {
263 for (
auto& [used_node, info] : loop_used_nodes.
used_nodes) {
264 Input* input =
new (&used_node_inputs[
i++])
Input(used_node);
265 MarkUse(used_node, use, input, outer_loop_used_nodes);
267 node->set_used_nodes(used_node_inputs);
278 int i = state.
block()->predecessor_id();
279 if (!target->has_phi())
return;
282 for (
auto it = phis.
begin(); it != phis.
end();) {
284 if (!phi->is_used()) {
292 MarkUse(input, use, &phi->input(
i), loop_used_nodes);
321 node->record_next_use(use_id, input);
326 if (loop_used_nodes) {
334 if (input->operand().IsUnallocated()) {
335 const auto& operand =
336 compiler::UnallocatedOperand::cast(input->operand());
337 if (operand.HasRegisterPolicy() || operand.HasFixedRegisterPolicy() ||
338 operand.HasFixedFPRegisterPolicy()) {
340 it->second.first_register_use = use_id;
342 it->second.last_register_use = use_id;
349 template <
typename DeoptInfoT>
353 int use_id = node->id();
354 if (!deopt_info->has_input_locations()) {
360 deopt_info->ForEachInput([&](
ValueNode* node) {
361 MarkUse(node, use_id, input, loop_used_nodes);
Iterator RemoveAt(Iterator it)
static BuiltinContinuationFrameInfo Conservative(int parameters_count, const CallInterfaceDescriptor &continuation_descriptor, const RegisterConfiguration *register_config)
static CallInterfaceDescriptor CallInterfaceDescriptorFor(Builtin builtin)
uint32_t frame_size_in_bytes() const
static FastConstructStubFrameInfo Conservative()
static const RegisterConfiguration * Default()
static UnoptimizedFrameInfo Conservative(int parameters_count_with_receiver, int locals_count)
base::Vector< T > AllocateVector(size_t length)
ProcessResult Process(NodeT *node, const ProcessingState &state)
BlockProcessResult PreProcessBasicBlock(BasicBlock *block)
void PostProcessGraph(Graph *graph)
void PostProcessBasicBlock(BasicBlock *block)
void PreProcessGraph(Graph *graph)
const InlinedArgumentsDeoptFrame & as_inlined_arguments() const
const InterpretedDeoptFrame & as_interpreted() const
@ kConstructInvokeStubFrame
@ kBuiltinContinuationFrame
const BuiltinContinuationDeoptFrame & as_builtin_continuation() const
BlockProcessResult PreProcessBasicBlock(BasicBlock *block)
void MarkCheckpointNodes(NodeBase *node, DeoptInfoT *deopt_info, LoopUsedNodes *loop_used_nodes, const ProcessingState &state)
RegallocInfo * regalloc_info_
void MarkUse(ValueNode *node, uint32_t use_id, InputLocation *input, LoopUsedNodes *loop_used_nodes)
ProcessResult Process(NodeT *node, const ProcessingState &state)
void MarkJumpInputUses(uint32_t use, BasicBlock *target, const ProcessingState &state)
LiveRangeAndNextUseProcessor(MaglevCompilationInfo *compilation_info, Graph *graph, RegallocInfo *regalloc_info)
std::vector< LoopUsedNodes > loop_used_nodes_
void MarkInputUses(Phi *node, const ProcessingState &state)
void PostProcessGraph(Graph *graph)
void PreProcessGraph(Graph *graph)
void MarkInputUses(Jump *node, const ProcessingState &state)
void MarkInputUses(NodeT *node, const ProcessingState &state)
LoopUsedNodes * GetCurrentLoopUsedNodes()
void MarkInputUses(JumpLoop *node, const ProcessingState &state)
void MarkInputUses(CheckpointedJump *node, const ProcessingState &state)
void PostProcessBasicBlock(BasicBlock *block)
MaglevCompilationInfo * compilation_info_
ProcessResult Process(NodeT *node, const ProcessingState &state)
void PreProcessGraph(Graph *graph)
void PostProcessBasicBlock(BasicBlock *block)
BlockProcessResult PreProcessBasicBlock(BasicBlock *block)
void UpdateMaxDeoptedStackSize(DeoptInfo *deopt_info)
void PostProcessGraph(Graph *graph)
int max_deopted_stack_size_
const MaglevCompilationUnit * last_seen_unit_
int ConservativeFrameSize(const DeoptFrame *deopt_frame)
constexpr Input & input(int index)
void PostProcessBasicBlock(BasicBlock *block)
BlockProcessResult PreProcessBasicBlock(BasicBlock *block)
void PostProcessGraph(Graph *graph)
void PreProcessGraph(Graph *graph)
Handle< SharedFunctionInfo > info
#define DEF_PROCESS_NODE(NAME)
static constexpr int kAllocatableDoubleRegisterCount
static constexpr NodeIdT kInvalidNodeId
static constexpr NodeIdT kFirstValidNodeId
static constexpr int kAllocatableGeneralRegisterCount
constexpr int kSystemPointerSize
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
std::map< ValueNode *, NodeUse > used_nodes
NodeIdT first_register_use
NodeIdT last_register_use
ZonePtrList< ValueNode > reload_hints_
ZonePtrList< ValueNode > spill_hints_
absl::flat_hash_map< BasicBlock::Id, RegallocLoopInfo > loop_info_