V8 Project
v8::internal::Log Class Reference

#include <log-utils.h>

+ Collaboration diagram for v8::internal::Log:

Classes

class  BASE_EMBEDDED
 

Public Member Functions

void Initialize (const char *log_file_name)
 
void stop ()
 
FILE * Close ()
 
bool IsEnabled ()
 

Static Public Member Functions

static bool InitLogAtStart ()
 

Static Public Attributes

static const int kMessageBufferSize = 2048
 
static const char *const kLogToTemporaryFile = "&"
 
static const char *const kLogToConsole = "-"
 

Private Member Functions

 Log (Logger *logger)
 
void OpenStdout ()
 
void OpenFile (const char *name)
 
void OpenTemporaryFile ()
 
int WriteToFile (const char *msg, int length)
 

Private Attributes

bool is_stopped_
 
FILE * output_handle_
 
base::Mutex mutex_
 
char * message_buffer_
 
Loggerlogger_
 

Friends

class Logger
 

Detailed Description

Definition at line 16 of file log-utils.h.

Constructor & Destructor Documentation

◆ Log()

v8::internal::Log::Log ( Logger logger)
explicitprivate

Definition at line 18 of file log-utils.cc.

19  : is_stopped_(false),
22  logger_(logger) {
23 }
Logger * logger_
Definition: log-utils.h:129
FILE * output_handle_
Definition: log-utils.h:119
char * message_buffer_
Definition: log-utils.h:127
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

Member Function Documentation

◆ Close()

FILE * v8::internal::Log::Close ( )

Definition at line 74 of file log-utils.cc.

74  {
75  FILE* result = NULL;
76  if (output_handle_ != NULL) {
77  if (strcmp(FLAG_logfile, kLogToTemporaryFile) != 0) {
78  fclose(output_handle_);
79  } else {
80  result = output_handle_;
81  }
82  }
84 
87 
88  is_stopped_ = false;
89  return result;
90 }
static const char *const kLogToTemporaryFile
Definition: log-utils.h:46
void DeleteArray(T *array)
Definition: allocation.h:68

References v8::internal::DeleteArray(), is_stopped_, kLogToTemporaryFile, message_buffer_, NULL, and output_handle_.

Referenced by v8::internal::Logger::TearDown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Initialize()

void v8::internal::Log::Initialize ( const char *  log_file_name)

Definition at line 26 of file log-utils.cc.

26  {
27  message_buffer_ = NewArray<char>(kMessageBufferSize);
28 
29  // --log-all enables all the log flags.
30  if (FLAG_log_all) {
31  FLAG_log_api = true;
32  FLAG_log_code = true;
33  FLAG_log_gc = true;
34  FLAG_log_suspect = true;
35  FLAG_log_handles = true;
36  FLAG_log_regexp = true;
37  FLAG_log_internal_timer_events = true;
38  }
39 
40  // --prof implies --log-code.
41  if (FLAG_prof) FLAG_log_code = true;
42 
43  // If we're logging anything, we need to open the log file.
44  if (Log::InitLogAtStart()) {
45  if (strcmp(log_file_name, kLogToConsole) == 0) {
46  OpenStdout();
47  } else if (strcmp(log_file_name, kLogToTemporaryFile) == 0) {
49  } else {
50  OpenFile(log_file_name);
51  }
52  }
53 }
void OpenTemporaryFile()
Definition: log-utils.cc:62
static const int kMessageBufferSize
Definition: log-utils.h:42
void OpenFile(const char *name)
Definition: log-utils.cc:68
static bool InitLogAtStart()
Definition: log-utils.h:24
static const char *const kLogToConsole
Definition: log-utils.h:47

References InitLogAtStart(), kLogToConsole, kLogToTemporaryFile, kMessageBufferSize, message_buffer_, OpenFile(), OpenStdout(), and OpenTemporaryFile().

Referenced by v8::internal::Logger::SetUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitLogAtStart()

static bool v8::internal::Log::InitLogAtStart ( )
inlinestatic

Definition at line 24 of file log-utils.h.

24  {
25  return FLAG_log || FLAG_log_api || FLAG_log_code || FLAG_log_gc
26  || FLAG_log_handles || FLAG_log_suspect || FLAG_log_regexp
27  || FLAG_ll_prof || FLAG_perf_basic_prof || FLAG_perf_jit_prof
28  || FLAG_log_internal_timer_events;
29  }

Referenced by Initialize(), and v8::internal::Logger::SetUp().

+ Here is the caller graph for this function:

◆ IsEnabled()

bool v8::internal::Log::IsEnabled ( )
inline

Definition at line 37 of file log-utils.h.

37  {
38  return !is_stopped_ && output_handle_ != NULL;
39  }

References is_stopped_, NULL, and output_handle_.

