Commit cb51a138 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[tracing] Don't log precise script and function snapshots.

This removes the feature that we log precise information about
functions and scripts in "v8.compile", since it comes at a
significant cost and is not going to be used anytime soon. If
we ever decide that we need this, we will have to come up with
a cheaper way of doing this.

Fixed: v8:9874
Tbr: yangguo@chromium.org
Bug: v8:8598, v8:9039, v8:9325, v8:9874
Change-Id: I3481570b6fda2a050f05d2ae84cf3e9245f67d52
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1898652Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64783}
parent 721e3825
......@@ -1562,10 +1562,6 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
}
}
script->set_eval_from_position(eval_position);
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "Script",
TRACE_ID_WITH_SCOPE(Script::kTraceScope, script->id()),
script->ToTracedValue());
parse_info.set_eval();
parse_info.set_language_mode(language_mode);
......@@ -1985,10 +1981,6 @@ Handle<Script> NewScript(Isolate* isolate, ParseInfo* parse_info,
script->set_host_defined_options(*host_defined_options);
}
LOG(isolate, ScriptDetails(*script));
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "Script",
TRACE_ID_WITH_SCOPE(Script::kTraceScope, script->id()),
script->ToTracedValue());
return script;
}
......
......@@ -132,10 +132,6 @@ void OptimizedCompilationInfo::ReopenHandlesInNewHandleScope(Isolate* isolate) {
void OptimizedCompilationInfo::AbortOptimization(BailoutReason reason) {
DCHECK_NE(reason, BailoutReason::kNoReason);
if (bailout_reason_ == BailoutReason::kNoReason) {
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.AbortOptimization", TRACE_EVENT_SCOPE_THREAD,
"reason", GetBailoutReason(reason), "function",
shared_info()->TraceIDRef());
bailout_reason_ = reason;
}
SetFlag(kDisableFutureOptimization);
......@@ -144,10 +140,6 @@ void OptimizedCompilationInfo::AbortOptimization(BailoutReason reason) {
void OptimizedCompilationInfo::RetryOptimization(BailoutReason reason) {
DCHECK_NE(reason, BailoutReason::kNoReason);
if (GetFlag(kDisableFutureOptimization)) return;
TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.RetryOptimization", TRACE_EVENT_SCOPE_THREAD,
"reason", GetBailoutReason(reason), "function",
shared_info()->TraceIDRef());
bailout_reason_ = reason;
}
......@@ -251,33 +243,5 @@ OptimizedCompilationInfo::InlinedFunctionHolder::InlinedFunctionHolder(
position.inlined_function_id = DeoptimizationData::kNotInlinedIndex;
}
std::unique_ptr<v8::tracing::TracedValue>
OptimizedCompilationInfo::ToTracedValue() {
auto value = v8::tracing::TracedValue::Create();
value->SetBoolean("osr", is_osr());
value->SetBoolean("functionContextSpecialized",
is_function_context_specializing());
if (has_shared_info()) {
value->SetValue("function", shared_info()->TraceIDRef());
}
if (bailout_reason() != BailoutReason::kNoReason) {
value->SetString("bailoutReason", GetBailoutReason(bailout_reason()));
value->SetBoolean("disableFutureOptimization",
is_disable_future_optimization());
} else {
value->SetInteger("optimizationId", optimization_id());
value->BeginArray("inlinedFunctions");
for (auto const& inlined_function : inlined_functions()) {
value->BeginDictionary();
value->SetValue("function", inlined_function.shared_info->TraceIDRef());
// TODO(bmeurer): Also include the source position from the
// {inlined_function} here as dedicated "sourcePosition" field.
value->EndDictionary();
}
value->EndArray();
}
return value;
}
} // namespace internal
} // namespace v8
......@@ -284,8 +284,6 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
trace_turbo_filename_ = std::move(filename);
}
std::unique_ptr<v8::tracing::TracedValue> ToTracedValue();
TickCounter& tick_counter() { return tick_counter_; }
private:
......
......@@ -982,24 +982,13 @@ PipelineCompilationJob::PipelineCompilationJob(
pipeline_statistics_.get()),
pipeline_(&data_),
linkage_(nullptr) {
TRACE_EVENT_WITH_FLOW1(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "v8.optimizingCompile.start",
this, TRACE_EVENT_FLAG_FLOW_OUT, "function", shared_info->TraceIDRef());
}
PipelineCompilationJob::~PipelineCompilationJob() {
TRACE_EVENT_WITH_FLOW1(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"v8.optimizingCompile.end", this,
TRACE_EVENT_FLAG_FLOW_IN, "compilationInfo",
compilation_info()->ToTracedValue());
}
PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl(
Isolate* isolate) {
TRACE_EVENT_WITH_FLOW1(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "v8.optimizingCompile.prepare",
this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, "function",
compilation_info()->shared_info()->TraceIDRef());
if (compilation_info()->bytecode_array()->length() >
FLAG_max_optimized_bytecode_size) {
return AbortOptimization(BailoutReason::kFunctionTooBig);
......@@ -1076,11 +1065,6 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl(
}
PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl() {
TRACE_EVENT_WITH_FLOW1(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "v8.optimizingCompile.execute",
this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, "function",
compilation_info()->shared_info()->TraceIDRef());
if (FLAG_concurrent_inlining) {
if (!pipeline_.CreateGraph()) {
return AbortOptimization(BailoutReason::kGraphBuildingFailed);
......@@ -1101,10 +1085,6 @@ PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl() {
PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl(
Isolate* isolate) {
TRACE_EVENT_WITH_FLOW1(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "v8.optimizingCompile.finalize",
this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, "function",
compilation_info()->shared_info()->TraceIDRef());
MaybeHandle<Code> maybe_code = pipeline_.FinalizeCode();
Handle<Code> code;
if (!maybe_code.ToHandle(&code)) {
......
......@@ -1646,9 +1646,6 @@ Handle<Script> Factory::NewScriptWithId(Handle<String> source, int script_id) {
MaybeObjectHandle::Weak(script));
heap->set_script_list(*scripts);
LOG(isolate(), ScriptEvent(Logger::ScriptEventType::kCreate, script_id));
TRACE_EVENT_OBJECT_CREATED_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "Script",
TRACE_ID_WITH_SCOPE(Script::kTraceScope, script_id));
return script;
}
......@@ -3379,15 +3376,6 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForLiteral(
SharedFunctionInfo::InitFromFunctionLiteral(shared, literal, is_toplevel);
SharedFunctionInfo::SetScript(shared, script, literal->function_literal_id(),
false);
TRACE_EVENT_OBJECT_CREATED_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "SharedFunctionInfo",
TRACE_ID_WITH_SCOPE(SharedFunctionInfo::kTraceScope,
shared->TraceID(literal)));
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "SharedFunctionInfo",
TRACE_ID_WITH_SCOPE(SharedFunctionInfo::kTraceScope,
shared->TraceID(literal)),
shared->ToTracedValue(literal));
return shared;
}
......
......@@ -4790,37 +4790,6 @@ MaybeHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
return handle(SharedFunctionInfo::cast(heap_object), isolate);
}
std::unique_ptr<v8::tracing::TracedValue> Script::ToTracedValue() {
auto value = v8::tracing::TracedValue::Create();
if (name().IsString()) {
value->SetString("name", String::cast(name()).ToCString());
}
value->SetInteger("lineOffset", line_offset());
value->SetInteger("columnOffset", column_offset());
if (source_mapping_url().IsString()) {
value->SetString("sourceMappingURL",
String::cast(source_mapping_url()).ToCString());
}
if (source().IsString()) {
value->SetString("source", String::cast(source()).ToCString());
}
return value;
}
// static
const char* Script::kTraceScope = "v8::internal::Script";
uint64_t Script::TraceID() const { return id(); }
std::unique_ptr<v8::tracing::TracedValue> Script::TraceIDRef() const {
auto value = v8::tracing::TracedValue::Create();
std::ostringstream ost;
ost << "0x" << std::hex << TraceID();
value->SetString("id_ref", ost.str());
value->SetString("scope", kTraceScope);
return value;
}
Script::Iterator::Iterator(Isolate* isolate)
: iterator_(isolate->heap()->script_list()) {}
......@@ -4841,61 +4810,6 @@ uint32_t SharedFunctionInfo::Hash() {
return static_cast<uint32_t>(base::hash_combine(start_pos, script_id));
}
std::unique_ptr<v8::tracing::TracedValue> SharedFunctionInfo::ToTracedValue(
FunctionLiteral* literal) {
auto value = v8::tracing::TracedValue::Create();
if (HasSharedName()) {
value->SetString("name", Name().ToCString());
}
if (HasInferredName()) {
value->SetString("inferredName", inferred_name().ToCString());
}
if (is_toplevel()) {
value->SetBoolean("isToplevel", true);
}
value->SetInteger("formalParameterCount", internal_formal_parameter_count());
value->SetString("languageMode", LanguageMode2String(language_mode()));
value->SetString("kind", FunctionKind2String(kind()));
if (script().IsScript()) {
value->SetValue("script", Script::cast(script()).TraceIDRef());
value->BeginDictionary("sourcePosition");
Script::PositionInfo info;
// We get the start position from the {literal} here, because the
// SharedFunctionInfo itself might not have a way to get to the
// start position early on (currently that's the case when it's
// marked for eager compilation).
if (Script::cast(script()).GetPositionInfo(literal->start_position(), &info,
Script::WITH_OFFSET)) {
value->SetInteger("line", info.line + 1);
value->SetInteger("column", info.column + 1);
}
value->EndDictionary();
}
return value;
}
// static
const char* SharedFunctionInfo::kTraceScope =
"v8::internal::SharedFunctionInfo";
uint64_t SharedFunctionInfo::TraceID(FunctionLiteral* literal) const {
int literal_id =
literal ? literal->function_literal_id() : function_literal_id();
Script script = Script::cast(this->script());
return (static_cast<uint64_t>(script.id() + 1) << 32) |
(static_cast<uint64_t>(literal_id));
}
std::unique_ptr<v8::tracing::TracedValue> SharedFunctionInfo::TraceIDRef()
const {
auto value = v8::tracing::TracedValue::Create();
std::ostringstream ost;
ost << "0x" << std::hex << TraceID();
value->SetString("id_ref", ost.str());
value->SetString("scope", kTraceScope);
return value;
}
Code SharedFunctionInfo::GetCode() const {
// ======
// NOTE: This chain of checks MUST be kept in sync with the equivalent CSA
......
......@@ -16,10 +16,6 @@
namespace v8 {
namespace tracing {
class TracedValue;
}
namespace internal {
// Script describes a script which has been added to the VM.
......@@ -194,18 +190,6 @@ class Script : public Struct {
MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(
Isolate* isolate, const FunctionLiteral* fun);
// Returns the Script in a format tracing can support.
std::unique_ptr<v8::tracing::TracedValue> ToTracedValue();
// The tracing scope for Script objects.
static const char* kTraceScope;
// Returns the unique TraceID for this Script (within the kTraceScope).
uint64_t TraceID() const;
// Returns the unique trace ID reference for this Script.
std::unique_ptr<v8::tracing::TracedValue> TraceIDRef() const;
// Iterate over all script objects on the heap.
class V8_EXPORT_PRIVATE Iterator {
public:
......
......@@ -24,10 +24,6 @@
namespace v8 {
namespace tracing {
class TracedValue;
}
namespace internal {
class AsmWasmData;
......@@ -577,22 +573,6 @@ class SharedFunctionInfo : public HeapObject {
void PrintSourceCode(std::ostream& os);
#endif
// Returns the SharedFunctionInfo in a format tracing can support.
std::unique_ptr<v8::tracing::TracedValue> ToTracedValue(
FunctionLiteral* literal);
// The tracing scope for SharedFunctionInfo objects.
static const char* kTraceScope;
// Returns the unique TraceID for this SharedFunctionInfo (within the
// kTraceScope, works only for functions that have a Script and start/end
// position).
uint64_t TraceID(FunctionLiteral* literal = nullptr) const;
// Returns the unique trace ID reference for this SharedFunctionInfo
// (based on the |TraceID()| above).
std::unique_ptr<v8::tracing::TracedValue> TraceIDRef() const;
// Iterate over all shared function infos in a given script.
class ScriptIterator {
public:
......
......@@ -156,13 +156,6 @@ void Deserializer::LogScriptEvents(Script script) {
LOG(isolate_,
ScriptEvent(Logger::ScriptEventType::kDeserialize, script.id()));
LOG(isolate_, ScriptDetails(script));
TRACE_EVENT_OBJECT_CREATED_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "Script",
TRACE_ID_WITH_SCOPE("v8::internal::Script", script.id()));
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "Script",
TRACE_ID_WITH_SCOPE("v8::internal::Script", script.id()),
script.ToTracedValue());
}
StringTableInsertionKey::StringTableInsertionKey(String string)
......
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