Commit 0dcb488c authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Build translation array on background

Move the translation array building to the "compile" rather than
"generate code" phase of maglev compilation, as a graph processor after
register allocation. This allows it to be done on a background thread.

Drive-by: Use the new OptimizedOut functionality of the translation
array builder.

Bug: v8:7700
Change-Id: If4202737f1eeb38281f306c23f408105c5fb0ef1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3811501Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82228}
parent e4d28751
This diff is collapsed.
......@@ -11,11 +11,17 @@
#include "src/handles/maybe-handles.h"
namespace v8 {
namespace base {
class DefaultAllocationPolicy;
}
namespace internal {
class Isolate;
class PersistentHandles;
class SharedFunctionInfo;
class TranslationArrayBuilder;
class Zone;
namespace compiler {
......@@ -62,6 +68,19 @@ class MaglevCompilationInfo final {
void set_graph(Graph* graph) { graph_ = graph; }
Graph* graph() const { return graph_; }
void set_translation_array_builder(
TranslationArrayBuilder* translation_array_builder,
IdentityMap<int, base::DefaultAllocationPolicy>* deopt_literals) {
translation_array_builder_ = translation_array_builder;
deopt_literals_ = deopt_literals;
}
TranslationArrayBuilder& translation_array_builder() const {
return *translation_array_builder_;
}
IdentityMap<int, base::DefaultAllocationPolicy>& deopt_literals() const {
return *deopt_literals_;
}
// Flag accessors (for thread-safe access to global flags).
// TODO(v8:7700): Consider caching these.
#define V(Name) \
......@@ -96,6 +115,9 @@ class MaglevCompilationInfo final {
// Produced off-thread during ExecuteJobImpl.
Graph* graph_ = nullptr;
TranslationArrayBuilder* translation_array_builder_ = nullptr;
IdentityMap<int, base::DefaultAllocationPolicy>* deopt_literals_ = nullptr;
#define V(Name) const bool Name##_;
MAGLEV_COMPILATION_FLAG_LIST(V)
#undef V
......
This diff is collapsed.
......@@ -675,7 +675,7 @@ void ValueNode::DoLoadToRegister(MaglevCodeGenState* code_gen_state,
__ Movsd(reg, code_gen_state->GetStackSlot(
compiler::AllocatedOperand::cast(spill_slot())));
}
Handle<Object> ValueNode::Reify(Isolate* isolate) {
Handle<Object> ValueNode::Reify(LocalIsolate* isolate) {
switch (opcode()) {
#define V(Name) \
case Opcode::k##Name: \
......@@ -711,7 +711,7 @@ void SmiConstant::AllocateVreg(MaglevVregAllocationState* vreg_state) {
}
void SmiConstant::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {}
Handle<Object> SmiConstant::DoReify(Isolate* isolate) {
Handle<Object> SmiConstant::DoReify(LocalIsolate* isolate) {
return handle(value_, isolate);
}
void SmiConstant::DoLoadToRegister(MaglevCodeGenState* code_gen_state,
......@@ -728,8 +728,8 @@ void Float64Constant::AllocateVreg(MaglevVregAllocationState* vreg_state) {
}
void Float64Constant::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {}
Handle<Object> Float64Constant::DoReify(Isolate* isolate) {
return isolate->factory()->NewNumber(value_);
Handle<Object> Float64Constant::DoReify(LocalIsolate* isolate) {
return isolate->factory()->NewNumber<AllocationType::kOld>(value_);
}
void Float64Constant::DoLoadToRegister(MaglevCodeGenState* code_gen_state,
DoubleRegister reg) {
......@@ -749,7 +749,9 @@ void Constant::DoLoadToRegister(MaglevCodeGenState* code_gen_state,
Register reg) {
__ Move(reg, object_.object());
}
Handle<Object> Constant::DoReify(Isolate* isolate) { return object_.object(); }
Handle<Object> Constant::DoReify(LocalIsolate* isolate) {
return object_.object();
}
void Constant::PrintParams(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
os << "(" << object_ << ")";
......@@ -942,7 +944,7 @@ void RootConstant::DoLoadToRegister(MaglevCodeGenState* code_gen_state,
Register reg) {
__ LoadRoot(reg, index());
}
Handle<Object> RootConstant::DoReify(Isolate* isolate) {
Handle<Object> RootConstant::DoReify(LocalIsolate* isolate) {
return isolate->root_handle(index());
}
void RootConstant::PrintParams(std::ostream& os,
......@@ -2181,8 +2183,8 @@ void Int32Constant::DoLoadToRegister(MaglevCodeGenState* code_gen_state,
Register reg) {
__ Move(reg, Immediate(value()));
}
Handle<Object> Int32Constant::DoReify(Isolate* isolate) {
return isolate->factory()->NewNumber(value());
Handle<Object> Int32Constant::DoReify(LocalIsolate* isolate) {
return isolate->factory()->NewNumber<AllocationType::kOld>(value());
}
void Int32Constant::PrintParams(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
......
......@@ -901,7 +901,7 @@ class ValueNode : public Node {
void LoadToRegister(MaglevCodeGenState*, DoubleRegister);
void DoLoadToRegister(MaglevCodeGenState*, Register);
void DoLoadToRegister(MaglevCodeGenState*, DoubleRegister);
Handle<Object> Reify(Isolate* isolate);
Handle<Object> Reify(LocalIsolate* isolate);
void Spill(compiler::AllocatedOperand operand) {
#ifdef DEBUG
......@@ -1502,7 +1502,7 @@ class Int32Constant : public FixedInputValueNodeT<0, Int32Constant> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const;
void DoLoadToRegister(MaglevCodeGenState*, OutputRegister);
Handle<Object> DoReify(Isolate* isolate);
Handle<Object> DoReify(LocalIsolate* isolate);
private:
const int32_t value_;
......@@ -1530,7 +1530,7 @@ class Float64Constant : public FixedInputValueNodeT<0, Float64Constant> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const;
void DoLoadToRegister(MaglevCodeGenState*, OutputRegister);
Handle<Object> DoReify(Isolate* isolate);
Handle<Object> DoReify(LocalIsolate* isolate);
private:
const double value_;
......@@ -1900,7 +1900,7 @@ class SmiConstant : public FixedInputValueNodeT<0, SmiConstant> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const;
void DoLoadToRegister(MaglevCodeGenState*, OutputRegister);
Handle<Object> DoReify(Isolate* isolate);
Handle<Object> DoReify(LocalIsolate* isolate);
private:
const Smi value_;
......@@ -1926,7 +1926,7 @@ class Constant : public FixedInputValueNodeT<0, Constant> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const;
void DoLoadToRegister(MaglevCodeGenState*, OutputRegister);
Handle<Object> DoReify(Isolate* isolate);
Handle<Object> DoReify(LocalIsolate* isolate);
private:
const compiler::HeapObjectRef object_;
......@@ -1950,7 +1950,7 @@ class RootConstant : public FixedInputValueNodeT<0, RootConstant> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const;
void DoLoadToRegister(MaglevCodeGenState*, OutputRegister);
Handle<Object> DoReify(Isolate* isolate);
Handle<Object> DoReify(LocalIsolate* isolate);
private:
const RootIndex index_;
......
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