Commit 149c7773 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[compiler] Fix --trace-turbo-reduction in the presence of direct reads

... by unparking the local heap before accessing the handles.

Bug: v8:7790
Change-Id: I0910fd8ad2a1e9cbbf312acb4f26358a09891f0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2404455Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Auto-Submit: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69852}
parent e6f65401
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "src/compiler/graph-reducer.h"
#include <functional> #include <functional>
#include <limits> #include <limits>
#include "src/codegen/tick-counter.h" #include "src/codegen/tick-counter.h"
#include "src/compiler/graph-reducer.h"
#include "src/compiler/graph.h" #include "src/compiler/graph.h"
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/node-properties.h" #include "src/compiler/node-properties.h"
#include "src/compiler/node.h" #include "src/compiler/node.h"
#include "src/compiler/verifier.h" #include "src/compiler/verifier.h"
...@@ -27,14 +29,15 @@ enum class GraphReducer::State : uint8_t { ...@@ -27,14 +29,15 @@ enum class GraphReducer::State : uint8_t {
void Reducer::Finalize() {} void Reducer::Finalize() {}
GraphReducer::GraphReducer(Zone* zone, Graph* graph, TickCounter* tick_counter, GraphReducer::GraphReducer(Zone* zone, Graph* graph, TickCounter* tick_counter,
Node* dead) JSHeapBroker* broker, Node* dead)
: graph_(graph), : graph_(graph),
dead_(dead), dead_(dead),
state_(graph, 4), state_(graph, 4),
reducers_(zone), reducers_(zone),
revisit_(zone), revisit_(zone),
stack_(zone), stack_(zone),
tick_counter_(tick_counter) { tick_counter_(tick_counter),
broker_(broker) {
if (dead != nullptr) { if (dead != nullptr) {
NodeProperties::SetType(dead_, Type::None()); NodeProperties::SetType(dead_, Type::None());
} }
...@@ -94,6 +97,9 @@ Reduction GraphReducer::Reduce(Node* const node) { ...@@ -94,6 +97,9 @@ Reduction GraphReducer::Reduce(Node* const node) {
// all the other reducers for this node, as now there may be more // all the other reducers for this node, as now there may be more
// opportunities for reduction. // opportunities for reduction.
if (FLAG_trace_turbo_reduction) { if (FLAG_trace_turbo_reduction) {
UnparkedScopeIfNeeded unparked(broker_);
// TODO(neis): Disallow racy handle dereference once we stop
// supporting --no-local-heaps --no-turbo-direct-heap-access.
AllowHandleDereference allow_deref; AllowHandleDereference allow_deref;
StdoutStream{} << "- In-place update of #" << *node << " by reducer " StdoutStream{} << "- In-place update of #" << *node << " by reducer "
<< (*i)->reducer_name() << std::endl; << (*i)->reducer_name() << std::endl;
...@@ -104,6 +110,9 @@ Reduction GraphReducer::Reduce(Node* const node) { ...@@ -104,6 +110,9 @@ Reduction GraphReducer::Reduce(Node* const node) {
} else { } else {
// {node} was replaced by another node. // {node} was replaced by another node.
if (FLAG_trace_turbo_reduction) { if (FLAG_trace_turbo_reduction) {
UnparkedScopeIfNeeded unparked(broker_);
// TODO(neis): Disallow racy handle dereference once we stop
// supporting --no-local-heaps --no-turbo-direct-heap-access.
AllowHandleDereference allow_deref; AllowHandleDereference allow_deref;
StdoutStream{} << "- Replacement of #" << *node << " with #" StdoutStream{} << "- Replacement of #" << *node << " with #"
<< *(reduction.replacement()) << " by reducer " << *(reduction.replacement()) << " by reducer "
......
...@@ -17,8 +17,8 @@ class TickCounter; ...@@ -17,8 +17,8 @@ class TickCounter;
namespace compiler { namespace compiler {
// Forward declarations.
class Graph; class Graph;
class JSHeapBroker;
class Node; class Node;
// NodeIds are identifying numbers for nodes that can be used to index auxiliary // NodeIds are identifying numbers for nodes that can be used to index auxiliary
...@@ -136,7 +136,7 @@ class V8_EXPORT_PRIVATE GraphReducer ...@@ -136,7 +136,7 @@ class V8_EXPORT_PRIVATE GraphReducer
: public NON_EXPORTED_BASE(AdvancedReducer::Editor) { : public NON_EXPORTED_BASE(AdvancedReducer::Editor) {
public: public:
GraphReducer(Zone* zone, Graph* graph, TickCounter* tick_counter, GraphReducer(Zone* zone, Graph* graph, TickCounter* tick_counter,
Node* dead = nullptr); JSHeapBroker* broker, Node* dead = nullptr);
~GraphReducer() override; ~GraphReducer() override;
Graph* graph() const { return graph_; } Graph* graph() const { return graph_; }
...@@ -189,6 +189,7 @@ class V8_EXPORT_PRIVATE GraphReducer ...@@ -189,6 +189,7 @@ class V8_EXPORT_PRIVATE GraphReducer
ZoneQueue<Node*> revisit_; ZoneQueue<Node*> revisit_;
ZoneStack<NodeState> stack_; ZoneStack<NodeState> stack_;
TickCounter* const tick_counter_; TickCounter* const tick_counter_;
JSHeapBroker* const broker_;
DISALLOW_COPY_AND_ASSIGN(GraphReducer); DISALLOW_COPY_AND_ASSIGN(GraphReducer);
}; };
......
...@@ -442,6 +442,27 @@ class OffHeapBytecodeArray final : public interpreter::AbstractBytecodeArray { ...@@ -442,6 +442,27 @@ class OffHeapBytecodeArray final : public interpreter::AbstractBytecodeArray {
BytecodeArrayRef array_; BytecodeArrayRef array_;
}; };
// Scope that unparks the LocalHeap, if:
// a) We have a JSHeapBroker,
// b) Said JSHeapBroker has a LocalHeap, and
// c) Said LocalHeap has been parked.
// Used, for example, when printing the graph with --trace-turbo with a
// previously parked LocalHeap.
class UnparkedScopeIfNeeded {
public:
explicit UnparkedScopeIfNeeded(JSHeapBroker* broker) {
if (broker != nullptr) {
LocalHeap* local_heap = broker->local_heap();
if (local_heap != nullptr && local_heap->IsParked()) {
unparked_scope.emplace(local_heap);
}
}
}
private:
base::Optional<UnparkedScope> unparked_scope;
};
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -784,27 +784,6 @@ class LocalHeapScope { ...@@ -784,27 +784,6 @@ class LocalHeapScope {
OptimizedCompilationInfo* info_; OptimizedCompilationInfo* info_;
}; };
// Scope that unparks the LocalHeap, if:
// a) We have a JSHeapBroker,
// b) Said JSHeapBroker has a LocalHeap, and
// c) Said LocalHeap has been parked.
// Used, for example, when printing the graph with --trace-turbo with a
// previously parked LocalHeap.
class UnparkedScopeIfNeeded {
public:
explicit UnparkedScopeIfNeeded(JSHeapBroker* broker) {
if (broker != nullptr) {
LocalHeap* local_heap = broker->local_heap();
if (local_heap != nullptr && local_heap->IsParked()) {
unparked_scope.emplace(local_heap);
}
}
}
private:
base::Optional<UnparkedScope> unparked_scope;
};
void PrintFunctionSource(OptimizedCompilationInfo* info, Isolate* isolate, void PrintFunctionSource(OptimizedCompilationInfo* info, Isolate* isolate,
int source_id, Handle<SharedFunctionInfo> shared) { int source_id, Handle<SharedFunctionInfo> shared) {
if (!shared->script().IsUndefined(isolate)) { if (!shared->script().IsUndefined(isolate)) {
...@@ -1440,7 +1419,7 @@ struct InliningPhase { ...@@ -1440,7 +1419,7 @@ struct InliningPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
OptimizedCompilationInfo* info = data->info(); OptimizedCompilationInfo* info = data->info();
GraphReducer graph_reducer(temp_zone, data->graph(), &info->tick_counter(), GraphReducer graph_reducer(temp_zone, data->graph(), &info->tick_counter(),
data->jsgraph()->Dead()); data->broker(), data->jsgraph()->Dead());
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common(), temp_zone); data->common(), temp_zone);
CheckpointElimination checkpoint_elimination(&graph_reducer); CheckpointElimination checkpoint_elimination(&graph_reducer);
...@@ -1539,7 +1518,7 @@ struct UntyperPhase { ...@@ -1539,7 +1518,7 @@ struct UntyperPhase {
} }
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
RemoveTypeReducer remove_type_reducer; RemoveTypeReducer remove_type_reducer;
AddReducer(data, &graph_reducer, &remove_type_reducer); AddReducer(data, &graph_reducer, &remove_type_reducer);
...@@ -1560,7 +1539,7 @@ struct CopyMetadataForConcurrentCompilePhase { ...@@ -1560,7 +1539,7 @@ struct CopyMetadataForConcurrentCompilePhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
JSHeapCopyReducer heap_copy_reducer(data->broker()); JSHeapCopyReducer heap_copy_reducer(data->broker());
AddReducer(data, &graph_reducer, &heap_copy_reducer); AddReducer(data, &graph_reducer, &heap_copy_reducer);
...@@ -1606,7 +1585,7 @@ struct TypedLoweringPhase { ...@@ -1606,7 +1585,7 @@ struct TypedLoweringPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common(), temp_zone); data->common(), temp_zone);
...@@ -1650,7 +1629,7 @@ struct EscapeAnalysisPhase { ...@@ -1650,7 +1629,7 @@ struct EscapeAnalysisPhase {
&data->info()->tick_counter(), temp_zone); &data->info()->tick_counter(), temp_zone);
escape_analysis.ReduceGraph(); escape_analysis.ReduceGraph();
GraphReducer reducer(temp_zone, data->graph(), GraphReducer reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
EscapeAnalysisReducer escape_reducer(&reducer, data->jsgraph(), EscapeAnalysisReducer escape_reducer(&reducer, data->jsgraph(),
escape_analysis.analysis_result(), escape_analysis.analysis_result(),
...@@ -1667,7 +1646,7 @@ struct TypeAssertionsPhase { ...@@ -1667,7 +1646,7 @@ struct TypeAssertionsPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
AddTypeAssertionsReducer type_assertions(&graph_reducer, data->jsgraph(), AddTypeAssertionsReducer type_assertions(&graph_reducer, data->jsgraph(),
temp_zone); temp_zone);
...@@ -1721,7 +1700,7 @@ struct GenericLoweringPhase { ...@@ -1721,7 +1700,7 @@ struct GenericLoweringPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
JSGenericLowering generic_lowering(data->jsgraph(), &graph_reducer, JSGenericLowering generic_lowering(data->jsgraph(), &graph_reducer,
data->broker()); data->broker());
...@@ -1735,7 +1714,7 @@ struct EarlyOptimizationPhase { ...@@ -1735,7 +1714,7 @@ struct EarlyOptimizationPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common(), temp_zone); data->common(), temp_zone);
...@@ -1812,7 +1791,7 @@ struct EffectControlLinearizationPhase { ...@@ -1812,7 +1791,7 @@ struct EffectControlLinearizationPhase {
// doing a common operator reducer and dead code elimination just before // doing a common operator reducer and dead code elimination just before
// it, to eliminate conditional deopts with a constant condition. // it, to eliminate conditional deopts with a constant condition.
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
data->common(), temp_zone); data->common(), temp_zone);
...@@ -1845,7 +1824,7 @@ struct LoadEliminationPhase { ...@@ -1845,7 +1824,7 @@ struct LoadEliminationPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
BranchElimination branch_condition_elimination(&graph_reducer, BranchElimination branch_condition_elimination(&graph_reducer,
data->jsgraph(), temp_zone, data->jsgraph(), temp_zone,
...@@ -1906,7 +1885,7 @@ struct LateOptimizationPhase { ...@@ -1906,7 +1885,7 @@ struct LateOptimizationPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
BranchElimination branch_condition_elimination(&graph_reducer, BranchElimination branch_condition_elimination(&graph_reducer,
data->jsgraph(), temp_zone); data->jsgraph(), temp_zone);
...@@ -1934,7 +1913,7 @@ struct MachineOperatorOptimizationPhase { ...@@ -1934,7 +1913,7 @@ struct MachineOperatorOptimizationPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
ValueNumberingReducer value_numbering(temp_zone, data->graph()->zone()); ValueNumberingReducer value_numbering(temp_zone, data->graph()->zone());
MachineOperatorReducer machine_reducer(&graph_reducer, data->jsgraph()); MachineOperatorReducer machine_reducer(&graph_reducer, data->jsgraph());
...@@ -2005,7 +1984,7 @@ struct CsaEarlyOptimizationPhase { ...@@ -2005,7 +1984,7 @@ struct CsaEarlyOptimizationPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
MachineOperatorReducer machine_reducer(&graph_reducer, data->jsgraph()); MachineOperatorReducer machine_reducer(&graph_reducer, data->jsgraph());
BranchElimination branch_condition_elimination(&graph_reducer, BranchElimination branch_condition_elimination(&graph_reducer,
...@@ -2033,7 +2012,7 @@ struct CsaOptimizationPhase { ...@@ -2033,7 +2012,7 @@ struct CsaOptimizationPhase {
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(), data->broker(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
BranchElimination branch_condition_elimination(&graph_reducer, BranchElimination branch_condition_elimination(&graph_reducer,
data->jsgraph(), temp_zone); data->jsgraph(), temp_zone);
...@@ -3168,7 +3147,7 @@ void Pipeline::GenerateCodeForWasmFunction( ...@@ -3168,7 +3147,7 @@ void Pipeline::GenerateCodeForWasmFunction(
PipelineRunScope scope(&data, "V8.WasmFullOptimization", PipelineRunScope scope(&data, "V8.WasmFullOptimization",
RuntimeCallCounterId::kOptimizeWasmFullOptimization); RuntimeCallCounterId::kOptimizeWasmFullOptimization);
GraphReducer graph_reducer(scope.zone(), data.graph(), GraphReducer graph_reducer(scope.zone(), data.graph(),
&data.info()->tick_counter(), &data.info()->tick_counter(), data.broker(),
data.mcgraph()->Dead()); data.mcgraph()->Dead());
DeadCodeElimination dead_code_elimination(&graph_reducer, data.graph(), DeadCodeElimination dead_code_elimination(&graph_reducer, data.graph(),
data.common(), scope.zone()); data.common(), scope.zone());
...@@ -3188,7 +3167,7 @@ void Pipeline::GenerateCodeForWasmFunction( ...@@ -3188,7 +3167,7 @@ void Pipeline::GenerateCodeForWasmFunction(
PipelineRunScope scope(&data, "V8.OptimizeWasmBaseOptimization", PipelineRunScope scope(&data, "V8.OptimizeWasmBaseOptimization",
RuntimeCallCounterId::kOptimizeWasmBaseOptimization); RuntimeCallCounterId::kOptimizeWasmBaseOptimization);
GraphReducer graph_reducer(scope.zone(), data.graph(), GraphReducer graph_reducer(scope.zone(), data.graph(),
&data.info()->tick_counter(), &data.info()->tick_counter(), data.broker(),
data.mcgraph()->Dead()); data.mcgraph()->Dead());
ValueNumberingReducer value_numbering(scope.zone(), data.graph()->zone()); ValueNumberingReducer value_numbering(scope.zone(), data.graph()->zone());
AddReducer(&data, &graph_reducer, &value_numbering); AddReducer(&data, &graph_reducer, &value_numbering);
......
...@@ -325,7 +325,7 @@ void Typer::Run(const NodeVector& roots, ...@@ -325,7 +325,7 @@ void Typer::Run(const NodeVector& roots,
induction_vars->ChangeToInductionVariablePhis(); induction_vars->ChangeToInductionVariablePhis();
} }
Visitor visitor(this, induction_vars); Visitor visitor(this, induction_vars);
GraphReducer graph_reducer(zone(), graph(), tick_counter_); GraphReducer graph_reducer(zone(), graph(), tick_counter_, broker());
graph_reducer.AddReducer(&visitor); graph_reducer.AddReducer(&visitor);
for (Node* const root : roots) graph_reducer.ReduceNode(root); for (Node* const root : roots) graph_reducer.ReduceNode(root);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
......
...@@ -33,7 +33,7 @@ class ContextSpecializationTester : public HandleAndZoneScope { ...@@ -33,7 +33,7 @@ class ContextSpecializationTester : public HandleAndZoneScope {
simplified_(main_zone()), simplified_(main_zone()),
jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_, jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_,
&machine_), &machine_),
reducer_(main_zone(), graph(), &tick_counter_), reducer_(main_zone(), graph(), &tick_counter_, &js_heap_broker_),
js_heap_broker_(main_isolate(), main_zone()), js_heap_broker_(main_isolate(), main_zone()),
spec_(&reducer_, jsgraph(), &js_heap_broker_, context, spec_(&reducer_, jsgraph(), &js_heap_broker_, context,
MaybeHandle<JSFunction>()) {} MaybeHandle<JSFunction>()) {}
......
...@@ -93,8 +93,8 @@ class JSTypedLoweringTester : public HandleAndZoneScope { ...@@ -93,8 +93,8 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
CHECK(!heap_copy_reducer.Reduce(node).Changed()); CHECK(!heap_copy_reducer.Reduce(node).Changed());
JSGraph jsgraph(main_isolate(), &graph, &common, &javascript, &simplified, JSGraph jsgraph(main_isolate(), &graph, &common, &javascript, &simplified,
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(main_zone(), &graph, &tick_counter,
GraphReducer graph_reducer(main_zone(), &graph, &tick_counter); &js_heap_broker);
JSTypedLowering reducer(&graph_reducer, &jsgraph, &js_heap_broker, JSTypedLowering reducer(&graph_reducer, &jsgraph, &js_heap_broker,
main_zone()); main_zone());
Reduction reduction = reducer.Reduce(node); Reduction reduction = reducer.Reduce(node);
......
...@@ -88,7 +88,8 @@ class ReducerTester : public HandleAndZoneScope { ...@@ -88,7 +88,8 @@ class ReducerTester : public HandleAndZoneScope {
javascript(main_zone()), javascript(main_zone()),
jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine), jsgraph(isolate, &graph, &common, &javascript, nullptr, &machine),
maxuint32(Constant<int32_t>(kMaxUInt32)), maxuint32(Constant<int32_t>(kMaxUInt32)),
graph_reducer(main_zone(), &graph, &tick_counter, jsgraph.Dead()) { graph_reducer(main_zone(), &graph, &tick_counter, nullptr,
jsgraph.Dead()) {
Node* s = graph.NewNode(common.Start(num_parameters)); Node* s = graph.NewNode(common.Start(num_parameters));
graph.SetStart(s); graph.SetStart(s);
} }
......
...@@ -28,7 +28,8 @@ class BranchEliminationTest : public GraphTest { ...@@ -28,7 +28,8 @@ class BranchEliminationTest : public GraphTest {
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(isolate(), graph(), common(), &javascript, nullptr, JSGraph jsgraph(isolate(), graph(), common(), &javascript, nullptr,
machine()); machine());
GraphReducer graph_reducer(zone(), graph(), tick_counter(), jsgraph.Dead()); GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker(),
jsgraph.Dead());
BranchElimination branch_condition_elimination(&graph_reducer, &jsgraph, BranchElimination branch_condition_elimination(&graph_reducer, &jsgraph,
zone()); zone());
graph_reducer.AddReducer(&branch_condition_elimination); graph_reducer.AddReducer(&branch_condition_elimination);
......
...@@ -74,8 +74,7 @@ class ConstantFoldingReducerTest : public TypedGraphTest { ...@@ -74,8 +74,7 @@ class ConstantFoldingReducerTest : public TypedGraphTest {
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(), JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(),
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker());
GraphReducer graph_reducer(zone(), graph(), tick_counter());
ConstantFoldingReducer reducer(&graph_reducer, &jsgraph, broker()); ConstantFoldingReducer reducer(&graph_reducer, &jsgraph, broker());
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -314,7 +314,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ValueUse) { ...@@ -314,7 +314,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ValueUse) {
Node* zero = graph()->NewNode(common.Int32Constant(0)); Node* zero = graph()->NewNode(common.Int32Constant(0));
Node* use_value = graph()->NewNode(common.Return(), zero, node, start, start); Node* use_value = graph()->NewNode(common.Return(), zero, node, start, start);
Node* replacement = graph()->NewNode(&kMockOperator); Node* replacement = graph()->NewNode(&kMockOperator);
GraphReducer graph_reducer(zone(), graph(), nullptr); GraphReducer graph_reducer(zone(), graph(), nullptr, nullptr);
ReplaceWithValueReducer r(&graph_reducer); ReplaceWithValueReducer r(&graph_reducer);
r.ReplaceWithValue(node, replacement); r.ReplaceWithValue(node, replacement);
EXPECT_EQ(replacement, use_value->InputAt(1)); EXPECT_EQ(replacement, use_value->InputAt(1));
...@@ -331,7 +331,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) { ...@@ -331,7 +331,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_EffectUse) {
Node* use_control = graph()->NewNode(common.Merge(1), start); Node* use_control = graph()->NewNode(common.Merge(1), start);
Node* use_effect = graph()->NewNode(common.EffectPhi(1), node, use_control); Node* use_effect = graph()->NewNode(common.EffectPhi(1), node, use_control);
Node* replacement = graph()->NewNode(&kMockOperator); Node* replacement = graph()->NewNode(&kMockOperator);
GraphReducer graph_reducer(zone(), graph(), nullptr); GraphReducer graph_reducer(zone(), graph(), nullptr, nullptr);
ReplaceWithValueReducer r(&graph_reducer); ReplaceWithValueReducer r(&graph_reducer);
r.ReplaceWithValue(node, replacement); r.ReplaceWithValue(node, replacement);
EXPECT_EQ(start, use_effect->InputAt(0)); EXPECT_EQ(start, use_effect->InputAt(0));
...@@ -350,7 +350,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse1) { ...@@ -350,7 +350,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse1) {
Node* success = graph()->NewNode(common.IfSuccess(), node); Node* success = graph()->NewNode(common.IfSuccess(), node);
Node* use_control = graph()->NewNode(common.Merge(1), success); Node* use_control = graph()->NewNode(common.Merge(1), success);
Node* replacement = graph()->NewNode(&kMockOperator); Node* replacement = graph()->NewNode(&kMockOperator);
GraphReducer graph_reducer(zone(), graph(), nullptr); GraphReducer graph_reducer(zone(), graph(), nullptr, nullptr);
ReplaceWithValueReducer r(&graph_reducer); ReplaceWithValueReducer r(&graph_reducer);
r.ReplaceWithValue(node, replacement); r.ReplaceWithValue(node, replacement);
EXPECT_EQ(start, use_control->InputAt(0)); EXPECT_EQ(start, use_control->InputAt(0));
...@@ -371,7 +371,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse2) { ...@@ -371,7 +371,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse2) {
Node* exception = graph()->NewNode(common.IfException(), effect, node); Node* exception = graph()->NewNode(common.IfException(), effect, node);
Node* use_control = graph()->NewNode(common.Merge(1), success); Node* use_control = graph()->NewNode(common.Merge(1), success);
Node* replacement = graph()->NewNode(&kMockOperator); Node* replacement = graph()->NewNode(&kMockOperator);
GraphReducer graph_reducer(zone(), graph(), tick_counter(), dead); GraphReducer graph_reducer(zone(), graph(), tick_counter(), nullptr, dead);
ReplaceWithValueReducer r(&graph_reducer); ReplaceWithValueReducer r(&graph_reducer);
r.ReplaceWithValue(node, replacement); r.ReplaceWithValue(node, replacement);
EXPECT_EQ(start, use_control->InputAt(0)); EXPECT_EQ(start, use_control->InputAt(0));
...@@ -395,7 +395,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse3) { ...@@ -395,7 +395,7 @@ TEST_F(AdvancedReducerTest, ReplaceWithValue_ControlUse3) {
Node* exception = graph()->NewNode(common.IfException(), effect, node); Node* exception = graph()->NewNode(common.IfException(), effect, node);
Node* use_control = graph()->NewNode(common.Merge(1), success); Node* use_control = graph()->NewNode(common.Merge(1), success);
Node* replacement = graph()->NewNode(&kMockOperator); Node* replacement = graph()->NewNode(&kMockOperator);
GraphReducer graph_reducer(zone(), graph(), tick_counter(), dead); GraphReducer graph_reducer(zone(), graph(), tick_counter(), nullptr, dead);
ReplaceWithValueReducer r(&graph_reducer); ReplaceWithValueReducer r(&graph_reducer);
r.ReplaceWithValue(node, replacement); r.ReplaceWithValue(node, replacement);
EXPECT_EQ(start, use_control->InputAt(0)); EXPECT_EQ(start, use_control->InputAt(0));
...@@ -425,20 +425,20 @@ class GraphReducerTest : public TestWithZone { ...@@ -425,20 +425,20 @@ class GraphReducerTest : public TestWithZone {
protected: protected:
void ReduceNode(Node* node, Reducer* r) { void ReduceNode(Node* node, Reducer* r) {
GraphReducer reducer(zone(), graph(), tick_counter()); GraphReducer reducer(zone(), graph(), tick_counter(), nullptr);
reducer.AddReducer(r); reducer.AddReducer(r);
reducer.ReduceNode(node); reducer.ReduceNode(node);
} }
void ReduceNode(Node* node, Reducer* r1, Reducer* r2) { void ReduceNode(Node* node, Reducer* r1, Reducer* r2) {
GraphReducer reducer(zone(), graph(), tick_counter()); GraphReducer reducer(zone(), graph(), tick_counter(), nullptr);
reducer.AddReducer(r1); reducer.AddReducer(r1);
reducer.AddReducer(r2); reducer.AddReducer(r2);
reducer.ReduceNode(node); reducer.ReduceNode(node);
} }
void ReduceNode(Node* node, Reducer* r1, Reducer* r2, Reducer* r3) { void ReduceNode(Node* node, Reducer* r1, Reducer* r2, Reducer* r3) {
GraphReducer reducer(zone(), graph(), tick_counter()); GraphReducer reducer(zone(), graph(), tick_counter(), nullptr);
reducer.AddReducer(r1); reducer.AddReducer(r1);
reducer.AddReducer(r2); reducer.AddReducer(r2);
reducer.AddReducer(r3); reducer.AddReducer(r3);
...@@ -446,20 +446,20 @@ class GraphReducerTest : public TestWithZone { ...@@ -446,20 +446,20 @@ class GraphReducerTest : public TestWithZone {
} }
void ReduceGraph(Reducer* r1) { void ReduceGraph(Reducer* r1) {
GraphReducer reducer(zone(), graph(), tick_counter()); GraphReducer reducer(zone(), graph(), tick_counter(), nullptr);
reducer.AddReducer(r1); reducer.AddReducer(r1);
reducer.ReduceGraph(); reducer.ReduceGraph();
} }
void ReduceGraph(Reducer* r1, Reducer* r2) { void ReduceGraph(Reducer* r1, Reducer* r2) {
GraphReducer reducer(zone(), graph(), tick_counter()); GraphReducer reducer(zone(), graph(), tick_counter(), nullptr);
reducer.AddReducer(r1); reducer.AddReducer(r1);
reducer.AddReducer(r2); reducer.AddReducer(r2);
reducer.ReduceGraph(); reducer.ReduceGraph();
} }
void ReduceGraph(Reducer* r1, Reducer* r2, Reducer* r3) { void ReduceGraph(Reducer* r1, Reducer* r2, Reducer* r3) {
GraphReducer reducer(zone(), graph(), tick_counter()); GraphReducer reducer(zone(), graph(), tick_counter(), nullptr);
reducer.AddReducer(r1); reducer.AddReducer(r1);
reducer.AddReducer(r2); reducer.AddReducer(r2);
reducer.AddReducer(r3); reducer.AddReducer(r3);
......
...@@ -34,9 +34,7 @@ class JSCallReducerTest : public TypedGraphTest { ...@@ -34,9 +34,7 @@ class JSCallReducerTest : public TypedGraphTest {
SimplifiedOperatorBuilder simplified(zone()); SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker());
GraphReducer graph_reducer(zone(), graph(), tick_counter());
JSCallReducer reducer(&graph_reducer, &jsgraph, broker(), zone(), JSCallReducer reducer(&graph_reducer, &jsgraph, broker(), zone(),
JSCallReducer::kNoFlags, &deps_); JSCallReducer::kNoFlags, &deps_);
return reducer.Reduce(node); return reducer.Reduce(node);
......
...@@ -43,8 +43,7 @@ class JSCreateLoweringTest : public TypedGraphTest { ...@@ -43,8 +43,7 @@ class JSCreateLoweringTest : public TypedGraphTest {
SimplifiedOperatorBuilder simplified(zone()); SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker());
GraphReducer graph_reducer(zone(), graph(), tick_counter());
JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, broker(), JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph, broker(),
zone()); zone());
return reducer.Reduce(node); return reducer.Reduce(node);
......
...@@ -35,8 +35,7 @@ class JSIntrinsicLoweringTest : public GraphTest { ...@@ -35,8 +35,7 @@ class JSIntrinsicLoweringTest : public GraphTest {
SimplifiedOperatorBuilder simplified(zone()); SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker());
GraphReducer graph_reducer(zone(), graph(), tick_counter());
JSIntrinsicLowering reducer(&graph_reducer, &jsgraph, broker()); JSIntrinsicLowering reducer(&graph_reducer, &jsgraph, broker());
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -50,8 +50,7 @@ class JSTypedLoweringTest : public TypedGraphTest { ...@@ -50,8 +50,7 @@ class JSTypedLoweringTest : public TypedGraphTest {
SimplifiedOperatorBuilder simplified(zone()); SimplifiedOperatorBuilder simplified(zone());
JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified, JSGraph jsgraph(isolate(), graph(), common(), javascript(), &simplified,
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker());
GraphReducer graph_reducer(zone(), graph(), tick_counter());
JSTypedLowering reducer(&graph_reducer, &jsgraph, broker(), zone()); JSTypedLowering reducer(&graph_reducer, &jsgraph, broker(), zone());
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -34,7 +34,8 @@ class MachineOperatorReducerTest : public GraphTest { ...@@ -34,7 +34,8 @@ class MachineOperatorReducerTest : public GraphTest {
javascript_(zone()), javascript_(zone()),
jsgraph_(isolate(), graph(), &common_, &javascript_, nullptr, jsgraph_(isolate(), graph(), &common_, &javascript_, nullptr,
&machine_), &machine_),
graph_reducer_(zone(), graph(), tick_counter(), jsgraph_.Dead()) {} graph_reducer_(zone(), graph(), tick_counter(), broker(),
jsgraph_.Dead()) {}
protected: protected:
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
......
...@@ -30,13 +30,12 @@ class SimplifiedOperatorReducerTest : public GraphTest { ...@@ -30,13 +30,12 @@ class SimplifiedOperatorReducerTest : public GraphTest {
protected: protected:
Reduction Reduce(Node* node) { Reduction Reduce(Node* node) {
JSHeapBroker broker(isolate(), zone());
MachineOperatorBuilder machine(zone()); MachineOperatorBuilder machine(zone());
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(), JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(),
&machine); &machine);
GraphReducer graph_reducer(zone(), graph(), tick_counter()); GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker());
SimplifiedOperatorReducer reducer(&graph_reducer, &jsgraph, &broker); SimplifiedOperatorReducer reducer(&graph_reducer, &jsgraph, broker());
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
...@@ -36,8 +36,7 @@ class TypedOptimizationTest : public TypedGraphTest { ...@@ -36,8 +36,7 @@ class TypedOptimizationTest : public TypedGraphTest {
JSOperatorBuilder javascript(zone()); JSOperatorBuilder javascript(zone());
JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(), JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(),
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. GraphReducer graph_reducer(zone(), graph(), tick_counter(), broker());
GraphReducer graph_reducer(zone(), graph(), tick_counter());
TypedOptimization reducer(&graph_reducer, &deps_, &jsgraph, broker()); TypedOptimization reducer(&graph_reducer, &deps_, &jsgraph, broker());
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
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