Commit 31dde88e authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

Revert "[csa] use JSGraph to create constants in CodeAssembler"

This reverts commit 53308bf7.

Reason for revert: Fails on multiple arm bots, e.g. https://ci.chromium.org/p/v8/builders/ci/V8%20Arm%20-%20debug/12441

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=tebbi@chromium.org,mslekova@chromium.org

Change-Id: I6df6782adfb40632f51681942efab9b591f72cab
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1969901Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65483}
parent d69bfcf7
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#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"
...@@ -85,11 +84,7 @@ CodeAssemblerState::CodeAssemblerState(Isolate* isolate, Zone* zone, ...@@ -85,11 +84,7 @@ 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;
...@@ -185,7 +180,7 @@ Handle<Code> CodeAssembler::GenerateCode(CodeAssemblerState* state, ...@@ -185,7 +180,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, state->jsgraph_, rasm->isolate(), rasm->call_descriptor(), graph,
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();
...@@ -246,15 +241,15 @@ void CodeAssembler::GenerateCheckMaybeObjectIsObject(Node* node, ...@@ -246,15 +241,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>(jsgraph()->Int32Constant(value)); return UncheckedCast<Int32T>(raw_assembler()->Int32Constant(value));
} }
TNode<Int64T> CodeAssembler::Int64Constant(int64_t value) { TNode<Int64T> CodeAssembler::Int64Constant(int64_t value) {
return UncheckedCast<Int64T>(jsgraph()->Int64Constant(value)); return UncheckedCast<Int64T>(raw_assembler()->Int64Constant(value));
} }
TNode<IntPtrT> CodeAssembler::IntPtrConstant(intptr_t value) { TNode<IntPtrT> CodeAssembler::IntPtrConstant(intptr_t value) {
return UncheckedCast<IntPtrT>(jsgraph()->IntPtrConstant(value)); return UncheckedCast<IntPtrT>(raw_assembler()->IntPtrConstant(value));
} }
TNode<Number> CodeAssembler::NumberConstant(double value) { TNode<Number> CodeAssembler::NumberConstant(double value) {
...@@ -282,7 +277,7 @@ TNode<Smi> CodeAssembler::SmiConstant(int value) { ...@@ -282,7 +277,7 @@ TNode<Smi> CodeAssembler::SmiConstant(int value) {
TNode<HeapObject> CodeAssembler::UntypedHeapConstant( TNode<HeapObject> CodeAssembler::UntypedHeapConstant(
Handle<HeapObject> object) { Handle<HeapObject> object) {
return UncheckedCast<HeapObject>(jsgraph()->HeapConstant(object)); return UncheckedCast<HeapObject>(raw_assembler()->HeapConstant(object));
} }
TNode<String> CodeAssembler::StringConstant(const char* str) { TNode<String> CodeAssembler::StringConstant(const char* str) {
...@@ -294,7 +289,7 @@ TNode<String> CodeAssembler::StringConstant(const char* str) { ...@@ -294,7 +289,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>(
jsgraph()->HeapConstant(Handle<HeapObject>::cast(object))); raw_assembler()->HeapConstant(Handle<HeapObject>::cast(object)));
} }
TNode<ExternalReference> CodeAssembler::ExternalConstant( TNode<ExternalReference> CodeAssembler::ExternalConstant(
...@@ -304,7 +299,7 @@ TNode<ExternalReference> CodeAssembler::ExternalConstant( ...@@ -304,7 +299,7 @@ TNode<ExternalReference> CodeAssembler::ExternalConstant(
} }
TNode<Float64T> CodeAssembler::Float64Constant(double value) { TNode<Float64T> CodeAssembler::Float64Constant(double value) {
return UncheckedCast<Float64T>(jsgraph()->Float64Constant(value)); return UncheckedCast<Float64T>(raw_assembler()->Float64Constant(value));
} }
bool CodeAssembler::ToInt32Constant(Node* node, int32_t* out_value) { bool CodeAssembler::ToInt32Constant(Node* node, int32_t* out_value) {
...@@ -1613,8 +1608,6 @@ RawMachineAssembler* CodeAssembler::raw_assembler() const { ...@@ -1613,8 +1608,6 @@ 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,7 +187,6 @@ class CodeAssemblerVariable; ...@@ -187,7 +187,6 @@ 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;
...@@ -1184,7 +1183,6 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -1184,7 +1183,6 @@ 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();
...@@ -1439,7 +1437,6 @@ class V8_EXPORT_PRIVATE CodeAssemblerState { ...@@ -1439,7 +1437,6 @@ 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,8 +209,7 @@ class PipelineData { ...@@ -209,8 +209,7 @@ 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,
JSGraph* jsgraph, Schedule* schedule, Schedule* schedule, SourcePositionTable* source_positions,
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),
...@@ -233,23 +232,15 @@ class PipelineData { ...@@ -233,23 +232,15 @@ 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) {
if (jsgraph) { simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_);
jsgraph_ = jsgraph; machine_ = new (graph_zone_) MachineOperatorBuilder(
simplified_ = jsgraph->simplified(); graph_zone_, MachineType::PointerRepresentation(),
machine_ = jsgraph->machine(); InstructionSelector::SupportedMachineOperatorFlags(),
common_ = jsgraph->common(); InstructionSelector::AlignmentRequirements());
javascript_ = jsgraph->javascript(); common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_);
} else { javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_);
simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); jsgraph_ = new (graph_zone_)
machine_ = new (graph_zone_) MachineOperatorBuilder( JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_);
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.
...@@ -1195,7 +1186,7 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob { ...@@ -1195,7 +1186,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, nullptr, source_positions, 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) {}
...@@ -2575,7 +2566,7 @@ bool PipelineImpl::OptimizeGraphForMidTier(Linkage* linkage) { ...@@ -2575,7 +2566,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,
JSGraph* jsgraph, SourcePositionTable* source_positions, Code::Kind kind, 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);
...@@ -2592,7 +2583,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub( ...@@ -2592,7 +2583,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,
jsgraph, nullptr, source_positions, &node_origins, 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;
...@@ -2642,7 +2633,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub( ...@@ -2642,7 +2633,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.jsgraph(), data.schedule(), data.graph(), 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);
...@@ -2811,8 +2802,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForTesting( ...@@ -2811,8 +2802,7 @@ 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,
nullptr, schedule, nullptr, node_positions, nullptr, schedule, nullptr, node_positions, nullptr, options);
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,7 +34,6 @@ namespace compiler { ...@@ -34,7 +34,6 @@ 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;
...@@ -73,7 +72,7 @@ class Pipeline : public AllStatic { ...@@ -73,7 +72,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,
JSGraph* jsgraph, SourcePositionTable* source_positions, Code::Kind kind, 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);
......
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