Referenced by v8::internal::Logger::ApiEntryCall(), v8::internal::Logger::ApiEvent(), v8::internal::Logger::ApiIndexedPropertyAccess(), v8::internal::Logger::ApiIndexedSecurityCheck(), v8::internal::Logger::ApiNamedPropertyAccess(), v8::internal::Logger::ApiNamedSecurityCheck(), v8::internal::Logger::ApiObjectAccess(), v8::internal::Logger::CallbackEventInternal(), v8::internal::Logger::CodeCreateEvent(), v8::internal::Logger::CodeDeleteEvent(), v8::internal::Logger::CodeDeoptEvent(), v8::internal::Logger::CodeDisableOptEvent(), v8::internal::Logger::CodeMovingGCEvent(), v8::internal::Logger::CurrentTimeEvent(), v8::internal::Logger::DebugEvent(), v8::internal::Logger::DebugTag(), v8::internal::Logger::DeleteEvent(), v8::internal::Logger::HandleEvent(), v8::internal::Logger::HeapSampleBeginEvent(), v8::internal::Logger::HeapSampleEndEvent(), v8::internal::Logger::HeapSampleItemEvent(), v8::internal::Logger::MoveEventInternal(), v8::internal::Logger::NewEvent(), OpenFile(), OpenStdout(), OpenTemporaryFile(), v8::internal::Logger::ProfilerBeginEvent(), v8::internal::Logger::RegExpCodeCreateEvent(), v8::internal::Logger::RegExpCompileEvent(), v8::internal::Logger::ResourceEvent(), v8::internal::Logger::SharedLibraryEvent(), v8::internal::Logger::SnapshotPositionEvent(), v8::internal::Logger::StopProfiler(), v8::internal::Logger::SuspectReadEvent(), v8::internal::Logger::TickEvent(), v8::internal::Logger::TimerEvent(), v8::internal::Logger::UncheckedIntEvent(), v8::internal::Logger::UncheckedIntPtrTEvent(), and v8::internal::Logger::UncheckedStringEvent().

+ Here is the caller graph for this function:

◆ OpenFile()

void v8::internal::Log::OpenFile ( const char *  name)
private

Definition at line 68 of file log-utils.cc.

68  {
69  DCHECK(!IsEnabled());
71 }
static const char *const LogFileOpenMode
Definition: platform.h:187
static FILE * FOpen(const char *path, const char *mode)
bool IsEnabled()
Definition: log-utils.h:37
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, v8::base::OS::FOpen(), IsEnabled(), v8::base::OS::LogFileOpenMode, name, and output_handle_.

Referenced by Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OpenStdout()

void v8::internal::Log::OpenStdout ( )
private

Definition at line 56 of file log-utils.cc.

56  {
57  DCHECK(!IsEnabled());
58  output_handle_ = stdout;
59 }

References DCHECK, IsEnabled(), and output_handle_.

Referenced by Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OpenTemporaryFile()

void v8::internal::Log::OpenTemporaryFile ( )
private

Definition at line 62 of file log-utils.cc.

62  {
63  DCHECK(!IsEnabled());
65 }
static FILE * OpenTemporaryFile()

References DCHECK, IsEnabled(), v8::base::OS::OpenTemporaryFile(), and output_handle_.

Referenced by Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void v8::internal::Log::stop ( )
inline

Definition at line 22 of file log-utils.h.

22 { is_stopped_ = true; }

References is_stopped_.

◆ WriteToFile()

int v8::internal::Log::WriteToFile ( const char *  msg,
int  length 
)
inlineprivate

Definition at line 105 of file log-utils.h.

105  {
107  size_t rv = fwrite(msg, 1, length, output_handle_);
108  DCHECK(static_cast<size_t>(length) == rv);
109  USE(rv);
110  fflush(output_handle_);
111  return length;
112  }
void USE(T)
Definition: macros.h:322

References DCHECK, NULL, output_handle_, and USE().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Logger

friend class Logger
friend

Definition at line 131 of file log-utils.h.

Member Data Documentation

◆ is_stopped_

bool v8::internal::Log::is_stopped_
private

Definition at line 115 of file log-utils.h.

Referenced by Close(), IsEnabled(), and stop().

◆ kLogToConsole

const char *const v8::internal::Log::kLogToConsole = "-"
static

Definition at line 47 of file log-utils.h.

Referenced by Initialize().

◆ kLogToTemporaryFile

const char *const v8::internal::Log::kLogToTemporaryFile = "&"
static

Definition at line 46 of file log-utils.h.

Referenced by Close(), and Initialize().

◆ kMessageBufferSize

const int v8::internal::Log::kMessageBufferSize = 2048
static

Definition at line 42 of file log-utils.h.

Referenced by Initialize().

◆ logger_

Logger* v8::internal::Log::logger_
private

Definition at line 129 of file log-utils.h.

◆ message_buffer_

char* v8::internal::Log::message_buffer_
private

Definition at line 127 of file log-utils.h.

Referenced by Close(), and Initialize().

◆ mutex_

base::Mutex v8::internal::Log::mutex_
private

Definition at line 123 of file log-utils.h.

◆ output_handle_

FILE* v8::internal::Log::output_handle_
private

Definition at line 119 of file log-utils.h.

Referenced by Close(), IsEnabled(), OpenFile(), OpenStdout(), OpenTemporaryFile(), and WriteToFile().


The documentation for this class was generated from the following files: