Commit 1dd3e29b authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[api] Use FLAG_log to check whether logging is enabled

Doing a function call into the logger to decide whether logging is
enabled or not is more costly than necessary.

This CL changes logging to take FLAG_log as main signal whether logging
could be active. If FLAG_log == false, logging cannot be active. In
that case we always call into the logger and perform detailed checks
there.

This CL changes flag-definitions to set FLAG_log if they need logging.

Change-Id: Ia51ed9fb7128451bf1dcf345fab257547aab4a47
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2602461Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72186}
parent 73c399bb
...@@ -528,7 +528,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction function, ...@@ -528,7 +528,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate, JSFunction function,
input_frame_context_(0), input_frame_context_(0),
actual_argument_count_(0), actual_argument_count_(0),
stack_fp_(0), stack_fp_(0),
trace_scope_(FLAG_trace_deopt trace_scope_(FLAG_trace_deopt || FLAG_log_deopt
? new CodeTracer::Scope(isolate->GetCodeTracer()) ? new CodeTracer::Scope(isolate->GetCodeTracer())
: nullptr) { : nullptr) {
if (isolate->deoptimizer_lazy_throw()) { if (isolate->deoptimizer_lazy_throw()) {
...@@ -783,7 +783,7 @@ void Deoptimizer::TraceDeoptEnd(double deopt_duration) { ...@@ -783,7 +783,7 @@ void Deoptimizer::TraceDeoptEnd(double deopt_duration) {
// static // static
void Deoptimizer::TraceMarkForDeoptimization(Code code, const char* reason) { void Deoptimizer::TraceMarkForDeoptimization(Code code, const char* reason) {
if (!FLAG_trace_deopt) return; if (!FLAG_trace_deopt && !FLAG_log_deopt) return;
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
Isolate* isolate = code.GetIsolate(); Isolate* isolate = code.GetIsolate();
...@@ -792,12 +792,14 @@ void Deoptimizer::TraceMarkForDeoptimization(Code code, const char* reason) { ...@@ -792,12 +792,14 @@ 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 " (", if (FLAG_trace_deopt) {
code.ptr()); PrintF(scope.file(), "[marking dependent code " V8PRIxPTR_FMT " (",
deopt_data.SharedFunctionInfo().ShortPrint(scope.file()); code.ptr());
PrintF(") (opt id %d) for deoptimization, reason: %s]\n", deopt_data.SharedFunctionInfo().ShortPrint(scope.file());
deopt_data.OptimizationId().value(), reason); PrintF(") (opt id %d) for deoptimization, reason: %s]\n",
deopt_data.OptimizationId().value(), reason);
}
if (!FLAG_log_deopt) return;
no_gc.Release(); no_gc.Release();
{ {
HandleScope scope(isolate); HandleScope scope(isolate);
......
...@@ -3885,7 +3885,8 @@ bool Isolate::NeedsDetailedOptimizedCodeLineInfo() const { ...@@ -3885,7 +3885,8 @@ bool Isolate::NeedsDetailedOptimizedCodeLineInfo() const {
bool Isolate::NeedsSourcePositionsForProfiling() const { bool Isolate::NeedsSourcePositionsForProfiling() const {
return FLAG_trace_deopt || FLAG_trace_turbo || FLAG_trace_turbo_graph || return FLAG_trace_deopt || FLAG_trace_turbo || FLAG_trace_turbo_graph ||
FLAG_turbo_profiling || FLAG_perf_prof || is_profiling() || FLAG_turbo_profiling || FLAG_perf_prof || is_profiling() ||
debug_->is_active() || logger_->is_logging() || FLAG_trace_maps; debug_->is_active() || logger_->is_logging() || FLAG_log_maps ||
FLAG_log_ic;
} }
void Isolate::SetFeedbackVectorsForProfilingTools(Object value) { void Isolate::SetFeedbackVectorsForProfilingTools(Object value) {
......
...@@ -844,9 +844,9 @@ DEFINE_INT(wasm_tier_mask_for_testing, 0, ...@@ -844,9 +844,9 @@ DEFINE_INT(wasm_tier_mask_for_testing, 0,
DEFINE_BOOL(validate_asm, true, "validate asm.js modules before compiling") DEFINE_BOOL(validate_asm, true, "validate asm.js modules before compiling")
DEFINE_BOOL(suppress_asm_messages, false, DEFINE_BOOL(suppress_asm_messages, false,
"don't emit asm.js related messages (for golden file testing)") "don't emit asm.js related messages (for golden file testing)")
DEFINE_BOOL(trace_asm_time, false, "log asm.js timing info to the console") DEFINE_BOOL(trace_asm_time, false, "print asm.js timing info to the console")
DEFINE_BOOL(trace_asm_scanner, false, DEFINE_BOOL(trace_asm_scanner, false,
"log tokens encountered by asm.js scanner") "print tokens encountered by asm.js scanner")
DEFINE_BOOL(trace_asm_parser, false, "verbose logging of asm.js parse failures") DEFINE_BOOL(trace_asm_parser, false, "verbose logging of asm.js parse failures")
DEFINE_BOOL(stress_validate_asm, false, "try to validate everything as asm.js") DEFINE_BOOL(stress_validate_asm, false, "try to validate everything as asm.js")
...@@ -1290,6 +1290,7 @@ DEFINE_BOOL(trace_opt_verbose, false, ...@@ -1290,6 +1290,7 @@ DEFINE_BOOL(trace_opt_verbose, false,
DEFINE_IMPLICATION(trace_opt_verbose, trace_opt) DEFINE_IMPLICATION(trace_opt_verbose, trace_opt)
DEFINE_BOOL(trace_opt_stats, false, "trace optimized compilation statistics") DEFINE_BOOL(trace_opt_stats, false, "trace optimized compilation statistics")
DEFINE_BOOL(trace_deopt, false, "trace deoptimization") DEFINE_BOOL(trace_deopt, false, "trace deoptimization")
DEFINE_BOOL(log_deopt, false, "log deoptimization")
DEFINE_BOOL(trace_deopt_verbose, false, "extra verbose deoptimization tracing") DEFINE_BOOL(trace_deopt_verbose, false, "extra verbose deoptimization tracing")
DEFINE_IMPLICATION(trace_deopt_verbose, trace_deopt) DEFINE_IMPLICATION(trace_deopt_verbose, trace_deopt)
DEFINE_BOOL(trace_file_names, false, DEFINE_BOOL(trace_file_names, false,
...@@ -1365,9 +1366,11 @@ DEFINE_BOOL(sampling_heap_profiler_suppress_randomness, false, ...@@ -1365,9 +1366,11 @@ DEFINE_BOOL(sampling_heap_profiler_suppress_randomness, false,
DEFINE_BOOL(use_idle_notification, true, DEFINE_BOOL(use_idle_notification, true,
"Use idle notification to reduce memory footprint.") "Use idle notification to reduce memory footprint.")
// ic.cc // ic.cc
DEFINE_BOOL(trace_ic, false, DEFINE_BOOL(log_ic, false,
"trace inline cache state transitions for tools/ic-processor") "Log inline cache state transitions for tools/ic-processor")
DEFINE_IMPLICATION(trace_ic, log_code) DEFINE_BOOL(trace_ic, false, "See --log-ic")
DEFINE_IMPLICATION(trace_ic, log_ic)
DEFINE_IMPLICATION(log_ic, log_code)
DEFINE_GENERIC_IMPLICATION( DEFINE_GENERIC_IMPLICATION(
trace_ic, TracingFlags::ic_stats.store( trace_ic, TracingFlags::ic_stats.store(
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE)) v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
...@@ -1386,9 +1389,9 @@ DEFINE_BOOL(thin_strings, true, "Enable ThinString support") ...@@ -1386,9 +1389,9 @@ DEFINE_BOOL(thin_strings, true, "Enable ThinString support")
DEFINE_BOOL(trace_prototype_users, false, DEFINE_BOOL(trace_prototype_users, false,
"Trace updates to prototype user tracking") "Trace updates to prototype user tracking")
DEFINE_BOOL(trace_for_in_enumerate, false, "Trace for-in enumerate slow-paths") DEFINE_BOOL(trace_for_in_enumerate, false, "Trace for-in enumerate slow-paths")
DEFINE_BOOL(trace_maps, false, "trace map creation") DEFINE_BOOL(log_maps, false, "Log map creation")
DEFINE_BOOL(trace_maps_details, true, "also log map details") DEFINE_BOOL(log_maps_details, true, "Also log map details")
DEFINE_IMPLICATION(trace_maps, log_code) DEFINE_IMPLICATION(log_maps, log_code)
// parser.cc // parser.cc
DEFINE_BOOL(allow_natives_syntax, false, "allow natives syntax") DEFINE_BOOL(allow_natives_syntax, false, "allow natives syntax")
...@@ -1710,6 +1713,10 @@ DEFINE_BOOL(trace_wasm_gdb_remote, false, "trace Webassembly GDB-remote server") ...@@ -1710,6 +1713,10 @@ DEFINE_BOOL(trace_wasm_gdb_remote, false, "trace Webassembly GDB-remote server")
// //
// Logging and profiling flags // Logging and profiling flags
// //
// Logging flag dependencies are are also set separately in
// V8::InitializeOncePerProcessImpl. Please add your flag to the log_all_flags
// list in v8.cc to properly set FLAG_log and automatically enable it with
// --log-all.
#undef FLAG #undef FLAG
#define FLAG FLAG_FULL #define FLAG FLAG_FULL
...@@ -1722,6 +1729,7 @@ DEFINE_BOOL(logfile_per_isolate, true, "Separate log files for each isolate.") ...@@ -1722,6 +1729,7 @@ DEFINE_BOOL(logfile_per_isolate, true, "Separate log files for each isolate.")
DEFINE_BOOL(log, false, DEFINE_BOOL(log, false,
"Minimal logging (no API, code, GC, suspect, or handles samples).") "Minimal logging (no API, code, GC, suspect, or handles samples).")
DEFINE_BOOL(log_all, false, "Log all events to the log file.") DEFINE_BOOL(log_all, false, "Log all events to the log file.")
DEFINE_BOOL(log_api, false, "Log API events to the log file.") DEFINE_BOOL(log_api, false, "Log API events to the log file.")
DEFINE_BOOL(log_code, false, DEFINE_BOOL(log_code, false,
"Log code events to the log file without profiling.") "Log code events to the log file without profiling.")
...@@ -1735,14 +1743,6 @@ DEFINE_BOOL(log_function_events, false, ...@@ -1735,14 +1743,6 @@ DEFINE_BOOL(log_function_events, false,
"Log function events " "Log function events "
"(parse, compile, execute) separately.") "(parse, compile, execute) separately.")
DEFINE_IMPLICATION(log_all, log_api)
DEFINE_IMPLICATION(log_all, log_code)
DEFINE_IMPLICATION(log_all, log_code_disassemble)
DEFINE_IMPLICATION(log_all, log_suspect)
DEFINE_IMPLICATION(log_all, log_handles)
DEFINE_IMPLICATION(log_all, log_internal_timer_events)
DEFINE_IMPLICATION(log_all, log_function_events)
DEFINE_BOOL(detailed_line_info, false, DEFINE_BOOL(detailed_line_info, false,
"Always generate detailed line information for CPU profiling.") "Always generate detailed line information for CPU profiling.")
......
...@@ -1482,7 +1482,7 @@ Map Factory::InitializeMap(Map map, InstanceType type, int instance_size, ...@@ -1482,7 +1482,7 @@ Map Factory::InitializeMap(Map map, InstanceType type, int instance_size,
map.clear_padding(); map.clear_padding();
map.set_elements_kind(elements_kind); map.set_elements_kind(elements_kind);
isolate()->counters()->maps_created()->Increment(); isolate()->counters()->maps_created()->Increment();
if (FLAG_trace_maps) LOG(isolate(), MapCreate(map)); if (FLAG_log_maps) LOG(isolate(), MapCreate(map));
return map; return map;
} }
......
...@@ -346,7 +346,7 @@ Handle<JSGlobalProxy> Bootstrapper::NewRemoteContext( ...@@ -346,7 +346,7 @@ Handle<JSGlobalProxy> Bootstrapper::NewRemoteContext(
} }
void Bootstrapper::LogAllMaps() { void Bootstrapper::LogAllMaps() {
if (!FLAG_trace_maps || isolate_->initialized_from_snapshot()) return; if (!FLAG_log_maps || isolate_->initialized_from_snapshot()) return;
// Log all created Map objects that are on the heap. For snapshots the Map // Log all created Map objects that are on the heap. For snapshots the Map
// logging happens during deserialization in order to avoid printing Maps // logging happens during deserialization in order to avoid printing Maps
// multiple times during partial deserialization. // multiple times during partial deserialization.
......
...@@ -57,6 +57,36 @@ void V8::TearDown() { ...@@ -57,6 +57,36 @@ void V8::TearDown() {
} }
void V8::InitializeOncePerProcessImpl() { void V8::InitializeOncePerProcessImpl() {
// Update logging information before enforcing flag implications.
bool* log_all_flags[] = {&FLAG_turbo_profiling_log_builtins,
&FLAG_log_all,
&FLAG_log_api,
&FLAG_log_code,
&FLAG_log_code_disassemble,
&FLAG_log_handles,
&FLAG_log_suspect,
&FLAG_log_source_code,
&FLAG_log_function_events,
&FLAG_log_internal_timer_events,
&FLAG_log_deopt,
&FLAG_log_ic,
&FLAG_log_maps};
if (FLAG_log_all) {
// Enable all logging flags
for (auto* flag : log_all_flags) {
*flag = true;
}
FLAG_log = true;
} else if (!FLAG_log) {
// Enable --log if any log flag is set.
for (const auto* flag : log_all_flags) {
if (!*flag) continue;
FLAG_log = true;
break;
}
FLAG_log |= FLAG_perf_basic_prof || FLAG_prof || FLAG_prof_cpp;
}
FlagList::EnforceFlagImplications(); FlagList::EnforceFlagImplications();
if (FLAG_predictable && FLAG_random_seed == 0) { if (FLAG_predictable && FLAG_random_seed == 0) {
......
...@@ -25,7 +25,7 @@ const char* const Log::kLogToConsole = "-"; ...@@ -25,7 +25,7 @@ const char* const Log::kLogToConsole = "-";
// static // static
FILE* Log::CreateOutputHandle(std::string file_name) { FILE* Log::CreateOutputHandle(std::string file_name) {
// If we're logging anything, we need to open the log file. // If we're logging anything, we need to open the log file.
if (!Log::InitLogAtStart()) { if (!FLAG_log) {
return nullptr; return nullptr;
} else if (Log::IsLoggingToConsole(file_name)) { } else if (Log::IsLoggingToConsole(file_name)) {
return stdout; return stdout;
......
...@@ -32,15 +32,6 @@ class Log { ...@@ -32,15 +32,6 @@ class Log {
public: public:
explicit Log(Logger* logger, std::string log_file_name); explicit Log(Logger* logger, std::string log_file_name);
static bool InitLogAtStart() {
return FLAG_log || FLAG_log_all || FLAG_log_api || FLAG_log_code ||
FLAG_log_handles || FLAG_log_suspect || FLAG_ll_prof ||
FLAG_perf_basic_prof || FLAG_perf_prof || FLAG_log_source_code ||
FLAG_gdbjit || FLAG_log_internal_timer_events || FLAG_prof_cpp ||
FLAG_trace_ic || FLAG_log_function_events || FLAG_trace_zone_stats ||
FLAG_turbo_profiling_log_builtins;
}
V8_EXPORT_PRIVATE static bool IsLoggingToConsole(std::string file_name); V8_EXPORT_PRIVATE static bool IsLoggingToConsole(std::string file_name);
V8_EXPORT_PRIVATE static bool IsLoggingToTemporaryFile(std::string file_name); V8_EXPORT_PRIVATE static bool IsLoggingToTemporaryFile(std::string file_name);
......
...@@ -1030,10 +1030,7 @@ void Logger::UncheckedStringEvent(const char* name, const char* value) { ...@@ -1030,10 +1030,7 @@ void Logger::UncheckedStringEvent(const char* name, const char* value) {
} }
void Logger::IntPtrTEvent(const char* name, intptr_t value) { void Logger::IntPtrTEvent(const char* name, intptr_t value) {
if (FLAG_log) UncheckedIntPtrTEvent(name, value); if (!FLAG_log) return;
}
void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) {
MSG_BUILDER(); MSG_BUILDER();
msg << name << kNext; msg << name << kNext;
msg.AppendFormatString("%" V8PRIdPTR, value); msg.AppendFormatString("%" V8PRIdPTR, value);
...@@ -1470,7 +1467,7 @@ void Logger::ProcessDeoptEvent(Handle<Code> code, SourcePosition position, ...@@ -1470,7 +1467,7 @@ void Logger::ProcessDeoptEvent(Handle<Code> code, SourcePosition position,
void Logger::CodeDeoptEvent(Handle<Code> code, DeoptimizeKind kind, Address pc, void Logger::CodeDeoptEvent(Handle<Code> code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta, bool reuse_code) { int fp_to_sp_delta, bool reuse_code) {
if (!is_logging()) return; if (!is_logging() || !FLAG_log_deopt) return;
Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(*code, pc); Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(*code, pc);
ProcessDeoptEvent(code, info.position, ProcessDeoptEvent(code, info.position,
Deoptimizer::MessageFor(kind, reuse_code), Deoptimizer::MessageFor(kind, reuse_code),
...@@ -1480,7 +1477,7 @@ void Logger::CodeDeoptEvent(Handle<Code> code, DeoptimizeKind kind, Address pc, ...@@ -1480,7 +1477,7 @@ void Logger::CodeDeoptEvent(Handle<Code> code, DeoptimizeKind kind, Address pc,
void Logger::CodeDependencyChangeEvent(Handle<Code> code, void Logger::CodeDependencyChangeEvent(Handle<Code> code,
Handle<SharedFunctionInfo> sfi, Handle<SharedFunctionInfo> sfi,
const char* reason) { const char* reason) {
if (!is_logging()) return; if (!is_logging() || !FLAG_log_deopt) return;
SourcePosition position(sfi->StartPosition(), -1); SourcePosition position(sfi->StartPosition(), -1);
ProcessDeoptEvent(code, position, "dependency-change", reason); ProcessDeoptEvent(code, position, "dependency-change", reason);
} }
...@@ -1488,41 +1485,41 @@ void Logger::CodeDependencyChangeEvent(Handle<Code> code, ...@@ -1488,41 +1485,41 @@ void Logger::CodeDependencyChangeEvent(Handle<Code> code,
namespace { namespace {
void CodeLinePosEvent( void CodeLinePosEvent(
JitLogger* jit_logger, Address code_start, JitLogger& jit_logger, Address code_start,
SourcePositionTableIterator& iter) { // NOLINT(runtime/references) SourcePositionTableIterator& iter) { // NOLINT(runtime/references)
if (jit_logger) { void* jit_handler_data = jit_logger.StartCodePosInfoEvent();
void* jit_handler_data = jit_logger->StartCodePosInfoEvent(); for (; !iter.done(); iter.Advance()) {
for (; !iter.done(); iter.Advance()) { if (iter.is_statement()) {
if (iter.is_statement()) { jit_logger.AddCodeLinePosInfoEvent(jit_handler_data, iter.code_offset(),
jit_logger->AddCodeLinePosInfoEvent( iter.source_position().ScriptOffset(),
jit_handler_data, iter.code_offset(), JitCodeEvent::STATEMENT_POSITION);
iter.source_position().ScriptOffset(),
JitCodeEvent::STATEMENT_POSITION);
}
jit_logger->AddCodeLinePosInfoEvent(jit_handler_data, iter.code_offset(),
iter.source_position().ScriptOffset(),
JitCodeEvent::POSITION);
} }
jit_logger->EndCodePosInfoEvent(code_start, jit_handler_data); jit_logger.AddCodeLinePosInfoEvent(jit_handler_data, iter.code_offset(),
iter.source_position().ScriptOffset(),
JitCodeEvent::POSITION);
} }
jit_logger.EndCodePosInfoEvent(code_start, jit_handler_data);
} }
} // namespace } // namespace
void Logger::CodeLinePosInfoRecordEvent(Address code_start, void Logger::CodeLinePosInfoRecordEvent(Address code_start,
ByteArray source_position_table) { ByteArray source_position_table) {
if (!jit_logger_) return;
SourcePositionTableIterator iter(source_position_table); SourcePositionTableIterator iter(source_position_table);
CodeLinePosEvent(jit_logger_.get(), code_start, iter); CodeLinePosEvent(*jit_logger_, code_start, iter);
} }
void Logger::CodeLinePosInfoRecordEvent( void Logger::CodeLinePosInfoRecordEvent(
Address code_start, Vector<const byte> source_position_table) { Address code_start, Vector<const byte> source_position_table) {
if (!jit_logger_) return;
SourcePositionTableIterator iter(source_position_table); SourcePositionTableIterator iter(source_position_table);
CodeLinePosEvent(jit_logger_.get(), code_start, iter); CodeLinePosEvent(*jit_logger_, code_start, iter);
} }
void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) { void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) {
if (code_name == nullptr) return; // Not a code object. if (code_name == nullptr) return; // Not a code object.
if (!is_listening_to_code_events()) return;
MSG_BUILDER(); MSG_BUILDER();
msg << kLogEventsNames[CodeEventListener::SNAPSHOT_CODE_NAME_EVENT] << kNext msg << kLogEventsNames[CodeEventListener::SNAPSHOT_CODE_NAME_EVENT] << kNext
<< pos << kNext << code_name; << pos << kNext << code_name;
...@@ -1727,7 +1724,7 @@ void Logger::TickEvent(TickSample* sample, bool overflow) { ...@@ -1727,7 +1724,7 @@ void Logger::TickEvent(TickSample* sample, bool overflow) {
void Logger::ICEvent(const char* type, bool keyed, Handle<Map> map, void Logger::ICEvent(const char* type, bool keyed, Handle<Map> map,
Handle<Object> key, char old_state, char new_state, Handle<Object> key, char old_state, char new_state,
const char* modifier, const char* slow_stub_reason) { const char* modifier, const char* slow_stub_reason) {
if (!FLAG_trace_ic) return; if (!FLAG_log_ic) return;
MSG_BUILDER(); MSG_BUILDER();
if (keyed) msg << "Keyed"; if (keyed) msg << "Keyed";
int line; int line;
...@@ -1753,7 +1750,7 @@ void Logger::ICEvent(const char* type, bool keyed, Handle<Map> map, ...@@ -1753,7 +1750,7 @@ void Logger::ICEvent(const char* type, bool keyed, Handle<Map> map,
void Logger::MapEvent(const char* type, Handle<Map> from, Handle<Map> to, void Logger::MapEvent(const char* type, Handle<Map> from, Handle<Map> to,
const char* reason, Handle<HeapObject> name_or_sfi) { const char* reason, Handle<HeapObject> name_or_sfi) {
if (!FLAG_trace_maps) return; if (!FLAG_log_maps) return;
if (!to.is_null()) MapDetails(*to); if (!to.is_null()) MapDetails(*to);
int line = -1; int line = -1;
int column = -1; int column = -1;
...@@ -1784,7 +1781,7 @@ void Logger::MapEvent(const char* type, Handle<Map> from, Handle<Map> to, ...@@ -1784,7 +1781,7 @@ void Logger::MapEvent(const char* type, Handle<Map> from, Handle<Map> to,
} }
void Logger::MapCreate(Map map) { void Logger::MapCreate(Map map) {
if (!FLAG_trace_maps) return; if (!FLAG_log_maps) return;
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
MSG_BUILDER(); MSG_BUILDER();
msg << "map-create" << kNext << Time() << kNext << AsHex::Address(map.ptr()); msg << "map-create" << kNext << Time() << kNext << AsHex::Address(map.ptr());
...@@ -1792,12 +1789,12 @@ void Logger::MapCreate(Map map) { ...@@ -1792,12 +1789,12 @@ void Logger::MapCreate(Map map) {
} }
void Logger::MapDetails(Map map) { void Logger::MapDetails(Map map) {
if (!FLAG_trace_maps) return; if (!FLAG_log_maps) return;
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
MSG_BUILDER(); MSG_BUILDER();
msg << "map-details" << kNext << Time() << kNext << AsHex::Address(map.ptr()) msg << "map-details" << kNext << Time() << kNext << AsHex::Address(map.ptr())
<< kNext; << kNext;
if (FLAG_trace_maps_details) { if (FLAG_log_maps_details) {
std::ostringstream buffer; std::ostringstream buffer;
map.PrintMapDetails(buffer); map.PrintMapDetails(buffer);
msg << buffer.str().c_str(); msg << buffer.str().c_str();
...@@ -2008,21 +2005,16 @@ bool Logger::SetUp(Isolate* isolate) { ...@@ -2008,21 +2005,16 @@ bool Logger::SetUp(Isolate* isolate) {
std::make_unique<LowLevelLogger>(isolate, log_file_name.str().c_str()); std::make_unique<LowLevelLogger>(isolate, log_file_name.str().c_str());
AddCodeEventListener(ll_logger_.get()); AddCodeEventListener(ll_logger_.get());
} }
ticker_ = std::make_unique<Ticker>(isolate, FLAG_prof_sampling_interval); ticker_ = std::make_unique<Ticker>(isolate, FLAG_prof_sampling_interval);
if (FLAG_log) UpdateIsLogging(true);
if (Log::InitLogAtStart()) UpdateIsLogging(true);
timer_.Start(); timer_.Start();
if (FLAG_prof_cpp) { if (FLAG_prof_cpp) {
UpdateIsLogging(true); CHECK(FLAG_log);
CHECK(is_logging());
profiler_ = std::make_unique<Profiler>(isolate); profiler_ = std::make_unique<Profiler>(isolate);
profiler_->Engage(); profiler_->Engage();
} }
if (is_logging_) AddCodeEventListener(this); if (is_logging_) AddCodeEventListener(this);
return true; return true;
} }
......
...@@ -72,10 +72,9 @@ class SourcePosition; ...@@ -72,10 +72,9 @@ class SourcePosition;
class Ticker; class Ticker;
#undef LOG #undef LOG
#define LOG(isolate, Call) \ #define LOG(isolate, Call) \
do { \ do { \
auto&& logger = (isolate)->logger(); \ if (v8::internal::FLAG_log) (isolate)->logger()->Call; \
if (logger->is_logging()) logger->Call; \
} while (false) } while (false)
#define LOG_CODE_EVENT(isolate, Call) \ #define LOG_CODE_EVENT(isolate, Call) \
...@@ -305,9 +304,6 @@ class Logger : public CodeEventListener { ...@@ -305,9 +304,6 @@ class Logger : public CodeEventListener {
// Logs a StringEvent regardless of whether FLAG_log is true. // Logs a StringEvent regardless of whether FLAG_log is true.
void UncheckedStringEvent(const char* name, const char* value); void UncheckedStringEvent(const char* name, const char* value);
// Logs an IntPtrTEvent regardless of whether FLAG_log is true.
void UncheckedIntPtrTEvent(const char* name, intptr_t value);
// Logs a scripts sources. Keeps track of all logged scripts to ensure that // Logs a scripts sources. Keeps track of all logged scripts to ensure that
// each script is logged only once. // each script is logged only once.
bool EnsureLogScriptSource(Script script); bool EnsureLogScriptSource(Script script);
......
...@@ -450,7 +450,7 @@ void JSFunction::SetInitialMap(Handle<JSFunction> function, Handle<Map> map, ...@@ -450,7 +450,7 @@ void JSFunction::SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
} }
function->set_prototype_or_initial_map(*map); function->set_prototype_or_initial_map(*map);
map->SetConstructor(*function); map->SetConstructor(*function);
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("InitialMap", Handle<Map>(), map, "", LOG(isolate, MapEvent("InitialMap", Handle<Map>(), map, "",
SharedFunctionInfo::DebugName( SharedFunctionInfo::DebugName(
handle(function->shared(), isolate)))); handle(function->shared(), isolate))));
......
...@@ -3541,7 +3541,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object, ...@@ -3541,7 +3541,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
object->SetProperties(ReadOnlyRoots(isolate).empty_fixed_array()); object->SetProperties(ReadOnlyRoots(isolate).empty_fixed_array());
// Check that it really works. // Check that it really works.
DCHECK(object->HasFastProperties()); DCHECK(object->HasFastProperties());
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("SlowToFast", old_map, new_map, reason)); LOG(isolate, MapEvent("SlowToFast", old_map, new_map, reason));
} }
return; return;
...@@ -3650,7 +3650,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object, ...@@ -3650,7 +3650,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
new_map->SetOutOfObjectUnusedPropertyFields(unused_property_fields); new_map->SetOutOfObjectUnusedPropertyFields(unused_property_fields);
} }
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("SlowToFast", old_map, new_map, reason)); LOG(isolate, MapEvent("SlowToFast", old_map, new_map, reason));
} }
// Transform the object. // Transform the object.
......
...@@ -613,7 +613,7 @@ void Map::DeprecateTransitionTree(Isolate* isolate) { ...@@ -613,7 +613,7 @@ void Map::DeprecateTransitionTree(Isolate* isolate) {
DCHECK(!constructor_or_backpointer().IsFunctionTemplateInfo()); DCHECK(!constructor_or_backpointer().IsFunctionTemplateInfo());
DCHECK(CanBeDeprecated()); DCHECK(CanBeDeprecated());
set_is_deprecated(true); set_is_deprecated(true);
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("Deprecate", handle(*this, isolate), Handle<Map>())); LOG(isolate, MapEvent("Deprecate", handle(*this, isolate), Handle<Map>()));
} }
dependent_code().DeoptimizeDependentCodeGroup( dependent_code().DeoptimizeDependentCodeGroup(
...@@ -1537,7 +1537,7 @@ Handle<Map> Map::Normalize(Isolate* isolate, Handle<Map> fast_map, ...@@ -1537,7 +1537,7 @@ Handle<Map> Map::Normalize(Isolate* isolate, Handle<Map> fast_map,
Map::kSize - offset)); Map::kSize - offset));
} }
#endif #endif
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("NormalizeCached", fast_map, new_map, reason)); LOG(isolate, MapEvent("NormalizeCached", fast_map, new_map, reason));
} }
} else { } else {
...@@ -1547,7 +1547,7 @@ Handle<Map> Map::Normalize(Isolate* isolate, Handle<Map> fast_map, ...@@ -1547,7 +1547,7 @@ Handle<Map> Map::Normalize(Isolate* isolate, Handle<Map> fast_map,
cache->Set(fast_map, new_map); cache->Set(fast_map, new_map);
isolate->counters()->maps_normalized()->Increment(); isolate->counters()->maps_normalized()->Increment();
} }
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("Normalize", fast_map, new_map, reason)); LOG(isolate, MapEvent("Normalize", fast_map, new_map, reason));
} }
} }
...@@ -1729,12 +1729,12 @@ void Map::ConnectTransition(Isolate* isolate, Handle<Map> parent, ...@@ -1729,12 +1729,12 @@ void Map::ConnectTransition(Isolate* isolate, Handle<Map> parent,
} }
if (parent->IsDetached(isolate)) { if (parent->IsDetached(isolate)) {
DCHECK(child->IsDetached(isolate)); DCHECK(child->IsDetached(isolate));
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("Transition", parent, child, "prototype", name)); LOG(isolate, MapEvent("Transition", parent, child, "prototype", name));
} }
} else { } else {
TransitionsAccessor(isolate, parent).Insert(name, child, flag); TransitionsAccessor(isolate, parent).Insert(name, child, flag);
if (FLAG_trace_maps) { if (FLAG_log_maps) {
LOG(isolate, MapEvent("Transition", parent, child, "", name)); LOG(isolate, MapEvent("Transition", parent, child, "", name));
} }
} }
...@@ -1772,7 +1772,7 @@ Handle<Map> Map::CopyReplaceDescriptors( ...@@ -1772,7 +1772,7 @@ Handle<Map> Map::CopyReplaceDescriptors(
LayoutDescriptor::FastPointerLayout()); LayoutDescriptor::FastPointerLayout());
} }
} }
if (FLAG_trace_maps && !is_connected) { if (FLAG_log_maps && !is_connected) {
LOG(isolate, MapEvent("ReplaceDescriptors", map, result, reason, LOG(isolate, MapEvent("ReplaceDescriptors", map, result, reason,
maybe_name.is_null() ? Handle<HeapObject>() : name)); maybe_name.is_null() ? Handle<HeapObject>() : name));
} }
...@@ -2198,7 +2198,7 @@ Handle<Map> Map::TransitionToDataProperty(Isolate* isolate, Handle<Map> map, ...@@ -2198,7 +2198,7 @@ Handle<Map> Map::TransitionToDataProperty(Isolate* isolate, Handle<Map> map,
const char* reason = "TooManyFastProperties"; const char* reason = "TooManyFastProperties";
#if V8_TRACE_MAPS #if V8_TRACE_MAPS
std::unique_ptr<ScopedVector<char>> buffer; std::unique_ptr<ScopedVector<char>> buffer;
if (FLAG_trace_maps) { if (FLAG_log_maps) {
ScopedVector<char> name_buffer(100); ScopedVector<char> name_buffer(100);
name->NameShortPrint(name_buffer); name->NameShortPrint(name_buffer);
buffer.reset(new ScopedVector<char>(128)); buffer.reset(new ScopedVector<char>(128));
......
...@@ -660,7 +660,7 @@ MaybeHandle<Object> DefineClass( ...@@ -660,7 +660,7 @@ MaybeHandle<Object> DefineClass(
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return MaybeHandle<Object>(); return MaybeHandle<Object>();
} }
if (FLAG_trace_maps) { if (FLAG_log_maps) {
Handle<Map> empty_map; Handle<Map> empty_map;
LOG(isolate, LOG(isolate,
MapEvent("InitialMap", empty_map, handle(constructor->map(), isolate), MapEvent("InitialMap", empty_map, handle(constructor->map(), isolate),
......
...@@ -282,7 +282,7 @@ void Deserializer::DeserializeDeferredObjects() { ...@@ -282,7 +282,7 @@ void Deserializer::DeserializeDeferredObjects() {
void Deserializer::LogNewMapEvents() { void Deserializer::LogNewMapEvents() {
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
for (Handle<Map> map : new_maps_) { for (Handle<Map> map : new_maps_) {
DCHECK(FLAG_trace_maps); DCHECK(FLAG_log_maps);
LOG(isolate(), MapCreate(*map)); LOG(isolate(), MapCreate(*map));
LOG(isolate(), MapDetails(*map)); LOG(isolate(), MapDetails(*map));
} }
...@@ -387,7 +387,7 @@ void Deserializer::PostProcessNewObject(Handle<Map> map, Handle<HeapObject> obj, ...@@ -387,7 +387,7 @@ void Deserializer::PostProcessNewObject(Handle<Map> map, Handle<HeapObject> obj,
new_code_objects_.push_back(Handle<Code>::cast(obj)); new_code_objects_.push_back(Handle<Code>::cast(obj));
} }
} else if (InstanceTypeChecker::IsMap(instance_type)) { } else if (InstanceTypeChecker::IsMap(instance_type)) {
if (FLAG_trace_maps) { if (FLAG_log_maps) {
// Keep track of all seen Maps to log them later since they might be only // Keep track of all seen Maps to log them later since they might be only
// partially initialized at this point. // partially initialized at this point.
new_maps_.push_back(Handle<Map>::cast(obj)); new_maps_.push_back(Handle<Map>::cast(obj));
......
...@@ -99,7 +99,7 @@ void StartupDeserializer::DeserializeStringTable() { ...@@ -99,7 +99,7 @@ void StartupDeserializer::DeserializeStringTable() {
} }
void StartupDeserializer::LogNewMapEvents() { void StartupDeserializer::LogNewMapEvents() {
if (FLAG_trace_maps) LOG(isolate(), LogAllMaps()); if (FLAG_log_maps) LOG(isolate(), LogAllMaps());
} }
void StartupDeserializer::FlushICache() { void StartupDeserializer::FlushICache() {
......
...@@ -504,6 +504,7 @@ UNINITIALIZED_TEST(Issue539892) { ...@@ -504,6 +504,7 @@ UNINITIALIZED_TEST(Issue539892) {
UNINITIALIZED_TEST(LogAll) { UNINITIALIZED_TEST(LogAll) {
SETUP_FLAGS(); SETUP_FLAGS();
i::FLAG_log_all = true; i::FLAG_log_all = true;
i::FLAG_log_deopt = true;
i::FLAG_log_api = true; i::FLAG_log_api = true;
i::FLAG_turbo_inlining = false; i::FLAG_turbo_inlining = false;
i::FLAG_log_internal_timer_events = true; i::FLAG_log_internal_timer_events = true;
...@@ -802,7 +803,7 @@ UNINITIALIZED_TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) { ...@@ -802,7 +803,7 @@ UNINITIALIZED_TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
UNINITIALIZED_TEST(TraceMaps) { UNINITIALIZED_TEST(TraceMaps) {
SETUP_FLAGS(); SETUP_FLAGS();
i::FLAG_trace_maps = true; i::FLAG_log_maps = true;
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
...@@ -837,7 +838,7 @@ UNINITIALIZED_TEST(TraceMaps) { ...@@ -837,7 +838,7 @@ UNINITIALIZED_TEST(TraceMaps) {
CHECK(logger.ContainsLine({"map,Transition", ",0x"})); CHECK(logger.ContainsLine({"map,Transition", ",0x"}));
CHECK(logger.ContainsLine({"map-details", ",0x"})); CHECK(logger.ContainsLine({"map-details", ",0x"}));
} }
i::FLAG_trace_maps = false; i::FLAG_log_maps = false;
isolate->Dispose(); isolate->Dispose();
} }
...@@ -895,7 +896,7 @@ UNINITIALIZED_TEST(LogMapsDetailsStartup) { ...@@ -895,7 +896,7 @@ UNINITIALIZED_TEST(LogMapsDetailsStartup) {
} }
// Test that all Map details from Maps in the snapshot are logged properly. // Test that all Map details from Maps in the snapshot are logged properly.
SETUP_FLAGS(); SETUP_FLAGS();
i::FLAG_trace_maps = true; i::FLAG_log_maps = true;
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
...@@ -917,7 +918,7 @@ UNINITIALIZED_TEST(LogMapsDetailsCode) { ...@@ -917,7 +918,7 @@ UNINITIALIZED_TEST(LogMapsDetailsCode) {
} }
SETUP_FLAGS(); SETUP_FLAGS();
i::FLAG_retain_maps_for_n_gc = 0xFFFFFFF; i::FLAG_retain_maps_for_n_gc = 0xFFFFFFF;
i::FLAG_trace_maps = true; i::FLAG_log_maps = true;
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
...@@ -1014,7 +1015,7 @@ UNINITIALIZED_TEST(LogMapsDetailsContexts) { ...@@ -1014,7 +1015,7 @@ UNINITIALIZED_TEST(LogMapsDetailsContexts) {
} }
// Test that all Map details from Maps in the snapshot are logged properly. // Test that all Map details from Maps in the snapshot are logged properly.
SETUP_FLAGS(); SETUP_FLAGS();
i::FLAG_trace_maps = true; i::FLAG_log_maps = true;
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params); v8::Isolate* isolate = v8::Isolate::New(create_params);
......
...@@ -175,7 +175,7 @@ found in the LICENSE file. --> ...@@ -175,7 +175,7 @@ found in the LICENSE file. -->
<dd>Enable all V8 logging options.</dd> <dd>Enable all V8 logging options.</dd>
<dt> <dt>
<a href="https://source.chromium.org/search?q=FLAG_trace_maps"> <a href="https://source.chromium.org/search?q=FLAG_trace_maps">
<code>--trace-maps</code> <code>--log-maps</code>
</a> </a>
</dt> </dt>
<dd> <dd>
...@@ -183,7 +183,7 @@ found in the LICENSE file. --> ...@@ -183,7 +183,7 @@ found in the LICENSE file. -->
</dd> </dd>
<dt> <dt>
<a href="https://source.chromium.org/search?q=FLAG_trace_ic"> <a href="https://source.chromium.org/search?q=FLAG_trace_ic">
<code>--trace-ic</code> <code>--log-ic</code>
</a> </a>
</dt> </dt>
<dd> <dd>
...@@ -206,6 +206,12 @@ found in the LICENSE file. --> ...@@ -206,6 +206,12 @@ found in the LICENSE file. -->
<code>--log-api</code> <code>--log-api</code>
</a> </a>
</dt> </dt>
<dd>Log details about deoptimized code</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_log_deopt">
<code>--log-deopt</code>
</a>
</dt>
<dd>Log various API uses.</dd> <dd>Log various API uses.</dd>
</dl> </dl>
......
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