From e5eab3d67ac0bd8d3889f30f509ae883fd4d0c33 Mon Sep 17 00:00:00 2001 From: Jakob Linke Date: Wed, 7 Sep 2022 11:18:47 +0200 Subject: [PATCH] [maglev] Add a (mostly empty for now) MaglevAssembler Bug: v8:7700 Change-Id: Idf4cd2544e7ee3912809cbf95cee4823be36d1dd Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3875905 Reviewed-by: Leszek Swirski Commit-Queue: Jakob Linke Auto-Submit: Jakob Linke Cr-Commit-Position: refs/heads/main@{#83021} --- BUILD.gn | 2 + src/maglev/maglev-assembler-inl.h | 39 ++ src/maglev/maglev-assembler.h | 71 +++ src/maglev/maglev-code-gen-state.h | 65 +-- src/maglev/maglev-code-generator.cc | 84 +-- src/maglev/maglev-compiler.cc | 1 - src/maglev/maglev-ir.cc | 757 +++++++++++++--------------- src/maglev/maglev-ir.h | 520 ++++++------------- 8 files changed, 675 insertions(+), 864 deletions(-) create mode 100644 src/maglev/maglev-assembler-inl.h create mode 100644 src/maglev/maglev-assembler.h diff --git a/BUILD.gn b/BUILD.gn index afa37f0124..cff5f24199 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -3615,6 +3615,8 @@ v8_header_set("v8_internal_headers") { if (v8_enable_maglev) { sources += [ + "src/maglev/maglev-assembler-inl.h", + "src/maglev/maglev-assembler.h", "src/maglev/maglev-basic-block.h", "src/maglev/maglev-code-gen-state.h", "src/maglev/maglev-code-generator.h", diff --git a/src/maglev/maglev-assembler-inl.h b/src/maglev/maglev-assembler-inl.h new file mode 100644 index 0000000000..60e8a1b9b1 --- /dev/null +++ b/src/maglev/maglev-assembler-inl.h @@ -0,0 +1,39 @@ +// Copyright 2022 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_MAGLEV_MAGLEV_ASSEMBLER_INL_H_ +#define V8_MAGLEV_MAGLEV_ASSEMBLER_INL_H_ + +#include "src/codegen/macro-assembler-inl.h" +#include "src/maglev/maglev-assembler.h" +#include "src/maglev/maglev-code-gen-state.h" + +namespace v8 { +namespace internal { +namespace maglev { + +inline void MaglevAssembler::DefineLazyDeoptPoint(LazyDeoptInfo* info) { + info->deopting_call_return_pc = pc_offset_for_safepoint(); + code_gen_state()->PushLazyDeopt(info); + safepoint_table_builder()->DefineSafepoint(this); +} + +inline void MaglevAssembler::DefineExceptionHandlerPoint(NodeBase* node) { + ExceptionHandlerInfo* info = node->exception_handler_info(); + if (!info->HasExceptionHandler()) return; + info->pc_offset = pc_offset_for_safepoint(); + code_gen_state()->PushHandlerInfo(node); +} + +inline void MaglevAssembler::DefineExceptionHandlerAndLazyDeoptPoint( + NodeBase* node) { + DefineExceptionHandlerPoint(node); + DefineLazyDeoptPoint(node->lazy_deopt_info()); +} + +} // namespace maglev +} // namespace internal +} // namespace v8 + +#endif // V8_MAGLEV_MAGLEV_ASSEMBLER_INL_H_ diff --git a/src/maglev/maglev-assembler.h b/src/maglev/maglev-assembler.h new file mode 100644 index 0000000000..c4fa5cabf5 --- /dev/null +++ b/src/maglev/maglev-assembler.h @@ -0,0 +1,71 @@ +// Copyright 2022 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_MAGLEV_MAGLEV_ASSEMBLER_H_ +#define V8_MAGLEV_MAGLEV_ASSEMBLER_H_ + +#include "src/codegen/macro-assembler.h" +#include "src/maglev/maglev-code-gen-state.h" + +namespace v8 { +namespace internal { +namespace maglev { + +class MaglevAssembler : public MacroAssembler { + public: + explicit MaglevAssembler(MaglevCodeGenState* code_gen_state) + : MacroAssembler(code_gen_state->isolate(), CodeObjectRequired::kNo), + code_gen_state_(code_gen_state) {} + + inline MemOperand GetStackSlot(const compiler::AllocatedOperand& operand) { + return MemOperand(rbp, GetFramePointerOffsetForStackSlot(operand)); + } + + inline MemOperand ToMemOperand(const compiler::InstructionOperand& operand) { + return GetStackSlot(compiler::AllocatedOperand::cast(operand)); + } + + inline MemOperand ToMemOperand(const ValueLocation& location) { + return ToMemOperand(location.operand()); + } + + inline int GetFramePointerOffsetForStackSlot( + const compiler::AllocatedOperand& operand) { + int index = operand.index(); + if (operand.representation() != MachineRepresentation::kTagged) { + index += code_gen_state()->tagged_slots(); + } + return GetFramePointerOffsetForStackSlot(index); + } + + inline void DefineLazyDeoptPoint(LazyDeoptInfo* info); + inline void DefineExceptionHandlerPoint(NodeBase* node); + inline void DefineExceptionHandlerAndLazyDeoptPoint(NodeBase* node); + + compiler::NativeContextRef native_context() const { + return code_gen_state()->broker()->target_native_context(); + } + + MaglevCodeGenState* code_gen_state() const { return code_gen_state_; } + MaglevSafepointTableBuilder* safepoint_table_builder() const { + return code_gen_state()->safepoint_table_builder(); + } + MaglevCompilationInfo* compilation_info() const { + return code_gen_state()->compilation_info(); + } + + private: + inline constexpr int GetFramePointerOffsetForStackSlot(int index) { + return StandardFrameConstants::kExpressionsOffset - + index * kSystemPointerSize; + } + + MaglevCodeGenState* const code_gen_state_; +}; + +} // namespace maglev +} // namespace internal +} // namespace v8 + +#endif // V8_MAGLEV_MAGLEV_ASSEMBLER_H_ diff --git a/src/maglev/maglev-code-gen-state.h b/src/maglev/maglev-code-gen-state.h index 496e4c5c86..01fdb8216b 100644 --- a/src/maglev/maglev-code-gen-state.h +++ b/src/maglev/maglev-code-gen-state.h @@ -8,7 +8,6 @@ #include "src/codegen/assembler.h" #include "src/codegen/label.h" #include "src/codegen/machine-type.h" -#include "src/codegen/macro-assembler.h" #include "src/codegen/maglev-safepoint-table.h" #include "src/common/globals.h" #include "src/compiler/backend/instruction.h" @@ -21,11 +20,11 @@ namespace internal { namespace maglev { class InterpreterFrameState; +class MaglevAssembler; class DeferredCodeInfo { public: - virtual void Generate(MaglevCodeGenState* code_gen_state, - Label* return_label) = 0; + virtual void Generate(MaglevAssembler* masm, Label* return_label) = 0; Label deferred_code_label; Label return_label; }; @@ -35,8 +34,7 @@ class MaglevCodeGenState { MaglevCodeGenState(MaglevCompilationInfo* compilation_info, MaglevSafepointTableBuilder* safepoint_table_builder) : compilation_info_(compilation_info), - safepoint_table_builder_(safepoint_table_builder), - masm_(isolate(), CodeObjectRequired::kNo) {} + safepoint_table_builder_(safepoint_table_builder) {} void set_tagged_slots(int slots) { tagged_slots_ = slots; } void set_untagged_slots(int slots) { untagged_slots_ = slots; } @@ -55,13 +53,9 @@ class MaglevCodeGenState { const std::vector& lazy_deopts() const { return lazy_deopts_; } - inline void DefineLazyDeoptPoint(LazyDeoptInfo* info); void PushHandlerInfo(NodeBase* node) { handlers_.push_back(node); } const std::vector& handlers() const { return handlers_; } - inline void DefineExceptionHandlerPoint(NodeBase* node); - - inline void DefineExceptionHandlerAndLazyDeoptPoint(NodeBase* node); compiler::NativeContextRef native_context() const { return broker()->target_native_context(); @@ -71,49 +65,17 @@ class MaglevCodeGenState { MaglevGraphLabeller* graph_labeller() const { return compilation_info_->graph_labeller(); } - MacroAssembler* masm() { return &masm_; } int stack_slots() const { return untagged_slots_ + tagged_slots_; } + int tagged_slots() const { return tagged_slots_; } MaglevSafepointTableBuilder* safepoint_table_builder() const { return safepoint_table_builder_; } MaglevCompilationInfo* compilation_info() const { return compilation_info_; } - inline int GetFramePointerOffsetForStackSlot( - const compiler::AllocatedOperand& operand) { - int index = operand.index(); - if (operand.representation() != MachineRepresentation::kTagged) { - index += tagged_slots_; - } - return GetFramePointerOffsetForStackSlot(index); - } - - inline MemOperand GetStackSlot(const compiler::AllocatedOperand& operand) { - return MemOperand(rbp, GetFramePointerOffsetForStackSlot(operand)); - } - - inline MemOperand ToMemOperand(const compiler::InstructionOperand& operand) { - return GetStackSlot(compiler::AllocatedOperand::cast(operand)); - } - - inline MemOperand ToMemOperand(const ValueLocation& location) { - return ToMemOperand(location.operand()); - } - - inline MemOperand TopOfStack() { - return MemOperand(rbp, - GetFramePointerOffsetForStackSlot(stack_slots() - 1)); - } - private: - inline constexpr int GetFramePointerOffsetForStackSlot(int index) { - return StandardFrameConstants::kExpressionsOffset - - index * kSystemPointerSize; - } - MaglevCompilationInfo* const compilation_info_; MaglevSafepointTableBuilder* const safepoint_table_builder_; - MacroAssembler masm_; std::vector deferred_code_; std::vector eager_deopts_; std::vector lazy_deopts_; @@ -158,25 +120,6 @@ inline DoubleRegister ToDoubleRegister(const ValueLocation& location) { return ToDoubleRegister(location.operand()); } -inline void MaglevCodeGenState::DefineLazyDeoptPoint(LazyDeoptInfo* info) { - info->deopting_call_return_pc = masm()->pc_offset_for_safepoint(); - PushLazyDeopt(info); - safepoint_table_builder()->DefineSafepoint(masm()); -} - -inline void MaglevCodeGenState::DefineExceptionHandlerPoint(NodeBase* node) { - ExceptionHandlerInfo* info = node->exception_handler_info(); - if (!info->HasExceptionHandler()) return; - info->pc_offset = masm()->pc_offset_for_safepoint(); - PushHandlerInfo(node); -} - -inline void MaglevCodeGenState::DefineExceptionHandlerAndLazyDeoptPoint( - NodeBase* node) { - DefineExceptionHandlerPoint(node); - DefineLazyDeoptPoint(node->lazy_deopt_info()); -} - } // namespace maglev } // namespace internal } // namespace v8 diff --git a/src/maglev/maglev-code-generator.cc b/src/maglev/maglev-code-generator.cc index 0a3d57b9bb..2c8c14dd5e 100644 --- a/src/maglev/maglev-code-generator.cc +++ b/src/maglev/maglev-code-generator.cc @@ -19,6 +19,7 @@ #include "src/deoptimizer/translation-array.h" #include "src/execution/frame-constants.h" #include "src/interpreter/bytecode-register.h" +#include "src/maglev/maglev-assembler-inl.h" #include "src/maglev/maglev-code-gen-state.h" #include "src/maglev/maglev-compilation-unit.h" #include "src/maglev/maglev-graph-labeller.h" @@ -93,17 +94,15 @@ class ParallelMoveResolver { RegisterTHelper::kAllocatableRegisters; public: - explicit ParallelMoveResolver(MaglevCodeGenState* code_gen_state) - : code_gen_state_(code_gen_state) {} + explicit ParallelMoveResolver(MaglevAssembler* masm) : masm_(masm) {} void RecordMove(ValueNode* source_node, compiler::InstructionOperand source, compiler::AllocatedOperand target) { if (target.IsRegister()) { RecordMoveToRegister(source_node, source, ToRegisterT(target)); } else { - RecordMoveToStackSlot( - source_node, source, - code_gen_state_->GetFramePointerOffsetForStackSlot(target)); + RecordMoveToStackSlot(source_node, source, + masm_->GetFramePointerOffsetForStackSlot(target)); } } @@ -118,7 +117,7 @@ class ParallelMoveResolver { ValueNode* materializing_register_move = materializing_register_moves_[reg.code()]; if (materializing_register_move) { - materializing_register_move->LoadToRegister(code_gen_state_, reg); + materializing_register_move->LoadToRegister(masm_, reg); } } // Emit stack moves until the move set is empty -- each EmitMoveChain will @@ -128,7 +127,7 @@ class ParallelMoveResolver { StartEmitMoveChain(moves_from_stack_slot_.begin()->first); } for (auto [stack_slot, node] : materializing_stack_slot_moves_) { - node->LoadToRegister(code_gen_state_, kScratchRegT); + node->LoadToRegister(masm_, kScratchRegT); EmitStackMove(stack_slot, kScratchRegT); } } @@ -219,7 +218,7 @@ class ParallelMoveResolver { moves_from_register_[source_reg.code()].registers.set(target_reg); } } else if (source.IsAnyStackSlot()) { - uint32_t source_slot = code_gen_state_->GetFramePointerOffsetForStackSlot( + uint32_t source_slot = masm_->GetFramePointerOffsetForStackSlot( compiler::AllocatedOperand::cast(source)); moves_from_stack_slot_[source_slot].registers.set(target_reg); } else { @@ -240,7 +239,7 @@ class ParallelMoveResolver { moves_from_register_[source_reg.code()].stack_slots.push_back( target_slot); } else if (source.IsAnyStackSlot()) { - uint32_t source_slot = code_gen_state_->GetFramePointerOffsetForStackSlot( + uint32_t source_slot = masm_->GetFramePointerOffsetForStackSlot( compiler::AllocatedOperand::cast(source)); if (source_slot != target_slot) { moves_from_stack_slot_[source_slot].stack_slots.push_back(target_slot); @@ -405,9 +404,9 @@ class ParallelMoveResolver { __ movq(MemOperand(rbp, stack_slot), kScratchRegister); } - MacroAssembler* masm() { return code_gen_state_->masm(); } + MacroAssembler* masm() const { return masm_; } - MaglevCodeGenState* code_gen_state_; + MaglevAssembler* const masm_; // Keep moves to/from registers and stack slots separate -- there are a fixed // number of registers but an infinite number of stack slots, so the register @@ -433,8 +432,8 @@ class ParallelMoveResolver { class ExceptionHandlerTrampolineBuilder { public: - ExceptionHandlerTrampolineBuilder(MaglevCodeGenState* code_gen_state) - : code_gen_state_(code_gen_state) {} + explicit ExceptionHandlerTrampolineBuilder(MaglevAssembler* masm) + : masm_(masm) {} void EmitTrampolineFor(NodeBase* node) { DCHECK(node->properties().can_throw()); @@ -460,13 +459,13 @@ class ExceptionHandlerTrampolineBuilder { } private: - MaglevCodeGenState* code_gen_state_; + MaglevAssembler* const masm_; using Move = std::pair; base::SmallVector direct_moves_; base::SmallVector materialisation_moves_; bool save_accumulator_ = false; - MacroAssembler* masm() { return code_gen_state_->masm(); } + MacroAssembler* masm() const { return masm_; } void ClearState() { direct_moves_.clear(); @@ -603,12 +602,12 @@ class ExceptionHandlerTrampolineBuilder { MemOperand ToMemOperand(ValueNode* node) { DCHECK(node->allocation().IsAnyStackSlot()); - return code_gen_state_->ToMemOperand(node->allocation()); + return masm_->ToMemOperand(node->allocation()); } MemOperand ToMemOperand(const ValueLocation& location) { DCHECK(location.operand().IsStackSlot()); - return code_gen_state_->ToMemOperand(location.operand()); + return masm_->ToMemOperand(location.operand()); } template @@ -624,9 +623,9 @@ class ExceptionHandlerTrampolineBuilder { void EmitConstantLoad(const ValueLocation& dst, ValueNode* value) { DCHECK(value->allocation().IsConstant()); if (dst.operand().IsRegister()) { - value->LoadToRegister(code_gen_state_, dst.AssignedGeneralRegister()); + value->LoadToRegister(masm_, dst.AssignedGeneralRegister()); } else { - value->LoadToRegister(code_gen_state_, kScratchRegister); + value->LoadToRegister(masm_, kScratchRegister); __ movq(ToMemOperand(dst), kScratchRegister); } } @@ -634,8 +633,8 @@ class ExceptionHandlerTrampolineBuilder { class MaglevCodeGeneratingNodeProcessor { public: - explicit MaglevCodeGeneratingNodeProcessor(MaglevCodeGenState* code_gen_state) - : code_gen_state_(code_gen_state) {} + explicit MaglevCodeGeneratingNodeProcessor(MaglevAssembler* masm) + : masm_(masm) {} void PreProcessGraph(MaglevCompilationInfo*, Graph* graph) { if (FLAG_maglev_break_on_entry) { @@ -686,8 +685,8 @@ class MaglevCodeGeneratingNodeProcessor { __ Push(kJSFunctionRegister); // Callee's JS function. __ Push(kJavaScriptCallArgCountRegister); // Actual argument count. - code_gen_state_->set_untagged_slots(graph->untagged_stack_slots()); - code_gen_state_->set_tagged_slots(graph->tagged_stack_slots()); + code_gen_state()->set_untagged_slots(graph->untagged_stack_slots()); + code_gen_state()->set_tagged_slots(graph->tagged_stack_slots()); { ASM_CODE_COMMENT_STRING(masm(), " Stack/interrupt check"); @@ -699,7 +698,7 @@ class MaglevCodeGeneratingNodeProcessor { __ Move(kScratchRegister, rsp); // TODO(leszeks): Include a max call argument size here. __ subq(kScratchRegister, - Immediate(code_gen_state_->stack_slots() * kSystemPointerSize)); + Immediate(code_gen_state()->stack_slots() * kSystemPointerSize)); __ cmpq(kScratchRegister, __ StackLimitAsOperand(StackLimitKind::kInterruptStackLimit)); @@ -758,7 +757,7 @@ class MaglevCodeGeneratingNodeProcessor { __ PushAll(RegisterInput::kAllowedRegisters); // Push the frame size __ Push(Immediate( - Smi::FromInt(code_gen_state_->stack_slots() * kSystemPointerSize))); + Smi::FromInt(code_gen_state()->stack_slots() * kSystemPointerSize))); __ CallRuntime(Runtime::kStackGuardWithGap, 1); __ PopAll(RegisterInput::kAllowedRegisters); __ jmp(&deferred_call_stack_guard_return_); @@ -787,7 +786,7 @@ class MaglevCodeGeneratingNodeProcessor { __ movq(kScratchRegister, rbp); __ subq(kScratchRegister, rsp); __ cmpq(kScratchRegister, - Immediate(code_gen_state_->stack_slots() * kSystemPointerSize + + Immediate(code_gen_state()->stack_slots() * kSystemPointerSize + StandardFrameConstants::kFixedFrameSizeFromFp)); __ Assert(equal, AbortReason::kStackAccessBelowStackPointer); } @@ -798,7 +797,7 @@ class MaglevCodeGeneratingNodeProcessor { state); } - node->GenerateCode(code_gen_state_, state); + node->GenerateCode(masm(), state); if (std::is_base_of::value) { ValueNode* value_node = node->template Cast(); @@ -809,10 +808,10 @@ class MaglevCodeGeneratingNodeProcessor { if (!source.IsAnyStackSlot()) { if (FLAG_code_comments) __ RecordComment("-- Spill:"); if (source.IsRegister()) { - __ movq(code_gen_state_->GetStackSlot(value_node->spill_slot()), + __ movq(masm()->GetStackSlot(value_node->spill_slot()), ToRegister(source)); } else { - __ Movsd(code_gen_state_->GetStackSlot(value_node->spill_slot()), + __ Movsd(masm()->GetStackSlot(value_node->spill_slot()), ToDoubleRegister(source)); } } else { @@ -836,8 +835,8 @@ class MaglevCodeGeneratingNodeProcessor { // TODO(leszeks): Move these to fields, to allow their data structure // allocations to be reused. Will need some sort of state resetting. - ParallelMoveResolver register_moves(code_gen_state_); - ParallelMoveResolver double_register_moves(code_gen_state_); + ParallelMoveResolver register_moves(masm_); + ParallelMoveResolver double_register_moves(masm_); // Remember what registers were assigned to by a Phi, to avoid clobbering // them with RegisterMoves. @@ -922,17 +921,20 @@ class MaglevCodeGeneratingNodeProcessor { double_register_moves.EmitMoves(); } - Isolate* isolate() const { return code_gen_state_->isolate(); } - MacroAssembler* masm() const { return code_gen_state_->masm(); } + Isolate* isolate() const { return masm_->isolate(); } + MaglevAssembler* masm() const { return masm_; } + MaglevCodeGenState* code_gen_state() const { + return masm()->code_gen_state(); + } MaglevGraphLabeller* graph_labeller() const { - return code_gen_state_->graph_labeller(); + return code_gen_state()->graph_labeller(); } MaglevSafepointTableBuilder* safepoint_table_builder() const { - return code_gen_state_->safepoint_table_builder(); + return code_gen_state()->safepoint_table_builder(); } private: - MaglevCodeGenState* code_gen_state_; + MaglevAssembler* const masm_; Label deferred_call_stack_guard_; Label deferred_call_stack_guard_return_; }; @@ -952,7 +954,8 @@ class MaglevCodeGeneratorImpl final { graph->tagged_stack_slots(), graph->untagged_stack_slots()), code_gen_state_(compilation_info, safepoint_table_builder()), - processor_(compilation_info, &code_gen_state_), + masm_(&code_gen_state_), + processor_(compilation_info, &masm_), graph_(graph) {} MaybeHandle Generate() { @@ -972,7 +975,7 @@ class MaglevCodeGeneratorImpl final { for (DeferredCodeInfo* deferred_code : code_gen_state_.deferred_code()) { __ RecordComment("-- Deferred block"); __ bind(&deferred_code->deferred_code_label); - deferred_code->Generate(&code_gen_state_, &deferred_code->return_label); + deferred_code->Generate(masm(), &deferred_code->return_label); __ Trap(); } } @@ -1013,7 +1016,7 @@ class MaglevCodeGeneratorImpl final { void EmitExceptionHandlersTrampolines() { if (code_gen_state_.handlers().size() == 0) return; - ExceptionHandlerTrampolineBuilder builder(&code_gen_state_); + ExceptionHandlerTrampolineBuilder builder(masm()); __ RecordComment("-- Exception handlers trampolines"); for (NodeBase* node : code_gen_state_.handlers()) { builder.EmitTrampolineFor(node); @@ -1151,13 +1154,14 @@ class MaglevCodeGeneratorImpl final { Isolate* isolate() const { return code_gen_state_.compilation_info()->isolate(); } - MacroAssembler* masm() { return code_gen_state_.masm(); } + MaglevAssembler* masm() { return &masm_; } MaglevSafepointTableBuilder* safepoint_table_builder() { return &safepoint_table_builder_; } MaglevSafepointTableBuilder safepoint_table_builder_; MaglevCodeGenState code_gen_state_; + MaglevAssembler masm_; GraphProcessor processor_; Graph* const graph_; diff --git a/src/maglev/maglev-compiler.cc b/src/maglev/maglev-compiler.cc index eb224c0c32..88f600e5af 100644 --- a/src/maglev/maglev-compiler.cc +++ b/src/maglev/maglev-compiler.cc @@ -13,7 +13,6 @@ #include "src/base/threaded-list.h" #include "src/codegen/interface-descriptors-inl.h" #include "src/codegen/machine-type.h" -#include "src/codegen/macro-assembler.h" #include "src/codegen/register.h" #include "src/codegen/reglist.h" #include "src/common/globals.h" diff --git a/src/maglev/maglev-ir.cc b/src/maglev/maglev-ir.cc index b57cc1a4a7..c001f51124 100644 --- a/src/maglev/maglev-ir.cc +++ b/src/maglev/maglev-ir.cc @@ -10,7 +10,6 @@ #include "src/builtins/builtins-constructor.h" #include "src/codegen/interface-descriptors-inl.h" #include "src/codegen/interface-descriptors.h" -#include "src/codegen/macro-assembler-inl.h" #include "src/codegen/maglev-safepoint-table.h" #include "src/codegen/register.h" #include "src/codegen/reglist.h" @@ -20,6 +19,7 @@ #include "src/deoptimizer/deoptimize-reason.h" #include "src/ic/handler-configuration.h" #include "src/interpreter/bytecode-flags.h" +#include "src/maglev/maglev-assembler-inl.h" #include "src/maglev/maglev-code-gen-state.h" #include "src/maglev/maglev-compilation-unit.h" #include "src/maglev/maglev-graph-labeller.h" @@ -40,7 +40,7 @@ const char* OpcodeToString(Opcode opcode) { return names[static_cast(opcode)]; } -#define __ code_gen_state->masm()-> +#define __ masm-> namespace { @@ -98,8 +98,8 @@ void UseFixed(Input& input, Register reg) { // Code gen helpers. // --- -void Branch(MaglevCodeGenState* code_gen_state, Condition condition, - BasicBlock* if_true, BasicBlock* if_false, BasicBlock* next_block) { +void Branch(MaglevAssembler* masm, Condition condition, BasicBlock* if_true, + BasicBlock* if_false, BasicBlock* next_block) { // We don't have any branch probability information, so try to jump // over whatever the next block emitted is. if (if_false == next_block) { @@ -115,9 +115,9 @@ void Branch(MaglevCodeGenState* code_gen_state, Condition condition, } } -void PushInput(MaglevCodeGenState* code_gen_state, const Input& input) { +void PushInput(MaglevAssembler* masm, const Input& input) { if (input.operand().IsConstant()) { - input.node()->LoadToRegister(code_gen_state, kScratchRegister); + input.node()->LoadToRegister(masm, kScratchRegister); __ Push(kScratchRegister); } else { // TODO(leszeks): Consider special casing the value. (Toon: could possibly @@ -129,15 +129,15 @@ void PushInput(MaglevCodeGenState* code_gen_state, const Input& input) { __ Push(operand.GetRegister()); } else { DCHECK(operand.IsStackSlot()); - __ Push(code_gen_state->GetStackSlot(operand)); + __ Push(masm->GetStackSlot(operand)); } } } -Register FromAnyToRegister(MaglevCodeGenState* code_gen_state, Register scratch, +Register FromAnyToRegister(MaglevAssembler* masm, Register scratch, const Input& input) { if (input.operand().IsConstant()) { - input.node()->LoadToRegister(code_gen_state, scratch); + input.node()->LoadToRegister(masm, scratch); return scratch; } const compiler::AllocatedOperand& operand = @@ -146,16 +146,15 @@ Register FromAnyToRegister(MaglevCodeGenState* code_gen_state, Register scratch, return ToRegister(input); } else { DCHECK(operand.IsStackSlot()); - __ movq(scratch, code_gen_state->ToMemOperand(input)); + __ movq(scratch, masm->ToMemOperand(input)); return scratch; } } class SaveRegisterStateForCall { public: - SaveRegisterStateForCall(MaglevCodeGenState* code_gen_state, - RegisterSnapshot snapshot) - : code_gen_state(code_gen_state), snapshot_(snapshot) { + SaveRegisterStateForCall(MaglevAssembler* masm, RegisterSnapshot snapshot) + : masm(masm), snapshot_(snapshot) { __ PushAll(snapshot_.live_registers); __ PushAll(snapshot_.live_double_registers, kDoubleSize); } @@ -168,8 +167,7 @@ class SaveRegisterStateForCall { MaglevSafepointTableBuilder::Safepoint DefineSafepoint() { // TODO(leszeks): Avoid emitting safepoints when there are no registers to // save. - auto safepoint = code_gen_state->safepoint_table_builder()->DefineSafepoint( - code_gen_state->masm()); + auto safepoint = masm->safepoint_table_builder()->DefineSafepoint(masm); int pushed_reg_index = 0; for (Register reg : snapshot_.live_registers) { if (snapshot_.live_tagged_registers.has(reg)) { @@ -184,14 +182,13 @@ class SaveRegisterStateForCall { MaglevSafepointTableBuilder::Safepoint DefineSafepointWithLazyDeopt( LazyDeoptInfo* lazy_deopt_info) { - lazy_deopt_info->deopting_call_return_pc = - code_gen_state->masm()->pc_offset_for_safepoint(); - code_gen_state->PushLazyDeopt(lazy_deopt_info); + lazy_deopt_info->deopting_call_return_pc = masm->pc_offset_for_safepoint(); + masm->code_gen_state()->PushLazyDeopt(lazy_deopt_info); return DefineSafepoint(); } private: - MaglevCodeGenState* code_gen_state; + MaglevAssembler* masm; RegisterSnapshot snapshot_; }; @@ -339,17 +336,16 @@ class DeferredCodeInfoImpl final : public DeferredCodeInfo { DeferredCodeInfoImpl(DeferredCodeInfoImpl&&) = delete; DeferredCodeInfoImpl(const DeferredCodeInfoImpl&) = delete; - void Generate(MaglevCodeGenState* code_gen_state, - Label* return_label) override { - DoCall(code_gen_state, return_label, std::make_index_sequence{}); + void Generate(MaglevAssembler* masm, Label* return_label) override { + DoCall(masm, return_label, std::make_index_sequence{}); } private: template - auto DoCall(MaglevCodeGenState* code_gen_state, Label* return_label, + auto DoCall(MaglevAssembler* masm, Label* return_label, std::index_sequence) { // TODO(leszeks): This could be replaced with std::apply in C++17. - return function(code_gen_state, return_label, std::get(args)...); + return function(masm, return_label, std::get(args)...); } FunctionPointer function; @@ -357,16 +353,16 @@ class DeferredCodeInfoImpl final : public DeferredCodeInfo { }; template -DeferredCodeInfo* PushDeferredCode(MaglevCodeGenState* code_gen_state, +DeferredCodeInfo* PushDeferredCode(MaglevAssembler* masm, Function&& deferred_code_gen, Args&&... args) { using DeferredCodeInfoT = DeferredCodeInfoImpl; DeferredCodeInfoT* deferred_code = - code_gen_state->compilation_info()->zone()->New( - code_gen_state->compilation_info(), deferred_code_gen, + masm->compilation_info()->zone()->New( + masm->compilation_info(), deferred_code_gen, std::forward(args)...); - code_gen_state->PushDeferredCode(deferred_code); + masm->code_gen_state()->PushDeferredCode(deferred_code); return deferred_code; } @@ -374,10 +370,10 @@ DeferredCodeInfo* PushDeferredCode(MaglevCodeGenState* code_gen_state, // change until `deferred_code_gen` is actually executed. Use either a // non-capturing lambda, or a plain function pointer. template -void JumpToDeferredIf(Condition cond, MaglevCodeGenState* code_gen_state, +void JumpToDeferredIf(Condition cond, MaglevAssembler* masm, Function&& deferred_code_gen, Args&&... args) { DeferredCodeInfo* deferred_code = PushDeferredCode( - code_gen_state, std::forward(deferred_code_gen), + masm, std::forward(deferred_code_gen), std::forward(args)...); if (FLAG_code_comments) { __ RecordComment("-- Jump to deferred code"); @@ -390,9 +386,8 @@ void JumpToDeferredIf(Condition cond, MaglevCodeGenState* code_gen_state, // Inlined computations. // --- -void AllocateRaw(MaglevCodeGenState* code_gen_state, - RegisterSnapshot& register_snapshot, Register object, - int size_in_bytes, +void AllocateRaw(MaglevAssembler* masm, RegisterSnapshot& register_snapshot, + Register object, int size_in_bytes, AllocationType alloc_type = AllocationType::kYoung, AllocationAlignment alignment = kTaggedAligned) { // TODO(victorgomes): Call the runtime for large object allocation. @@ -402,7 +397,7 @@ void AllocateRaw(MaglevCodeGenState* code_gen_state, alloc_type = AllocationType::kOld; } bool in_new_space = alloc_type == AllocationType::kYoung; - Isolate* isolate = code_gen_state->isolate(); + Isolate* isolate = masm->isolate(); ExternalReference top = in_new_space ? ExternalReference::new_space_allocation_top_address(isolate) @@ -412,7 +407,7 @@ void AllocateRaw(MaglevCodeGenState* code_gen_state, ? ExternalReference::new_space_allocation_limit_address(isolate) : ExternalReference::old_space_allocation_limit_address(isolate); - ZoneLabelRef done(code_gen_state->compilation_info()->zone()); + ZoneLabelRef done(masm->compilation_info()->zone()); Register new_top = kScratchRegister; // Check if there is enough space. __ Move(object, __ ExternalReferenceAsOperand(top)); @@ -420,16 +415,15 @@ void AllocateRaw(MaglevCodeGenState* code_gen_state, __ cmpq(new_top, __ ExternalReferenceAsOperand(limit)); // Otherwise call runtime. JumpToDeferredIf( - greater_equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, + greater_equal, masm, + [](MaglevAssembler* masm, Label* return_label, RegisterSnapshot register_snapshot, Register object, Builtin builtin, int size_in_bytes, ZoneLabelRef done) { // Remove {object} from snapshot, since it is the returned allocated // HeapObject. register_snapshot.live_registers.clear(object); { - SaveRegisterStateForCall save_register_state(code_gen_state, - register_snapshot); + SaveRegisterStateForCall save_register_state(masm, register_snapshot); using D = AllocateDescriptor; __ Move(D::GetRegisterParameter(D::kRequestedSize), size_in_bytes); __ CallBuiltin(builtin); @@ -448,17 +442,16 @@ void AllocateRaw(MaglevCodeGenState* code_gen_state, __ bind(*done); } -void ToBoolean(MaglevCodeGenState* code_gen_state, Register value, - ZoneLabelRef is_true, ZoneLabelRef is_false, - bool fallthrough_when_true) { +void ToBoolean(MaglevAssembler* masm, Register value, ZoneLabelRef is_true, + ZoneLabelRef is_false, bool fallthrough_when_true) { Register map = kScratchRegister; // Check if {{value}} is Smi. __ CheckSmi(value); JumpToDeferredIf( - zero, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register value, ZoneLabelRef is_true, ZoneLabelRef is_false) { + zero, masm, + [](MaglevAssembler* masm, Label* return_label, Register value, + ZoneLabelRef is_true, ZoneLabelRef is_false) { // Check if {value} is not zero. __ SmiCompare(value, Smi::FromInt(0)); __ j(equal, *is_false); @@ -483,9 +476,9 @@ void ToBoolean(MaglevCodeGenState* code_gen_state, Register value, // Check if {{value}} is a HeapNumber. __ CompareRoot(map, RootIndex::kHeapNumberMap); JumpToDeferredIf( - equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register value, ZoneLabelRef is_true, ZoneLabelRef is_false) { + equal, masm, + [](MaglevAssembler* masm, Label* return_label, Register value, + ZoneLabelRef is_true, ZoneLabelRef is_false) { // Sets scratch register to 0.0. __ Xorpd(kScratchDoubleReg, kScratchDoubleReg); // Sets ZF if equal to 0.0, -0.0 or NaN. @@ -499,9 +492,9 @@ void ToBoolean(MaglevCodeGenState* code_gen_state, Register value, // Check if {{value}} is a BigInt. __ CompareRoot(map, RootIndex::kBigIntMap); JumpToDeferredIf( - equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register value, ZoneLabelRef is_true, ZoneLabelRef is_false) { + equal, masm, + [](MaglevAssembler* masm, Label* return_label, Register value, + ZoneLabelRef is_true, ZoneLabelRef is_false) { __ testl(FieldOperand(value, BigInt::kBitfieldOffset), Immediate(BigInt::LengthBits::kMask)); __ j(zero, *is_false); @@ -519,43 +512,43 @@ void ToBoolean(MaglevCodeGenState* code_gen_state, Register value, // Deopt // --- -void RegisterEagerDeopt(MaglevCodeGenState* code_gen_state, - EagerDeoptInfo* deopt_info, DeoptimizeReason reason) { +void RegisterEagerDeopt(MaglevAssembler* masm, EagerDeoptInfo* deopt_info, + DeoptimizeReason reason) { if (deopt_info->reason != DeoptimizeReason::kUnknown) { DCHECK_EQ(deopt_info->reason, reason); } if (deopt_info->deopt_entry_label.is_unused()) { - code_gen_state->PushEagerDeopt(deopt_info); + masm->code_gen_state()->PushEagerDeopt(deopt_info); deopt_info->reason = reason; } } -void EmitEagerDeopt(MaglevCodeGenState* code_gen_state, - EagerDeoptInfo* deopt_info, DeoptimizeReason reason) { - RegisterEagerDeopt(code_gen_state, deopt_info, reason); +void EmitEagerDeopt(MaglevAssembler* masm, EagerDeoptInfo* deopt_info, + DeoptimizeReason reason) { + RegisterEagerDeopt(masm, deopt_info, reason); __ RecordComment("-- Jump to eager deopt"); __ jmp(&deopt_info->deopt_entry_label); } template -void EmitEagerDeopt(MaglevCodeGenState* code_gen_state, NodeT* node, +void EmitEagerDeopt(MaglevAssembler* masm, NodeT* node, DeoptimizeReason reason) { static_assert(NodeT::kProperties.can_eager_deopt()); - EmitEagerDeopt(code_gen_state, node->eager_deopt_info(), reason); + EmitEagerDeopt(masm, node->eager_deopt_info(), reason); } -void EmitEagerDeoptIf(Condition cond, MaglevCodeGenState* code_gen_state, +void EmitEagerDeoptIf(Condition cond, MaglevAssembler* masm, DeoptimizeReason reason, EagerDeoptInfo* deopt_info) { - RegisterEagerDeopt(code_gen_state, deopt_info, reason); + RegisterEagerDeopt(masm, deopt_info, reason); __ RecordComment("-- Jump to eager deopt"); __ j(cond, &deopt_info->deopt_entry_label); } template -void EmitEagerDeoptIf(Condition cond, MaglevCodeGenState* code_gen_state, +void EmitEagerDeoptIf(Condition cond, MaglevAssembler* masm, DeoptimizeReason reason, NodeT* node) { static_assert(NodeT::kProperties.can_eager_deopt()); - EmitEagerDeoptIf(cond, code_gen_state, reason, node->eager_deopt_info()); + EmitEagerDeoptIf(cond, masm, reason, node->eager_deopt_info()); } // --- @@ -671,63 +664,58 @@ DeoptInfo::DeoptInfo(Zone* zone, const MaglevCompilationUnit& compilation_unit, // --- namespace { template -void LoadToRegisterHelper(NodeT* node, MaglevCodeGenState* code_gen_state, - Register reg) { +void LoadToRegisterHelper(NodeT* node, MaglevAssembler* masm, Register reg) { if constexpr (NodeT::kProperties.value_representation() != ValueRepresentation::kFloat64) { - return node->DoLoadToRegister(code_gen_state, reg); + return node->DoLoadToRegister(masm, reg); } else { UNREACHABLE(); } } template -void LoadToRegisterHelper(NodeT* node, MaglevCodeGenState* code_gen_state, +void LoadToRegisterHelper(NodeT* node, MaglevAssembler* masm, DoubleRegister reg) { if constexpr (NodeT::kProperties.value_representation() == ValueRepresentation::kFloat64) { - return node->DoLoadToRegister(code_gen_state, reg); + return node->DoLoadToRegister(masm, reg); } else { UNREACHABLE(); } } } // namespace -void ValueNode::LoadToRegister(MaglevCodeGenState* code_gen_state, - Register reg) { +void ValueNode::LoadToRegister(MaglevAssembler* masm, Register reg) { switch (opcode()) { #define V(Name) \ case Opcode::k##Name: \ - return LoadToRegisterHelper(this->Cast(), code_gen_state, reg); + return LoadToRegisterHelper(this->Cast(), masm, reg); VALUE_NODE_LIST(V) #undef V default: UNREACHABLE(); } } -void ValueNode::LoadToRegister(MaglevCodeGenState* code_gen_state, - DoubleRegister reg) { +void ValueNode::LoadToRegister(MaglevAssembler* masm, DoubleRegister reg) { switch (opcode()) { #define V(Name) \ case Opcode::k##Name: \ - return LoadToRegisterHelper(this->Cast(), code_gen_state, reg); + return LoadToRegisterHelper(this->Cast(), masm, reg); VALUE_NODE_LIST(V) #undef V default: UNREACHABLE(); } } -void ValueNode::DoLoadToRegister(MaglevCodeGenState* code_gen_state, - Register reg) { +void ValueNode::DoLoadToRegister(MaglevAssembler* masm, Register reg) { DCHECK(is_spilled()); DCHECK(!use_double_register()); - __ movq(reg, code_gen_state->GetStackSlot( - compiler::AllocatedOperand::cast(spill_slot()))); + __ movq(reg, + masm->GetStackSlot(compiler::AllocatedOperand::cast(spill_slot()))); } -void ValueNode::DoLoadToRegister(MaglevCodeGenState* code_gen_state, - DoubleRegister reg) { +void ValueNode::DoLoadToRegister(MaglevAssembler* masm, DoubleRegister reg) { DCHECK(is_spilled()); DCHECK(use_double_register()); - __ Movsd(reg, code_gen_state->GetStackSlot( - compiler::AllocatedOperand::cast(spill_slot()))); + __ Movsd(reg, + masm->GetStackSlot(compiler::AllocatedOperand::cast(spill_slot()))); } Handle ValueNode::Reify(LocalIsolate* isolate) { switch (opcode()) { @@ -763,13 +751,12 @@ void ValueNode::SetConstantLocation() { void SmiConstant::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsConstant(vreg_state, this); } -void SmiConstant::GenerateCode(MaglevCodeGenState* code_gen_state, +void SmiConstant::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) {} Handle SmiConstant::DoReify(LocalIsolate* isolate) { return handle(value_, isolate); } -void SmiConstant::DoLoadToRegister(MaglevCodeGenState* code_gen_state, - Register reg) { +void SmiConstant::DoLoadToRegister(MaglevAssembler* masm, Register reg) { __ Move(reg, Immediate(value())); } void SmiConstant::PrintParams(std::ostream& os, @@ -780,12 +767,12 @@ void SmiConstant::PrintParams(std::ostream& os, void Float64Constant::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsConstant(vreg_state, this); } -void Float64Constant::GenerateCode(MaglevCodeGenState* code_gen_state, +void Float64Constant::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) {} Handle Float64Constant::DoReify(LocalIsolate* isolate) { return isolate->factory()->NewNumber(value_); } -void Float64Constant::DoLoadToRegister(MaglevCodeGenState* code_gen_state, +void Float64Constant::DoLoadToRegister(MaglevAssembler* masm, DoubleRegister reg) { __ Move(reg, value()); } @@ -797,10 +784,9 @@ void Float64Constant::PrintParams(std::ostream& os, void Constant::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsConstant(vreg_state, this); } -void Constant::GenerateCode(MaglevCodeGenState* code_gen_state, +void Constant::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) {} -void Constant::DoLoadToRegister(MaglevCodeGenState* code_gen_state, - Register reg) { +void Constant::DoLoadToRegister(MaglevAssembler* masm, Register reg) { __ Move(reg, object_.object()); } Handle Constant::DoReify(LocalIsolate* isolate) { @@ -818,7 +804,7 @@ void DeleteProperty::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(key(), D::GetRegisterParameter(D::kKey)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void DeleteProperty::GenerateCode(MaglevCodeGenState* code_gen_state, +void DeleteProperty::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -827,7 +813,7 @@ void DeleteProperty::GenerateCode(MaglevCodeGenState* code_gen_state, __ Move(D::GetRegisterParameter(D::kLanguageMode), Smi::FromInt(static_cast(mode()))); __ CallBuiltin(Builtin::kDeleteProperty); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void DeleteProperty::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -843,7 +829,7 @@ void GeneratorStore::AllocateVreg(MaglevVregAllocationState* vreg_state) { RequireSpecificTemporary(WriteBarrierDescriptor::ObjectRegister()); RequireSpecificTemporary(WriteBarrierDescriptor::SlotAddressRegister()); } -void GeneratorStore::GenerateCode(MaglevCodeGenState* code_gen_state, +void GeneratorStore::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register generator = ToRegister(generator_input()); Register array = WriteBarrierDescriptor::ObjectRegister(); @@ -856,17 +842,15 @@ void GeneratorStore::GenerateCode(MaglevCodeGenState* code_gen_state, // register since it's a known temporary, and the write barrier slow path // generates better code when value == scratch. Can't use kScratchRegister // because CheckPageFlag uses it. - Register value = FromAnyToRegister( - code_gen_state, WriteBarrierDescriptor::SlotAddressRegister(), - parameters_and_registers(i)); + Register value = + FromAnyToRegister(masm, WriteBarrierDescriptor::SlotAddressRegister(), + parameters_and_registers(i)); DeferredCodeInfo* deferred_write_barrier = PushDeferredCode( - code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register value, Register array, GeneratorStore* node, - int32_t offset) { - ASM_CODE_COMMENT_STRING(code_gen_state->masm(), - "Write barrier slow path"); + masm, + [](MaglevAssembler* masm, Label* return_label, Register value, + Register array, GeneratorStore* node, int32_t offset) { + ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path"); // Use WriteBarrierDescriptor::SlotAddressRegister() as the scratch // register, see comment above. __ CheckPageFlag( @@ -907,15 +891,13 @@ void GeneratorStore::GenerateCode(MaglevCodeGenState* code_gen_state, // Use WriteBarrierDescriptor::SlotAddressRegister() as the scratch // register, see comment above. Register context = FromAnyToRegister( - code_gen_state, WriteBarrierDescriptor::SlotAddressRegister(), - context_input()); + masm, WriteBarrierDescriptor::SlotAddressRegister(), context_input()); DeferredCodeInfo* deferred_context_write_barrier = PushDeferredCode( - code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register context, Register generator, GeneratorStore* node) { - ASM_CODE_COMMENT_STRING(code_gen_state->masm(), - "Write barrier slow path"); + masm, + [](MaglevAssembler* masm, Label* return_label, Register context, + Register generator, GeneratorStore* node) { + ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path"); // Use WriteBarrierDescriptor::SlotAddressRegister() as the scratch // register, see comment above. // TODO(leszeks): The context is almost always going to be in old-space, @@ -967,7 +949,7 @@ void GeneratorRestoreRegister::AllocateVreg( DefineAsRegister(vreg_state, this); set_temporaries_needed(1); } -void GeneratorRestoreRegister::GenerateCode(MaglevCodeGenState* code_gen_state, +void GeneratorRestoreRegister::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register array = ToRegister(array_input()); Register result_reg = ToRegister(result()); @@ -998,7 +980,7 @@ void ForInPrepare::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(enumerator(), D::GetRegisterParameter(D::kEnumerator)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void ForInPrepare::GenerateCode(MaglevCodeGenState* code_gen_state, +void ForInPrepare::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1018,7 +1000,7 @@ void ForInNext::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(cache_index(), D::GetRegisterParameter(D::kCacheIndex)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void ForInNext::GenerateCode(MaglevCodeGenState* code_gen_state, +void ForInNext::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1032,7 +1014,7 @@ void ForInNext::GenerateCode(MaglevCodeGenState* code_gen_state, DCHECK_EQ(D::GetStackParameterCount(), 1); __ Push(feedback().vector); __ CallBuiltin(Builtin::kForInNext); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void GetIterator::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -1041,7 +1023,7 @@ void GetIterator::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(receiver(), D::GetRegisterParameter(D::kReceiver)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void GetIterator::GenerateCode(MaglevCodeGenState* code_gen_state, +void GetIterator::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1058,7 +1040,7 @@ void GetSecondReturnedValue::AllocateVreg( MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister1); } -void GetSecondReturnedValue::GenerateCode(MaglevCodeGenState* code_gen_state, +void GetSecondReturnedValue::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // No-op. This is just a hack that binds kReturnRegister1 to a value node. // kReturnRegister1 is guaranteed to be free in the register allocator, since @@ -1086,7 +1068,7 @@ void InitialValue::AllocateVreg(MaglevVregAllocationState* vreg_state) { source().index(), vreg_state->AllocateVirtualRegister()); } -void InitialValue::GenerateCode(MaglevCodeGenState* code_gen_state, +void InitialValue::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // No-op, the value is already in the appropriate slot. } @@ -1099,7 +1081,7 @@ void LoadGlobal::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(context(), kContextRegister); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void LoadGlobal::GenerateCode(MaglevCodeGenState* code_gen_state, +void LoadGlobal::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // TODO(leszeks): Port the nice Sparkplug CallBuiltin helper. if (typeof_mode() == TypeofMode::kNotInside) { @@ -1124,7 +1106,7 @@ void LoadGlobal::GenerateCode(MaglevCodeGenState* code_gen_state, __ CallBuiltin(Builtin::kLoadGlobalICInsideTypeof); } - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void LoadGlobal::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -1137,7 +1119,7 @@ void StoreGlobal::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value(), D::GetRegisterParameter(D::kValue)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void StoreGlobal::GenerateCode(MaglevCodeGenState* code_gen_state, +void StoreGlobal::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1148,7 +1130,7 @@ void StoreGlobal::GenerateCode(MaglevCodeGenState* code_gen_state, __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kStoreGlobalIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void StoreGlobal::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -1158,7 +1140,7 @@ void StoreGlobal::PrintParams(std::ostream& os, void RegisterInput::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, input()); } -void RegisterInput::GenerateCode(MaglevCodeGenState* code_gen_state, +void RegisterInput::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // Nothing to be done, the value is already in the register. } @@ -1170,7 +1152,7 @@ void RegisterInput::PrintParams(std::ostream& os, void RootConstant::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsConstant(vreg_state, this); } -void RootConstant::GenerateCode(MaglevCodeGenState* code_gen_state, +void RootConstant::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) {} bool RootConstant::ToBoolean(LocalIsolate* local_isolate) const { switch (index_) { @@ -1183,8 +1165,7 @@ bool RootConstant::ToBoolean(LocalIsolate* local_isolate) const { return true; } } -void RootConstant::DoLoadToRegister(MaglevCodeGenState* code_gen_state, - Register reg) { +void RootConstant::DoLoadToRegister(MaglevAssembler* masm, Register reg) { __ LoadRoot(reg, index()); } Handle RootConstant::DoReify(LocalIsolate* isolate) { @@ -1199,10 +1180,10 @@ void CreateEmptyArrayLiteral::AllocateVreg( MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateEmptyArrayLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateEmptyArrayLiteral::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CreateEmptyArrayLiteralDescriptor; - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ Move(D::GetRegisterParameter(D::kSlot), Smi::FromInt(feedback().index())); __ Move(D::GetRegisterParameter(D::kFeedbackVector), feedback().vector); __ CallBuiltin(Builtin::kCreateEmptyArrayLiteral); @@ -1211,9 +1192,9 @@ void CreateEmptyArrayLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, void CreateArrayLiteral::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateArrayLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateArrayLiteral::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ Push(feedback().vector); __ Push(TaggedIndex::FromIntptr(feedback().index())); __ Push(constant_elements().object()); @@ -1225,10 +1206,10 @@ void CreateShallowArrayLiteral::AllocateVreg( MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateShallowArrayLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateShallowArrayLiteral::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CreateShallowArrayLiteralDescriptor; - __ Move(D::ContextRegister(), code_gen_state->native_context().object()); + __ Move(D::ContextRegister(), masm->native_context().object()); __ Move(D::GetRegisterParameter(D::kMaybeFeedbackVector), feedback().vector); __ Move(D::GetRegisterParameter(D::kSlot), TaggedIndex::FromIntptr(feedback().index())); @@ -1241,9 +1222,9 @@ void CreateShallowArrayLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, void CreateObjectLiteral::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateObjectLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateObjectLiteral::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ Push(feedback().vector); __ Push(TaggedIndex::FromIntptr(feedback().index())); __ Push(boilerplate_descriptor().object()); @@ -1255,11 +1236,11 @@ void CreateEmptyObjectLiteral::AllocateVreg( MaglevVregAllocationState* vreg_state) { DefineAsRegister(vreg_state, this); } -void CreateEmptyObjectLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateEmptyObjectLiteral::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(result()); RegisterSnapshot save_registers = register_snapshot(); - AllocateRaw(code_gen_state, save_registers, object, map().instance_size()); + AllocateRaw(masm, save_registers, object, map().instance_size()); __ Move(kScratchRegister, map().object()); __ StoreTaggedField(FieldOperand(object, HeapObject::kMapOffset), kScratchRegister); @@ -1279,10 +1260,10 @@ void CreateShallowObjectLiteral::AllocateVreg( MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateShallowObjectLiteral::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { +void CreateShallowObjectLiteral::GenerateCode(MaglevAssembler* masm, + const ProcessingState& state) { using D = CreateShallowObjectLiteralDescriptor; - __ Move(D::ContextRegister(), code_gen_state->native_context().object()); + __ Move(D::ContextRegister(), masm->native_context().object()); __ Move(D::GetRegisterParameter(D::kMaybeFeedbackVector), feedback().vector); __ Move(D::GetRegisterParameter(D::kSlot), TaggedIndex::FromIntptr(feedback().index())); @@ -1310,7 +1291,7 @@ void CreateFunctionContext::AllocateVreg( } DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateFunctionContext::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateFunctionContext::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { if (scope_type() == FUNCTION_SCOPE) { using D = CallInterfaceDescriptorFor< @@ -1341,7 +1322,7 @@ void FastCreateClosure::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(context(), D::ContextRegister()); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void FastCreateClosure::GenerateCode(MaglevCodeGenState* code_gen_state, +void FastCreateClosure::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; @@ -1361,7 +1342,7 @@ void CreateClosure::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(context(), kContextRegister); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateClosure::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateClosure::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Runtime::FunctionId function_id = pretenured() ? Runtime::kNewClosure_Tenured : Runtime::kNewClosure; @@ -1382,10 +1363,10 @@ void CreateClosure::PrintParams(std::ostream& os, void CreateRegExpLiteral::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CreateRegExpLiteral::GenerateCode(MaglevCodeGenState* code_gen_state, +void CreateRegExpLiteral::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CreateRegExpLiteralDescriptor; - __ Move(D::ContextRegister(), code_gen_state->native_context().object()); + __ Move(D::ContextRegister(), masm->native_context().object()); __ Move(D::GetRegisterParameter(D::kMaybeFeedbackVector), feedback().vector); __ Move(D::GetRegisterParameter(D::kSlot), TaggedIndex::FromIntptr(feedback().index())); @@ -1400,18 +1381,18 @@ void GetTemplateObject::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void GetTemplateObject::GenerateCode(MaglevCodeGenState* code_gen_state, +void GetTemplateObject::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = GetTemplateObjectDescriptor; - __ Move(D::ContextRegister(), code_gen_state->native_context().object()); + __ Move(D::ContextRegister(), masm->native_context().object()); __ Move(D::GetRegisterParameter(D::kMaybeFeedbackVector), feedback().vector); __ Move(D::GetRegisterParameter(D::kSlot), feedback().slot.ToInt()); __ Move(D::GetRegisterParameter(D::kShared), shared_function_info_.object()); __ CallBuiltin(Builtin::kGetTemplateObject); } -void Abort::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) { +void Abort::AllocateVreg(MaglevVregAllocationState* vreg_state) {} +void Abort::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { __ Push(Smi::FromInt(static_cast(reason()))); __ CallRuntime(Runtime::kAbort, 1); __ Trap(); @@ -1424,7 +1405,7 @@ void Abort::PrintParams(std::ostream& os, void CheckMaps::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(receiver_input()); } -void CheckMaps::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckMaps::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(receiver_input()); @@ -1432,11 +1413,10 @@ void CheckMaps::GenerateCode(MaglevCodeGenState* code_gen_state, __ AssertNotSmi(object); } else { Condition is_smi = __ CheckSmi(object); - EmitEagerDeoptIf(is_smi, code_gen_state, DeoptimizeReason::kWrongMap, this); + EmitEagerDeoptIf(is_smi, masm, DeoptimizeReason::kWrongMap, this); } __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map().object()); - EmitEagerDeoptIf(not_equal, code_gen_state, DeoptimizeReason::kWrongMap, - this); + EmitEagerDeoptIf(not_equal, masm, DeoptimizeReason::kWrongMap, this); } void CheckMaps::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -1445,12 +1425,12 @@ void CheckMaps::PrintParams(std::ostream& os, void CheckSmi::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(receiver_input()); } -void CheckSmi::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckSmi::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(receiver_input()); Condition is_smi = __ CheckSmi(object); - EmitEagerDeoptIf(NegateCondition(is_smi), code_gen_state, - DeoptimizeReason::kNotASmi, this); + EmitEagerDeoptIf(NegateCondition(is_smi), masm, DeoptimizeReason::kNotASmi, + this); } void CheckSmi::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const {} @@ -1458,7 +1438,7 @@ void CheckSmi::PrintParams(std::ostream& os, void CheckNumber::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(receiver_input()); } -void CheckNumber::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckNumber::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Label done; Register value = ToRegister(receiver_input()); @@ -1474,39 +1454,36 @@ void CheckNumber::GenerateCode(MaglevCodeGenState* code_gen_state, __ cmpw(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset), Immediate(BIGINT_TYPE)); } - EmitEagerDeoptIf(not_equal, code_gen_state, DeoptimizeReason::kNotANumber, - this); + EmitEagerDeoptIf(not_equal, masm, DeoptimizeReason::kNotANumber, this); __ bind(&done); } void CheckHeapObject::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(receiver_input()); } -void CheckHeapObject::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckHeapObject::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(receiver_input()); Condition is_smi = __ CheckSmi(object); - EmitEagerDeoptIf(is_smi, code_gen_state, DeoptimizeReason::kSmi, this); + EmitEagerDeoptIf(is_smi, masm, DeoptimizeReason::kSmi, this); } void CheckHeapObject::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const {} void CheckSymbol::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(receiver_input()); } -void CheckSymbol::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckSymbol::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(receiver_input()); if (check_type_ == CheckType::kOmitHeapObjectCheck) { __ AssertNotSmi(object); } else { Condition is_smi = __ CheckSmi(object); - EmitEagerDeoptIf(is_smi, code_gen_state, DeoptimizeReason::kNotASymbol, - this); + EmitEagerDeoptIf(is_smi, masm, DeoptimizeReason::kNotASymbol, this); } __ LoadMap(kScratchRegister, object); __ CmpInstanceType(kScratchRegister, SYMBOL_TYPE); - EmitEagerDeoptIf(not_equal, code_gen_state, DeoptimizeReason::kNotASymbol, - this); + EmitEagerDeoptIf(not_equal, masm, DeoptimizeReason::kNotASymbol, this); } void CheckSymbol::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const {} @@ -1514,20 +1491,19 @@ void CheckSymbol::PrintParams(std::ostream& os, void CheckString::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(receiver_input()); } -void CheckString::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckString::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(receiver_input()); if (check_type_ == CheckType::kOmitHeapObjectCheck) { __ AssertNotSmi(object); } else { Condition is_smi = __ CheckSmi(object); - EmitEagerDeoptIf(is_smi, code_gen_state, DeoptimizeReason::kNotAString, - this); + EmitEagerDeoptIf(is_smi, masm, DeoptimizeReason::kNotAString, this); } __ LoadMap(kScratchRegister, object); __ CmpInstanceTypeRange(kScratchRegister, kScratchRegister, FIRST_STRING_TYPE, LAST_STRING_TYPE); - EmitEagerDeoptIf(above, code_gen_state, DeoptimizeReason::kNotAString, this); + EmitEagerDeoptIf(above, masm, DeoptimizeReason::kNotAString, this); } void CheckString::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const {} @@ -1536,7 +1512,7 @@ void CheckMapsWithMigration::AllocateVreg( MaglevVregAllocationState* vreg_state) { UseRegister(receiver_input()); } -void CheckMapsWithMigration::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckMapsWithMigration::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(receiver_input()); @@ -1544,17 +1520,15 @@ void CheckMapsWithMigration::GenerateCode(MaglevCodeGenState* code_gen_state, __ AssertNotSmi(object); } else { Condition is_smi = __ CheckSmi(object); - EmitEagerDeoptIf(is_smi, code_gen_state, DeoptimizeReason::kWrongMap, this); + EmitEagerDeoptIf(is_smi, masm, DeoptimizeReason::kWrongMap, this); } __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map().object()); JumpToDeferredIf( - not_equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register object, CheckMapsWithMigration* node, - EagerDeoptInfo* deopt_info) { - RegisterEagerDeopt(code_gen_state, deopt_info, - DeoptimizeReason::kWrongMap); + not_equal, masm, + [](MaglevAssembler* masm, Label* return_label, Register object, + CheckMapsWithMigration* node, EagerDeoptInfo* deopt_info) { + RegisterEagerDeopt(masm, deopt_info, DeoptimizeReason::kWrongMap); // Reload the map to avoid needing to save it on a temporary in the fast // path. @@ -1571,11 +1545,10 @@ void CheckMapsWithMigration::GenerateCode(MaglevCodeGenState* code_gen_state, Register return_val = Register::no_reg(); { SaveRegisterStateForCall save_register_state( - code_gen_state, node->register_snapshot()); + masm, node->register_snapshot()); __ Push(object); - __ Move(kContextRegister, - code_gen_state->broker()->target_native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ CallRuntime(Runtime::kTryMigrateInstance); save_register_state.DefineSafepoint(); @@ -1615,7 +1588,7 @@ void CheckedInternalizedString::AllocateVreg( set_temporaries_needed(1); DefineSameAsFirst(vreg_state, this); } -void CheckedInternalizedString::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckedInternalizedString::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(object_input()); RegList temps = temporaries(); @@ -1625,7 +1598,7 @@ void CheckedInternalizedString::GenerateCode(MaglevCodeGenState* code_gen_state, __ AssertNotSmi(object); } else { Condition is_smi = __ CheckSmi(object); - EmitEagerDeoptIf(is_smi, code_gen_state, DeoptimizeReason::kWrongMap, this); + EmitEagerDeoptIf(is_smi, masm, DeoptimizeReason::kWrongMap, this); } __ LoadMap(map_tmp, object); @@ -1634,10 +1607,10 @@ void CheckedInternalizedString::GenerateCode(MaglevCodeGenState* code_gen_state, Immediate(kIsNotStringMask | kIsNotInternalizedMask)); static_assert((kStringTag | kInternalizedTag) == 0); JumpToDeferredIf( - not_zero, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register object, CheckedInternalizedString* node, - EagerDeoptInfo* deopt_info, Register map_tmp) { + not_zero, masm, + [](MaglevAssembler* masm, Label* return_label, Register object, + CheckedInternalizedString* node, EagerDeoptInfo* deopt_info, + Register map_tmp) { __ RecordComment("Deferred Test IsThinString"); __ movw(map_tmp, FieldOperand(map_tmp, Map::kInstanceTypeOffset)); static_assert(kThinStringTagBit > 0); @@ -1662,7 +1635,7 @@ void LoadTaggedField::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(object_input()); DefineAsRegister(vreg_state, this); } -void LoadTaggedField::GenerateCode(MaglevCodeGenState* code_gen_state, +void LoadTaggedField::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(object_input()); __ AssertNotSmi(object); @@ -1678,7 +1651,7 @@ void LoadDoubleField::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsRegister(vreg_state, this); set_temporaries_needed(1); } -void LoadDoubleField::GenerateCode(MaglevCodeGenState* code_gen_state, +void LoadDoubleField::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register tmp = temporaries().PopFirst(); Register object = ToRegister(object_input()); @@ -1699,7 +1672,7 @@ void StoreTaggedFieldNoWriteBarrier::AllocateVreg( UseRegister(value_input()); } void StoreTaggedFieldNoWriteBarrier::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { + MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(object_input()); Register value = ToRegister(value_input()); @@ -1717,7 +1690,7 @@ void StoreTaggedFieldWithWriteBarrier::AllocateVreg( UseRegister(value_input()); } void StoreTaggedFieldWithWriteBarrier::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { + MaglevAssembler* masm, const ProcessingState& state) { // TODO(leszeks): Consider making this an arbitrary register and push/popping // in the deferred path. Register object = WriteBarrierDescriptor::ObjectRegister(); @@ -1729,12 +1702,10 @@ void StoreTaggedFieldWithWriteBarrier::GenerateCode( __ StoreTaggedField(FieldOperand(object, offset()), value); DeferredCodeInfo* deferred_write_barrier = PushDeferredCode( - code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register value, Register object, - StoreTaggedFieldWithWriteBarrier* node) { - ASM_CODE_COMMENT_STRING(code_gen_state->masm(), - "Write barrier slow path"); + masm, + [](MaglevAssembler* masm, Label* return_label, Register value, + Register object, StoreTaggedFieldWithWriteBarrier* node) { + ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path"); __ CheckPageFlag( value, kScratchRegister, MemoryChunk::kPointersToHereAreInterestingOrInSharedHeapMask, zero, @@ -1778,7 +1749,7 @@ void LoadNamedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(object_input(), D::GetRegisterParameter(D::kReceiver)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void LoadNamedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, +void LoadNamedGeneric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = LoadWithVectorDescriptor; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1788,7 +1759,7 @@ void LoadNamedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, Smi::FromInt(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kLoadIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void LoadNamedGeneric::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -1804,7 +1775,7 @@ void LoadNamedFromSuperGeneric::AllocateVreg( D::GetRegisterParameter(D::kLookupStartObject)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void LoadNamedFromSuperGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, +void LoadNamedFromSuperGeneric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = LoadWithReceiverAndVectorDescriptor; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1816,7 +1787,7 @@ void LoadNamedFromSuperGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, Smi::FromInt(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kLoadSuperIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void LoadNamedFromSuperGeneric::PrintParams( std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -1830,7 +1801,7 @@ void SetNamedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value_input(), D::GetRegisterParameter(D::kValue)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void SetNamedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, +void SetNamedGeneric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1841,7 +1812,7 @@ void SetNamedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, Smi::FromInt(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kStoreIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void SetNamedGeneric::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -1856,7 +1827,7 @@ void DefineNamedOwnGeneric::AllocateVreg( UseFixed(value_input(), D::GetRegisterParameter(D::kValue)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void DefineNamedOwnGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, +void DefineNamedOwnGeneric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1867,7 +1838,7 @@ void DefineNamedOwnGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, Smi::FromInt(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kDefineNamedOwnIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void DefineNamedOwnGeneric::PrintParams( std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -1882,7 +1853,7 @@ void SetKeyedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value_input(), D::GetRegisterParameter(D::kValue)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void SetKeyedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, +void SetKeyedGeneric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1893,7 +1864,7 @@ void SetKeyedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, Smi::FromInt(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kKeyedStoreIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void DefineKeyedOwnGeneric::AllocateVreg( @@ -1905,7 +1876,7 @@ void DefineKeyedOwnGeneric::AllocateVreg( UseFixed(value_input(), D::GetRegisterParameter(D::kValue)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void DefineKeyedOwnGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, +void DefineKeyedOwnGeneric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1916,7 +1887,7 @@ void DefineKeyedOwnGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, Smi::FromInt(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kDefineKeyedOwnIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void StoreInArrayLiteralGeneric::AllocateVreg( @@ -1928,8 +1899,8 @@ void StoreInArrayLiteralGeneric::AllocateVreg( UseFixed(value_input(), D::GetRegisterParameter(D::kValue)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void StoreInArrayLiteralGeneric::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { +void StoreInArrayLiteralGeneric::GenerateCode(MaglevAssembler* masm, + const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); DCHECK_EQ(ToRegister(object_input()), D::GetRegisterParameter(D::kReceiver)); @@ -1939,7 +1910,7 @@ void StoreInArrayLiteralGeneric::GenerateCode( Smi::FromInt(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kStoreInArrayLiteralIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void GetKeyedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -1949,7 +1920,7 @@ void GetKeyedGeneric::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(key_input(), D::GetRegisterParameter(D::kName)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void GetKeyedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, +void GetKeyedGeneric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); @@ -1959,13 +1930,13 @@ void GetKeyedGeneric::GenerateCode(MaglevCodeGenState* code_gen_state, TaggedIndex::FromIntptr(feedback().slot.ToInt())); __ Move(D::GetRegisterParameter(D::kVector), feedback().vector); __ CallBuiltin(Builtin::kKeyedLoadIC); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void GapMove::AllocateVreg(MaglevVregAllocationState* vreg_state) { UNREACHABLE(); } -void GapMove::GenerateCode(MaglevCodeGenState* code_gen_state, +void GapMove::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { if (source().IsRegister()) { Register source_reg = ToRegister(source()); @@ -1973,7 +1944,7 @@ void GapMove::GenerateCode(MaglevCodeGenState* code_gen_state, DCHECK(target().IsRegister()); __ movq(ToRegister(target()), source_reg); } else { - __ movq(code_gen_state->ToMemOperand(target()), source_reg); + __ movq(masm->ToMemOperand(target()), source_reg); } } else if (source().IsDoubleRegister()) { DoubleRegister source_reg = ToDoubleRegister(source()); @@ -1981,11 +1952,11 @@ void GapMove::GenerateCode(MaglevCodeGenState* code_gen_state, DCHECK(target().IsDoubleRegister()); __ Movsd(ToDoubleRegister(target()), source_reg); } else { - __ Movsd(code_gen_state->ToMemOperand(target()), source_reg); + __ Movsd(masm->ToMemOperand(target()), source_reg); } } else { DCHECK(source().IsAnyStackSlot()); - MemOperand source_op = code_gen_state->ToMemOperand(source()); + MemOperand source_op = masm->ToMemOperand(source()); if (target().IsRegister()) { __ movq(ToRegister(target()), source_op); } else if (target().IsDoubleRegister()) { @@ -1993,7 +1964,7 @@ void GapMove::GenerateCode(MaglevCodeGenState* code_gen_state, } else { DCHECK(target().IsAnyStackSlot()); __ movq(kScratchRegister, source_op); - __ movq(code_gen_state->ToMemOperand(target()), kScratchRegister); + __ movq(masm->ToMemOperand(target()), kScratchRegister); } } } @@ -2021,13 +1992,13 @@ struct GetRegister { } }; } // namespace -void ConstantGapMove::GenerateCode(MaglevCodeGenState* code_gen_state, +void ConstantGapMove::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { switch (node_->opcode()) { #define CASE(Name) \ case Opcode::k##Name: \ return node_->Cast()->DoLoadToRegister( \ - code_gen_state, GetRegister::Get(target())); + masm, GetRegister::Get(target())); CONSTANT_VALUE_NODE_LIST(CASE) #undef CASE default: @@ -2065,14 +2036,14 @@ void UnaryWithFeedbackNode::AllocateVreg( template void UnaryWithFeedbackNode::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { + MaglevAssembler* masm, const ProcessingState& state) { using D = UnaryOp_WithFeedbackDescriptor; DCHECK_EQ(ToRegister(operand_input()), D::GetRegisterParameter(D::kValue)); - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ Move(D::GetRegisterParameter(D::kSlot), Immediate(feedback().index())); __ Move(D::GetRegisterParameter(D::kFeedbackVector), feedback().vector); __ CallBuiltin(BuiltinFor(kOperation)); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } template @@ -2086,24 +2057,24 @@ void BinaryWithFeedbackNode::AllocateVreg( template void BinaryWithFeedbackNode::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { + MaglevAssembler* masm, const ProcessingState& state) { using D = BinaryOp_WithFeedbackDescriptor; DCHECK_EQ(ToRegister(left_input()), D::GetRegisterParameter(D::kLeft)); DCHECK_EQ(ToRegister(right_input()), D::GetRegisterParameter(D::kRight)); - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ Move(D::GetRegisterParameter(D::kSlot), Immediate(feedback().index())); __ Move(D::GetRegisterParameter(D::kFeedbackVector), feedback().vector); __ CallBuiltin(BuiltinFor(kOperation)); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } #define DEF_OPERATION(Name) \ void Name::AllocateVreg(MaglevVregAllocationState* vreg_state) { \ Base::AllocateVreg(vreg_state); \ } \ - void Name::GenerateCode(MaglevCodeGenState* code_gen_state, \ + void Name::GenerateCode(MaglevAssembler* masm, \ const ProcessingState& state) { \ - Base::GenerateCode(code_gen_state, state); \ + Base::GenerateCode(masm, state); \ } GENERIC_OPERATIONS_NODE_LIST(DEF_OPERATION) #undef DEF_OPERATION @@ -2114,12 +2085,12 @@ void Int32AddWithOverflow::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Int32AddWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32AddWithOverflow::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); __ addl(left, right); - EmitEagerDeoptIf(overflow, code_gen_state, DeoptimizeReason::kOverflow, this); + EmitEagerDeoptIf(overflow, masm, DeoptimizeReason::kOverflow, this); } void Int32SubtractWithOverflow::AllocateVreg( @@ -2129,12 +2100,12 @@ void Int32SubtractWithOverflow::AllocateVreg( DefineSameAsFirst(vreg_state, this); } -void Int32SubtractWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32SubtractWithOverflow::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); __ subl(left, right); - EmitEagerDeoptIf(overflow, code_gen_state, DeoptimizeReason::kOverflow, this); + EmitEagerDeoptIf(overflow, masm, DeoptimizeReason::kOverflow, this); } void Int32MultiplyWithOverflow::AllocateVreg( @@ -2145,7 +2116,7 @@ void Int32MultiplyWithOverflow::AllocateVreg( set_temporaries_needed(1); } -void Int32MultiplyWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32MultiplyWithOverflow::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register result = ToRegister(this->result()); Register right = ToRegister(right_input()); @@ -2155,7 +2126,7 @@ void Int32MultiplyWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, __ movl(saved_left, result); // TODO(leszeks): peephole optimise multiplication by a constant. __ imull(result, right); - EmitEagerDeoptIf(overflow, code_gen_state, DeoptimizeReason::kOverflow, this); + EmitEagerDeoptIf(overflow, masm, DeoptimizeReason::kOverflow, this); // If the result is zero, check if either lhs or rhs is negative. Label end; @@ -2168,7 +2139,7 @@ void Int32MultiplyWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, // so deopt. // TODO(leszeks): Consider splitting these deopts to have distinct deopt // reasons. Otherwise, the reason has to match the above. - EmitEagerDeoptIf(less, code_gen_state, DeoptimizeReason::kOverflow, this); + EmitEagerDeoptIf(less, masm, DeoptimizeReason::kOverflow, this); } __ bind(&end); } @@ -2183,7 +2154,7 @@ void Int32DivideWithOverflow::AllocateVreg( RequireSpecificTemporary(rdx); } -void Int32DivideWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32DivideWithOverflow::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DCHECK(temporaries().has(rax)); DCHECK(temporaries().has(rdx)); @@ -2203,9 +2174,9 @@ void Int32DivideWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, // Check if {right} is positive (and not zero). __ cmpl(right, Immediate(0)); JumpToDeferredIf( - less_equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, - Register right, Int32DivideWithOverflow* node) { + less_equal, masm, + [](MaglevAssembler* masm, Label* return_label, Register right, + Int32DivideWithOverflow* node) { // {right} is negative or zero. // Check if {right} is zero. @@ -2214,15 +2185,13 @@ void Int32DivideWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, // better. Right now all eager deopts in a node have to be the same -- // we should allow a node to emit multiple eager deopts with different // reasons. - EmitEagerDeoptIf(equal, code_gen_state, DeoptimizeReason::kNotInt32, - node); + EmitEagerDeoptIf(equal, masm, DeoptimizeReason::kNotInt32, node); // Check if {left} is zero, as that would produce minus zero. Left is in // rax already. __ cmpl(rax, Immediate(0)); // TODO(leszeks): Better DeoptimizeReason = kMinusZero. - EmitEagerDeoptIf(equal, code_gen_state, DeoptimizeReason::kNotInt32, - node); + EmitEagerDeoptIf(equal, masm, DeoptimizeReason::kNotInt32, node); // Check if {left} is kMinInt and {right} is -1, in which case we'd have // to return -kMinInt, which is not representable as Int32. @@ -2231,7 +2200,7 @@ void Int32DivideWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, __ cmpl(right, Immediate(-1)); __ j(not_equal, return_label); // TODO(leszeks): Better DeoptimizeReason = kOverflow. - EmitEagerDeopt(code_gen_state, node->eager_deopt_info(), + EmitEagerDeopt(masm, node->eager_deopt_info(), DeoptimizeReason::kNotInt32); }, right, this); @@ -2241,8 +2210,7 @@ void Int32DivideWithOverflow::GenerateCode(MaglevCodeGenState* code_gen_state, // Check that the remainder is zero. __ cmpl(rdx, Immediate(0)); - EmitEagerDeoptIf(not_equal, code_gen_state, DeoptimizeReason::kNotInt32, - this); + EmitEagerDeoptIf(not_equal, masm, DeoptimizeReason::kNotInt32, this); DCHECK_EQ(ToRegister(result()), rax); } @@ -2252,7 +2220,7 @@ void Int32BitwiseAnd::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Int32BitwiseAnd::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32BitwiseAnd::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); @@ -2265,7 +2233,7 @@ void Int32BitwiseOr::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Int32BitwiseOr::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32BitwiseOr::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); @@ -2278,7 +2246,7 @@ void Int32BitwiseXor::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Int32BitwiseXor::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32BitwiseXor::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); @@ -2293,7 +2261,7 @@ void Int32ShiftLeft::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Int32ShiftLeft::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32ShiftLeft::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); DCHECK_EQ(rcx, ToRegister(right_input())); @@ -2308,7 +2276,7 @@ void Int32ShiftRight::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Int32ShiftRight::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32ShiftRight::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); DCHECK_EQ(rcx, ToRegister(right_input())); @@ -2324,7 +2292,7 @@ void Int32ShiftRightLogical::AllocateVreg( DefineSameAsFirst(vreg_state, this); } -void Int32ShiftRightLogical::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32ShiftRightLogical::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); DCHECK_EQ(rcx, ToRegister(right_input())); @@ -2363,7 +2331,7 @@ void Int32CompareNode::AllocateVreg( template void Int32CompareNode::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { + MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); Register result = ToRegister(this->result()); @@ -2386,9 +2354,9 @@ void Int32CompareNode::GenerateCode( void Name::AllocateVreg(MaglevVregAllocationState* vreg_state) { \ Base::AllocateVreg(vreg_state); \ } \ - void Name::GenerateCode(MaglevCodeGenState* code_gen_state, \ + void Name::GenerateCode(MaglevAssembler* masm, \ const ProcessingState& state) { \ - Base::GenerateCode(code_gen_state, state); \ + Base::GenerateCode(masm, state); \ } DEF_OPERATION(Int32Equal) DEF_OPERATION(Int32StrictEqual) @@ -2404,7 +2372,7 @@ void Float64Add::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Float64Add::GenerateCode(MaglevCodeGenState* code_gen_state, +void Float64Add::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DoubleRegister left = ToDoubleRegister(left_input()); DoubleRegister right = ToDoubleRegister(right_input()); @@ -2417,7 +2385,7 @@ void Float64Subtract::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Float64Subtract::GenerateCode(MaglevCodeGenState* code_gen_state, +void Float64Subtract::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DoubleRegister left = ToDoubleRegister(left_input()); DoubleRegister right = ToDoubleRegister(right_input()); @@ -2430,7 +2398,7 @@ void Float64Multiply::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Float64Multiply::GenerateCode(MaglevCodeGenState* code_gen_state, +void Float64Multiply::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DoubleRegister left = ToDoubleRegister(left_input()); DoubleRegister right = ToDoubleRegister(right_input()); @@ -2443,7 +2411,7 @@ void Float64Divide::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void Float64Divide::GenerateCode(MaglevCodeGenState* code_gen_state, +void Float64Divide::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DoubleRegister left = ToDoubleRegister(left_input()); DoubleRegister right = ToDoubleRegister(right_input()); @@ -2460,7 +2428,7 @@ void Float64CompareNode::AllocateVreg( template void Float64CompareNode::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { + MaglevAssembler* masm, const ProcessingState& state) { DoubleRegister left = ToDoubleRegister(left_input()); DoubleRegister right = ToDoubleRegister(right_input()); Register result = ToRegister(this->result()); @@ -2483,9 +2451,9 @@ void Float64CompareNode::GenerateCode( void Name::AllocateVreg(MaglevVregAllocationState* vreg_state) { \ Base::AllocateVreg(vreg_state); \ } \ - void Name::GenerateCode(MaglevCodeGenState* code_gen_state, \ + void Name::GenerateCode(MaglevAssembler* masm, \ const ProcessingState& state) { \ - Base::GenerateCode(code_gen_state, state); \ + Base::GenerateCode(masm, state); \ } DEF_OPERATION(Float64Equal) DEF_OPERATION(Float64StrictEqual) @@ -2500,15 +2468,15 @@ void CheckedSmiUntag::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void CheckedSmiUntag::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckedSmiUntag::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register value = ToRegister(input()); // TODO(leszeks): Consider optimizing away this test and using the carry bit // of the `sarl` for cases where the deopt uses the value from a different // register. Condition is_smi = __ CheckSmi(value); - EmitEagerDeoptIf(NegateCondition(is_smi), code_gen_state, - DeoptimizeReason::kNotASmi, this); + EmitEagerDeoptIf(NegateCondition(is_smi), masm, DeoptimizeReason::kNotASmi, + this); __ SmiToInt32(value); } @@ -2517,20 +2485,19 @@ void CheckedSmiTag::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineSameAsFirst(vreg_state, this); } -void CheckedSmiTag::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckedSmiTag::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register reg = ToRegister(input()); __ addl(reg, reg); - EmitEagerDeoptIf(overflow, code_gen_state, DeoptimizeReason::kOverflow, this); + EmitEagerDeoptIf(overflow, masm, DeoptimizeReason::kOverflow, this); } void Int32Constant::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsConstant(vreg_state, this); } -void Int32Constant::GenerateCode(MaglevCodeGenState* code_gen_state, +void Int32Constant::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) {} -void Int32Constant::DoLoadToRegister(MaglevCodeGenState* code_gen_state, - Register reg) { +void Int32Constant::DoLoadToRegister(MaglevAssembler* masm, Register reg) { __ Move(reg, Immediate(value())); } Handle Int32Constant::DoReify(LocalIsolate* isolate) { @@ -2545,7 +2512,7 @@ void Float64Box::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(input()); DefineAsRegister(vreg_state, this); } -void Float64Box::GenerateCode(MaglevCodeGenState* code_gen_state, +void Float64Box::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DoubleRegister value = ToDoubleRegister(input()); Register object = ToRegister(result()); @@ -2554,7 +2521,7 @@ void Float64Box::GenerateCode(MaglevCodeGenState* code_gen_state, // call might trash it. RegisterSnapshot save_registers = register_snapshot(); save_registers.live_double_registers.set(value); - AllocateRaw(code_gen_state, save_registers, object, HeapNumber::kSize); + AllocateRaw(masm, save_registers, object, HeapNumber::kSize); __ LoadRoot(kScratchRegister, RootIndex::kHeapNumberMap); __ StoreTaggedField(FieldOperand(object, HeapObject::kMapOffset), kScratchRegister); @@ -2565,7 +2532,7 @@ void CheckedFloat64Unbox::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(input()); DefineAsRegister(vreg_state, this); } -void CheckedFloat64Unbox::GenerateCode(MaglevCodeGenState* code_gen_state, +void CheckedFloat64Unbox::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register value = ToRegister(input()); Label is_not_smi, done; @@ -2585,8 +2552,7 @@ void CheckedFloat64Unbox::GenerateCode(MaglevCodeGenState* code_gen_state, // Check if HeapNumber, deopt otherwise. __ CompareRoot(FieldOperand(value, HeapObject::kMapOffset), RootIndex::kHeapNumberMap); - EmitEagerDeoptIf(not_equal, code_gen_state, DeoptimizeReason::kNotANumber, - this); + EmitEagerDeoptIf(not_equal, masm, DeoptimizeReason::kNotANumber, this); __ Movsd(ToDoubleRegister(result()), FieldOperand(value, HeapNumber::kValueOffset)); __ bind(&done); @@ -2596,7 +2562,7 @@ void LogicalNot::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(value()); DefineAsRegister(vreg_state, this); } -void LogicalNot::GenerateCode(MaglevCodeGenState* code_gen_state, +void LogicalNot::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(value()); Register return_value = ToRegister(result()); @@ -2626,11 +2592,11 @@ void SetPendingMessage::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsRegister(vreg_state, this); } -void SetPendingMessage::GenerateCode(MaglevCodeGenState* code_gen_state, +void SetPendingMessage::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register message = ToRegister(value()); Register return_value = ToRegister(result()); - Isolate* isolate = code_gen_state->isolate(); + Isolate* isolate = masm->isolate(); MemOperand message_op = __ ExternalReferenceAsOperand( ExternalReference::address_of_pending_message(isolate), kScratchRegister); __ Move(return_value, message_op); @@ -2641,14 +2607,14 @@ void ToBooleanLogicalNot::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(value()); DefineAsRegister(vreg_state, this); } -void ToBooleanLogicalNot::GenerateCode(MaglevCodeGenState* code_gen_state, +void ToBooleanLogicalNot::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(value()); Register return_value = ToRegister(result()); Label done; - Zone* zone = code_gen_state->compilation_info()->zone(); + Zone* zone = masm->compilation_info()->zone(); ZoneLabelRef object_is_true(zone), object_is_false(zone); - ToBoolean(code_gen_state, object, object_is_true, object_is_false, true); + ToBoolean(masm, object, object_is_true, object_is_false, true); __ bind(*object_is_true); __ LoadRoot(return_value, RootIndex::kFalseValue); __ jmp(&done); @@ -2662,7 +2628,7 @@ void TaggedEqual::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(rhs()); DefineAsRegister(vreg_state, this); } -void TaggedEqual::GenerateCode(MaglevCodeGenState* code_gen_state, +void TaggedEqual::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Label done, if_equal; __ cmp_tagged(ToRegister(lhs()), ToRegister(rhs())); @@ -2679,7 +2645,7 @@ void TaggedNotEqual::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(rhs()); DefineAsRegister(vreg_state, this); } -void TaggedNotEqual::GenerateCode(MaglevCodeGenState* code_gen_state, +void TaggedNotEqual::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Label done, if_equal; __ cmp_tagged(ToRegister(lhs()), ToRegister(rhs())); @@ -2698,7 +2664,7 @@ void TestInstanceOf::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(callable(), D::GetRegisterParameter(D::kRight)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void TestInstanceOf::GenerateCode(MaglevCodeGenState* code_gen_state, +void TestInstanceOf::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { #ifdef DEBUG using D = CallInterfaceDescriptorFor::type; @@ -2707,7 +2673,7 @@ void TestInstanceOf::GenerateCode(MaglevCodeGenState* code_gen_state, DCHECK_EQ(ToRegister(callable()), D::GetRegisterParameter(D::kRight)); #endif __ CallBuiltin(Builtin::kInstanceOf); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void TestUndetectable::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -2715,7 +2681,7 @@ void TestUndetectable::AllocateVreg(MaglevVregAllocationState* vreg_state) { set_temporaries_needed(1); DefineAsRegister(vreg_state, this); } -void TestUndetectable::GenerateCode(MaglevCodeGenState* code_gen_state, +void TestUndetectable::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register object = ToRegister(value()); Register return_value = ToRegister(result()); @@ -2738,7 +2704,7 @@ void TestTypeOf::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(value()); DefineAsRegister(vreg_state, this); } -void TestTypeOf::GenerateCode(MaglevCodeGenState* code_gen_state, +void TestTypeOf::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using LiteralFlag = interpreter::TestTypeOfFlags::LiteralFlag; Register object = ToRegister(value()); @@ -2832,15 +2798,14 @@ void ToName::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value_input(), D::GetRegisterParameter(D::kInput)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void ToName::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) { +void ToName::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { #ifdef DEBUG using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(context()), kContextRegister); DCHECK_EQ(ToRegister(value_input()), D::GetRegisterParameter(D::kInput)); #endif // DEBUG __ CallBuiltin(Builtin::kToName); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void ToNumberOrNumeric::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -2849,7 +2814,7 @@ void ToNumberOrNumeric::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value_input(), D::GetRegisterParameter(D::kArgument)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void ToNumberOrNumeric::GenerateCode(MaglevCodeGenState* code_gen_state, +void ToNumberOrNumeric::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { switch (mode()) { case Object::Conversion::kToNumber: @@ -2859,7 +2824,7 @@ void ToNumberOrNumeric::GenerateCode(MaglevCodeGenState* code_gen_state, __ CallBuiltin(Builtin::kToNumeric); break; } - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void ToObject::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -2868,7 +2833,7 @@ void ToObject::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value_input(), D::GetRegisterParameter(D::kInput)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void ToObject::GenerateCode(MaglevCodeGenState* code_gen_state, +void ToObject::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { #ifdef DEBUG using D = CallInterfaceDescriptorFor::type; @@ -2885,7 +2850,7 @@ void ToObject::GenerateCode(MaglevCodeGenState* code_gen_state, __ j(greater_equal, &done); __ bind(&call_builtin); __ CallBuiltin(Builtin::kToObject); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); __ bind(&done); } @@ -2895,7 +2860,7 @@ void ToString::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value_input(), D::GetRegisterParameter(D::kO)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void ToString::GenerateCode(MaglevCodeGenState* code_gen_state, +void ToString::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { #ifdef DEBUG using D = CallInterfaceDescriptorFor::type; @@ -2912,7 +2877,7 @@ void ToString::GenerateCode(MaglevCodeGenState* code_gen_state, __ j(less, &done); __ bind(&call_builtin); __ CallBuiltin(Builtin::kToString); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); __ bind(&done); } @@ -2920,7 +2885,7 @@ void ChangeInt32ToFloat64::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(input()); DefineAsRegister(vreg_state, this); } -void ChangeInt32ToFloat64::GenerateCode(MaglevCodeGenState* code_gen_state, +void ChangeInt32ToFloat64::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { __ Cvtlsi2sd(ToDoubleRegister(result()), ToRegister(input())); } @@ -2938,8 +2903,7 @@ void Phi::AllocateVregInPostProcess(MaglevVregAllocationState* vreg_state) { UseAny(input); } } -void Phi::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) {} +void Phi::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) {} void Phi::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { os << "(" << owner().ToString() << ")"; @@ -2954,8 +2918,7 @@ void Call::AllocateVreg(MaglevVregAllocationState* vreg_state) { } DefineAsFixed(vreg_state, this, kReturnRegister0); } -void Call::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) { +void Call::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // TODO(leszeks): Port the nice Sparkplug CallBuiltin helper. DCHECK_EQ(ToRegister(function()), @@ -2964,7 +2927,7 @@ void Call::GenerateCode(MaglevCodeGenState* code_gen_state, DCHECK_EQ(ToRegister(context()), kContextRegister); for (int i = num_args() - 1; i >= 0; --i) { - PushInput(code_gen_state, arg(i)); + PushInput(masm, arg(i)); } uint32_t arg_count = num_args(); @@ -2986,7 +2949,7 @@ void Call::GenerateCode(MaglevCodeGenState* code_gen_state, break; } - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void Construct::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -2999,7 +2962,7 @@ void Construct::AllocateVreg(MaglevVregAllocationState* vreg_state) { } DefineAsFixed(vreg_state, this, kReturnRegister0); } -void Construct::GenerateCode(MaglevCodeGenState* code_gen_state, +void Construct::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = ConstructStubDescriptor; DCHECK_EQ(ToRegister(function()), D::GetRegisterParameter(D::kTarget)); @@ -3007,7 +2970,7 @@ void Construct::GenerateCode(MaglevCodeGenState* code_gen_state, DCHECK_EQ(ToRegister(context()), kContextRegister); for (int i = num_args() - 1; i >= 0; --i) { - PushInput(code_gen_state, arg(i)); + PushInput(masm, arg(i)); } uint32_t arg_count = num_args(); @@ -3016,7 +2979,7 @@ void Construct::GenerateCode(MaglevCodeGenState* code_gen_state, __ CallBuiltin(Builtin::kConstruct); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void CallBuiltin::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -3036,7 +2999,7 @@ void CallBuiltin::AllocateVreg(MaglevVregAllocationState* vreg_state) { DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CallBuiltin::PassFeedbackSlotOnStack(MaglevCodeGenState* code_gen_state) { +void CallBuiltin::PassFeedbackSlotOnStack(MaglevAssembler* masm) { DCHECK(has_feedback()); switch (slot_type()) { case kTaggedIndex: @@ -3048,8 +3011,7 @@ void CallBuiltin::PassFeedbackSlotOnStack(MaglevCodeGenState* code_gen_state) { } } -void CallBuiltin::PassFeedbackSlotInRegister( - MaglevCodeGenState* code_gen_state) { +void CallBuiltin::PassFeedbackSlotInRegister(MaglevAssembler* masm) { DCHECK(has_feedback()); auto descriptor = Builtins::CallInterfaceDescriptorFor(builtin()); int slot_index = InputCountWithoutContext(); @@ -3065,7 +3027,7 @@ void CallBuiltin::PassFeedbackSlotInRegister( } } -void CallBuiltin::PushFeedback(MaglevCodeGenState* code_gen_state) { +void CallBuiltin::PushFeedback(MaglevAssembler* masm) { DCHECK(has_feedback()); auto descriptor = Builtins::CallInterfaceDescriptorFor(builtin()); @@ -3077,10 +3039,10 @@ void CallBuiltin::PushFeedback(MaglevCodeGenState* code_gen_state) { // 2. Feedback slot is in register and vector is on stack. // 3. Feedback slot and vector are on stack. if (vector_index < descriptor.GetRegisterParameterCount()) { - PassFeedbackSlotInRegister(code_gen_state); + PassFeedbackSlotInRegister(masm); __ Move(descriptor.GetRegisterParameter(vector_index), feedback().vector); } else if (vector_index == descriptor.GetRegisterParameterCount()) { - PassFeedbackSlotInRegister(code_gen_state); + PassFeedbackSlotInRegister(masm); // We do not allow var args if has_feedback(), so here we have only one // parameter on stack and do not need to check stack arguments order. __ Push(feedback().vector); @@ -3088,39 +3050,39 @@ void CallBuiltin::PushFeedback(MaglevCodeGenState* code_gen_state) { // Same as above. We does not allow var args if has_feedback(), so feedback // slot and vector must be last two inputs. if (descriptor.GetStackArgumentOrder() == StackArgumentOrder::kDefault) { - PassFeedbackSlotOnStack(code_gen_state); + PassFeedbackSlotOnStack(masm); __ Push(feedback().vector); } else { DCHECK_EQ(descriptor.GetStackArgumentOrder(), StackArgumentOrder::kJS); __ Push(feedback().vector); - PassFeedbackSlotOnStack(code_gen_state); + PassFeedbackSlotOnStack(masm); } } } -void CallBuiltin::GenerateCode(MaglevCodeGenState* code_gen_state, +void CallBuiltin::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { auto descriptor = Builtins::CallInterfaceDescriptorFor(builtin()); if (descriptor.GetStackArgumentOrder() == StackArgumentOrder::kDefault) { for (int i = InputsInRegisterCount(); i < InputCountWithoutContext(); ++i) { - PushInput(code_gen_state, input(i)); + PushInput(masm, input(i)); } if (has_feedback()) { - PushFeedback(code_gen_state); + PushFeedback(masm); } } else { DCHECK_EQ(descriptor.GetStackArgumentOrder(), StackArgumentOrder::kJS); if (has_feedback()) { - PushFeedback(code_gen_state); + PushFeedback(masm); } for (int i = InputCountWithoutContext() - 1; i >= InputsInRegisterCount(); --i) { - PushInput(code_gen_state, input(i)); + PushInput(masm, input(i)); } } __ CallBuiltin(builtin()); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void CallBuiltin::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -3134,15 +3096,15 @@ void CallRuntime::AllocateVreg(MaglevVregAllocationState* vreg_state) { } DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CallRuntime::GenerateCode(MaglevCodeGenState* code_gen_state, +void CallRuntime::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DCHECK_EQ(ToRegister(context()), kContextRegister); for (int i = 0; i < num_args(); i++) { - PushInput(code_gen_state, arg(i)); + PushInput(masm, arg(i)); } __ CallRuntime(function_id(), num_args()); // TODO(victorgomes): Not sure if this is needed for all runtime calls. - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void CallRuntime::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -3159,7 +3121,7 @@ void CallWithSpread::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(spread(), D::GetRegisterParameter(D::kSpread)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void CallWithSpread::GenerateCode(MaglevCodeGenState* code_gen_state, +void CallWithSpread::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(function()), D::GetRegisterParameter(D::kTarget)); @@ -3167,12 +3129,12 @@ void CallWithSpread::GenerateCode(MaglevCodeGenState* code_gen_state, // Push other arguments (other than the spread) to the stack. int argc_no_spread = num_args() - 1; for (int i = argc_no_spread - 1; i >= 0; --i) { - PushInput(code_gen_state, arg(i)); + PushInput(masm, arg(i)); } __ Move(D::GetRegisterParameter(D::kArgumentsCount), Immediate(argc_no_spread)); __ CallBuiltin(Builtin::kCallWithSpread); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void ConstructWithSpread::AllocateVreg(MaglevVregAllocationState* vreg_state) { @@ -3186,7 +3148,7 @@ void ConstructWithSpread::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(spread(), D::GetRegisterParameter(D::kSpread)); DefineAsFixed(vreg_state, this, kReturnRegister0); } -void ConstructWithSpread::GenerateCode(MaglevCodeGenState* code_gen_state, +void ConstructWithSpread::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { using D = CallInterfaceDescriptorFor::type; DCHECK_EQ(ToRegister(function()), D::GetRegisterParameter(D::kTarget)); @@ -3195,19 +3157,19 @@ void ConstructWithSpread::GenerateCode(MaglevCodeGenState* code_gen_state, // Push other arguments (other than the spread) to the stack. int argc_no_spread = num_args() - 1; for (int i = argc_no_spread - 1; i >= 0; --i) { - PushInput(code_gen_state, arg(i)); + PushInput(masm, arg(i)); } __ Move(D::GetRegisterParameter(D::kActualArgumentsCount), Immediate(argc_no_spread)); __ CallBuiltin(Builtin::kConstructWithSpread); - code_gen_state->DefineExceptionHandlerAndLazyDeoptPoint(this); + masm->DefineExceptionHandlerAndLazyDeoptPoint(this); } void IncreaseInterruptBudget::AllocateVreg( MaglevVregAllocationState* vreg_state) { set_temporaries_needed(1); } -void IncreaseInterruptBudget::GenerateCode(MaglevCodeGenState* code_gen_state, +void IncreaseInterruptBudget::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register scratch = temporaries().first(); __ movq(scratch, MemOperand(rbp, StandardFrameConstants::kFunctionOffset)); @@ -3225,7 +3187,7 @@ void ReduceInterruptBudget::AllocateVreg( MaglevVregAllocationState* vreg_state) { set_temporaries_needed(1); } -void ReduceInterruptBudget::GenerateCode(MaglevCodeGenState* code_gen_state, +void ReduceInterruptBudget::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register scratch = temporaries().first(); __ movq(scratch, MemOperand(rbp, StandardFrameConstants::kFunctionOffset)); @@ -3234,13 +3196,13 @@ void ReduceInterruptBudget::GenerateCode(MaglevCodeGenState* code_gen_state, __ subl(FieldOperand(scratch, FeedbackCell::kInterruptBudgetOffset), Immediate(amount())); JumpToDeferredIf( - less, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, + less, masm, + [](MaglevAssembler* masm, Label* return_label, ReduceInterruptBudget* node) { { SaveRegisterStateForCall save_register_state( - code_gen_state, node->register_snapshot()); - __ Move(kContextRegister, code_gen_state->native_context().object()); + masm, node->register_snapshot()); + __ Move(kContextRegister, masm->native_context().object()); __ Push(MemOperand(rbp, StandardFrameConstants::kFunctionOffset)); __ CallRuntime(Runtime::kBytecodeBudgetInterruptWithStackCheck_Maglev, 1); @@ -3260,23 +3222,22 @@ void ThrowReferenceErrorIfHole::AllocateVreg( MaglevVregAllocationState* vreg_state) { UseAny(value()); } -void ThrowReferenceErrorIfHole::GenerateCode(MaglevCodeGenState* code_gen_state, +void ThrowReferenceErrorIfHole::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { if (value().operand().IsRegister()) { __ CompareRoot(ToRegister(value()), RootIndex::kTheHoleValue); } else { DCHECK(value().operand().IsStackSlot()); - __ CompareRoot(code_gen_state->ToMemOperand(value()), - RootIndex::kTheHoleValue); + __ CompareRoot(masm->ToMemOperand(value()), RootIndex::kTheHoleValue); } JumpToDeferredIf( - equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, + equal, masm, + [](MaglevAssembler* masm, Label* return_label, ThrowReferenceErrorIfHole* node) { - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ Push(node->name().object()); __ CallRuntime(Runtime::kThrowAccessedUninitializedVariable, 1); - code_gen_state->DefineLazyDeoptPoint(node->lazy_deopt_info()); + masm->DefineLazyDeoptPoint(node->lazy_deopt_info()); __ Abort(AbortReason::kUnexpectedReturnFromThrow); }, this); @@ -3286,22 +3247,21 @@ void ThrowSuperNotCalledIfHole::AllocateVreg( MaglevVregAllocationState* vreg_state) { UseAny(value()); } -void ThrowSuperNotCalledIfHole::GenerateCode(MaglevCodeGenState* code_gen_state, +void ThrowSuperNotCalledIfHole::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { if (value().operand().IsRegister()) { __ CompareRoot(ToRegister(value()), RootIndex::kTheHoleValue); } else { DCHECK(value().operand().IsStackSlot()); - __ CompareRoot(code_gen_state->ToMemOperand(value()), - RootIndex::kTheHoleValue); + __ CompareRoot(masm->ToMemOperand(value()), RootIndex::kTheHoleValue); } JumpToDeferredIf( - equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, + equal, masm, + [](MaglevAssembler* masm, Label* return_label, ThrowSuperNotCalledIfHole* node) { - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ CallRuntime(Runtime::kThrowSuperNotCalled, 0); - code_gen_state->DefineLazyDeoptPoint(node->lazy_deopt_info()); + masm->DefineLazyDeoptPoint(node->lazy_deopt_info()); __ Abort(AbortReason::kUnexpectedReturnFromThrow); }, this); @@ -3312,21 +3272,20 @@ void ThrowSuperAlreadyCalledIfNotHole::AllocateVreg( UseAny(value()); } void ThrowSuperAlreadyCalledIfNotHole::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { + MaglevAssembler* masm, const ProcessingState& state) { if (value().operand().IsRegister()) { __ CompareRoot(ToRegister(value()), RootIndex::kTheHoleValue); } else { DCHECK(value().operand().IsStackSlot()); - __ CompareRoot(code_gen_state->ToMemOperand(value()), - RootIndex::kTheHoleValue); + __ CompareRoot(masm->ToMemOperand(value()), RootIndex::kTheHoleValue); } JumpToDeferredIf( - not_equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, + not_equal, masm, + [](MaglevAssembler* masm, Label* return_label, ThrowSuperAlreadyCalledIfNotHole* node) { - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ CallRuntime(Runtime::kThrowSuperAlreadyCalledError, 0); - code_gen_state->DefineLazyDeoptPoint(node->lazy_deopt_info()); + masm->DefineLazyDeoptPoint(node->lazy_deopt_info()); __ Abort(AbortReason::kUnexpectedReturnFromThrow); }, this); @@ -3337,20 +3296,20 @@ void ThrowIfNotSuperConstructor::AllocateVreg( UseRegister(constructor()); UseRegister(function()); } -void ThrowIfNotSuperConstructor::GenerateCode( - MaglevCodeGenState* code_gen_state, const ProcessingState& state) { +void ThrowIfNotSuperConstructor::GenerateCode(MaglevAssembler* masm, + const ProcessingState& state) { __ LoadMap(kScratchRegister, ToRegister(constructor())); __ testl(FieldOperand(kScratchRegister, Map::kBitFieldOffset), Immediate(Map::Bits1::IsConstructorBit::kMask)); JumpToDeferredIf( - equal, code_gen_state, - [](MaglevCodeGenState* code_gen_state, Label* return_label, + equal, masm, + [](MaglevAssembler* masm, Label* return_label, ThrowIfNotSuperConstructor* node) { - __ Move(kContextRegister, code_gen_state->native_context().object()); + __ Move(kContextRegister, masm->native_context().object()); __ Push(ToRegister(node->constructor())); __ Push(ToRegister(node->function())); __ CallRuntime(Runtime::kThrowNotSuperConstructor, 2); - code_gen_state->DefineLazyDeoptPoint(node->lazy_deopt_info()); + masm->DefineLazyDeoptPoint(node->lazy_deopt_info()); __ Abort(AbortReason::kUnexpectedReturnFromThrow); }, this); @@ -3362,15 +3321,13 @@ void ThrowIfNotSuperConstructor::GenerateCode( void Return::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseFixed(value_input(), kReturnRegister0); } -void Return::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) { +void Return::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DCHECK_EQ(ToRegister(value_input()), kReturnRegister0); // Read the formal number of parameters from the top level compilation unit // (i.e. the outermost, non inlined function). - int formal_params_size = code_gen_state->compilation_info() - ->toplevel_compilation_unit() - ->parameter_count(); + int formal_params_size = + masm->compilation_info()->toplevel_compilation_unit()->parameter_count(); // We're not going to continue execution, so we can use an arbitrary register // here instead of relying on temporaries from the register allocator. @@ -3403,9 +3360,8 @@ void Return::GenerateCode(MaglevCodeGenState* code_gen_state, } void Deopt::AllocateVreg(MaglevVregAllocationState* vreg_state) {} -void Deopt::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) { - EmitEagerDeopt(code_gen_state, this, reason()); +void Deopt::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { + EmitEagerDeopt(masm, this, reason()); } void Deopt::PrintParams(std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -3415,8 +3371,7 @@ void Deopt::PrintParams(std::ostream& os, void Switch::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(value()); } -void Switch::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) { +void Switch::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { std::unique_ptr labels = std::make_unique(size()); for (int i = 0; i < size(); i++) { labels[i] = (targets())[i].block_ptr()->label(); @@ -3431,8 +3386,7 @@ void Switch::GenerateCode(MaglevCodeGenState* code_gen_state, } void Jump::AllocateVreg(MaglevVregAllocationState* vreg_state) {} -void Jump::GenerateCode(MaglevCodeGenState* code_gen_state, - const ProcessingState& state) { +void Jump::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // Avoid emitting a jump to the next block. if (target() != state.next_block()) { __ jmp(target()->label()); @@ -3440,7 +3394,7 @@ void Jump::GenerateCode(MaglevCodeGenState* code_gen_state, } void JumpToInlined::AllocateVreg(MaglevVregAllocationState* vreg_state) {} -void JumpToInlined::GenerateCode(MaglevCodeGenState* code_gen_state, +void JumpToInlined::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // Avoid emitting a jump to the next block. if (target() != state.next_block()) { @@ -3453,7 +3407,7 @@ void JumpToInlined::PrintParams(std::ostream& os, } void JumpFromInlined::AllocateVreg(MaglevVregAllocationState* vreg_state) {} -void JumpFromInlined::GenerateCode(MaglevCodeGenState* code_gen_state, +void JumpFromInlined::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // Avoid emitting a jump to the next block. if (target() != state.next_block()) { @@ -3463,10 +3417,10 @@ void JumpFromInlined::GenerateCode(MaglevCodeGenState* code_gen_state, namespace { -void AttemptOnStackReplacement(MaglevCodeGenState* code_gen_state, - Label* return_label, JumpLoopPrologue* node, - Register scratch0, Register scratch1, - int32_t loop_depth, FeedbackSlot feedback_slot, +void AttemptOnStackReplacement(MaglevAssembler* masm, Label* return_label, + JumpLoopPrologue* node, Register scratch0, + Register scratch1, int32_t loop_depth, + FeedbackSlot feedback_slot, BytecodeOffset osr_offset) { // Two cases may cause us to attempt OSR, in the following order: // @@ -3476,7 +3430,7 @@ void AttemptOnStackReplacement(MaglevCodeGenState* code_gen_state, // // See also: InterpreterAssembler::OnStackReplacement. - baseline::BaselineAssembler basm(code_gen_state->masm()); + baseline::BaselineAssembler basm(masm); // Case 1). Label deopt; @@ -3520,8 +3474,8 @@ void AttemptOnStackReplacement(MaglevCodeGenState* code_gen_state, } } }); - SaveRegisterStateForCall save_register_state(code_gen_state, snapshot); - __ Move(kContextRegister, code_gen_state->native_context().object()); + SaveRegisterStateForCall save_register_state(masm, snapshot); + __ Move(kContextRegister, masm->native_context().object()); __ Push(Smi::FromInt(osr_offset.ToInt())); __ CallRuntime(Runtime::kCompileOptimizedOSRFromMaglev, 1); save_register_state.DefineSafepoint(); @@ -3537,8 +3491,7 @@ void AttemptOnStackReplacement(MaglevCodeGenState* code_gen_state, __ bind(&deopt); if (V8_LIKELY(FLAG_turbofan)) { - EmitEagerDeopt(code_gen_state, node, - DeoptimizeReason::kPrepareForOnStackReplacement); + EmitEagerDeopt(masm, node, DeoptimizeReason::kPrepareForOnStackReplacement); } else { // Fall through. With TF disabled we cannot OSR and thus it doesn't make // sense to start the process. We do still perform all remaining @@ -3552,7 +3505,7 @@ void AttemptOnStackReplacement(MaglevCodeGenState* code_gen_state, void JumpLoopPrologue::AllocateVreg(MaglevVregAllocationState* vreg_state) { set_temporaries_needed(2); } -void JumpLoopPrologue::GenerateCode(MaglevCodeGenState* code_gen_state, +void JumpLoopPrologue::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register scratch0 = temporaries().PopFirst(); Register scratch1 = temporaries().PopFirst(); @@ -3567,13 +3520,12 @@ void JumpLoopPrologue::GenerateCode(MaglevCodeGenState* code_gen_state, static_assert(FeedbackVector::MaybeHasOptimizedOsrCodeBit::encode(true) > FeedbackVector::kMaxOsrUrgency); __ cmpl(osr_state, Immediate(loop_depth_)); - JumpToDeferredIf(above, code_gen_state, AttemptOnStackReplacement, this, - scratch0, scratch1, loop_depth_, feedback_slot_, - osr_offset_); + JumpToDeferredIf(above, masm, AttemptOnStackReplacement, this, scratch0, + scratch1, loop_depth_, feedback_slot_, osr_offset_); } void JumpLoop::AllocateVreg(MaglevVregAllocationState* vreg_state) {} -void JumpLoop::GenerateCode(MaglevCodeGenState* code_gen_state, +void JumpLoop::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { __ jmp(target()->label()); } @@ -3581,10 +3533,10 @@ void JumpLoop::GenerateCode(MaglevCodeGenState* code_gen_state, void BranchIfRootConstant::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(condition_input()); } -void BranchIfRootConstant::GenerateCode(MaglevCodeGenState* code_gen_state, +void BranchIfRootConstant::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { __ CompareRoot(ToRegister(condition_input()), root_index()); - Branch(code_gen_state, equal, if_true(), if_false(), state.next_block()); + Branch(masm, equal, if_true(), if_false(), state.next_block()); } void BranchIfRootConstant::PrintParams( std::ostream& os, MaglevGraphLabeller* graph_labeller) const { @@ -3595,7 +3547,7 @@ void BranchIfUndefinedOrNull::AllocateVreg( MaglevVregAllocationState* vreg_state) { UseRegister(condition_input()); } -void BranchIfUndefinedOrNull::GenerateCode(MaglevCodeGenState* code_gen_state, +void BranchIfUndefinedOrNull::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register value = ToRegister(condition_input()); __ JumpIfRoot(value, RootIndex::kUndefinedValue, if_true()->label()); @@ -3609,26 +3561,25 @@ void BranchIfUndefinedOrNull::GenerateCode(MaglevCodeGenState* code_gen_state, void BranchIfJSReceiver::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(condition_input()); } -void BranchIfJSReceiver::GenerateCode(MaglevCodeGenState* code_gen_state, +void BranchIfJSReceiver::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register value = ToRegister(condition_input()); __ JumpIfSmi(value, if_false()->label()); __ LoadMap(kScratchRegister, value); __ CmpInstanceType(kScratchRegister, FIRST_JS_RECEIVER_TYPE); - Branch(code_gen_state, above_equal, if_true(), if_false(), - state.next_block()); + Branch(masm, above_equal, if_true(), if_false(), state.next_block()); } void BranchIfInt32Compare::AllocateVreg(MaglevVregAllocationState* vreg_state) { UseRegister(left_input()); UseRegister(right_input()); } -void BranchIfInt32Compare::GenerateCode(MaglevCodeGenState* code_gen_state, +void BranchIfInt32Compare::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); __ cmpl(left, right); - Branch(code_gen_state, ConditionFor(operation_), if_true(), if_false(), + Branch(masm, ConditionFor(operation_), if_true(), if_false(), state.next_block()); } void BranchIfFloat64Compare::PrintParams( @@ -3641,12 +3592,12 @@ void BranchIfFloat64Compare::AllocateVreg( UseRegister(left_input()); UseRegister(right_input()); } -void BranchIfFloat64Compare::GenerateCode(MaglevCodeGenState* code_gen_state, +void BranchIfFloat64Compare::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { DoubleRegister left = ToDoubleRegister(left_input()); DoubleRegister right = ToDoubleRegister(right_input()); __ Ucomisd(left, right); - Branch(code_gen_state, ConditionFor(operation_), if_true(), if_false(), + Branch(masm, ConditionFor(operation_), if_true(), if_false(), state.next_block()); } void BranchIfInt32Compare::PrintParams( @@ -3659,12 +3610,12 @@ void BranchIfReferenceCompare::AllocateVreg( UseRegister(left_input()); UseRegister(right_input()); } -void BranchIfReferenceCompare::GenerateCode(MaglevCodeGenState* code_gen_state, +void BranchIfReferenceCompare::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { Register left = ToRegister(left_input()); Register right = ToRegister(right_input()); __ cmp_tagged(left, right); - Branch(code_gen_state, ConditionFor(operation_), if_true(), if_false(), + Branch(masm, ConditionFor(operation_), if_true(), if_false(), state.next_block()); } void BranchIfReferenceCompare::PrintParams( @@ -3677,7 +3628,7 @@ void BranchIfToBooleanTrue::AllocateVreg( // TODO(victorgomes): consider using any input instead. UseRegister(condition_input()); } -void BranchIfToBooleanTrue::GenerateCode(MaglevCodeGenState* code_gen_state, +void BranchIfToBooleanTrue::GenerateCode(MaglevAssembler* masm, const ProcessingState& state) { // BasicBlocks are zone allocated and so safe to be casted to ZoneLabelRef. ZoneLabelRef true_label = @@ -3685,8 +3636,8 @@ void BranchIfToBooleanTrue::GenerateCode(MaglevCodeGenState* code_gen_state, ZoneLabelRef false_label = ZoneLabelRef::UnsafeFromLabelPointer(if_false()->label()); bool fallthrough_when_true = (if_true() == state.next_block()); - ToBoolean(code_gen_state, ToRegister(condition_input()), true_label, - false_label, fallthrough_when_true); + ToBoolean(masm, ToRegister(condition_input()), true_label, false_label, + fallthrough_when_true); } } // namespace maglev diff --git a/src/maglev/maglev-ir.h b/src/maglev/maglev-ir.h index c94d30c529..0e83eb6cad 100644 --- a/src/maglev/maglev-ir.h +++ b/src/maglev/maglev-ir.h @@ -31,6 +31,7 @@ namespace maglev { class BasicBlock; class ProcessingState; +class MaglevAssembler; class MaglevCodeGenState; class MaglevCompilationUnit; class MaglevGraphLabeller; @@ -323,6 +324,16 @@ enum class ValueRepresentation : uint8_t { kTagged, kInt32, kFloat64 }; NODE_BASE_LIST(DEF_FORWARD_DECLARATION) #undef DEF_FORWARD_DECLARATION +#define DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() \ + void AllocateVreg(MaglevVregAllocationState*); \ + void GenerateCode(MaglevAssembler*, const ProcessingState&); \ + void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + +#define DECL_NODE_INTERFACE() \ + void AllocateVreg(MaglevVregAllocationState*); \ + void GenerateCode(MaglevAssembler*, const ProcessingState&); \ + void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + using NodeIdT = uint32_t; static constexpr uint32_t kInvalidNodeId = 0; static constexpr uint32_t kFirstValidNodeId = 1; @@ -1050,10 +1061,10 @@ class ValueNode : public Node { void SetConstantLocation(); /* For constants only. */ - void LoadToRegister(MaglevCodeGenState*, Register); - void LoadToRegister(MaglevCodeGenState*, DoubleRegister); - void DoLoadToRegister(MaglevCodeGenState*, Register); - void DoLoadToRegister(MaglevCodeGenState*, DoubleRegister); + void LoadToRegister(MaglevAssembler*, Register); + void LoadToRegister(MaglevAssembler*, DoubleRegister); + void DoLoadToRegister(MaglevAssembler*, Register); + void DoLoadToRegister(MaglevAssembler*, DoubleRegister); Handle Reify(LocalIsolate* isolate); void Spill(compiler::AllocatedOperand operand) { @@ -1337,9 +1348,7 @@ class UnaryWithFeedbackNode : public FixedInputValueNodeT<1, Derived> { const compiler::FeedbackSource& feedback) : Base(bitfield), feedback_(feedback) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() const compiler::FeedbackSource feedback_; }; @@ -1363,9 +1372,7 @@ class BinaryWithFeedbackNode : public FixedInputValueNodeT<2, Derived> { const compiler::FeedbackSource& feedback) : Base(bitfield), feedback_(feedback) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() const compiler::FeedbackSource feedback_; }; @@ -1377,9 +1384,7 @@ class BinaryWithFeedbackNode : public FixedInputValueNodeT<2, Derived> { public: \ Name(uint64_t bitfield, const compiler::FeedbackSource& feedback) \ : Base(bitfield, feedback) {} \ - void AllocateVreg(MaglevVregAllocationState*); \ - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); \ - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} \ + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() \ }; #define DEF_UNARY_WITH_FEEDBACK_NODE(Name) \ @@ -1410,20 +1415,16 @@ class Int32BinaryWithOverflowNode : public FixedInputValueNodeT<2, Derived> { protected: explicit Int32BinaryWithOverflowNode(uint64_t bitfield) : Base(bitfield) {} - // void AllocateVreg(MaglevVregAllocationState*, const ProcessingState&); - // void GenerateCode(MaglevCodeGenState*, const ProcessingState&); void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} }; -#define DEF_OPERATION_NODE(Name, Super, OpName) \ - class Name : public Super { \ - using Base = Super; \ - \ - public: \ - explicit Name(uint64_t bitfield) : Base(bitfield) {} \ - void AllocateVreg(MaglevVregAllocationState*); \ - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); \ - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} \ +#define DEF_OPERATION_NODE(Name, Super, OpName) \ + class Name : public Super { \ + using Base = Super; \ + \ + public: \ + explicit Name(uint64_t bitfield) : Base(bitfield) {} \ + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() \ }; #define DEF_INT32_BINARY_WITH_OVERFLOW_NODE(Name) \ @@ -1456,15 +1457,13 @@ class Int32BinaryNode : public FixedInputValueNodeT<2, Derived> { void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} }; -#define DEF_OPERATION_NODE(Name, Super, OpName) \ - class Name : public Super { \ - using Base = Super; \ - \ - public: \ - explicit Name(uint64_t bitfield) : Base(bitfield) {} \ - void AllocateVreg(MaglevVregAllocationState*); \ - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); \ - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} \ +#define DEF_OPERATION_NODE(Name, Super, OpName) \ + class Name : public Super { \ + using Base = Super; \ + \ + public: \ + explicit Name(uint64_t bitfield) : Base(bitfield) {} \ + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() \ }; #define DEF_INT32_BINARY_NODE(Name) \ @@ -1493,20 +1492,16 @@ class Int32CompareNode : public FixedInputValueNodeT<2, Derived> { protected: explicit Int32CompareNode(uint64_t bitfield) : Base(bitfield) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; -#define DEF_OPERATION_NODE(Name, Super, OpName) \ - class Name : public Super { \ - using Base = Super; \ - \ - public: \ - explicit Name(uint64_t bitfield) : Base(bitfield) {} \ - void AllocateVreg(MaglevVregAllocationState*); \ - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); \ - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} \ +#define DEF_OPERATION_NODE(Name, Super, OpName) \ + class Name : public Super { \ + using Base = Super; \ + \ + public: \ + explicit Name(uint64_t bitfield) : Base(bitfield) {} \ + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() \ }; #define DEF_INT32_COMPARE_NODE(Name) \ @@ -1539,15 +1534,13 @@ class Float64BinaryNode : public FixedInputValueNodeT<2, Derived> { void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} }; -#define DEF_OPERATION_NODE(Name, Super, OpName) \ - class Name : public Super { \ - using Base = Super; \ - \ - public: \ - explicit Name(uint64_t bitfield) : Base(bitfield) {} \ - void AllocateVreg(MaglevVregAllocationState*); \ - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); \ - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} \ +#define DEF_OPERATION_NODE(Name, Super, OpName) \ + class Name : public Super { \ + using Base = Super; \ + \ + public: \ + explicit Name(uint64_t bitfield) : Base(bitfield) {} \ + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() \ }; #define DEF_FLOAT64_BINARY_NODE(Name) \ @@ -1579,20 +1572,16 @@ class Float64CompareNode : public FixedInputValueNodeT<2, Derived> { protected: explicit Float64CompareNode(uint64_t bitfield) : Base(bitfield) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; -#define DEF_OPERATION_NODE(Name, Super, OpName) \ - class Name : public Super { \ - using Base = Super; \ - \ - public: \ - explicit Name(uint64_t bitfield) : Base(bitfield) {} \ - void AllocateVreg(MaglevVregAllocationState*); \ - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); \ - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} \ +#define DEF_OPERATION_NODE(Name, Super, OpName) \ + class Name : public Super { \ + using Base = Super; \ + \ + public: \ + explicit Name(uint64_t bitfield) : Base(bitfield) {} \ + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() \ }; #define DEF_FLOAT64_COMPARE_NODE(Name) \ @@ -1618,9 +1607,7 @@ class CheckedSmiTag : public FixedInputValueNodeT<1, CheckedSmiTag> { Input& input() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class CheckedSmiUntag : public FixedInputValueNodeT<1, CheckedSmiUntag> { @@ -1635,9 +1622,7 @@ class CheckedSmiUntag : public FixedInputValueNodeT<1, CheckedSmiUntag> { Input& input() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class Int32Constant : public FixedInputValueNodeT<0, Int32Constant> { @@ -1655,11 +1640,9 @@ class Int32Constant : public FixedInputValueNodeT<0, Int32Constant> { bool ToBoolean(LocalIsolate* local_isolate) const { return value_ != 0; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() - void DoLoadToRegister(MaglevCodeGenState*, OutputRegister); + void DoLoadToRegister(MaglevAssembler*, OutputRegister); Handle DoReify(LocalIsolate* isolate); private: @@ -1683,11 +1666,9 @@ class Float64Constant : public FixedInputValueNodeT<0, Float64Constant> { return value_ != 0.0 && !std::isnan(value_); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() - void DoLoadToRegister(MaglevCodeGenState*, OutputRegister); + void DoLoadToRegister(MaglevAssembler*, OutputRegister); Handle DoReify(LocalIsolate* isolate); private: @@ -1705,9 +1686,7 @@ class Float64Box : public FixedInputValueNodeT<1, Float64Box> { Input& input() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ChangeInt32ToFloat64 @@ -1722,9 +1701,7 @@ class ChangeInt32ToFloat64 Input& input() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class CheckedFloat64Unbox @@ -1740,9 +1717,7 @@ class CheckedFloat64Unbox Input& input() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class LogicalNot : public FixedInputValueNodeT<1, LogicalNot> { @@ -1753,9 +1728,7 @@ class LogicalNot : public FixedInputValueNodeT<1, LogicalNot> { Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class SetPendingMessage : public FixedInputValueNodeT<1, SetPendingMessage> { @@ -1766,9 +1739,7 @@ class SetPendingMessage : public FixedInputValueNodeT<1, SetPendingMessage> { Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ToBooleanLogicalNot @@ -1780,9 +1751,7 @@ class ToBooleanLogicalNot Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class TaggedEqual : public FixedInputValueNodeT<2, TaggedEqual> { @@ -1794,9 +1763,7 @@ class TaggedEqual : public FixedInputValueNodeT<2, TaggedEqual> { Input& lhs() { return Node::input(0); } Input& rhs() { return Node::input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class TaggedNotEqual : public FixedInputValueNodeT<2, TaggedNotEqual> { @@ -1808,9 +1775,7 @@ class TaggedNotEqual : public FixedInputValueNodeT<2, TaggedNotEqual> { Input& lhs() { return Node::input(0); } Input& rhs() { return Node::input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class TestInstanceOf : public FixedInputValueNodeT<3, TestInstanceOf> { @@ -1826,9 +1791,7 @@ class TestInstanceOf : public FixedInputValueNodeT<3, TestInstanceOf> { Input& object() { return input(1); } Input& callable() { return input(2); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class TestUndetectable : public FixedInputValueNodeT<1, TestUndetectable> { @@ -1839,9 +1802,7 @@ class TestUndetectable : public FixedInputValueNodeT<1, TestUndetectable> { Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class TestTypeOf : public FixedInputValueNodeT<1, TestTypeOf> { @@ -1854,9 +1815,7 @@ class TestTypeOf : public FixedInputValueNodeT<1, TestTypeOf> { Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: interpreter::TestTypeOfFlags::LiteralFlag literal_; @@ -1874,9 +1833,7 @@ class ToName : public FixedInputValueNodeT<2, ToName> { Input& context() { return Node::input(0); } Input& value_input() { return Node::input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ToNumberOrNumeric : public FixedInputValueNodeT<2, ToNumberOrNumeric> { @@ -1893,9 +1850,7 @@ class ToNumberOrNumeric : public FixedInputValueNodeT<2, ToNumberOrNumeric> { Input& value_input() { return Node::input(1); } Object::Conversion mode() const { return mode_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const Object::Conversion mode_; @@ -1917,9 +1872,7 @@ class DeleteProperty : public FixedInputValueNodeT<3, DeleteProperty> { LanguageMode mode() const { return mode_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const LanguageMode mode_; @@ -1961,9 +1914,7 @@ class GeneratorStore : public NodeT { set_input(i + kFixedInputCount, node); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const int suspend_id_; @@ -1987,9 +1938,7 @@ class JumpLoopPrologue : public FixedInputNodeT<0, JumpLoopPrologue> { static constexpr OpProperties kProperties = OpProperties::NeedsRegisterSnapshot() | OpProperties::EagerDeopt(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: // For OSR. @@ -2013,9 +1962,7 @@ class ForInPrepare : public FixedInputValueNodeT<2, ForInPrepare> { Input& context() { return Node::input(0); } Input& enumerator() { return Node::input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::FeedbackSource feedback_; @@ -2038,9 +1985,7 @@ class ForInNext : public FixedInputValueNodeT<5, ForInNext> { Input& cache_type() { return Node::input(3); } Input& cache_index() { return Node::input(4); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::FeedbackSource feedback_; @@ -2066,9 +2011,7 @@ class GetIterator : public FixedInputValueNodeT<2, GetIterator> { int call_slot() const { return call_slot_; } Handle feedback() const { return feedback_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const int load_slot_; @@ -2083,9 +2026,7 @@ class GetSecondReturnedValue public: explicit GetSecondReturnedValue(uint64_t bitfield) : Base(bitfield) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ToObject : public FixedInputValueNodeT<2, ToObject> { @@ -2100,9 +2041,7 @@ class ToObject : public FixedInputValueNodeT<2, ToObject> { Input& context() { return Node::input(0); } Input& value_input() { return Node::input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ToString : public FixedInputValueNodeT<2, ToString> { @@ -2117,9 +2056,7 @@ class ToString : public FixedInputValueNodeT<2, ToString> { Input& context() { return Node::input(0); } Input& value_input() { return Node::input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class GeneratorRestoreRegister @@ -2133,9 +2070,7 @@ class GeneratorRestoreRegister Input& array_input() { return input(0); } int index() const { return index_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const int index_; @@ -2150,9 +2085,7 @@ class InitialValue : public FixedInputValueNodeT<0, InitialValue> { interpreter::Register source() const { return source_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const interpreter::Register source_; @@ -2172,9 +2105,7 @@ class RegisterInput : public FixedInputValueNodeT<0, RegisterInput> { Register input() const { return input_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const Register input_; @@ -2195,11 +2126,9 @@ class SmiConstant : public FixedInputValueNodeT<0, SmiConstant> { return value_ != Smi::FromInt(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() - void DoLoadToRegister(MaglevCodeGenState*, OutputRegister); + void DoLoadToRegister(MaglevAssembler*, OutputRegister); Handle DoReify(LocalIsolate* isolate); private: @@ -2221,11 +2150,9 @@ class Constant : public FixedInputValueNodeT<0, Constant> { bool IsTheHole() const { return object_.IsTheHole(); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() - void DoLoadToRegister(MaglevCodeGenState*, OutputRegister); + void DoLoadToRegister(MaglevAssembler*, OutputRegister); Handle DoReify(LocalIsolate* isolate); private: @@ -2245,11 +2172,9 @@ class RootConstant : public FixedInputValueNodeT<0, RootConstant> { RootIndex index() const { return index_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() - void DoLoadToRegister(MaglevCodeGenState*, OutputRegister); + void DoLoadToRegister(MaglevAssembler*, OutputRegister); Handle DoReify(LocalIsolate* isolate); private: @@ -2270,9 +2195,7 @@ class CreateEmptyArrayLiteral // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::FeedbackSource feedback_; @@ -2298,9 +2221,7 @@ class CreateArrayLiteral : public FixedInputValueNodeT<0, CreateArrayLiteral> { // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::HeapObjectRef constant_elements_; @@ -2328,9 +2249,7 @@ class CreateShallowArrayLiteral // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::HeapObjectRef constant_elements_; @@ -2361,9 +2280,7 @@ class CreateObjectLiteral // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::ObjectBoilerplateDescriptionRef boilerplate_descriptor_; @@ -2383,9 +2300,7 @@ class CreateEmptyObjectLiteral compiler::MapRef map() { return map_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::MapRef map_; @@ -2416,9 +2331,7 @@ class CreateShallowObjectLiteral // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::ObjectBoilerplateDescriptionRef boilerplate_descriptor_; @@ -2448,9 +2361,7 @@ class CreateFunctionContext // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::ScopeInfoRef scope_info_; @@ -2479,9 +2390,7 @@ class FastCreateClosure : public FixedInputValueNodeT<1, FastCreateClosure> { // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::SharedFunctionInfoRef shared_function_info_; @@ -2506,9 +2415,7 @@ class CreateRegExpLiteral // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: compiler::StringRef pattern_; @@ -2540,9 +2447,7 @@ class CreateClosure : public FixedInputValueNodeT<1, CreateClosure> { // The implementation currently calls runtime. static constexpr OpProperties kProperties = OpProperties::Call(); - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::SharedFunctionInfoRef shared_function_info_; @@ -2569,9 +2474,7 @@ class CheckMaps : public FixedInputNodeT<1, CheckMaps> { static constexpr int kReceiverIndex = 0; Input& receiver_input() { return input(kReceiverIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::MapRef map_; @@ -2588,9 +2491,7 @@ class CheckSmi : public FixedInputNodeT<1, CheckSmi> { static constexpr int kReceiverIndex = 0; Input& receiver_input() { return input(kReceiverIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() }; class CheckNumber : public FixedInputNodeT<1, CheckNumber> { @@ -2606,9 +2507,7 @@ class CheckNumber : public FixedInputNodeT<1, CheckNumber> { Input& receiver_input() { return input(kReceiverIndex); } Object::Conversion mode() const { return mode_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const Object::Conversion mode_; @@ -2625,9 +2524,7 @@ class CheckHeapObject : public FixedInputNodeT<1, CheckHeapObject> { static constexpr int kReceiverIndex = 0; Input& receiver_input() { return input(kReceiverIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() }; class CheckSymbol : public FixedInputNodeT<1, CheckSymbol> { @@ -2642,9 +2539,7 @@ class CheckSymbol : public FixedInputNodeT<1, CheckSymbol> { static constexpr int kReceiverIndex = 0; Input& receiver_input() { return input(kReceiverIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const CheckType check_type_; @@ -2662,9 +2557,7 @@ class CheckString : public FixedInputNodeT<1, CheckString> { static constexpr int kReceiverIndex = 0; Input& receiver_input() { return input(kReceiverIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const CheckType check_type_; @@ -2690,9 +2583,7 @@ class CheckMapsWithMigration static constexpr int kReceiverIndex = 0; Input& receiver_input() { return input(kReceiverIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::MapRef map_; @@ -2717,9 +2608,7 @@ class CheckedInternalizedString static constexpr int kObjectIndex = 0; Input& object_input() { return Node::input(kObjectIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const CheckType check_type_; @@ -2747,9 +2636,7 @@ class GetTemplateObject : public FixedInputValueNodeT<1, GetTemplateObject> { } compiler::FeedbackSource feedback() const { return feedback_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: compiler::SharedFunctionInfoRef shared_function_info_; @@ -2770,9 +2657,7 @@ class LoadTaggedField : public FixedInputValueNodeT<1, LoadTaggedField> { static constexpr int kObjectIndex = 0; Input& object_input() { return input(kObjectIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const int offset_; @@ -2793,9 +2678,7 @@ class LoadDoubleField : public FixedInputValueNodeT<1, LoadDoubleField> { static constexpr int kObjectIndex = 0; Input& object_input() { return input(kObjectIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const int offset_; @@ -2818,9 +2701,7 @@ class StoreTaggedFieldNoWriteBarrier Input& object_input() { return input(kObjectIndex); } Input& value_input() { return input(kValueIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const int offset_; @@ -2844,9 +2725,7 @@ class StoreTaggedFieldWithWriteBarrier Input& object_input() { return input(kObjectIndex); } Input& value_input() { return input(kValueIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const int offset_; @@ -2873,9 +2752,7 @@ class LoadGlobal : public FixedInputValueNodeT<1, LoadGlobal> { Input& context() { return input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::NameRef name_; @@ -2900,9 +2777,7 @@ class StoreGlobal : public FixedInputValueNodeT<2, StoreGlobal> { Input& context() { return input(0); } Input& value() { return input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::NameRef name_; @@ -2928,9 +2803,7 @@ class LoadNamedGeneric : public FixedInputValueNodeT<2, LoadNamedGeneric> { Input& context() { return input(kContextIndex); } Input& object_input() { return input(kObjectIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::NameRef name_; @@ -2960,9 +2833,7 @@ class LoadNamedFromSuperGeneric Input& receiver() { return input(kReceiverIndex); } Input& lookup_start_object() { return input(kLookupStartObjectIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::NameRef name_; @@ -2990,9 +2861,7 @@ class SetNamedGeneric : public FixedInputValueNodeT<3, SetNamedGeneric> { Input& object_input() { return input(kObjectIndex); } Input& value_input() { return input(kValueIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::NameRef name_; @@ -3022,9 +2891,7 @@ class DefineNamedOwnGeneric Input& object_input() { return input(kObjectIndex); } Input& value_input() { return input(kValueIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const compiler::NameRef name_; @@ -3054,9 +2921,7 @@ class StoreInArrayLiteralGeneric Input& name_input() { return input(kNameIndex); } Input& value_input() { return input(kValueIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::FeedbackSource feedback_; @@ -3082,9 +2947,7 @@ class GetKeyedGeneric : public FixedInputValueNodeT<3, GetKeyedGeneric> { Input& object_input() { return input(kObjectIndex); } Input& key_input() { return input(kKeyIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::FeedbackSource feedback_; @@ -3112,9 +2975,7 @@ class SetKeyedGeneric : public FixedInputValueNodeT<4, SetKeyedGeneric> { Input& key_input() { return input(kKeyIndex); } Input& value_input() { return input(kValueIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::FeedbackSource feedback_; @@ -3143,9 +3004,7 @@ class DefineKeyedOwnGeneric Input& key_input() { return input(kKeyIndex); } Input& value_input() { return input(kValueIndex); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::FeedbackSource feedback_; @@ -3162,9 +3021,7 @@ class GapMove : public FixedInputNodeT<0, GapMove> { compiler::AllocatedOperand source() const { return source_; } compiler::AllocatedOperand target() const { return target_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: compiler::AllocatedOperand source_; @@ -3182,9 +3039,7 @@ class ConstantGapMove : public FixedInputNodeT<0, ConstantGapMove> { compiler::AllocatedOperand target() const { return target_; } ValueNode* node() const { return node_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: ValueNode* node_; @@ -3211,10 +3066,8 @@ class Phi : public ValueNodeT { using Node::reduce_input_count; using Node::set_input; - void AllocateVreg(MaglevVregAllocationState*); + DECL_NODE_INTERFACE() void AllocateVregInPostProcess(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; private: Phi** next() { return &next_; } @@ -3260,9 +3113,7 @@ class Call : public ValueNodeT { set_input(i + kFixedInputCount, node); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: ConvertReceiverMode receiver_mode_; @@ -3306,9 +3157,7 @@ class Construct : public ValueNodeT { set_input(i + kFixedInputCount, node); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class CallBuiltin : public ValueNodeT { @@ -3384,14 +3233,12 @@ class CallBuiltin : public ValueNodeT { void set_arg(int i, ValueNode* node) { set_input(i, node); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: - void PassFeedbackSlotOnStack(MaglevCodeGenState*); - void PassFeedbackSlotInRegister(MaglevCodeGenState*); - void PushFeedback(MaglevCodeGenState*); + void PassFeedbackSlotOnStack(MaglevAssembler*); + void PassFeedbackSlotInRegister(MaglevAssembler*); + void PushFeedback(MaglevAssembler*); Builtin builtin_; base::Optional feedback_; @@ -3430,9 +3277,7 @@ class CallRuntime : public ValueNodeT { return Runtime::FunctionForId(function_id())->result_size; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: Runtime::FunctionId function_id_; @@ -3471,9 +3316,7 @@ class CallWithSpread : public ValueNodeT { return input(input_count() - 1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ConstructWithSpread : public ValueNodeT { @@ -3514,9 +3357,7 @@ class ConstructWithSpread : public ValueNodeT { return input(input_count() - 1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class IncreaseInterruptBudget @@ -3531,9 +3372,7 @@ class IncreaseInterruptBudget int amount() const { return amount_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const int amount_; @@ -3557,9 +3396,7 @@ class ReduceInterruptBudget : public FixedInputNodeT<0, ReduceInterruptBudget> { int amount() const { return amount_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const int amount_; @@ -3581,9 +3418,7 @@ class ThrowReferenceErrorIfHole Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const compiler::NameRef name_; @@ -3601,9 +3436,7 @@ class ThrowSuperNotCalledIfHole Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ThrowSuperAlreadyCalledIfNotHole @@ -3619,9 +3452,7 @@ class ThrowSuperAlreadyCalledIfNotHole Input& value() { return Node::input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ThrowIfNotSuperConstructor @@ -3637,9 +3468,7 @@ class ThrowIfNotSuperConstructor Input& constructor() { return Node::input(0); } Input& function() { return Node::input(1); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class ControlNode : public NodeBase { @@ -3765,9 +3594,7 @@ class Jump : public UnconditionalControlNodeT { Jump(uint64_t bitfield, BasicBlockRef* target_refs) : Base(bitfield, target_refs) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class JumpLoop : public UnconditionalControlNodeT { @@ -3780,9 +3607,7 @@ class JumpLoop : public UnconditionalControlNodeT { explicit JumpLoop(uint64_t bitfield, BasicBlockRef* ref) : Base(bitfield, ref) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() base::Vector used_nodes() { return used_node_locations_; } void set_used_nodes(base::Vector locations) { @@ -3801,9 +3626,7 @@ class JumpToInlined : public UnconditionalControlNodeT { MaglevCompilationUnit* unit) : Base(bitfield, target_refs), unit_(unit) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() const MaglevCompilationUnit* unit() const { return unit_; } @@ -3818,9 +3641,7 @@ class JumpFromInlined : public UnconditionalControlNodeT { explicit JumpFromInlined(uint64_t bitfield, BasicBlockRef* target_refs) : Base(bitfield, target_refs) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class Abort : public ControlNode { @@ -3832,9 +3653,7 @@ class Abort : public ControlNode { AbortReason reason() const { return reason_; } - void AllocateVreg(MaglevVregAllocationState*) {} - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: const AbortReason reason_; @@ -3848,9 +3667,7 @@ class Return : public ControlNode { Input& value_input() { return input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class Deopt : public ControlNode { @@ -3864,9 +3681,7 @@ class Deopt : public ControlNode { DeoptimizeReason reason() const { return reason_; } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: DeoptimizeReason reason_; @@ -3902,9 +3717,7 @@ class Switch : public ConditionalControlNode { Input& value() { return input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() private: const int value_base_; @@ -3926,9 +3739,7 @@ class BranchIfRootConstant RootIndex root_index() { return root_index_; } Input& condition_input() { return input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: RootIndex root_index_; @@ -3946,9 +3757,7 @@ class BranchIfUndefinedOrNull Input& condition_input() { return input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class BranchIfJSReceiver : public BranchControlNodeT<1, BranchIfJSReceiver> { @@ -3961,9 +3770,7 @@ class BranchIfJSReceiver : public BranchControlNodeT<1, BranchIfJSReceiver> { Input& condition_input() { return input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class BranchIfToBooleanTrue @@ -3979,9 +3786,7 @@ class BranchIfToBooleanTrue Input& condition_input() { return input(0); } - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} + DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS() }; class BranchIfInt32Compare @@ -3999,9 +3804,7 @@ class BranchIfInt32Compare BasicBlockRef* if_false_refs) : Base(bitfield, if_true_refs, if_false_refs), operation_(operation) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: Operation operation_; @@ -4022,9 +3825,7 @@ class BranchIfFloat64Compare BasicBlockRef* if_false_refs) : Base(bitfield, if_true_refs, if_false_refs), operation_(operation) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: Operation operation_; @@ -4045,14 +3846,15 @@ class BranchIfReferenceCompare BasicBlockRef* if_false_refs) : Base(bitfield, if_true_refs, if_false_refs), operation_(operation) {} - void AllocateVreg(MaglevVregAllocationState*); - void GenerateCode(MaglevCodeGenState*, const ProcessingState&); - void PrintParams(std::ostream&, MaglevGraphLabeller*) const; + DECL_NODE_INTERFACE() private: Operation operation_; }; +#undef DECL_NODE_INTERFACE_WITH_EMPTY_PRINT_PARAMS +#undef DECL_NODE_INTERFACE + } // namespace maglev } // namespace internal } // namespace v8