[compiler] Introduce --trace-code-dependencies

This is helpful for debugging. At the moment it reports any
installations of code dependencies and, by implying
--trace-deopt-verbose, any deopts due to dependency changes.

Change-Id: I910a6dc165cc3586eaf7e5f322c90924359ae6ba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2519566
Auto-Submit: Georg Neis <neis@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70983}
This commit is contained in:
Georg Neis 2020-11-04 18:21:41 +01:00 committed by Commit Bot
parent 2dc1799585
commit 77a77f050a
4 changed files with 12 additions and 3 deletions

View File

@ -739,10 +739,10 @@ void Deoptimizer::TraceMarkForDeoptimization(Code code, const char* reason) {
DeoptimizationData deopt_data = DeoptimizationData::cast(maybe_data); DeoptimizationData deopt_data = DeoptimizationData::cast(maybe_data);
CodeTracer::Scope scope(isolate->GetCodeTracer()); CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintF(scope.file(), "[marking dependent code " V8PRIxPTR_FMT " ", PrintF(scope.file(), "[marking dependent code " V8PRIxPTR_FMT " (",
code.ptr()); code.ptr());
deopt_data.SharedFunctionInfo().ShortPrint(scope.file()); deopt_data.SharedFunctionInfo().ShortPrint(scope.file());
PrintF(" (opt id %d) for deoptimization, reason: %s]\n", PrintF(") (opt id %d) for deoptimization, reason: %s]\n",
deopt_data.OptimizationId().value(), reason); deopt_data.OptimizationId().value(), reason);
{ {
AllowHeapAllocation yes_gc; AllowHeapAllocation yes_gc;

View File

@ -448,6 +448,10 @@ DEFINE_NEG_IMPLICATION(jitless, interpreted_frames_native_stack)
DEFINE_BOOL(assert_types, false, DEFINE_BOOL(assert_types, false,
"generate runtime type assertions to test the typer") "generate runtime type assertions to test the typer")
DEFINE_BOOL(trace_code_dependencies, false, "trace code dependencies")
// Depend on --trace-deopt-verbose for reporting dependency invalidations.
DEFINE_IMPLICATION(trace_code_dependencies, trace_deopt_verbose)
// Flags for experimental implementation features. // Flags for experimental implementation features.
DEFINE_BOOL(allocation_site_pretenuring, true, DEFINE_BOOL(allocation_site_pretenuring, true,
"pretenure with allocation sites") "pretenure with allocation sites")

View File

@ -943,6 +943,11 @@ void DependentCode::InstallDependency(Isolate* isolate,
const MaybeObjectHandle& code, const MaybeObjectHandle& code,
Handle<HeapObject> object, Handle<HeapObject> object,
DependencyGroup group) { DependencyGroup group) {
if (V8_UNLIKELY(FLAG_trace_code_dependencies)) {
StdoutStream{} << "Installing dependency of [" << code->GetHeapObject()
<< "] on [" << object << "] in group ["
<< DependencyGroupName(group) << "]\n";
}
Handle<DependentCode> old_deps(DependentCode::GetDependentCode(object), Handle<DependentCode> old_deps(DependentCode::GetDependentCode(object),
isolate); isolate);
Handle<DependentCode> new_deps = Handle<DependentCode> new_deps =

View File

@ -641,7 +641,7 @@ class DependentCode : public WeakFixedArray {
kAllocationSiteTransitionChangedGroup kAllocationSiteTransitionChangedGroup
}; };
// Register a code dependency of {cell} on {object}. // Register a dependency of {code} on {object}, of the kind given by {group}.
V8_EXPORT_PRIVATE static void InstallDependency(Isolate* isolate, V8_EXPORT_PRIVATE static void InstallDependency(Isolate* isolate,
const MaybeObjectHandle& code, const MaybeObjectHandle& code,
Handle<HeapObject> object, Handle<HeapObject> object,