From a6f579eb2e51b0315e74cbd65252a297e8868626 Mon Sep 17 00:00:00 2001 From: Georg Neis Date: Wed, 26 Jul 2017 17:44:10 +0200 Subject: [PATCH] [modules] Add --trace-module-status for printing status transitions. This is for debugging only. R=adamk@chromium.org Bug: v8:1569 Change-Id: I6526d3a98e96bb1267f1850268c5dc83a64587a6 Reviewed-on: https://chromium-review.googlesource.com/586590 Commit-Queue: Georg Neis Reviewed-by: Adam Klein Cr-Commit-Position: refs/heads/master@{#46906} --- src/flag-definitions.h | 2 ++ src/objects.cc | 20 ++++++++++++++++++++ src/objects.h | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/src/flag-definitions.h b/src/flag-definitions.h index ddd7de9bcb..760382ec19 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -1080,6 +1080,8 @@ DEFINE_BOOL(print_global_handles, false, "report global handles after GC") DEFINE_BOOL(trace_turbo_escape, false, "enable tracing in escape analysis") // objects.cc +DEFINE_BOOL(trace_module_status, false, + "Trace status transitions of ECMAScript modules") DEFINE_BOOL(trace_normalization, false, "prints when objects are turned into dictionaries.") diff --git a/src/objects.cc b/src/objects.cc index 775e2fe2a2..20701ad933 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -19662,10 +19662,27 @@ void Module::StoreVariable(Handle module, int cell_index, module->GetCell(cell_index)->set_value(*value); } +#ifdef DEBUG +void Module::PrintStatusTransition(Status new_status) { + if (FLAG_trace_module_status) { + OFStream os(stdout); + os << "Changing module status from " << status() << " to " << new_status + << " for "; + script()->GetNameOrSourceURL()->Print(os); +#ifndef OBJECT_PRINT + os << "\n"; +#endif // OBJECT_PRINT + } +} +#endif // DEBUG + void Module::SetStatus(Status new_status) { DisallowHeapAllocation no_alloc; DCHECK_LE(status(), new_status); DCHECK_NE(new_status, Module::kErrored); +#ifdef DEBUG + PrintStatusTransition(new_status); +#endif // DEBUG set_status(new_status); } @@ -19692,6 +19709,9 @@ void Module::RecordError() { set_code(info()); DCHECK(exception()->IsTheHole(isolate)); +#ifdef DEBUG + PrintStatusTransition(Module::kErrored); +#endif // DEBUG set_status(Module::kErrored); set_exception(the_exception); } diff --git a/src/objects.h b/src/objects.h index 95f565a352..848d4aba50 100644 --- a/src/objects.h +++ b/src/objects.h @@ -5057,6 +5057,11 @@ class Module : public Struct { void SetStatus(Status status); void RecordError(); +#ifdef DEBUG + // For --trace-module-status. + void PrintStatusTransition(Status new_status); +#endif // DEBUG + DISALLOW_IMPLICIT_CONSTRUCTORS(Module); };