Reland "[csa] use JSGraph to create constants in CodeAssembler"
This is a reland of 53308bf7c0
Original change's description:
> [csa] use JSGraph to create constants in CodeAssembler
>
> Now that CodeAssembler uses optimizing TurboFan passes, creating
> constants without using the caching implemented in JSGraph leads to
> problems, since value numbering only works properly if all constants
> in the graph were introduced through the cache.
> To mitigate this, this CL creates the JSGraph earlier so that
> CodeAssembler can already use the same JSGraph used by later TurboFan
> optimizations.
> For other uses of RawMachineAssembler, everything stays as before.
>
> This issue is creating bot failures in
> https://chromium-review.googlesource.com/c/v8/v8/+/1958011
>
> Change-Id: Ife017876b19cb2602694279ef1da75f23e18a031
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1967329
> Reviewed-by: Maya Lekova <mslekova@chromium.org>
> Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#65477}
TBR=mslekova@chromium.org
Change-Id: I5c8218ce22470b3efa06d872176c910a4c5325a4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1977858
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65537}
This commit is contained in:
parent
a3039123f2
commit
d2528de478
@ -13,6 +13,7 @@
|
|||||||
#include "src/codegen/macro-assembler.h"
|
#include "src/codegen/macro-assembler.h"
|
||||||
#include "src/compiler/backend/instruction-selector.h"
|
#include "src/compiler/backend/instruction-selector.h"
|
||||||
#include "src/compiler/graph.h"
|
#include "src/compiler/graph.h"
|
||||||
|
#include "src/compiler/js-graph.h"
|
||||||
#include "src/compiler/linkage.h"
|
#include "src/compiler/linkage.h"
|
||||||
#include "src/compiler/node-matchers.h"
|
#include "src/compiler/node-matchers.h"
|
||||||
#include "src/compiler/pipeline.h"
|
#include "src/compiler/pipeline.h"
|
||||||
@ -84,7 +85,11 @@ CodeAssemblerState::CodeAssemblerState(Isolate* isolate, Zone* zone,
|
|||||||
name_(name),
|
name_(name),
|
||||||
builtin_index_(builtin_index),
|
builtin_index_(builtin_index),
|
||||||
code_generated_(false),
|
code_generated_(false),
|
||||||
variables_(zone) {}
|
variables_(zone),
|
||||||
|
jsgraph_(new (zone) JSGraph(
|
||||||
|
isolate, raw_assembler_->graph(), raw_assembler_->common(),
|
||||||
|
new (zone) JSOperatorBuilder(zone), raw_assembler_->simplified(),
|
||||||
|
raw_assembler_->machine())) {}
|
||||||
|
|
||||||
CodeAssemblerState::~CodeAssemblerState() = default;
|
CodeAssemblerState::~CodeAssemblerState() = default;
|
||||||
|
|
||||||
@ -180,7 +185,7 @@ Handle<Code> CodeAssembler::GenerateCode(CodeAssemblerState* state,
|
|||||||
Graph* graph = rasm->ExportForOptimization();
|
Graph* graph = rasm->ExportForOptimization();
|
||||||
|
|
||||||
code = Pipeline::GenerateCodeForCodeStub(
|
code = Pipeline::GenerateCodeForCodeStub(
|
||||||
rasm->isolate(), rasm->call_descriptor(), graph,
|
rasm->isolate(), rasm->call_descriptor(), graph, state->jsgraph_,
|
||||||
rasm->source_positions(), state->kind_, state->name_,
|
rasm->source_positions(), state->kind_, state->name_,
|
||||||
state->builtin_index_, rasm->poisoning_level(), options)
|
state->builtin_index_, rasm->poisoning_level(), options)
|
||||||
.ToHandleChecked();
|
.ToHandleChecked();
|
||||||
@ -241,15 +246,15 @@ void CodeAssembler::GenerateCheckMaybeObjectIsObject(Node* node,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TNode<Int32T> CodeAssembler::Int32Constant(int32_t value) {
|
TNode<Int32T> CodeAssembler::Int32Constant(int32_t value) {
|
||||||
return UncheckedCast<Int32T>(raw_assembler()->Int32Constant(value));
|
return UncheckedCast<Int32T>(jsgraph()->Int32Constant(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
TNode<Int64T> CodeAssembler::Int64Constant(int64_t value) {
|
TNode<Int64T> CodeAssembler::Int64Constant(int64_t value) {
|
||||||
return UncheckedCast<Int64T>(raw_assembler()->Int64Constant(value));
|
return UncheckedCast<Int64T>(jsgraph()->Int64Constant(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
TNode<IntPtrT> CodeAssembler::IntPtrConstant(intptr_t value) {
|
TNode<IntPtrT> CodeAssembler::IntPtrConstant(intptr_t value) {
|
||||||
return UncheckedCast<IntPtrT>(raw_assembler()->IntPtrConstant(value));
|
return UncheckedCast<IntPtrT>(jsgraph()->IntPtrConstant(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
TNode<Number> CodeAssembler::NumberConstant(double value) {
|
TNode<Number> CodeAssembler::NumberConstant(double value) {
|
||||||
@ -277,7 +282,7 @@ TNode<Smi> CodeAssembler::SmiConstant(int value) {
|
|||||||
|
|
||||||
TNode<HeapObject> CodeAssembler::UntypedHeapConstant(
|
TNode<HeapObject> CodeAssembler::UntypedHeapConstant(
|
||||||
Handle<HeapObject> object) {
|
Handle<HeapObject> object) {
|
||||||
return UncheckedCast<HeapObject>(raw_assembler()->HeapConstant(object));
|
return UncheckedCast<HeapObject>(jsgraph()->HeapConstant(object));
|
||||||
}
|
}
|
||||||
|
|
||||||
TNode<String> CodeAssembler::StringConstant(const char* str) {
|
TNode<String> CodeAssembler::StringConstant(const char* str) {
|
||||||
@ -289,7 +294,7 @@ TNode<String> CodeAssembler::StringConstant(const char* str) {
|
|||||||
TNode<Oddball> CodeAssembler::BooleanConstant(bool value) {
|
TNode<Oddball> CodeAssembler::BooleanConstant(bool value) {
|
||||||
Handle<Object> object = isolate()->factory()->ToBoolean(value);
|
Handle<Object> object = isolate()->factory()->ToBoolean(value);
|
||||||
return UncheckedCast<Oddball>(
|
return UncheckedCast<Oddball>(
|
||||||
raw_assembler()->HeapConstant(Handle<HeapObject>::cast(object)));
|
jsgraph()->HeapConstant(Handle<HeapObject>::cast(object)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TNode<ExternalReference> CodeAssembler::ExternalConstant(
|
TNode<ExternalReference> CodeAssembler::ExternalConstant(
|
||||||
@ -299,7 +304,7 @@ TNode<ExternalReference> CodeAssembler::ExternalConstant(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TNode<Float64T> CodeAssembler::Float64Constant(double value) {
|
TNode<Float64T> CodeAssembler::Float64Constant(double value) {
|
||||||
return UncheckedCast<Float64T>(raw_assembler()->Float64Constant(value));
|
return UncheckedCast<Float64T>(jsgraph()->Float64Constant(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CodeAssembler::ToInt32Constant(Node* node, int32_t* out_value) {
|
bool CodeAssembler::ToInt32Constant(Node* node, int32_t* out_value) {
|
||||||
@ -1608,6 +1613,8 @@ RawMachineAssembler* CodeAssembler::raw_assembler() const {
|
|||||||
return state_->raw_assembler_.get();
|
return state_->raw_assembler_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSGraph* CodeAssembler::jsgraph() const { return state_->jsgraph_; }
|
||||||
|
|
||||||
// The core implementation of Variable is stored through an indirection so
|
// The core implementation of Variable is stored through an indirection so
|
||||||
// that it can outlive the often block-scoped Variable declarations. This is
|
// that it can outlive the often block-scoped Variable declarations. This is
|
||||||
// needed to ensure that variable binding and merging through phis can
|
// needed to ensure that variable binding and merging through phis can
|
||||||
|
@ -187,6 +187,7 @@ class CodeAssemblerVariable;
|
|||||||
template <class T>
|
template <class T>
|
||||||
class TypedCodeAssemblerVariable;
|
class TypedCodeAssemblerVariable;
|
||||||
class CodeAssemblerState;
|
class CodeAssemblerState;
|
||||||
|
class JSGraph;
|
||||||
class Node;
|
class Node;
|
||||||
class RawMachineAssembler;
|
class RawMachineAssembler;
|
||||||
class RawMachineLabel;
|
class RawMachineLabel;
|
||||||
@ -1183,6 +1184,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
|
|||||||
TNode<Uint32T> Unsigned(TNode<Uint32T> x);
|
TNode<Uint32T> Unsigned(TNode<Uint32T> x);
|
||||||
|
|
||||||
RawMachineAssembler* raw_assembler() const;
|
RawMachineAssembler* raw_assembler() const;
|
||||||
|
JSGraph* jsgraph() const;
|
||||||
|
|
||||||
// Calls respective callback registered in the state.
|
// Calls respective callback registered in the state.
|
||||||
void CallPrologue();
|
void CallPrologue();
|
||||||
@ -1437,6 +1439,7 @@ class V8_EXPORT_PRIVATE CodeAssemblerState {
|
|||||||
std::vector<CodeAssemblerExceptionHandlerLabel*> exception_handler_labels_;
|
std::vector<CodeAssemblerExceptionHandlerLabel*> exception_handler_labels_;
|
||||||
using VariableId = uint32_t;
|
using VariableId = uint32_t;
|
||||||
VariableId next_variable_id_ = 0;
|
VariableId next_variable_id_ = 0;
|
||||||
|
JSGraph* jsgraph_;
|
||||||
|
|
||||||
VariableId NextVariableId() { return next_variable_id_++; }
|
VariableId NextVariableId() { return next_variable_id_++; }
|
||||||
|
|
||||||
|
@ -209,7 +209,8 @@ class PipelineData {
|
|||||||
// For CodeStubAssembler and machine graph testing entry point.
|
// For CodeStubAssembler and machine graph testing entry point.
|
||||||
PipelineData(ZoneStats* zone_stats, OptimizedCompilationInfo* info,
|
PipelineData(ZoneStats* zone_stats, OptimizedCompilationInfo* info,
|
||||||
Isolate* isolate, AccountingAllocator* allocator, Graph* graph,
|
Isolate* isolate, AccountingAllocator* allocator, Graph* graph,
|
||||||
Schedule* schedule, SourcePositionTable* source_positions,
|
JSGraph* jsgraph, Schedule* schedule,
|
||||||
|
SourcePositionTable* source_positions,
|
||||||
NodeOriginTable* node_origins, JumpOptimizationInfo* jump_opt,
|
NodeOriginTable* node_origins, JumpOptimizationInfo* jump_opt,
|
||||||
const AssemblerOptions& assembler_options)
|
const AssemblerOptions& assembler_options)
|
||||||
: isolate_(isolate),
|
: isolate_(isolate),
|
||||||
@ -232,15 +233,23 @@ class PipelineData {
|
|||||||
register_allocation_zone_(register_allocation_zone_scope_.zone()),
|
register_allocation_zone_(register_allocation_zone_scope_.zone()),
|
||||||
jump_optimization_info_(jump_opt),
|
jump_optimization_info_(jump_opt),
|
||||||
assembler_options_(assembler_options) {
|
assembler_options_(assembler_options) {
|
||||||
simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_);
|
if (jsgraph) {
|
||||||
machine_ = new (graph_zone_) MachineOperatorBuilder(
|
jsgraph_ = jsgraph;
|
||||||
graph_zone_, MachineType::PointerRepresentation(),
|
simplified_ = jsgraph->simplified();
|
||||||
InstructionSelector::SupportedMachineOperatorFlags(),
|
machine_ = jsgraph->machine();
|
||||||
InstructionSelector::AlignmentRequirements());
|
common_ = jsgraph->common();
|
||||||
common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_);
|
javascript_ = jsgraph->javascript();
|
||||||
javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_);
|
} else {
|
||||||
jsgraph_ = new (graph_zone_)
|
simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_);
|
||||||
JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_);
|
machine_ = new (graph_zone_) MachineOperatorBuilder(
|
||||||
|
graph_zone_, MachineType::PointerRepresentation(),
|
||||||
|
InstructionSelector::SupportedMachineOperatorFlags(),
|
||||||
|
InstructionSelector::AlignmentRequirements());
|
||||||
|
common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_);
|
||||||
|
javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_);
|
||||||
|
jsgraph_ = new (graph_zone_) JSGraph(isolate_, graph_, common_,
|
||||||
|
javascript_, simplified_, machine_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For register allocation testing entry point.
|
// For register allocation testing entry point.
|
||||||
@ -1186,7 +1195,7 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob {
|
|||||||
zone_(std::move(zone)),
|
zone_(std::move(zone)),
|
||||||
graph_(graph),
|
graph_(graph),
|
||||||
data_(&zone_stats_, &info_, isolate, wasm_engine->allocator(), graph_,
|
data_(&zone_stats_, &info_, isolate, wasm_engine->allocator(), graph_,
|
||||||
nullptr, source_positions,
|
nullptr, nullptr, source_positions,
|
||||||
new (zone_.get()) NodeOriginTable(graph_), nullptr, options),
|
new (zone_.get()) NodeOriginTable(graph_), nullptr, options),
|
||||||
pipeline_(&data_),
|
pipeline_(&data_),
|
||||||
wasm_engine_(wasm_engine) {}
|
wasm_engine_(wasm_engine) {}
|
||||||
@ -2566,7 +2575,7 @@ bool PipelineImpl::OptimizeGraphForMidTier(Linkage* linkage) {
|
|||||||
|
|
||||||
MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
|
MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
|
||||||
Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
|
Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
|
||||||
SourcePositionTable* source_positions, Code::Kind kind,
|
JSGraph* jsgraph, SourcePositionTable* source_positions, Code::Kind kind,
|
||||||
const char* debug_name, int32_t builtin_index,
|
const char* debug_name, int32_t builtin_index,
|
||||||
PoisoningMitigationLevel poisoning_level, const AssemblerOptions& options) {
|
PoisoningMitigationLevel poisoning_level, const AssemblerOptions& options) {
|
||||||
OptimizedCompilationInfo info(CStrVector(debug_name), graph->zone(), kind);
|
OptimizedCompilationInfo info(CStrVector(debug_name), graph->zone(), kind);
|
||||||
@ -2583,7 +2592,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
|
|||||||
bool should_optimize_jumps =
|
bool should_optimize_jumps =
|
||||||
isolate->serializer_enabled() && FLAG_turbo_rewrite_far_jumps;
|
isolate->serializer_enabled() && FLAG_turbo_rewrite_far_jumps;
|
||||||
PipelineData data(&zone_stats, &info, isolate, isolate->allocator(), graph,
|
PipelineData data(&zone_stats, &info, isolate, isolate->allocator(), graph,
|
||||||
nullptr, source_positions, &node_origins,
|
jsgraph, nullptr, source_positions, &node_origins,
|
||||||
should_optimize_jumps ? &jump_opt : nullptr, options);
|
should_optimize_jumps ? &jump_opt : nullptr, options);
|
||||||
data.set_verify_graph(FLAG_verify_csa);
|
data.set_verify_graph(FLAG_verify_csa);
|
||||||
std::unique_ptr<PipelineStatistics> pipeline_statistics;
|
std::unique_ptr<PipelineStatistics> pipeline_statistics;
|
||||||
@ -2633,7 +2642,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
|
|||||||
// repeat it for jump optimization. The first run has to happen on a temporary
|
// repeat it for jump optimization. The first run has to happen on a temporary
|
||||||
// pipeline to avoid deletion of zones on the main pipeline.
|
// pipeline to avoid deletion of zones on the main pipeline.
|
||||||
PipelineData second_data(&zone_stats, &info, isolate, isolate->allocator(),
|
PipelineData second_data(&zone_stats, &info, isolate, isolate->allocator(),
|
||||||
data.graph(), data.schedule(),
|
data.graph(), data.jsgraph(), data.schedule(),
|
||||||
data.source_positions(), data.node_origins(),
|
data.source_positions(), data.node_origins(),
|
||||||
data.jump_optimization_info(), options);
|
data.jump_optimization_info(), options);
|
||||||
second_data.set_verify_graph(FLAG_verify_csa);
|
second_data.set_verify_graph(FLAG_verify_csa);
|
||||||
@ -2802,7 +2811,8 @@ MaybeHandle<Code> Pipeline::GenerateCodeForTesting(
|
|||||||
ZoneStats zone_stats(isolate->allocator());
|
ZoneStats zone_stats(isolate->allocator());
|
||||||
NodeOriginTable* node_positions = new (info->zone()) NodeOriginTable(graph);
|
NodeOriginTable* node_positions = new (info->zone()) NodeOriginTable(graph);
|
||||||
PipelineData data(&zone_stats, info, isolate, isolate->allocator(), graph,
|
PipelineData data(&zone_stats, info, isolate, isolate->allocator(), graph,
|
||||||
schedule, nullptr, node_positions, nullptr, options);
|
nullptr, schedule, nullptr, node_positions, nullptr,
|
||||||
|
options);
|
||||||
std::unique_ptr<PipelineStatistics> pipeline_statistics;
|
std::unique_ptr<PipelineStatistics> pipeline_statistics;
|
||||||
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
|
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
|
||||||
pipeline_statistics.reset(new PipelineStatistics(
|
pipeline_statistics.reset(new PipelineStatistics(
|
||||||
|
@ -34,6 +34,7 @@ namespace compiler {
|
|||||||
class CallDescriptor;
|
class CallDescriptor;
|
||||||
class Graph;
|
class Graph;
|
||||||
class InstructionSequence;
|
class InstructionSequence;
|
||||||
|
class JSGraph;
|
||||||
class JSHeapBroker;
|
class JSHeapBroker;
|
||||||
class MachineGraph;
|
class MachineGraph;
|
||||||
class NodeOriginTable;
|
class NodeOriginTable;
|
||||||
@ -72,7 +73,7 @@ class Pipeline : public AllStatic {
|
|||||||
// Run the pipeline on a machine graph and generate code.
|
// Run the pipeline on a machine graph and generate code.
|
||||||
static MaybeHandle<Code> GenerateCodeForCodeStub(
|
static MaybeHandle<Code> GenerateCodeForCodeStub(
|
||||||
Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
|
Isolate* isolate, CallDescriptor* call_descriptor, Graph* graph,
|
||||||
SourcePositionTable* source_positions, Code::Kind kind,
|
JSGraph* jsgraph, SourcePositionTable* source_positions, Code::Kind kind,
|
||||||
const char* debug_name, int32_t builtin_index,
|
const char* debug_name, int32_t builtin_index,
|
||||||
PoisoningMitigationLevel poisoning_level,
|
PoisoningMitigationLevel poisoning_level,
|
||||||
const AssemblerOptions& options);
|
const AssemblerOptions& options);
|
||||||
|
Loading…
Reference in New Issue
Block a user