Commit e5eab3d6 authored by Jakob Linke's avatar Jakob Linke Committed by V8 LUCI CQ

[maglev] Add a (mostly empty for now) MaglevAssembler

Bug: v8:7700
Change-Id: Idf4cd2544e7ee3912809cbf95cee4823be36d1dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3875905Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Auto-Submit: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83021}
parent 49abe45e
......@@ -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",
......
// 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_
// 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_
......@@ -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<LazyDeoptInfo*>& lazy_deopts() const {
return lazy_deopts_;
}
inline void DefineLazyDeoptPoint(LazyDeoptInfo* info);
void PushHandlerInfo(NodeBase* node) { handlers_.push_back(node); }
const std::vector<NodeBase*>& 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<DeferredCodeInfo*> deferred_code_;
std::vector<EagerDeoptInfo*> eager_deopts_;
std::vector<LazyDeoptInfo*> 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
......
This diff is collapsed.
......@@ -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"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment