Commit 10cae735 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Pass MaglevCompilationInfo to more passes

MaglevCompilationInfo stores the overall compilation information (zone,
graph, labeller, etc.), while MaglevCompilationUnit stores per-function
information (function, bytecode analysis, register count, etc.).

Without inlining, these are 1:1 and we've been pretty sloppy in deciding
which to pass around. Once we implement inlining though, we want to be
careful to pass MaglevCompilationInfo where we're processing the whole
graph, and MaglevCompilationUnit where we're processing something
function-specific.

This does the pre-work of cleaning this up in preparation for inlining.

Bug: v8:7700
Change-Id: Ic50fdd97e56f6c963ab490bd419eb65fe0873688
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3596162
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80051}
parent 58fb7d8f
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "src/common/globals.h" #include "src/common/globals.h"
#include "src/compiler/backend/instruction.h" #include "src/compiler/backend/instruction.h"
#include "src/compiler/js-heap-broker.h" #include "src/compiler/js-heap-broker.h"
#include "src/maglev/maglev-compilation-unit.h" #include "src/maglev/maglev-compilation-info.h"
#include "src/maglev/maglev-ir.h" #include "src/maglev/maglev-ir.h"
namespace v8 { namespace v8 {
...@@ -32,9 +32,9 @@ class DeferredCodeInfo { ...@@ -32,9 +32,9 @@ class DeferredCodeInfo {
class MaglevCodeGenState { class MaglevCodeGenState {
public: public:
MaglevCodeGenState(MaglevCompilationUnit* compilation_unit, MaglevCodeGenState(MaglevCompilationInfo* compilation_info,
SafepointTableBuilder* safepoint_table_builder) SafepointTableBuilder* safepoint_table_builder)
: compilation_unit_(compilation_unit), : compilation_info_(compilation_info),
safepoint_table_builder_(safepoint_table_builder), safepoint_table_builder_(safepoint_table_builder),
masm_(isolate(), CodeObjectRequired::kNo) {} masm_(isolate(), CodeObjectRequired::kNo) {}
...@@ -61,25 +61,17 @@ class MaglevCodeGenState { ...@@ -61,25 +61,17 @@ class MaglevCodeGenState {
compiler::NativeContextRef native_context() const { compiler::NativeContextRef native_context() const {
return broker()->target_native_context(); return broker()->target_native_context();
} }
Isolate* isolate() const { return compilation_unit_->isolate(); } Isolate* isolate() const { return compilation_info_->isolate(); }
int parameter_count() const { return compilation_unit_->parameter_count(); } compiler::JSHeapBroker* broker() const { return compilation_info_->broker(); }
int register_count() const { return compilation_unit_->register_count(); }
const compiler::BytecodeAnalysis& bytecode_analysis() const {
return compilation_unit_->bytecode_analysis();
}
compiler::JSHeapBroker* broker() const { return compilation_unit_->broker(); }
const compiler::BytecodeArrayRef& bytecode() const {
return compilation_unit_->bytecode();
}
MaglevGraphLabeller* graph_labeller() const { MaglevGraphLabeller* graph_labeller() const {
return compilation_unit_->graph_labeller(); return compilation_info_->graph_labeller();
} }
MacroAssembler* masm() { return &masm_; } MacroAssembler* masm() { return &masm_; }
int stack_slots() const { return untagged_slots_ + tagged_slots_; } int stack_slots() const { return untagged_slots_ + tagged_slots_; }
SafepointTableBuilder* safepoint_table_builder() const { SafepointTableBuilder* safepoint_table_builder() const {
return safepoint_table_builder_; return safepoint_table_builder_;
} }
MaglevCompilationUnit* compilation_unit() const { return compilation_unit_; } MaglevCompilationInfo* compilation_info() const { return compilation_info_; }
// TODO(v8:7700): Clean up after all code paths are supported. // TODO(v8:7700): Clean up after all code paths are supported.
void set_found_unsupported_code_paths(bool val) { void set_found_unsupported_code_paths(bool val) {
...@@ -121,7 +113,7 @@ class MaglevCodeGenState { ...@@ -121,7 +113,7 @@ class MaglevCodeGenState {
index * kSystemPointerSize; index * kSystemPointerSize;
} }
MaglevCompilationUnit* const compilation_unit_; MaglevCompilationInfo* const compilation_info_;
SafepointTableBuilder* const safepoint_table_builder_; SafepointTableBuilder* const safepoint_table_builder_;
MacroAssembler masm_; MacroAssembler masm_;
......
...@@ -47,7 +47,7 @@ class MaglevCodeGeneratingNodeProcessor { ...@@ -47,7 +47,7 @@ class MaglevCodeGeneratingNodeProcessor {
explicit MaglevCodeGeneratingNodeProcessor(MaglevCodeGenState* code_gen_state) explicit MaglevCodeGeneratingNodeProcessor(MaglevCodeGenState* code_gen_state)
: code_gen_state_(code_gen_state) {} : code_gen_state_(code_gen_state) {}
void PreProcessGraph(MaglevCompilationUnit*, Graph* graph) { void PreProcessGraph(MaglevCompilationInfo*, Graph* graph) {
if (FLAG_maglev_break_on_entry) { if (FLAG_maglev_break_on_entry) {
__ int3(); __ int3();
} }
...@@ -87,9 +87,9 @@ class MaglevCodeGeneratingNodeProcessor { ...@@ -87,9 +87,9 @@ class MaglevCodeGeneratingNodeProcessor {
code_gen_state_->DefineSafepointStackSlots(safepoint); code_gen_state_->DefineSafepointStackSlots(safepoint);
} }
void PostProcessGraph(MaglevCompilationUnit*, Graph*) {} void PostProcessGraph(MaglevCompilationInfo*, Graph*) {}
void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block) { void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block) {
if (FLAG_code_comments) { if (FLAG_code_comments) {
std::stringstream ss; std::stringstream ss;
ss << "-- Block b" << graph_labeller()->BlockId(block); ss << "-- Block b" << graph_labeller()->BlockId(block);
...@@ -312,20 +312,20 @@ class MaglevCodeGeneratingNodeProcessor { ...@@ -312,20 +312,20 @@ class MaglevCodeGeneratingNodeProcessor {
class MaglevCodeGeneratorImpl final { class MaglevCodeGeneratorImpl final {
public: public:
static MaybeHandle<Code> Generate(MaglevCompilationUnit* compilation_unit, static MaybeHandle<Code> Generate(MaglevCompilationInfo* compilation_info,
Graph* graph) { Graph* graph) {
return MaglevCodeGeneratorImpl(compilation_unit, graph).Generate(); return MaglevCodeGeneratorImpl(compilation_info, graph).Generate();
} }
private: private:
static constexpr int kFunctionLiteralIndex = 0; static constexpr int kFunctionLiteralIndex = 0;
static constexpr int kOptimizedOutConstantIndex = 1; static constexpr int kOptimizedOutConstantIndex = 1;
MaglevCodeGeneratorImpl(MaglevCompilationUnit* compilation_unit, Graph* graph) MaglevCodeGeneratorImpl(MaglevCompilationInfo* compilation_info, Graph* graph)
: safepoint_table_builder_(compilation_unit->zone()), : safepoint_table_builder_(compilation_info->zone()),
translation_array_builder_(compilation_unit->zone()), translation_array_builder_(compilation_info->zone()),
code_gen_state_(compilation_unit, safepoint_table_builder()), code_gen_state_(compilation_info, safepoint_table_builder()),
processor_(compilation_unit, &code_gen_state_), processor_(compilation_info, &code_gen_state_),
graph_(graph) {} graph_(graph) {}
MaybeHandle<Code> Generate() { MaybeHandle<Code> Generate() {
...@@ -388,17 +388,20 @@ class MaglevCodeGeneratorImpl final { ...@@ -388,17 +388,20 @@ class MaglevCodeGeneratorImpl final {
deopt_info->deopt_index = translation_array_builder_.BeginTranslation( deopt_info->deopt_index = translation_array_builder_.BeginTranslation(
frame_count, jsframe_count, update_feedback_count); frame_count, jsframe_count, update_feedback_count);
const MaglevCompilationUnit& compilation_unit =
*code_gen_state_.compilation_info()->toplevel_compilation_unit();
// Returns are used for updating an accumulator or register after a lazy // Returns are used for updating an accumulator or register after a lazy
// deopt. // deopt.
const int return_offset = 0; const int return_offset = 0;
const int return_count = 0; const int return_count = 0;
translation_array_builder_.BeginInterpretedFrame( translation_array_builder_.BeginInterpretedFrame(
deopt_info->state.bytecode_position, kFunctionLiteralIndex, deopt_info->state.bytecode_position, kFunctionLiteralIndex,
code_gen_state_.register_count(), return_offset, return_count); compilation_unit.register_count(), return_offset, return_count);
EmitDeoptFrameValues( EmitDeoptFrameValues(compilation_unit, deopt_info->state.register_frame,
*code_gen_state_.compilation_unit(), deopt_info->state.register_frame, deopt_info->input_locations,
deopt_info->input_locations, interpreter::Register::invalid_value()); interpreter::Register::invalid_value());
} }
void EmitLazyDeopt(LazyDeoptInfo* deopt_info) { void EmitLazyDeopt(LazyDeoptInfo* deopt_info) {
...@@ -408,6 +411,9 @@ class MaglevCodeGeneratorImpl final { ...@@ -408,6 +411,9 @@ class MaglevCodeGeneratorImpl final {
deopt_info->deopt_index = translation_array_builder_.BeginTranslation( deopt_info->deopt_index = translation_array_builder_.BeginTranslation(
frame_count, jsframe_count, update_feedback_count); frame_count, jsframe_count, update_feedback_count);
const MaglevCompilationUnit& compilation_unit =
*code_gen_state_.compilation_info()->toplevel_compilation_unit();
// Return offsets are counted from the end of the translation frame, which // Return offsets are counted from the end of the translation frame, which
// is the array [parameters..., locals..., accumulator]. // is the array [parameters..., locals..., accumulator].
int return_offset; int return_offset;
...@@ -423,22 +429,22 @@ class MaglevCodeGeneratorImpl final { ...@@ -423,22 +429,22 @@ class MaglevCodeGeneratorImpl final {
// ^ // ^
// and this calculation gives, correctly: // and this calculation gives, correctly:
// 2 + 2 - 1 = 3 // 2 + 2 - 1 = 3
return_offset = code_gen_state_.register_count() + return_offset = compilation_unit.register_count() +
code_gen_state_.parameter_count() - compilation_unit.parameter_count() -
deopt_info->result_location.ToParameterIndex(); deopt_info->result_location.ToParameterIndex();
} else { } else {
return_offset = code_gen_state_.register_count() - return_offset = compilation_unit.register_count() -
deopt_info->result_location.index(); deopt_info->result_location.index();
} }
// TODO(leszeks): Support lazy deopts with multiple return values. // TODO(leszeks): Support lazy deopts with multiple return values.
int return_count = 1; int return_count = 1;
translation_array_builder_.BeginInterpretedFrame( translation_array_builder_.BeginInterpretedFrame(
deopt_info->state.bytecode_position, kFunctionLiteralIndex, deopt_info->state.bytecode_position, kFunctionLiteralIndex,
code_gen_state_.register_count(), return_offset, return_count); compilation_unit.register_count(), return_offset, return_count);
EmitDeoptFrameValues( EmitDeoptFrameValues(compilation_unit, deopt_info->state.register_frame,
*code_gen_state_.compilation_unit(), deopt_info->state.register_frame, deopt_info->input_locations,
deopt_info->input_locations, deopt_info->result_location); deopt_info->result_location);
} }
void EmitDeoptStoreRegister(const compiler::AllocatedOperand& operand, void EmitDeoptStoreRegister(const compiler::AllocatedOperand& operand,
...@@ -551,7 +557,7 @@ class MaglevCodeGeneratorImpl final { ...@@ -551,7 +557,7 @@ class MaglevCodeGeneratorImpl final {
i++; i++;
input_location++; input_location++;
}); });
while (i < code_gen_state_.register_count()) { while (i < compilation_unit.register_count()) {
translation_array_builder_.StoreLiteral(kOptimizedOutConstantIndex); translation_array_builder_.StoreLiteral(kOptimizedOutConstantIndex);
i++; i++;
} }
...@@ -613,15 +619,18 @@ class MaglevCodeGeneratorImpl final { ...@@ -613,15 +619,18 @@ class MaglevCodeGeneratorImpl final {
data->SetEagerDeoptCount(Smi::FromInt(eager_deopt_count)); data->SetEagerDeoptCount(Smi::FromInt(eager_deopt_count));
data->SetLazyDeoptCount(Smi::FromInt(lazy_deopt_count)); data->SetLazyDeoptCount(Smi::FromInt(lazy_deopt_count));
data->SetSharedFunctionInfo( data->SetSharedFunctionInfo(*code_gen_state_.compilation_info()
*code_gen_state_.compilation_unit()->shared_function_info().object()); ->toplevel_compilation_unit()
->shared_function_info()
.object());
// TODO(leszeks): Proper literals array. // TODO(leszeks): Proper literals array.
Handle<DeoptimizationLiteralArray> literals = Handle<DeoptimizationLiteralArray> literals =
isolate()->factory()->NewDeoptimizationLiteralArray(2); isolate()->factory()->NewDeoptimizationLiteralArray(2);
literals->set( literals->set(kFunctionLiteralIndex, *code_gen_state_.compilation_info()
kFunctionLiteralIndex, ->toplevel_compilation_unit()
*code_gen_state_.compilation_unit()->shared_function_info().object()); ->shared_function_info()
.object());
literals->set(kOptimizedOutConstantIndex, literals->set(kOptimizedOutConstantIndex,
ReadOnlyRoots(isolate()).optimized_out()); ReadOnlyRoots(isolate()).optimized_out());
data->SetLiteralArray(*literals); data->SetLiteralArray(*literals);
...@@ -668,7 +677,7 @@ class MaglevCodeGeneratorImpl final { ...@@ -668,7 +677,7 @@ class MaglevCodeGeneratorImpl final {
} }
Isolate* isolate() const { Isolate* isolate() const {
return code_gen_state_.compilation_unit()->isolate(); return code_gen_state_.compilation_info()->isolate();
} }
MacroAssembler* masm() { return code_gen_state_.masm(); } MacroAssembler* masm() { return code_gen_state_.masm(); }
SafepointTableBuilder* safepoint_table_builder() { SafepointTableBuilder* safepoint_table_builder() {
...@@ -689,8 +698,8 @@ class MaglevCodeGeneratorImpl final { ...@@ -689,8 +698,8 @@ class MaglevCodeGeneratorImpl final {
// static // static
MaybeHandle<Code> MaglevCodeGenerator::Generate( MaybeHandle<Code> MaglevCodeGenerator::Generate(
MaglevCompilationUnit* compilation_unit, Graph* graph) { MaglevCompilationInfo* compilation_info, Graph* graph) {
return MaglevCodeGeneratorImpl::Generate(compilation_unit, graph); return MaglevCodeGeneratorImpl::Generate(compilation_info, graph);
} }
} // namespace maglev } // namespace maglev
......
...@@ -12,11 +12,11 @@ namespace internal { ...@@ -12,11 +12,11 @@ namespace internal {
namespace maglev { namespace maglev {
class Graph; class Graph;
class MaglevCompilationUnit; class MaglevCompilationInfo;
class MaglevCodeGenerator : public AllStatic { class MaglevCodeGenerator : public AllStatic {
public: public:
static MaybeHandle<Code> Generate(MaglevCompilationUnit* compilation_unit, static MaybeHandle<Code> Generate(MaglevCompilationInfo* compilation_info,
Graph* graph); Graph* graph);
}; };
......
...@@ -54,9 +54,7 @@ MaglevCompilationInfo::MaglevCompilationInfo(Isolate* isolate, ...@@ -54,9 +54,7 @@ MaglevCompilationInfo::MaglevCompilationInfo(Isolate* isolate,
: zone_(isolate->allocator(), kMaglevZoneName), : zone_(isolate->allocator(), kMaglevZoneName),
isolate_(isolate), isolate_(isolate),
broker_(new compiler::JSHeapBroker( broker_(new compiler::JSHeapBroker(
isolate, zone(), FLAG_trace_heap_broker, CodeKind::MAGLEV)), isolate, zone(), FLAG_trace_heap_broker, CodeKind::MAGLEV))
shared_(function->shared(), isolate),
function_(function)
#define V(Name) , Name##_(FLAG_##Name) #define V(Name) , Name##_(FLAG_##Name)
MAGLEV_COMPILATION_FLAG_LIST(V) MAGLEV_COMPILATION_FLAG_LIST(V)
#undef V #undef V
...@@ -91,12 +89,7 @@ void MaglevCompilationInfo::set_graph_labeller( ...@@ -91,12 +89,7 @@ void MaglevCompilationInfo::set_graph_labeller(
graph_labeller_.reset(graph_labeller); graph_labeller_.reset(graph_labeller);
} }
void MaglevCompilationInfo::ReopenHandlesInNewHandleScope(Isolate* isolate) { void MaglevCompilationInfo::ReopenHandlesInNewHandleScope(Isolate* isolate) {}
DCHECK(!shared_.is_null());
shared_ = handle(*shared_, isolate);
DCHECK(!function_.is_null());
function_ = handle(*function_, isolate);
}
void MaglevCompilationInfo::set_persistent_handles( void MaglevCompilationInfo::set_persistent_handles(
std::unique_ptr<PersistentHandles>&& persistent_handles) { std::unique_ptr<PersistentHandles>&& persistent_handles) {
......
...@@ -51,7 +51,6 @@ class MaglevCompilationInfo final { ...@@ -51,7 +51,6 @@ class MaglevCompilationInfo final {
MaglevCompilationUnit* toplevel_compilation_unit() const { MaglevCompilationUnit* toplevel_compilation_unit() const {
return toplevel_compilation_unit_; return toplevel_compilation_unit_;
} }
Handle<JSFunction> function() const { return function_; }
bool has_graph_labeller() const { return !!graph_labeller_; } bool has_graph_labeller() const { return !!graph_labeller_; }
void set_graph_labeller(MaglevGraphLabeller* graph_labeller); void set_graph_labeller(MaglevGraphLabeller* graph_labeller);
...@@ -92,9 +91,6 @@ class MaglevCompilationInfo final { ...@@ -92,9 +91,6 @@ class MaglevCompilationInfo final {
// Must be initialized late since it requires an initialized heap broker. // Must be initialized late since it requires an initialized heap broker.
MaglevCompilationUnit* toplevel_compilation_unit_ = nullptr; MaglevCompilationUnit* toplevel_compilation_unit_ = nullptr;
Handle<SharedFunctionInfo> shared_;
Handle<JSFunction> function_;
std::unique_ptr<MaglevGraphLabeller> graph_labeller_; std::unique_ptr<MaglevGraphLabeller> graph_labeller_;
// Produced off-thread during ExecuteJobImpl. // Produced off-thread during ExecuteJobImpl.
......
...@@ -16,9 +16,11 @@ namespace maglev { ...@@ -16,9 +16,11 @@ namespace maglev {
MaglevCompilationUnit::MaglevCompilationUnit(MaglevCompilationInfo* info, MaglevCompilationUnit::MaglevCompilationUnit(MaglevCompilationInfo* info,
Handle<JSFunction> function) Handle<JSFunction> function)
: info_(info), : info_(info),
shared_function_info_(MakeRef(broker(), function->shared())), function_(MakeRef(broker(), function)),
shared_function_info_(function_.shared()),
bytecode_(shared_function_info_.GetBytecodeArray()), bytecode_(shared_function_info_.GetBytecodeArray()),
feedback_(MakeRef(broker(), function->feedback_vector())), feedback_(
function_.feedback_vector(info_->broker()->dependencies()).value()),
bytecode_analysis_(bytecode_.object(), zone(), BytecodeOffset::None(), bytecode_analysis_(bytecode_.object(), zone(), BytecodeOffset::None(),
true), true),
register_count_(bytecode_.register_count()), register_count_(bytecode_.register_count()),
......
...@@ -22,11 +22,11 @@ class Node; ...@@ -22,11 +22,11 @@ class Node;
// function. // function.
class MaglevCompilationUnit : public ZoneObject { class MaglevCompilationUnit : public ZoneObject {
public: public:
static MaglevCompilationUnit* New(Zone* zone, MaglevCompilationInfo* data, static MaglevCompilationUnit* New(Zone* zone, MaglevCompilationInfo* info,
Handle<JSFunction> function) { Handle<JSFunction> function) {
return zone->New<MaglevCompilationUnit>(data, function); return zone->New<MaglevCompilationUnit>(info, function);
} }
MaglevCompilationUnit(MaglevCompilationInfo* data, MaglevCompilationUnit(MaglevCompilationInfo* info,
Handle<JSFunction> function); Handle<JSFunction> function);
MaglevCompilationInfo* info() const { return info_; } MaglevCompilationInfo* info() const { return info_; }
...@@ -41,6 +41,7 @@ class MaglevCompilationUnit : public ZoneObject { ...@@ -41,6 +41,7 @@ class MaglevCompilationUnit : public ZoneObject {
const compiler::SharedFunctionInfoRef& shared_function_info() const { const compiler::SharedFunctionInfoRef& shared_function_info() const {
return shared_function_info_; return shared_function_info_;
} }
const compiler::JSFunctionRef& function() const { return function_; }
const compiler::BytecodeArrayRef& bytecode() const { return bytecode_; } const compiler::BytecodeArrayRef& bytecode() const { return bytecode_; }
const compiler::FeedbackVectorRef& feedback() const { return feedback_; } const compiler::FeedbackVectorRef& feedback() const { return feedback_; }
const compiler::BytecodeAnalysis& bytecode_analysis() const { const compiler::BytecodeAnalysis& bytecode_analysis() const {
...@@ -51,6 +52,7 @@ class MaglevCompilationUnit : public ZoneObject { ...@@ -51,6 +52,7 @@ class MaglevCompilationUnit : public ZoneObject {
private: private:
MaglevCompilationInfo* const info_; MaglevCompilationInfo* const info_;
const compiler::JSFunctionRef function_;
const compiler::SharedFunctionInfoRef shared_function_info_; const compiler::SharedFunctionInfoRef shared_function_info_;
const compiler::BytecodeArrayRef bytecode_; const compiler::BytecodeArrayRef bytecode_;
const compiler::FeedbackVectorRef feedback_; const compiler::FeedbackVectorRef feedback_;
......
...@@ -47,9 +47,9 @@ namespace maglev { ...@@ -47,9 +47,9 @@ namespace maglev {
class NumberingProcessor { class NumberingProcessor {
public: public:
void PreProcessGraph(MaglevCompilationUnit*, Graph* graph) { node_id_ = 1; } void PreProcessGraph(MaglevCompilationInfo*, Graph* graph) { node_id_ = 1; }
void PostProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PostProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block) {} void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block) {}
void Process(NodeBase* node, const ProcessingState& state) { void Process(NodeBase* node, const ProcessingState& state) {
node->set_id(node_id_++); node->set_id(node_id_++);
...@@ -61,9 +61,9 @@ class NumberingProcessor { ...@@ -61,9 +61,9 @@ class NumberingProcessor {
class UseMarkingProcessor { class UseMarkingProcessor {
public: public:
void PreProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PreProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PostProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PostProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block) {} void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block) {}
template <typename NodeT> template <typename NodeT>
void Process(NodeT* node, const ProcessingState& state) { void Process(NodeT* node, const ProcessingState& state) {
...@@ -110,27 +110,29 @@ class UseMarkingProcessor { ...@@ -110,27 +110,29 @@ class UseMarkingProcessor {
private: private:
void MarkCheckpointNodes(NodeBase* node, const EagerDeoptInfo* deopt_info, void MarkCheckpointNodes(NodeBase* node, const EagerDeoptInfo* deopt_info,
const ProcessingState& state) { const ProcessingState& state) {
const MaglevCompilationUnit& compilation_unit =
*state.compilation_info()->toplevel_compilation_unit();
const CompactInterpreterFrameState* register_frame = const CompactInterpreterFrameState* register_frame =
deopt_info->state.register_frame; deopt_info->state.register_frame;
int use_id = node->id(); int use_id = node->id();
int index = 0; int index = 0;
register_frame->ForEachValue( register_frame->ForEachValue(
*state.compilation_unit(), compilation_unit, [&](ValueNode* node, interpreter::Register reg) {
[&](ValueNode* node, interpreter::Register reg) {
node->mark_use(use_id, &deopt_info->input_locations[index++]); node->mark_use(use_id, &deopt_info->input_locations[index++]);
}); });
} }
void MarkCheckpointNodes(NodeBase* node, const LazyDeoptInfo* deopt_info, void MarkCheckpointNodes(NodeBase* node, const LazyDeoptInfo* deopt_info,
const ProcessingState& state) { const ProcessingState& state) {
const MaglevCompilationUnit& compilation_unit =
*state.compilation_info()->toplevel_compilation_unit();
const CompactInterpreterFrameState* register_frame = const CompactInterpreterFrameState* register_frame =
deopt_info->state.register_frame; deopt_info->state.register_frame;
int use_id = node->id(); int use_id = node->id();
int index = 0; int index = 0;
register_frame->ForEachValue( register_frame->ForEachValue(
*state.compilation_unit(), compilation_unit, [&](ValueNode* node, interpreter::Register reg) {
[&](ValueNode* node, interpreter::Register reg) {
// Skip over the result location. // Skip over the result location.
if (reg == deopt_info->result_location) return; if (reg == deopt_info->result_location) return;
node->mark_use(use_id, &deopt_info->input_locations[index++]); node->mark_use(use_id, &deopt_info->input_locations[index++]);
...@@ -140,27 +142,27 @@ class UseMarkingProcessor { ...@@ -140,27 +142,27 @@ class UseMarkingProcessor {
// static // static
void MaglevCompiler::Compile(LocalIsolate* local_isolate, void MaglevCompiler::Compile(LocalIsolate* local_isolate,
MaglevCompilationUnit* toplevel_compilation_unit) { MaglevCompilationInfo* compilation_info) {
compiler::UnparkedScopeIfNeeded unparked_scope( compiler::UnparkedScopeIfNeeded unparked_scope(compilation_info->broker());
toplevel_compilation_unit->broker());
// Build graph. // Build graph.
if (FLAG_print_maglev_code || FLAG_code_comments || FLAG_print_maglev_graph || if (FLAG_print_maglev_code || FLAG_code_comments || FLAG_print_maglev_graph ||
FLAG_trace_maglev_regalloc) { FLAG_trace_maglev_regalloc) {
toplevel_compilation_unit->info()->set_graph_labeller( compilation_info->set_graph_labeller(new MaglevGraphLabeller());
new MaglevGraphLabeller());
} }
// TODO(v8:7700): Support exceptions in maglev. We currently bail if exception // TODO(v8:7700): Support exceptions in maglev. We currently bail if exception
// handler table is non-empty. // handler table is non-empty.
if (toplevel_compilation_unit->bytecode().handler_table_size() > 0) { if (compilation_info->toplevel_compilation_unit()
->bytecode()
.handler_table_size() > 0) {
return; return;
} }
Graph* graph = Graph::New(toplevel_compilation_unit->zone()); Graph* graph = Graph::New(compilation_info->zone());
MaglevGraphBuilder graph_builder(local_isolate, toplevel_compilation_unit, MaglevGraphBuilder graph_builder(
graph); local_isolate, compilation_info->toplevel_compilation_unit(), graph);
graph_builder.Build(); graph_builder.Build();
...@@ -171,12 +173,12 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate, ...@@ -171,12 +173,12 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate,
if (FLAG_print_maglev_graph) { if (FLAG_print_maglev_graph) {
std::cout << "After graph buiding" << std::endl; std::cout << "After graph buiding" << std::endl;
PrintGraph(std::cout, toplevel_compilation_unit, graph_builder.graph()); PrintGraph(std::cout, compilation_info, graph_builder.graph());
} }
#ifdef DEBUG #ifdef DEBUG
{ {
GraphProcessor<MaglevGraphVerifier> verifier(toplevel_compilation_unit); GraphProcessor<MaglevGraphVerifier> verifier(compilation_info);
verifier.ProcessGraph(graph_builder.graph()); verifier.ProcessGraph(graph_builder.graph());
} }
#endif #endif
...@@ -184,49 +186,50 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate, ...@@ -184,49 +186,50 @@ void MaglevCompiler::Compile(LocalIsolate* local_isolate,
{ {
GraphMultiProcessor<NumberingProcessor, UseMarkingProcessor, GraphMultiProcessor<NumberingProcessor, UseMarkingProcessor,
MaglevVregAllocator> MaglevVregAllocator>
processor(toplevel_compilation_unit); processor(compilation_info);
processor.ProcessGraph(graph_builder.graph()); processor.ProcessGraph(graph_builder.graph());
} }
if (FLAG_print_maglev_graph) { if (FLAG_print_maglev_graph) {
std::cout << "After node processor" << std::endl; std::cout << "After node processor" << std::endl;
PrintGraph(std::cout, toplevel_compilation_unit, graph_builder.graph()); PrintGraph(std::cout, compilation_info, graph_builder.graph());
} }
StraightForwardRegisterAllocator allocator(toplevel_compilation_unit, StraightForwardRegisterAllocator allocator(compilation_info,
graph_builder.graph()); graph_builder.graph());
if (FLAG_print_maglev_graph) { if (FLAG_print_maglev_graph) {
std::cout << "After register allocation" << std::endl; std::cout << "After register allocation" << std::endl;
PrintGraph(std::cout, toplevel_compilation_unit, graph_builder.graph()); PrintGraph(std::cout, compilation_info, graph_builder.graph());
} }
// Stash the compiled graph on the compilation info. // Stash the compiled graph on the compilation info.
toplevel_compilation_unit->info()->set_graph(graph_builder.graph()); compilation_info->set_graph(graph_builder.graph());
} }
// static // static
MaybeHandle<CodeT> MaglevCompiler::GenerateCode( MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
MaglevCompilationUnit* toplevel_compilation_unit) { MaglevCompilationInfo* compilation_info) {
Graph* const graph = toplevel_compilation_unit->info()->graph(); Graph* const graph = compilation_info->graph();
if (graph == nullptr) { if (graph == nullptr) {
// Compilation failed. // Compilation failed.
toplevel_compilation_unit->shared_function_info() compilation_info->toplevel_compilation_unit()
->shared_function_info()
.object() .object()
->set_maglev_compilation_failed(true); ->set_maglev_compilation_failed(true);
return {}; return {};
} }
Handle<Code> code; Handle<Code> code;
if (!MaglevCodeGenerator::Generate(toplevel_compilation_unit, graph) if (!MaglevCodeGenerator::Generate(compilation_info, graph).ToHandle(&code)) {
.ToHandle(&code)) { compilation_info->toplevel_compilation_unit()
toplevel_compilation_unit->shared_function_info() ->shared_function_info()
.object() .object()
->set_maglev_compilation_failed(true); ->set_maglev_compilation_failed(true);
return {}; return {};
} }
compiler::JSHeapBroker* const broker = toplevel_compilation_unit->broker(); compiler::JSHeapBroker* const broker = compilation_info->broker();
const bool deps_committed_successfully = broker->dependencies()->Commit(code); const bool deps_committed_successfully = broker->dependencies()->Commit(code);
CHECK(deps_committed_successfully); CHECK(deps_committed_successfully);
...@@ -234,7 +237,7 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode( ...@@ -234,7 +237,7 @@ MaybeHandle<CodeT> MaglevCompiler::GenerateCode(
code->Print(); code->Print();
} }
Isolate* const isolate = toplevel_compilation_unit->isolate(); Isolate* const isolate = compilation_info->isolate();
isolate->native_context()->AddOptimizedCode(ToCodeT(*code)); isolate->native_context()->AddOptimizedCode(ToCodeT(*code));
return ToCodeT(code, isolate); return ToCodeT(code, isolate);
} }
......
...@@ -25,12 +25,12 @@ class MaglevCompiler : public AllStatic { ...@@ -25,12 +25,12 @@ class MaglevCompiler : public AllStatic {
public: public:
// May be called from any thread. // May be called from any thread.
static void Compile(LocalIsolate* local_isolate, static void Compile(LocalIsolate* local_isolate,
MaglevCompilationUnit* toplevel_compilation_unit); MaglevCompilationInfo* compilation_info);
// Called on the main thread after Compile has completed. // Called on the main thread after Compile has completed.
// TODO(v8:7700): Move this to a different class? // TODO(v8:7700): Move this to a different class?
static MaybeHandle<CodeT> GenerateCode( static MaybeHandle<CodeT> GenerateCode(
MaglevCompilationUnit* toplevel_compilation_unit); MaglevCompilationInfo* compilation_info);
}; };
} // namespace maglev } // namespace maglev
......
...@@ -101,24 +101,22 @@ CompilationJob::Status MaglevCompilationJob::PrepareJobImpl(Isolate* isolate) { ...@@ -101,24 +101,22 @@ CompilationJob::Status MaglevCompilationJob::PrepareJobImpl(Isolate* isolate) {
CompilationJob::Status MaglevCompilationJob::ExecuteJobImpl( CompilationJob::Status MaglevCompilationJob::ExecuteJobImpl(
RuntimeCallStats* stats, LocalIsolate* local_isolate) { RuntimeCallStats* stats, LocalIsolate* local_isolate) {
LocalIsolateScope scope{info(), local_isolate}; LocalIsolateScope scope{info(), local_isolate};
maglev::MaglevCompiler::Compile(local_isolate, maglev::MaglevCompiler::Compile(local_isolate, info());
info()->toplevel_compilation_unit());
// TODO(v8:7700): Actual return codes. // TODO(v8:7700): Actual return codes.
return CompilationJob::SUCCEEDED; return CompilationJob::SUCCEEDED;
} }
CompilationJob::Status MaglevCompilationJob::FinalizeJobImpl(Isolate* isolate) { CompilationJob::Status MaglevCompilationJob::FinalizeJobImpl(Isolate* isolate) {
Handle<CodeT> codet; Handle<CodeT> codet;
if (!maglev::MaglevCompiler::GenerateCode(info()->toplevel_compilation_unit()) if (!maglev::MaglevCompiler::GenerateCode(info()).ToHandle(&codet)) {
.ToHandle(&codet)) {
return CompilationJob::FAILED; return CompilationJob::FAILED;
} }
info()->function()->set_code(*codet); info()->toplevel_compilation_unit()->function().object()->set_code(*codet);
return CompilationJob::SUCCEEDED; return CompilationJob::SUCCEEDED;
} }
Handle<JSFunction> MaglevCompilationJob::function() const { Handle<JSFunction> MaglevCompilationJob::function() const {
return info_->function(); return info_->toplevel_compilation_unit()->function().object();
} }
// The JobTask is posted to V8::GetCurrentPlatform(). It's responsible for // The JobTask is posted to V8::GetCurrentPlatform(). It's responsible for
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
#include "src/maglev/maglev-graph-builder.h" #include "src/maglev/maglev-graph-builder.h"
#include "src/common/globals.h"
#include "src/compiler/compilation-dependencies.h" #include "src/compiler/compilation-dependencies.h"
#include "src/compiler/feedback-source.h" #include "src/compiler/feedback-source.h"
#include "src/compiler/heap-refs.h" #include "src/compiler/heap-refs.h"
#include "src/compiler/processed-feedback.h" #include "src/compiler/processed-feedback.h"
#include "src/handles/maybe-handles-inl.h" #include "src/handles/maybe-handles-inl.h"
#include "src/ic/handler-configuration-inl.h" #include "src/ic/handler-configuration-inl.h"
#include "src/maglev/maglev-compilation-unit.h"
#include "src/maglev/maglev-interpreter-frame-state.h"
#include "src/maglev/maglev-ir.h" #include "src/maglev/maglev-ir.h"
#include "src/objects/feedback-vector.h" #include "src/objects/feedback-vector.h"
#include "src/objects/name-inl.h" #include "src/objects/name-inl.h"
......
...@@ -215,9 +215,8 @@ MaglevPrintingVisitor::MaglevPrintingVisitor(std::ostream& os) ...@@ -215,9 +215,8 @@ MaglevPrintingVisitor::MaglevPrintingVisitor(std::ostream& os)
new MaglevPrintingVisitorOstream(os_, &targets_)) {} new MaglevPrintingVisitorOstream(os_, &targets_)) {}
void MaglevPrintingVisitor::PreProcessGraph( void MaglevPrintingVisitor::PreProcessGraph(
MaglevCompilationUnit* compilation_unit, Graph* graph) { MaglevCompilationInfo* compilation_info, Graph* graph) {
os_ << "Graph (param count: " << compilation_unit->parameter_count() os_ << "Graph\n\n";
<< ", frame size: " << compilation_unit->register_count() << ")\n\n";
for (BasicBlock* block : *graph) { for (BasicBlock* block : *graph) {
if (block->control_node()->Is<JumpLoop>()) { if (block->control_node()->Is<JumpLoop>()) {
...@@ -258,8 +257,8 @@ void MaglevPrintingVisitor::PreProcessGraph( ...@@ -258,8 +257,8 @@ void MaglevPrintingVisitor::PreProcessGraph(
} }
void MaglevPrintingVisitor::PreProcessBasicBlock( void MaglevPrintingVisitor::PreProcessBasicBlock(
MaglevCompilationUnit* compilation_unit, BasicBlock* block) { MaglevCompilationInfo* compilation_info, BasicBlock* block) {
MaglevGraphLabeller* graph_labeller = compilation_unit->graph_labeller(); MaglevGraphLabeller* graph_labeller = compilation_info->graph_labeller();
size_t loop_position = static_cast<size_t>(-1); size_t loop_position = static_cast<size_t>(-1);
if (loop_headers_.erase(block) > 0) { if (loop_headers_.erase(block) > 0) {
...@@ -315,9 +314,10 @@ void PrintEagerDeopt(std::ostream& os, std::vector<BasicBlock*> targets, ...@@ -315,9 +314,10 @@ void PrintEagerDeopt(std::ostream& os, std::vector<BasicBlock*> targets,
os << " ↱ eager @" << deopt_info->state.bytecode_position << " : {"; os << " ↱ eager @" << deopt_info->state.bytecode_position << " : {";
bool first = true; bool first = true;
int index = 0; int index = 0;
const MaglevCompilationUnit& compilation_unit =
*state.compilation_info()->toplevel_compilation_unit();
deopt_info->state.register_frame->ForEachValue( deopt_info->state.register_frame->ForEachValue(
*state.compilation_unit(), compilation_unit, [&](ValueNode* node, interpreter::Register reg) {
[&](ValueNode* node, interpreter::Register reg) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
...@@ -355,9 +355,10 @@ void PrintLazyDeopt(std::ostream& os, std::vector<BasicBlock*> targets, ...@@ -355,9 +355,10 @@ void PrintLazyDeopt(std::ostream& os, std::vector<BasicBlock*> targets,
os << " ↳ lazy @" << deopt_info->state.bytecode_position << " : {"; os << " ↳ lazy @" << deopt_info->state.bytecode_position << " : {";
bool first = true; bool first = true;
int index = 0; int index = 0;
const MaglevCompilationUnit& compilation_unit =
*state.compilation_info()->toplevel_compilation_unit();
deopt_info->state.register_frame->ForEachValue( deopt_info->state.register_frame->ForEachValue(
*state.compilation_unit(), compilation_unit, [&](ValueNode* node, interpreter::Register reg) {
[&](ValueNode* node, interpreter::Register reg) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
...@@ -517,9 +518,9 @@ void MaglevPrintingVisitor::Process(ControlNode* control_node, ...@@ -517,9 +518,9 @@ void MaglevPrintingVisitor::Process(ControlNode* control_node,
->set_padding(graph_labeller->max_node_id_width() + 4); ->set_padding(graph_labeller->max_node_id_width() + 4);
} }
void PrintGraph(std::ostream& os, MaglevCompilationUnit* compilation_unit, void PrintGraph(std::ostream& os, MaglevCompilationInfo* compilation_info,
Graph* const graph) { Graph* const graph) {
GraphProcessor<MaglevPrintingVisitor> printer(compilation_unit, os); GraphProcessor<MaglevPrintingVisitor> printer(compilation_info, os);
printer.ProcessGraph(graph); printer.ProcessGraph(graph);
} }
......
...@@ -17,7 +17,7 @@ namespace maglev { ...@@ -17,7 +17,7 @@ namespace maglev {
class BasicBlock; class BasicBlock;
class ControlNode; class ControlNode;
class Graph; class Graph;
class MaglevCompilationUnit; class MaglevCompilationInfo;
class MaglevGraphLabeller; class MaglevGraphLabeller;
class Node; class Node;
class NodeBase; class NodeBase;
...@@ -28,9 +28,9 @@ class MaglevPrintingVisitor { ...@@ -28,9 +28,9 @@ class MaglevPrintingVisitor {
public: public:
explicit MaglevPrintingVisitor(std::ostream& os); explicit MaglevPrintingVisitor(std::ostream& os);
void PreProcessGraph(MaglevCompilationUnit*, Graph* graph); void PreProcessGraph(MaglevCompilationInfo*, Graph* graph);
void PostProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PostProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block); void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block);
void Process(Phi* phi, const ProcessingState& state); void Process(Phi* phi, const ProcessingState& state);
void Process(Node* node, const ProcessingState& state); void Process(Node* node, const ProcessingState& state);
void Process(ControlNode* node, const ProcessingState& state); void Process(ControlNode* node, const ProcessingState& state);
...@@ -44,7 +44,7 @@ class MaglevPrintingVisitor { ...@@ -44,7 +44,7 @@ class MaglevPrintingVisitor {
std::vector<BasicBlock*> targets_; std::vector<BasicBlock*> targets_;
}; };
void PrintGraph(std::ostream& os, MaglevCompilationUnit* compilation_unit, void PrintGraph(std::ostream& os, MaglevCompilationInfo* compilation_info,
Graph* const graph); Graph* const graph);
class PrintNode { class PrintNode {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/compiler/bytecode-analysis.h" #include "src/compiler/bytecode-analysis.h"
#include "src/maglev/maglev-basic-block.h" #include "src/maglev/maglev-basic-block.h"
#include "src/maglev/maglev-compilation-info.h"
#include "src/maglev/maglev-graph.h" #include "src/maglev/maglev-graph.h"
#include "src/maglev/maglev-interpreter-frame-state.h" #include "src/maglev/maglev-interpreter-frame-state.h"
#include "src/maglev/maglev-ir.h" #include "src/maglev/maglev-ir.h"
...@@ -25,13 +26,13 @@ namespace maglev { ...@@ -25,13 +26,13 @@ namespace maglev {
// It expects a NodeProcessor class with: // It expects a NodeProcessor class with:
// //
// // A function that processes the graph before the nodes are walked. // // A function that processes the graph before the nodes are walked.
// void PreProcessGraph(MaglevCompilationUnit*, Graph* graph); // void PreProcessGraph(MaglevCompilationInfo*, Graph* graph);
// //
// // A function that processes the graph after the nodes are walked. // // A function that processes the graph after the nodes are walked.
// void PostProcessGraph(MaglevCompilationUnit*, Graph* graph); // void PostProcessGraph(MaglevCompilationInfo*, Graph* graph);
// //
// // A function that processes each basic block before its nodes are walked. // // A function that processes each basic block before its nodes are walked.
// void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block); // void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block);
// //
// // Process methods for each Node type. The GraphProcessor switches over // // Process methods for each Node type. The GraphProcessor switches over
// // the Node's opcode, casts it to the appropriate FooNode, and dispatches // // the Node's opcode, casts it to the appropriate FooNode, and dispatches
...@@ -45,9 +46,9 @@ class GraphProcessor; ...@@ -45,9 +46,9 @@ class GraphProcessor;
class ProcessingState { class ProcessingState {
public: public:
explicit ProcessingState(MaglevCompilationUnit* compilation_unit, explicit ProcessingState(MaglevCompilationInfo* compilation_info,
BlockConstIterator block_it) BlockConstIterator block_it)
: compilation_unit_(compilation_unit), block_it_(block_it) {} : compilation_info_(compilation_info), block_it_(block_it) {}
// Disallow copies, since the underlying frame states stay mutable. // Disallow copies, since the underlying frame states stay mutable.
ProcessingState(const ProcessingState&) = delete; ProcessingState(const ProcessingState&) = delete;
...@@ -56,17 +57,14 @@ class ProcessingState { ...@@ -56,17 +57,14 @@ class ProcessingState {
BasicBlock* block() const { return *block_it_; } BasicBlock* block() const { return *block_it_; }
BasicBlock* next_block() const { return *(block_it_ + 1); } BasicBlock* next_block() const { return *(block_it_ + 1); }
MaglevCompilationUnit* compilation_unit() const { return compilation_unit_; } MaglevCompilationInfo* compilation_info() const { return compilation_info_; }
int register_count() const { return compilation_unit_->register_count(); }
int parameter_count() const { return compilation_unit_->parameter_count(); }
MaglevGraphLabeller* graph_labeller() const { MaglevGraphLabeller* graph_labeller() const {
return compilation_unit_->graph_labeller(); return compilation_info_->graph_labeller();
} }
private: private:
MaglevCompilationUnit* compilation_unit_; MaglevCompilationInfo* compilation_info_;
BlockConstIterator block_it_; BlockConstIterator block_it_;
}; };
...@@ -74,20 +72,20 @@ template <typename NodeProcessor> ...@@ -74,20 +72,20 @@ template <typename NodeProcessor>
class GraphProcessor { class GraphProcessor {
public: public:
template <typename... Args> template <typename... Args>
explicit GraphProcessor(MaglevCompilationUnit* compilation_unit, explicit GraphProcessor(MaglevCompilationInfo* compilation_info,
Args&&... args) Args&&... args)
: compilation_unit_(compilation_unit), : compilation_info_(compilation_info),
node_processor_(std::forward<Args>(args)...) {} node_processor_(std::forward<Args>(args)...) {}
void ProcessGraph(Graph* graph) { void ProcessGraph(Graph* graph) {
graph_ = graph; graph_ = graph;
node_processor_.PreProcessGraph(compilation_unit_, graph); node_processor_.PreProcessGraph(compilation_info_, graph);
for (block_it_ = graph->begin(); block_it_ != graph->end(); ++block_it_) { for (block_it_ = graph->begin(); block_it_ != graph->end(); ++block_it_) {
BasicBlock* block = *block_it_; BasicBlock* block = *block_it_;
node_processor_.PreProcessBasicBlock(compilation_unit_, block); node_processor_.PreProcessBasicBlock(compilation_info_, block);
if (block->has_phi()) { if (block->has_phi()) {
for (Phi* phi : *block->phis()) { for (Phi* phi : *block->phis()) {
...@@ -104,7 +102,7 @@ class GraphProcessor { ...@@ -104,7 +102,7 @@ class GraphProcessor {
ProcessNodeBase(block->control_node(), GetCurrentState()); ProcessNodeBase(block->control_node(), GetCurrentState());
} }
node_processor_.PostProcessGraph(compilation_unit_, graph); node_processor_.PostProcessGraph(compilation_info_, graph);
} }
NodeProcessor& node_processor() { return node_processor_; } NodeProcessor& node_processor() { return node_processor_; }
...@@ -112,7 +110,7 @@ class GraphProcessor { ...@@ -112,7 +110,7 @@ class GraphProcessor {
private: private:
ProcessingState GetCurrentState() { ProcessingState GetCurrentState() {
return ProcessingState(compilation_unit_, block_it_); return ProcessingState(compilation_info_, block_it_);
} }
void ProcessNodeBase(NodeBase* node, const ProcessingState& state) { void ProcessNodeBase(NodeBase* node, const ProcessingState& state) {
...@@ -129,12 +127,7 @@ class GraphProcessor { ...@@ -129,12 +127,7 @@ class GraphProcessor {
void PreProcess(NodeBase* node, const ProcessingState& state) {} void PreProcess(NodeBase* node, const ProcessingState& state) {}
int register_count() const { return compilation_unit_->register_count(); } MaglevCompilationInfo* const compilation_info_;
const compiler::BytecodeAnalysis& bytecode_analysis() const {
return compilation_unit_->bytecode_analysis();
}
MaglevCompilationUnit* const compilation_unit_;
NodeProcessor node_processor_; NodeProcessor node_processor_;
Graph* graph_; Graph* graph_;
BlockConstIterator block_it_; BlockConstIterator block_it_;
...@@ -149,9 +142,9 @@ class NodeMultiProcessor; ...@@ -149,9 +142,9 @@ class NodeMultiProcessor;
template <> template <>
class NodeMultiProcessor<> { class NodeMultiProcessor<> {
public: public:
void PreProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PreProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PostProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PostProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block) {} void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block) {}
void Process(NodeBase* node, const ProcessingState& state) {} void Process(NodeBase* node, const ProcessingState& state) {}
}; };
...@@ -166,18 +159,18 @@ class NodeMultiProcessor<Processor, Processors...> ...@@ -166,18 +159,18 @@ class NodeMultiProcessor<Processor, Processors...>
processor_.Process(node, state); processor_.Process(node, state);
Base::Process(node, state); Base::Process(node, state);
} }
void PreProcessGraph(MaglevCompilationUnit* unit, Graph* graph) { void PreProcessGraph(MaglevCompilationInfo* info, Graph* graph) {
processor_.PreProcessGraph(unit, graph); processor_.PreProcessGraph(info, graph);
Base::PreProcessGraph(unit, graph); Base::PreProcessGraph(info, graph);
} }
void PostProcessGraph(MaglevCompilationUnit* unit, Graph* graph) { void PostProcessGraph(MaglevCompilationInfo* info, Graph* graph) {
// Post process in reverse order because that kind of makes sense. // Post process in reverse order because that kind of makes sense.
Base::PostProcessGraph(unit, graph); Base::PostProcessGraph(info, graph);
processor_.PostProcessGraph(unit, graph); processor_.PostProcessGraph(info, graph);
} }
void PreProcessBasicBlock(MaglevCompilationUnit* unit, BasicBlock* block) { void PreProcessBasicBlock(MaglevCompilationInfo* info, BasicBlock* block) {
processor_.PreProcessBasicBlock(unit, block); processor_.PreProcessBasicBlock(info, block);
Base::PreProcessBasicBlock(unit, block); Base::PreProcessBasicBlock(info, block);
} }
private: private:
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef V8_MAGLEV_MAGLEV_GRAPH_VERIFIER_H_ #ifndef V8_MAGLEV_MAGLEV_GRAPH_VERIFIER_H_
#define V8_MAGLEV_MAGLEV_GRAPH_VERIFIER_H_ #define V8_MAGLEV_MAGLEV_GRAPH_VERIFIER_H_
#include "src/maglev/maglev-compilation-info.h"
#include "src/maglev/maglev-graph-labeller.h" #include "src/maglev/maglev-graph-labeller.h"
#include "src/maglev/maglev-ir.h" #include "src/maglev/maglev-ir.h"
...@@ -33,14 +34,14 @@ class Graph; ...@@ -33,14 +34,14 @@ class Graph;
// are expected to be tagged/untagged. Add more verification later. // are expected to be tagged/untagged. Add more verification later.
class MaglevGraphVerifier { class MaglevGraphVerifier {
public: public:
void PreProcessGraph(MaglevCompilationUnit* compilation_unit, Graph* graph) { void PreProcessGraph(MaglevCompilationInfo* compilation_info, Graph* graph) {
if (compilation_unit->has_graph_labeller()) { if (compilation_info->has_graph_labeller()) {
graph_labeller_ = compilation_unit->graph_labeller(); graph_labeller_ = compilation_info->graph_labeller();
} }
} }
void PostProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PostProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block) {} void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block) {}
void CheckValueInputIs(NodeBase* node, int i, ValueRepresentation expected) { void CheckValueInputIs(NodeBase* node, int i, ValueRepresentation expected) {
ValueNode* input = node->input(i).node(); ValueNode* input = node->input(i).node();
......
...@@ -113,14 +113,14 @@ template <typename T, typename Enable = void> ...@@ -113,14 +113,14 @@ template <typename T, typename Enable = void>
struct CopyForDeferredHelper { struct CopyForDeferredHelper {
template <typename U> template <typename U>
struct No_Copy_Helper_Implemented_For_Type; struct No_Copy_Helper_Implemented_For_Type;
static void Copy(MaglevCompilationUnit* compilation_unit, static void Copy(MaglevCompilationInfo* compilation_info,
No_Copy_Helper_Implemented_For_Type<T>); No_Copy_Helper_Implemented_For_Type<T>);
}; };
// Helper for copies by value. // Helper for copies by value.
template <typename T, typename Enable = void> template <typename T, typename Enable = void>
struct CopyForDeferredByValue { struct CopyForDeferredByValue {
static T Copy(MaglevCompilationUnit* compilation_unit, T node) { static T Copy(MaglevCompilationInfo* compilation_info, T node) {
return node; return node;
} }
}; };
...@@ -139,10 +139,10 @@ template <typename T> ...@@ -139,10 +139,10 @@ template <typename T>
struct CopyForDeferredHelper< struct CopyForDeferredHelper<
T, typename std::enable_if<std::is_enum<T>::value>::type> T, typename std::enable_if<std::is_enum<T>::value>::type>
: public CopyForDeferredByValue<T> {}; : public CopyForDeferredByValue<T> {};
// MaglevCompilationUnits are copied by value. // MaglevCompilationInfos are copied by value.
template <> template <>
struct CopyForDeferredHelper<MaglevCompilationUnit*> struct CopyForDeferredHelper<MaglevCompilationInfo*>
: public CopyForDeferredByValue<MaglevCompilationUnit*> {}; : public CopyForDeferredByValue<MaglevCompilationInfo*> {};
// Machine registers are copied by value. // Machine registers are copied by value.
template <> template <>
struct CopyForDeferredHelper<Register> struct CopyForDeferredHelper<Register>
...@@ -151,36 +151,25 @@ struct CopyForDeferredHelper<Register> ...@@ -151,36 +151,25 @@ struct CopyForDeferredHelper<Register>
template <> template <>
struct CopyForDeferredHelper<BytecodeOffset> struct CopyForDeferredHelper<BytecodeOffset>
: public CopyForDeferredByValue<BytecodeOffset> {}; : public CopyForDeferredByValue<BytecodeOffset> {};
// InterpreterFrameState is cloned.
template <>
struct CopyForDeferredHelper<const InterpreterFrameState*> {
static const InterpreterFrameState* Copy(
MaglevCompilationUnit* compilation_unit,
const InterpreterFrameState* frame_state) {
return compilation_unit->zone()->New<InterpreterFrameState>(
*compilation_unit, *frame_state);
}
};
// EagerDeoptInfo pointers are copied by value. // EagerDeoptInfo pointers are copied by value.
template <> template <>
struct CopyForDeferredHelper<EagerDeoptInfo*> struct CopyForDeferredHelper<EagerDeoptInfo*>
: public CopyForDeferredByValue<EagerDeoptInfo*> {}; : public CopyForDeferredByValue<EagerDeoptInfo*> {};
template <typename T> template <typename T>
T CopyForDeferred(MaglevCompilationUnit* compilation_unit, T&& value) { T CopyForDeferred(MaglevCompilationInfo* compilation_info, T&& value) {
return CopyForDeferredHelper<T>::Copy(compilation_unit, return CopyForDeferredHelper<T>::Copy(compilation_info,
std::forward<T>(value)); std::forward<T>(value));
} }
template <typename T> template <typename T>
T CopyForDeferred(MaglevCompilationUnit* compilation_unit, T& value) { T CopyForDeferred(MaglevCompilationInfo* compilation_info, T& value) {
return CopyForDeferredHelper<T>::Copy(compilation_unit, value); return CopyForDeferredHelper<T>::Copy(compilation_info, value);
} }
template <typename T> template <typename T>
T CopyForDeferred(MaglevCompilationUnit* compilation_unit, const T& value) { T CopyForDeferred(MaglevCompilationInfo* compilation_info, const T& value) {
return CopyForDeferredHelper<T>::Copy(compilation_unit, value); return CopyForDeferredHelper<T>::Copy(compilation_info, value);
} }
template <typename Function, typename FunctionPointer = Function> template <typename Function, typename FunctionPointer = Function>
...@@ -213,10 +202,10 @@ class DeferredCodeInfoImpl final : public DeferredCodeInfo { ...@@ -213,10 +202,10 @@ class DeferredCodeInfoImpl final : public DeferredCodeInfo {
static constexpr size_t kSize = FunctionArgumentsTupleHelper<Function>::kSize; static constexpr size_t kSize = FunctionArgumentsTupleHelper<Function>::kSize;
template <typename... InArgs> template <typename... InArgs>
explicit DeferredCodeInfoImpl(MaglevCompilationUnit* compilation_unit, explicit DeferredCodeInfoImpl(MaglevCompilationInfo* compilation_info,
FunctionPointer function, InArgs&&... args) FunctionPointer function, InArgs&&... args)
: function(function), : function(function),
args(CopyForDeferred(compilation_unit, std::forward<InArgs>(args))...) { args(CopyForDeferred(compilation_info, std::forward<InArgs>(args))...) {
} }
DeferredCodeInfoImpl(DeferredCodeInfoImpl&&) = delete; DeferredCodeInfoImpl(DeferredCodeInfoImpl&&) = delete;
...@@ -244,8 +233,8 @@ void JumpToDeferredIf(Condition cond, MaglevCodeGenState* code_gen_state, ...@@ -244,8 +233,8 @@ void JumpToDeferredIf(Condition cond, MaglevCodeGenState* code_gen_state,
Function&& deferred_code_gen, Args&&... args) { Function&& deferred_code_gen, Args&&... args) {
using DeferredCodeInfoT = DeferredCodeInfoImpl<Function>; using DeferredCodeInfoT = DeferredCodeInfoImpl<Function>;
DeferredCodeInfoT* deferred_code = DeferredCodeInfoT* deferred_code =
code_gen_state->compilation_unit()->zone()->New<DeferredCodeInfoT>( code_gen_state->compilation_info()->zone()->New<DeferredCodeInfoT>(
code_gen_state->compilation_unit(), deferred_code_gen, code_gen_state->compilation_info(), deferred_code_gen,
std::forward<Args>(args)...); std::forward<Args>(args)...);
code_gen_state->PushDeferredCode(deferred_code); code_gen_state->PushDeferredCode(deferred_code);
...@@ -852,6 +841,12 @@ void Return::GenerateCode(MaglevCodeGenState* code_gen_state, ...@@ -852,6 +841,12 @@ void Return::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) { const ProcessingState& state) {
DCHECK_EQ(ToRegister(value_input()), kReturnRegister0); 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();
// We're not going to continue execution, so we can use an arbitrary register // We're not going to continue execution, so we can use an arbitrary register
// here instead of relying on temporaries from the register allocator. // here instead of relying on temporaries from the register allocator.
Register actual_params_size = r8; Register actual_params_size = r8;
...@@ -869,12 +864,11 @@ void Return::GenerateCode(MaglevCodeGenState* code_gen_state, ...@@ -869,12 +864,11 @@ void Return::GenerateCode(MaglevCodeGenState* code_gen_state,
// If actual is bigger than formal, then we should use it to free up the stack // If actual is bigger than formal, then we should use it to free up the stack
// arguments. // arguments.
Label drop_dynamic_arg_size; Label drop_dynamic_arg_size;
__ cmpq(actual_params_size, Immediate(code_gen_state->parameter_count())); __ cmpq(actual_params_size, Immediate(formal_params_size));
__ j(greater, &drop_dynamic_arg_size); __ j(greater, &drop_dynamic_arg_size);
// Drop receiver + arguments according to static formal arguments size. // Drop receiver + arguments according to static formal arguments size.
__ Ret(code_gen_state->parameter_count() * kSystemPointerSize, __ Ret(formal_params_size * kSystemPointerSize, kScratchRegister);
kScratchRegister);
__ bind(&drop_dynamic_arg_size); __ bind(&drop_dynamic_arg_size);
// Drop receiver + arguments according to dynamic arguments size. // Drop receiver + arguments according to dynamic arguments size.
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "src/codegen/register.h" #include "src/codegen/register.h"
#include "src/codegen/reglist.h" #include "src/codegen/reglist.h"
#include "src/compiler/backend/instruction.h" #include "src/compiler/backend/instruction.h"
#include "src/maglev/maglev-compilation-info.h"
#include "src/maglev/maglev-compilation-unit.h" #include "src/maglev/maglev-compilation-unit.h"
#include "src/maglev/maglev-graph-labeller.h" #include "src/maglev/maglev-graph-labeller.h"
#include "src/maglev/maglev-graph-printer.h" #include "src/maglev/maglev-graph-printer.h"
...@@ -79,8 +80,8 @@ bool IsLiveAtTarget(ValueNode* node, ControlNode* source, BasicBlock* target) { ...@@ -79,8 +80,8 @@ bool IsLiveAtTarget(ValueNode* node, ControlNode* source, BasicBlock* target) {
} // namespace } // namespace
StraightForwardRegisterAllocator::StraightForwardRegisterAllocator( StraightForwardRegisterAllocator::StraightForwardRegisterAllocator(
MaglevCompilationUnit* compilation_unit, Graph* graph) MaglevCompilationInfo* compilation_info, Graph* graph)
: compilation_unit_(compilation_unit) { : compilation_info_(compilation_info) {
ComputePostDominatingHoles(graph); ComputePostDominatingHoles(graph);
AllocateRegisters(graph); AllocateRegisters(graph);
graph->set_tagged_stack_slots(tagged_.top); graph->set_tagged_stack_slots(tagged_.top);
...@@ -213,7 +214,7 @@ void StraightForwardRegisterAllocator::PrintLiveRegs() const { ...@@ -213,7 +214,7 @@ void StraightForwardRegisterAllocator::PrintLiveRegs() const {
void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) { void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) {
if (FLAG_trace_maglev_regalloc) { if (FLAG_trace_maglev_regalloc) {
printing_visitor_.reset(new MaglevPrintingVisitor(std::cout)); printing_visitor_.reset(new MaglevPrintingVisitor(std::cout));
printing_visitor_->PreProcessGraph(compilation_unit_, graph); printing_visitor_->PreProcessGraph(compilation_info_, graph);
} }
for (block_it_ = graph->begin(); block_it_ != graph->end(); ++block_it_) { for (block_it_ = graph->begin(); block_it_ != graph->end(); ++block_it_) {
...@@ -225,7 +226,7 @@ void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) { ...@@ -225,7 +226,7 @@ void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) {
} }
if (FLAG_trace_maglev_regalloc) { if (FLAG_trace_maglev_regalloc) {
printing_visitor_->PreProcessBasicBlock(compilation_unit_, block); printing_visitor_->PreProcessBasicBlock(compilation_info_, block);
printing_visitor_->os() << "live regs: "; printing_visitor_->os() << "live regs: ";
PrintLiveRegs(); PrintLiveRegs();
...@@ -274,7 +275,7 @@ void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) { ...@@ -274,7 +275,7 @@ void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) {
compiler::AllocatedOperand::cast(allocation)); compiler::AllocatedOperand::cast(allocation));
if (FLAG_trace_maglev_regalloc) { if (FLAG_trace_maglev_regalloc) {
printing_visitor_->Process( printing_visitor_->Process(
phi, ProcessingState(compilation_unit_, block_it_)); phi, ProcessingState(compilation_info_, block_it_));
printing_visitor_->os() printing_visitor_->os()
<< "phi (new reg) " << phi->result().operand() << std::endl; << "phi (new reg) " << phi->result().operand() << std::endl;
} }
...@@ -288,7 +289,7 @@ void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) { ...@@ -288,7 +289,7 @@ void StraightForwardRegisterAllocator::AllocateRegisters(Graph* graph) {
phi->result().SetAllocated(phi->spill_slot()); phi->result().SetAllocated(phi->spill_slot());
if (FLAG_trace_maglev_regalloc) { if (FLAG_trace_maglev_regalloc) {
printing_visitor_->Process( printing_visitor_->Process(
phi, ProcessingState(compilation_unit_, block_it_)); phi, ProcessingState(compilation_info_, block_it_));
printing_visitor_->os() printing_visitor_->os()
<< "phi (stack) " << phi->result().operand() << std::endl; << "phi (stack) " << phi->result().operand() << std::endl;
} }
...@@ -340,9 +341,11 @@ void StraightForwardRegisterAllocator::UpdateUse( ...@@ -340,9 +341,11 @@ void StraightForwardRegisterAllocator::UpdateUse(
const EagerDeoptInfo& deopt_info) { const EagerDeoptInfo& deopt_info) {
const CompactInterpreterFrameState* checkpoint_state = const CompactInterpreterFrameState* checkpoint_state =
deopt_info.state.register_frame; deopt_info.state.register_frame;
const MaglevCompilationUnit& compilation_unit =
*compilation_info_->toplevel_compilation_unit();
int index = 0; int index = 0;
checkpoint_state->ForEachValue( checkpoint_state->ForEachValue(
*compilation_unit_, [&](ValueNode* node, interpreter::Register reg) { compilation_unit, [&](ValueNode* node, interpreter::Register reg) {
InputLocation* input = &deopt_info.input_locations[index++]; InputLocation* input = &deopt_info.input_locations[index++];
input->InjectAllocated(node->allocation()); input->InjectAllocated(node->allocation());
UpdateUse(node, input); UpdateUse(node, input);
...@@ -353,9 +356,11 @@ void StraightForwardRegisterAllocator::UpdateUse( ...@@ -353,9 +356,11 @@ void StraightForwardRegisterAllocator::UpdateUse(
const LazyDeoptInfo& deopt_info) { const LazyDeoptInfo& deopt_info) {
const CompactInterpreterFrameState* checkpoint_state = const CompactInterpreterFrameState* checkpoint_state =
deopt_info.state.register_frame; deopt_info.state.register_frame;
const MaglevCompilationUnit& compilation_unit =
*compilation_info_->toplevel_compilation_unit();
int index = 0; int index = 0;
checkpoint_state->ForEachValue( checkpoint_state->ForEachValue(
*compilation_unit_, [&](ValueNode* node, interpreter::Register reg) { compilation_unit, [&](ValueNode* node, interpreter::Register reg) {
// Skip over the result location. // Skip over the result location.
if (reg == deopt_info.result_location) return; if (reg == deopt_info.result_location) return;
InputLocation* input = &deopt_info.input_locations[index++]; InputLocation* input = &deopt_info.input_locations[index++];
...@@ -384,7 +389,7 @@ void StraightForwardRegisterAllocator::AllocateNode(Node* node) { ...@@ -384,7 +389,7 @@ void StraightForwardRegisterAllocator::AllocateNode(Node* node) {
if (FLAG_trace_maglev_regalloc) { if (FLAG_trace_maglev_regalloc) {
printing_visitor_->Process(node, printing_visitor_->Process(node,
ProcessingState(compilation_unit_, block_it_)); ProcessingState(compilation_info_, block_it_));
printing_visitor_->os() << "live regs: "; printing_visitor_->os() << "live regs: ";
PrintLiveRegs(); PrintLiveRegs();
printing_visitor_->os() << "\n"; printing_visitor_->os() << "\n";
...@@ -554,7 +559,7 @@ void StraightForwardRegisterAllocator::AllocateControlNode(ControlNode* node, ...@@ -554,7 +559,7 @@ void StraightForwardRegisterAllocator::AllocateControlNode(ControlNode* node,
if (FLAG_trace_maglev_regalloc) { if (FLAG_trace_maglev_regalloc) {
printing_visitor_->Process(node, printing_visitor_->Process(node,
ProcessingState(compilation_unit_, block_it_)); ProcessingState(compilation_info_, block_it_));
} }
} }
...@@ -567,7 +572,7 @@ void StraightForwardRegisterAllocator::TryAllocateToInput(Phi* phi) { ...@@ -567,7 +572,7 @@ void StraightForwardRegisterAllocator::TryAllocateToInput(Phi* phi) {
phi->result().SetAllocated(ForceAllocate(reg, phi)); phi->result().SetAllocated(ForceAllocate(reg, phi));
if (FLAG_trace_maglev_regalloc) { if (FLAG_trace_maglev_regalloc) {
printing_visitor_->Process( printing_visitor_->Process(
phi, ProcessingState(compilation_unit_, block_it_)); phi, ProcessingState(compilation_info_, block_it_));
printing_visitor_->os() printing_visitor_->os()
<< "phi (reuse) " << input.operand() << std::endl; << "phi (reuse) " << input.operand() << std::endl;
} }
...@@ -580,8 +585,8 @@ void StraightForwardRegisterAllocator::TryAllocateToInput(Phi* phi) { ...@@ -580,8 +585,8 @@ void StraightForwardRegisterAllocator::TryAllocateToInput(Phi* phi) {
void StraightForwardRegisterAllocator::AddMoveBeforeCurrentNode( void StraightForwardRegisterAllocator::AddMoveBeforeCurrentNode(
compiler::AllocatedOperand source, compiler::AllocatedOperand target) { compiler::AllocatedOperand source, compiler::AllocatedOperand target) {
GapMove* gap_move = GapMove* gap_move =
Node::New<GapMove>(compilation_unit_->zone(), {}, source, target); Node::New<GapMove>(compilation_info_->zone(), {}, source, target);
if (compilation_unit_->has_graph_labeller()) { if (compilation_info_->has_graph_labeller()) {
graph_labeller()->RegisterNode(gap_move); graph_labeller()->RegisterNode(gap_move);
} }
if (*node_it_ == nullptr) { if (*node_it_ == nullptr) {
...@@ -894,7 +899,7 @@ void StraightForwardRegisterAllocator::MergeRegisterValues(ControlNode* control, ...@@ -894,7 +899,7 @@ void StraightForwardRegisterAllocator::MergeRegisterValues(ControlNode* control,
const size_t size = sizeof(RegisterMerge) + const size_t size = sizeof(RegisterMerge) +
predecessor_count * sizeof(compiler::AllocatedOperand); predecessor_count * sizeof(compiler::AllocatedOperand);
void* buffer = compilation_unit_->zone()->Allocate<void*>(size); void* buffer = compilation_info_->zone()->Allocate<void*>(size);
merge = new (buffer) RegisterMerge(); merge = new (buffer) RegisterMerge();
merge->node = node == nullptr ? incoming : node; merge->node = node == nullptr ? incoming : node;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/codegen/reglist.h" #include "src/codegen/reglist.h"
#include "src/compiler/backend/instruction.h" #include "src/compiler/backend/instruction.h"
#include "src/maglev/maglev-compilation-info.h"
#include "src/maglev/maglev-graph.h" #include "src/maglev/maglev-graph.h"
#include "src/maglev/maglev-ir.h" #include "src/maglev/maglev-ir.h"
#include "src/maglev/maglev-regalloc-data.h" #include "src/maglev/maglev-regalloc-data.h"
...@@ -15,13 +16,13 @@ namespace v8 { ...@@ -15,13 +16,13 @@ namespace v8 {
namespace internal { namespace internal {
namespace maglev { namespace maglev {
class MaglevCompilationUnit; class MaglevCompilationInfo;
class MaglevPrintingVisitor; class MaglevPrintingVisitor;
class MergePointRegisterState; class MergePointRegisterState;
class StraightForwardRegisterAllocator { class StraightForwardRegisterAllocator {
public: public:
StraightForwardRegisterAllocator(MaglevCompilationUnit* compilation_unit, StraightForwardRegisterAllocator(MaglevCompilationInfo* compilation_info,
Graph* graph); Graph* graph);
~StraightForwardRegisterAllocator(); ~StraightForwardRegisterAllocator();
...@@ -110,10 +111,10 @@ class StraightForwardRegisterAllocator { ...@@ -110,10 +111,10 @@ class StraightForwardRegisterAllocator {
int predecessor_id); int predecessor_id);
MaglevGraphLabeller* graph_labeller() const { MaglevGraphLabeller* graph_labeller() const {
return compilation_unit_->graph_labeller(); return compilation_info_->graph_labeller();
} }
MaglevCompilationUnit* compilation_unit_; MaglevCompilationInfo* compilation_info_;
std::unique_ptr<MaglevPrintingVisitor> printing_visitor_; std::unique_ptr<MaglevPrintingVisitor> printing_visitor_;
BlockConstIterator block_it_; BlockConstIterator block_it_;
NodeIterator node_it_; NodeIterator node_it_;
......
...@@ -26,8 +26,8 @@ class MaglevVregAllocationState { ...@@ -26,8 +26,8 @@ class MaglevVregAllocationState {
class MaglevVregAllocator { class MaglevVregAllocator {
public: public:
void PreProcessGraph(MaglevCompilationUnit*, Graph* graph) {} void PreProcessGraph(MaglevCompilationInfo*, Graph* graph) {}
void PostProcessGraph(MaglevCompilationUnit*, Graph* graph) { void PostProcessGraph(MaglevCompilationInfo*, Graph* graph) {
for (BasicBlock* block : *graph) { for (BasicBlock* block : *graph) {
if (!block->has_phi()) continue; if (!block->has_phi()) continue;
for (Phi* phi : *block->phis()) { for (Phi* phi : *block->phis()) {
...@@ -35,7 +35,7 @@ class MaglevVregAllocator { ...@@ -35,7 +35,7 @@ class MaglevVregAllocator {
} }
} }
} }
void PreProcessBasicBlock(MaglevCompilationUnit*, BasicBlock* block) {} void PreProcessBasicBlock(MaglevCompilationInfo*, BasicBlock* block) {}
#define DEF_PROCESS_NODE(NAME) \ #define DEF_PROCESS_NODE(NAME) \
void Process(NAME* node, const ProcessingState& state) { \ void Process(NAME* node, const ProcessingState& state) { \
......
...@@ -14,10 +14,11 @@ namespace internal { ...@@ -14,10 +14,11 @@ namespace internal {
MaybeHandle<CodeT> Maglev::Compile(Isolate* isolate, MaybeHandle<CodeT> Maglev::Compile(Isolate* isolate,
Handle<JSFunction> function) { Handle<JSFunction> function) {
DCHECK(FLAG_maglev); DCHECK(FLAG_maglev);
auto info = maglev::MaglevCompilationInfo::New(isolate, function); std::unique_ptr<maglev::MaglevCompilationInfo> info =
maglev::MaglevCompilationUnit* const unit = info->toplevel_compilation_unit(); maglev::MaglevCompilationInfo::New(isolate, function);
maglev::MaglevCompiler::Compile(isolate->main_thread_local_isolate(), unit); maglev::MaglevCompiler::Compile(isolate->main_thread_local_isolate(),
return maglev::MaglevCompiler::GenerateCode(unit); info.get());
return maglev::MaglevCompiler::GenerateCode(info.get());
} }
} // namespace internal } // namespace internal
......
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