From 648ff5627ea0093c90bf81769111ae5850f671f6 Mon Sep 17 00:00:00 2001 From: Mike Stanton Date: Wed, 12 Jun 2019 11:04:24 +0200 Subject: [PATCH] [turbofan] JSHeapBroker logging respects --trace-turbo-filter As a component of the wider Turbofan logging scheme, it makes sense for JSHeapBroker logging to come through flags specified in the OptimizedCompilationInfo class, which uses --trace-turbo-filter to control which functions are logged. Bug: v8:7790 Change-Id: I3b068d8be78867ab0bd9607dda9eca4123b9d7b1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1655297 Reviewed-by: Maya Lekova Commit-Queue: Michael Stanton Cr-Commit-Position: refs/heads/master@{#62111} --- src/codegen/optimized-compilation-info.cc | 1 + src/codegen/optimized-compilation-info.h | 9 ++++++--- src/compiler/js-heap-broker.cc | 6 ++++-- src/compiler/js-heap-broker.h | 13 ++++++++----- src/compiler/pipeline.cc | 3 ++- .../compiler/test-js-context-specialization.cc | 2 +- test/cctest/compiler/test-js-typed-lowering.cc | 2 +- test/common/types-fuzz.h | 4 +++- .../compiler/common-operator-reducer-unittest.cc | 2 +- .../compiler/constant-folding-reducer-unittest.cc | 2 +- test/unittests/compiler/graph-unittest.cc | 2 +- .../simplified-operator-reducer-unittest.cc | 2 +- test/unittests/compiler/typer-unittest.cc | 2 +- 13 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/codegen/optimized-compilation-info.cc b/src/codegen/optimized-compilation-info.cc index 41fb95c29e..0f4fa83200 100644 --- a/src/codegen/optimized-compilation-info.cc +++ b/src/codegen/optimized-compilation-info.cc @@ -240,6 +240,7 @@ void OptimizedCompilationInfo::SetTracingFlags(bool passes_filter) { if (FLAG_trace_turbo) SetFlag(kTraceTurboJson); if (FLAG_trace_turbo_graph) SetFlag(kTraceTurboGraph); if (FLAG_trace_turbo_scheduled) SetFlag(kTraceTurboScheduled); + if (FLAG_trace_heap_broker) SetFlag(kTraceHeapBroker); } OptimizedCompilationInfo::InlinedFunctionHolder::InlinedFunctionHolder( diff --git a/src/codegen/optimized-compilation-info.h b/src/codegen/optimized-compilation-info.h index eca3a8fa32..e16e90dea8 100644 --- a/src/codegen/optimized-compilation-info.h +++ b/src/codegen/optimized-compilation-info.h @@ -60,9 +60,10 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final { kTraceTurboJson = 1 << 14, kTraceTurboGraph = 1 << 15, kTraceTurboScheduled = 1 << 16, - kWasmRuntimeExceptionSupport = 1 << 17, - kTurboControlFlowAwareAllocation = 1 << 18, - kTurboPreprocessRanges = 1 << 19 + kTraceHeapBroker = 1 << 17, + kWasmRuntimeExceptionSupport = 1 << 18, + kTurboControlFlowAwareAllocation = 1 << 19, + kTurboPreprocessRanges = 1 << 20 }; // Construct a compilation info for optimized compilation. @@ -193,6 +194,8 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final { return GetFlag(kTraceTurboScheduled); } + bool trace_heap_broker_enabled() const { return GetFlag(kTraceHeapBroker); } + // Code getters and setters. void SetCode(Handle code) { code_ = code; } diff --git a/src/compiler/js-heap-broker.cc b/src/compiler/js-heap-broker.cc index 86598e71ba..a4fe665c02 100644 --- a/src/compiler/js-heap-broker.cc +++ b/src/compiler/js-heap-broker.cc @@ -1861,14 +1861,16 @@ ObjectRef ContextRef::get(int index) const { return ObjectRef(broker(), data()->AsContext()->GetSlot(index)); } -JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone) +JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone, + bool tracing_enabled) : isolate_(isolate), broker_zone_(broker_zone), current_zone_(broker_zone), refs_(new (zone()) RefsMap(kMinimalRefsBucketCount, AddressMatcher(), zone())), array_and_object_prototypes_(zone()), - feedback_(zone()) { + feedback_(zone()), + tracing_enabled_(tracing_enabled) { // Note that this initialization of the refs_ pointer with the minimal // initial capacity is redundant in the normal use case (concurrent // compilation enabled, standard objects to be serialized), as the map diff --git a/src/compiler/js-heap-broker.h b/src/compiler/js-heap-broker.h index 801288c863..6202a419a8 100644 --- a/src/compiler/js-heap-broker.h +++ b/src/compiler/js-heap-broker.h @@ -820,26 +820,28 @@ struct FeedbackSource { }; }; -#define TRACE_BROKER(broker, x) \ - do { \ - if (FLAG_trace_heap_broker_verbose) broker->Trace() << x << '\n'; \ +#define TRACE_BROKER(broker, x) \ + do { \ + if (broker->tracing_enabled() && FLAG_trace_heap_broker_verbose) \ + broker->Trace() << x << '\n'; \ } while (false) #define TRACE_BROKER_MISSING(broker, x) \ do { \ - if (FLAG_trace_heap_broker) \ + if (broker->tracing_enabled()) \ broker->Trace() << __FUNCTION__ << ": missing " << x << '\n'; \ } while (false) class V8_EXPORT_PRIVATE JSHeapBroker { public: - JSHeapBroker(Isolate* isolate, Zone* broker_zone); + JSHeapBroker(Isolate* isolate, Zone* broker_zone, bool tracing_enabled); void SetNativeContextRef(); void SerializeStandardObjects(); Isolate* isolate() const { return isolate_; } Zone* zone() const { return current_zone_; } + bool tracing_enabled() const { return tracing_enabled_; } NativeContextRef native_context() const { return native_context_.value(); } PerIsolateCompilerCache* compiler_cache() const { return compiler_cache_; } @@ -907,6 +909,7 @@ class V8_EXPORT_PRIVATE JSHeapBroker { ZoneUnorderedMap feedback_; + bool tracing_enabled_; static const size_t kMinimalRefsBucketCount = 8; // must be power of 2 static const size_t kInitialRefsBucketCount = 1024; // must be power of 2 diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index 1e2733ba4c..ff23712716 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -115,7 +115,8 @@ class PipelineData { instruction_zone_(instruction_zone_scope_.zone()), codegen_zone_scope_(zone_stats_, ZONE_NAME), codegen_zone_(codegen_zone_scope_.zone()), - broker_(new JSHeapBroker(isolate_, info_->zone())), + broker_(new JSHeapBroker(isolate_, info_->zone(), + info_->trace_heap_broker_enabled())), register_allocation_zone_scope_(zone_stats_, ZONE_NAME), register_allocation_zone_(register_allocation_zone_scope_.zone()), assembler_options_(AssemblerOptions::Default(isolate)) { diff --git a/test/cctest/compiler/test-js-context-specialization.cc b/test/cctest/compiler/test-js-context-specialization.cc index 458b1e521b..22316c515d 100644 --- a/test/cctest/compiler/test-js-context-specialization.cc +++ b/test/cctest/compiler/test-js-context-specialization.cc @@ -31,7 +31,7 @@ class ContextSpecializationTester : public HandleAndZoneScope { jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_, &machine_), reducer_(main_zone(), graph()), - js_heap_broker_(main_isolate(), main_zone()), + js_heap_broker_(main_isolate(), main_zone(), FLAG_trace_heap_broker), spec_(&reducer_, jsgraph(), &js_heap_broker_, context, MaybeHandle()) {} diff --git a/test/cctest/compiler/test-js-typed-lowering.cc b/test/cctest/compiler/test-js-typed-lowering.cc index cc717c618e..62c5e4802b 100644 --- a/test/cctest/compiler/test-js-typed-lowering.cc +++ b/test/cctest/compiler/test-js-typed-lowering.cc @@ -24,7 +24,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { explicit JSTypedLoweringTester(int num_parameters = 0) : isolate(main_isolate()), canonical(isolate), - js_heap_broker(isolate, main_zone()), + js_heap_broker(isolate, main_zone(), FLAG_trace_heap_broker), binop(nullptr), unop(nullptr), javascript(main_zone()), diff --git a/test/common/types-fuzz.h b/test/common/types-fuzz.h index 06ab9067d8..043567554e 100644 --- a/test/common/types-fuzz.h +++ b/test/common/types-fuzz.h @@ -40,7 +40,9 @@ namespace compiler { class Types { public: Types(Zone* zone, Isolate* isolate, v8::base::RandomNumberGenerator* rng) - : zone_(zone), js_heap_broker_(isolate, zone), rng_(rng) { + : zone_(zone), + js_heap_broker_(isolate, zone, FLAG_trace_heap_broker), + rng_(rng) { #define DECLARE_TYPE(name, value) \ name = Type::name(); \ types.push_back(name); diff --git a/test/unittests/compiler/common-operator-reducer-unittest.cc b/test/unittests/compiler/common-operator-reducer-unittest.cc index c97bb96b49..690701cf56 100644 --- a/test/unittests/compiler/common-operator-reducer-unittest.cc +++ b/test/unittests/compiler/common-operator-reducer-unittest.cc @@ -29,7 +29,7 @@ class CommonOperatorReducerTest : public GraphTest { Reduction Reduce( AdvancedReducer::Editor* editor, Node* node, MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags) { - JSHeapBroker broker(isolate(), zone()); + JSHeapBroker broker(isolate(), zone(), FLAG_trace_heap_broker); MachineOperatorBuilder machine(zone(), MachineType::PointerRepresentation(), flags); CommonOperatorReducer reducer(editor, graph(), &broker, common(), &machine, diff --git a/test/unittests/compiler/constant-folding-reducer-unittest.cc b/test/unittests/compiler/constant-folding-reducer-unittest.cc index d30449daa7..4f98a0c1a3 100644 --- a/test/unittests/compiler/constant-folding-reducer-unittest.cc +++ b/test/unittests/compiler/constant-folding-reducer-unittest.cc @@ -63,7 +63,7 @@ class ConstantFoldingReducerTest : public TypedGraphTest { public: ConstantFoldingReducerTest() : TypedGraphTest(3), - broker_(isolate(), zone()), + broker_(isolate(), zone(), FLAG_trace_heap_broker), simplified_(zone()), deps_(&broker_, zone()) {} ~ConstantFoldingReducerTest() override = default; diff --git a/test/unittests/compiler/graph-unittest.cc b/test/unittests/compiler/graph-unittest.cc index f433dda42e..ceda10f863 100644 --- a/test/unittests/compiler/graph-unittest.cc +++ b/test/unittests/compiler/graph-unittest.cc @@ -18,7 +18,7 @@ GraphTest::GraphTest(int num_parameters) : canonical_(isolate()), common_(zone()), graph_(zone()), - broker_(isolate(), zone()), + broker_(isolate(), zone(), FLAG_trace_heap_broker), source_positions_(&graph_), node_origins_(&graph_) { graph()->SetStart(graph()->NewNode(common()->Start(num_parameters))); diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc index 1f44eb088b..7bbabc7d05 100644 --- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc +++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc @@ -29,7 +29,7 @@ class SimplifiedOperatorReducerTest : public GraphTest { protected: Reduction Reduce(Node* node) { - JSHeapBroker broker(isolate(), zone()); + JSHeapBroker broker(isolate(), zone(), FLAG_trace_heap_broker); MachineOperatorBuilder machine(zone()); JSOperatorBuilder javascript(zone()); JSGraph jsgraph(isolate(), graph(), common(), &javascript, simplified(), diff --git a/test/unittests/compiler/typer-unittest.cc b/test/unittests/compiler/typer-unittest.cc index 2eaa379f30..ec68993213 100644 --- a/test/unittests/compiler/typer-unittest.cc +++ b/test/unittests/compiler/typer-unittest.cc @@ -22,7 +22,7 @@ class TyperTest : public TypedGraphTest { public: TyperTest() : TypedGraphTest(3), - broker_(isolate(), zone()), + broker_(isolate(), zone(), FLAG_trace_heap_broker), operation_typer_(&broker_, zone()), types_(zone(), isolate(), random_number_generator()), javascript_(zone()),