[turbofan] Make serializer environment tracing more readable
Also, when --trace-heap-broker-verbose is on, we trace bytecode-by-bytecode alterations to the environment. Change-Id: I535a063cefd57f055711fdd7d7473cb63c963c7f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1622851 Reviewed-by: Maya Lekova <mslekova@chromium.org> Commit-Queue: Michael Stanton <mvstanton@chromium.org> Cr-Commit-Position: refs/heads/master@{#61733}
This commit is contained in:
parent
1aac6a435a
commit
1d1567a319
@ -166,26 +166,6 @@ void JSHeapBroker::IncrementTracingIndentation() { ++trace_indentation_; }
|
||||
|
||||
void JSHeapBroker::DecrementTracingIndentation() { --trace_indentation_; }
|
||||
|
||||
class TraceScope {
|
||||
public:
|
||||
TraceScope(JSHeapBroker* broker, const char* label)
|
||||
: TraceScope(broker, static_cast<void*>(broker), label) {}
|
||||
|
||||
TraceScope(JSHeapBroker* broker, ObjectData* data, const char* label)
|
||||
: TraceScope(broker, static_cast<void*>(data), label) {}
|
||||
|
||||
~TraceScope() { broker_->DecrementTracingIndentation(); }
|
||||
|
||||
private:
|
||||
JSHeapBroker* const broker_;
|
||||
|
||||
TraceScope(JSHeapBroker* broker, void* self, const char* label)
|
||||
: broker_(broker) {
|
||||
TRACE(broker_, "Running " << label << " on " << self);
|
||||
broker_->IncrementTracingIndentation();
|
||||
}
|
||||
};
|
||||
|
||||
PropertyCellData::PropertyCellData(JSHeapBroker* broker, ObjectData** storage,
|
||||
Handle<PropertyCell> object)
|
||||
: HeapObjectData(broker, storage, object),
|
||||
|
@ -820,6 +820,17 @@ struct FeedbackSource {
|
||||
};
|
||||
};
|
||||
|
||||
#define TRACE_BROKER(broker, x) \
|
||||
do { \
|
||||
if (FLAG_trace_heap_broker_verbose) broker->Trace() << x << '\n'; \
|
||||
} while (false)
|
||||
|
||||
#define TRACE_BROKER_MISSING(broker, x) \
|
||||
do { \
|
||||
if (FLAG_trace_heap_broker) \
|
||||
broker->Trace() << __FUNCTION__ << ": missing " << x << '\n'; \
|
||||
} while (false)
|
||||
|
||||
class V8_EXPORT_PRIVATE JSHeapBroker {
|
||||
public:
|
||||
JSHeapBroker(Isolate* isolate, Zone* broker_zone);
|
||||
@ -901,6 +912,26 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
|
||||
static const size_t kInitialRefsBucketCount = 1024; // must be power of 2
|
||||
};
|
||||
|
||||
class TraceScope {
|
||||
public:
|
||||
TraceScope(JSHeapBroker* broker, const char* label)
|
||||
: TraceScope(broker, static_cast<void*>(broker), label) {}
|
||||
|
||||
TraceScope(JSHeapBroker* broker, ObjectData* data, const char* label)
|
||||
: TraceScope(broker, static_cast<void*>(data), label) {}
|
||||
|
||||
TraceScope(JSHeapBroker* broker, void* subject, const char* label)
|
||||
: broker_(broker) {
|
||||
TRACE_BROKER(broker_, "Running " << label << " on " << subject);
|
||||
broker_->IncrementTracingIndentation();
|
||||
}
|
||||
|
||||
~TraceScope() { broker_->DecrementTracingIndentation(); }
|
||||
|
||||
private:
|
||||
JSHeapBroker* const broker_;
|
||||
};
|
||||
|
||||
#define ASSIGN_RETURN_NO_CHANGE_IF_DATA_MISSING(something_var, \
|
||||
optionally_something) \
|
||||
auto optionally_something_ = optionally_something; \
|
||||
@ -916,17 +947,6 @@ Reduction NoChangeBecauseOfMissingData(JSHeapBroker* broker,
|
||||
// compilation is finished.
|
||||
bool CanInlineElementAccess(MapRef const& map);
|
||||
|
||||
#define TRACE_BROKER(broker, x) \
|
||||
do { \
|
||||
if (FLAG_trace_heap_broker_verbose) broker->Trace() << x << '\n'; \
|
||||
} while (false)
|
||||
|
||||
#define TRACE_BROKER_MISSING(broker, x) \
|
||||
do { \
|
||||
if (FLAG_trace_heap_broker) \
|
||||
broker->Trace() << __FUNCTION__ << ": missing " << x << '\n'; \
|
||||
} while (false)
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -67,16 +67,15 @@ std::ostream& operator<<(std::ostream& out,
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Hints& hints) {
|
||||
!hints.constants().empty() &&
|
||||
out << "\t\tConstants (" << hints.constants().size() << "):" << std::endl;
|
||||
for (auto x : hints.constants()) out << Brief(*x) << std::endl;
|
||||
!hints.maps().empty() && out << "\t\tMaps (" << hints.maps().size()
|
||||
<< "):" << std::endl;
|
||||
for (auto x : hints.maps()) out << Brief(*x) << std::endl;
|
||||
!hints.function_blueprints().empty() &&
|
||||
out << "\t\tBlueprints (" << hints.function_blueprints().size()
|
||||
<< "):" << std::endl;
|
||||
for (auto x : hints.function_blueprints()) out << x;
|
||||
for (Handle<Object> constant : hints.constants()) {
|
||||
out << " constant " << Brief(*constant) << std::endl;
|
||||
}
|
||||
for (Handle<Map> map : hints.maps()) {
|
||||
out << " map " << Brief(*map) << std::endl;
|
||||
}
|
||||
for (FunctionBlueprint const& blueprint : hints.function_blueprints()) {
|
||||
out << " blueprint " << blueprint << std::endl;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -214,21 +213,43 @@ std::ostream& operator<<(
|
||||
std::ostream& out,
|
||||
const SerializerForBackgroundCompilation::Environment& env) {
|
||||
std::ostringstream output_stream;
|
||||
output_stream << "Function ";
|
||||
env.function_.shared->Name()->Print(output_stream);
|
||||
output_stream << "Parameter count: " << env.parameter_count() << std::endl;
|
||||
output_stream << "Register count: " << env.register_count() << std::endl;
|
||||
|
||||
output_stream << "Hints (" << env.environment_hints_.size() << "):\n";
|
||||
for (size_t i = 0; i < env.environment_hints_.size(); ++i) {
|
||||
if (env.environment_hints_[i].IsEmpty()) continue;
|
||||
|
||||
output_stream << "\tSlot " << i << std::endl;
|
||||
output_stream << env.environment_hints_[i];
|
||||
for (size_t i = 0; i << env.parameter_count(); ++i) {
|
||||
Hints const& hints = env.environment_hints_[i];
|
||||
if (!hints.IsEmpty()) {
|
||||
output_stream << "Hints for a" << i << ":\n" << hints;
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i << env.register_count(); ++i) {
|
||||
Hints const& hints = env.environment_hints_[env.parameter_count() + i];
|
||||
if (!hints.IsEmpty()) {
|
||||
output_stream << "Hints for r" << i << ":\n" << hints;
|
||||
}
|
||||
}
|
||||
{
|
||||
Hints const& hints = env.environment_hints_[env.accumulator_index()];
|
||||
if (!hints.IsEmpty()) {
|
||||
output_stream << "Hints for <accumulator>:\n" << hints;
|
||||
}
|
||||
}
|
||||
{
|
||||
Hints const& hints = env.environment_hints_[env.function_closure_index()];
|
||||
if (!hints.IsEmpty()) {
|
||||
output_stream << "Hints for <closure>:\n" << hints;
|
||||
}
|
||||
}
|
||||
{
|
||||
Hints const& hints = env.environment_hints_[env.current_context_index()];
|
||||
if (!hints.IsEmpty()) {
|
||||
output_stream << "Hints for <context>:\n" << hints;
|
||||
}
|
||||
}
|
||||
{
|
||||
Hints const& hints = env.return_value_hints_;
|
||||
if (!hints.IsEmpty()) {
|
||||
output_stream << "Hints for {return value}:\n" << hints;
|
||||
}
|
||||
}
|
||||
output_stream << "Return value:\n";
|
||||
output_stream << env.return_value_hints_
|
||||
<< "===========================================\n";
|
||||
|
||||
out << output_stream.str();
|
||||
return out;
|
||||
@ -269,6 +290,10 @@ SerializerForBackgroundCompilation::SerializerForBackgroundCompilation(
|
||||
environment_(new (zone) Environment(zone, broker_->isolate(), function,
|
||||
new_target, arguments)),
|
||||
stashed_environments_(zone) {
|
||||
TraceScope tracer(
|
||||
broker_, this,
|
||||
"SerializerForBackgroundCompilation::SerializerForBackgroundCompilation");
|
||||
TRACE_BROKER(broker_, "Initial environment:\n" << *environment_);
|
||||
Handle<JSFunction> closure;
|
||||
if (function.closure().ToHandle(&closure)) {
|
||||
JSFunctionRef(broker, closure).Serialize();
|
||||
@ -276,10 +301,14 @@ SerializerForBackgroundCompilation::SerializerForBackgroundCompilation(
|
||||
}
|
||||
|
||||
Hints SerializerForBackgroundCompilation::Run() {
|
||||
TraceScope tracer(broker(), this, "SerializerForBackgroundCompilation::Run");
|
||||
SharedFunctionInfoRef shared(broker(), environment()->function().shared);
|
||||
FeedbackVectorRef feedback_vector(broker(),
|
||||
environment()->function().feedback_vector);
|
||||
if (shared.IsSerializedForCompilation(feedback_vector)) {
|
||||
TRACE_BROKER(broker(), "Already ran serializer for SharedFunctionInfo "
|
||||
<< Brief(*shared.object())
|
||||
<< ", bailing out.\n");
|
||||
return Hints(zone());
|
||||
}
|
||||
shared.SetSerializedForCompilation(feedback_vector);
|
||||
@ -305,6 +334,12 @@ void SerializerForBackgroundCompilation::TraverseBytecode() {
|
||||
|
||||
for (; !iterator.done(); iterator.Advance()) {
|
||||
MergeAfterJump(&iterator);
|
||||
|
||||
TRACE_BROKER(broker(),
|
||||
"Handling bytecode: " << iterator.current_offset() << " "
|
||||
<< iterator.current_bytecode());
|
||||
TRACE_BROKER(broker(), "Current environment:\n" << *environment());
|
||||
|
||||
switch (iterator.current_bytecode()) {
|
||||
#define DEFINE_BYTECODE_CASE(name) \
|
||||
case interpreter::Bytecode::k##name: \
|
||||
@ -578,9 +613,6 @@ Hints SerializerForBackgroundCompilation::RunChildSerializer(
|
||||
return RunChildSerializer(function, new_target, padded, false);
|
||||
}
|
||||
|
||||
TRACE_BROKER(broker(), "Will run child serializer with environment:\n"
|
||||
<< *environment());
|
||||
|
||||
SerializerForBackgroundCompilation child_serializer(
|
||||
broker(), dependencies(), zone(), function, new_target, arguments,
|
||||
collect_source_positions());
|
||||
|
Loading…
Reference in New Issue
Block a user