2012-02-23 09:12:57 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_LOG_H_
|
|
|
|
#define V8_LOG_H_
|
|
|
|
|
2014-06-12 17:06:24 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
2014-06-30 13:25:46 +00:00
|
|
|
#include "src/base/platform/elapsed-timer.h"
|
|
|
|
#include "src/base/platform/platform.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/objects.h"
|
2009-06-24 13:09:34 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
2014-06-30 13:25:46 +00:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class Semaphore;
|
|
|
|
}
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Logger is used for collecting logging information from V8 during
|
|
|
|
// execution. The result is dumped to a file.
|
|
|
|
//
|
|
|
|
// Available command line flags:
|
|
|
|
//
|
|
|
|
// --log
|
|
|
|
// Minimal logging (no API, code, or GC sample events), default is off.
|
|
|
|
//
|
|
|
|
// --log-all
|
|
|
|
// Log all events to the file, default is off. This is the same as combining
|
2008-09-11 12:57:27 +00:00
|
|
|
// --log-api, --log-code, --log-gc, and --log-regexp.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
|
|
|
// --log-api
|
|
|
|
// Log API events to the logfile, default is off. --log-api implies --log.
|
|
|
|
//
|
|
|
|
// --log-code
|
|
|
|
// Log code (create, move, and delete) events to the logfile, default is off.
|
|
|
|
// --log-code implies --log.
|
|
|
|
//
|
|
|
|
// --log-gc
|
|
|
|
// Log GC heap samples after each GC that can be processed by hp2ps, default
|
|
|
|
// is off. --log-gc implies --log.
|
|
|
|
//
|
2008-09-11 12:57:27 +00:00
|
|
|
// --log-regexp
|
2008-09-11 13:00:30 +00:00
|
|
|
// Log creation and use of regular expressions, Default is off.
|
2008-09-11 12:57:27 +00:00
|
|
|
// --log-regexp implies --log.
|
|
|
|
//
|
2008-07-03 15:10:15 +00:00
|
|
|
// --logfile <filename>
|
|
|
|
// Specify the name of the logfile, default is "v8.log".
|
|
|
|
//
|
|
|
|
// --prof
|
|
|
|
// Collect statistical profiling information (ticks), default is off. The
|
|
|
|
// tick profiler requires code events, so --prof implies --log-code.
|
|
|
|
|
|
|
|
// Forward declarations.
|
2013-07-26 13:50:23 +00:00
|
|
|
class CodeEventListener;
|
2013-07-18 17:19:31 +00:00
|
|
|
class CompilationInfo;
|
|
|
|
class CpuProfiler;
|
|
|
|
class Isolate;
|
|
|
|
class Log;
|
|
|
|
class PositionsRecorder;
|
2008-07-03 15:10:15 +00:00
|
|
|
class Profiler;
|
2011-04-29 16:06:25 +00:00
|
|
|
class Ticker;
|
2013-07-18 17:19:31 +00:00
|
|
|
struct TickSample;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#undef LOG
|
2011-03-18 20:35:07 +00:00
|
|
|
#define LOG(isolate, Call) \
|
|
|
|
do { \
|
|
|
|
v8::internal::Logger* logger = \
|
|
|
|
(isolate)->logger(); \
|
|
|
|
if (logger->is_logging()) \
|
|
|
|
logger->Call; \
|
2009-01-06 13:24:52 +00:00
|
|
|
} while (false)
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-08-28 14:43:28 +00:00
|
|
|
#define LOG_CODE_EVENT(isolate, Call) \
|
|
|
|
do { \
|
|
|
|
v8::internal::Logger* logger = \
|
|
|
|
(isolate)->logger(); \
|
|
|
|
if (logger->is_logging_code_events()) \
|
|
|
|
logger->Call; \
|
|
|
|
} while (false)
|
|
|
|
|
2016-03-09 16:51:02 +00:00
|
|
|
#define LOG_EVENTS_AND_TAGS_LIST(V) \
|
|
|
|
V(CODE_CREATION_EVENT, "code-creation") \
|
|
|
|
V(CODE_DISABLE_OPT_EVENT, "code-disable-optimization") \
|
|
|
|
V(CODE_MOVE_EVENT, "code-move") \
|
|
|
|
V(CODE_DELETE_EVENT, "code-delete") \
|
|
|
|
V(CODE_MOVING_GC, "code-moving-gc") \
|
|
|
|
V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \
|
|
|
|
V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \
|
|
|
|
V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \
|
|
|
|
V(TICK_EVENT, "tick") \
|
|
|
|
V(REPEAT_META_EVENT, "repeat") \
|
|
|
|
V(BUILTIN_TAG, "Builtin") \
|
|
|
|
V(CALL_DEBUG_BREAK_TAG, "CallDebugBreak") \
|
|
|
|
V(CALL_DEBUG_PREPARE_STEP_IN_TAG, "CallDebugPrepareStepIn") \
|
|
|
|
V(CALL_INITIALIZE_TAG, "CallInitialize") \
|
|
|
|
V(CALL_MEGAMORPHIC_TAG, "CallMegamorphic") \
|
|
|
|
V(CALL_MISS_TAG, "CallMiss") \
|
|
|
|
V(CALL_NORMAL_TAG, "CallNormal") \
|
|
|
|
V(CALL_PRE_MONOMORPHIC_TAG, "CallPreMonomorphic") \
|
|
|
|
V(LOAD_INITIALIZE_TAG, "LoadInitialize") \
|
|
|
|
V(LOAD_PREMONOMORPHIC_TAG, "LoadPreMonomorphic") \
|
|
|
|
V(LOAD_MEGAMORPHIC_TAG, "LoadMegamorphic") \
|
|
|
|
V(STORE_INITIALIZE_TAG, "StoreInitialize") \
|
|
|
|
V(STORE_PREMONOMORPHIC_TAG, "StorePreMonomorphic") \
|
|
|
|
V(STORE_GENERIC_TAG, "StoreGeneric") \
|
|
|
|
V(STORE_MEGAMORPHIC_TAG, "StoreMegamorphic") \
|
|
|
|
V(KEYED_CALL_DEBUG_BREAK_TAG, "KeyedCallDebugBreak") \
|
|
|
|
V(KEYED_CALL_DEBUG_PREPARE_STEP_IN_TAG, "KeyedCallDebugPrepareStepIn") \
|
|
|
|
V(KEYED_CALL_INITIALIZE_TAG, "KeyedCallInitialize") \
|
|
|
|
V(KEYED_CALL_MEGAMORPHIC_TAG, "KeyedCallMegamorphic") \
|
|
|
|
V(KEYED_CALL_MISS_TAG, "KeyedCallMiss") \
|
|
|
|
V(KEYED_CALL_NORMAL_TAG, "KeyedCallNormal") \
|
|
|
|
V(KEYED_CALL_PRE_MONOMORPHIC_TAG, "KeyedCallPreMonomorphic") \
|
|
|
|
V(CALLBACK_TAG, "Callback") \
|
|
|
|
V(EVAL_TAG, "Eval") \
|
|
|
|
V(FUNCTION_TAG, "Function") \
|
|
|
|
V(HANDLER_TAG, "Handler") \
|
|
|
|
V(BYTECODE_HANDLER_TAG, "BytecodeHandler") \
|
|
|
|
V(KEYED_LOAD_IC_TAG, "KeyedLoadIC") \
|
|
|
|
V(KEYED_LOAD_POLYMORPHIC_IC_TAG, "KeyedLoadPolymorphicIC") \
|
|
|
|
V(KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, "KeyedExternalArrayLoadIC") \
|
|
|
|
V(KEYED_STORE_IC_TAG, "KeyedStoreIC") \
|
|
|
|
V(KEYED_STORE_POLYMORPHIC_IC_TAG, "KeyedStorePolymorphicIC") \
|
|
|
|
V(KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, "KeyedExternalArrayStoreIC") \
|
|
|
|
V(LAZY_COMPILE_TAG, "LazyCompile") \
|
|
|
|
V(CALL_IC_TAG, "CallIC") \
|
|
|
|
V(LOAD_IC_TAG, "LoadIC") \
|
|
|
|
V(LOAD_POLYMORPHIC_IC_TAG, "LoadPolymorphicIC") \
|
|
|
|
V(REG_EXP_TAG, "RegExp") \
|
|
|
|
V(SCRIPT_TAG, "Script") \
|
|
|
|
V(STORE_IC_TAG, "StoreIC") \
|
|
|
|
V(STORE_POLYMORPHIC_IC_TAG, "StorePolymorphicIC") \
|
|
|
|
V(STUB_TAG, "Stub") \
|
|
|
|
V(NATIVE_FUNCTION_TAG, "Function") \
|
|
|
|
V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \
|
|
|
|
V(NATIVE_SCRIPT_TAG, "Script")
|
2010-04-14 18:48:05 +00:00
|
|
|
// Note that 'NATIVE_' cases for functions and scripts are mapped onto
|
|
|
|
// original tags when writing to the log.
|
|
|
|
|
2010-04-12 07:23:43 +00:00
|
|
|
|
2013-07-18 13:18:46 +00:00
|
|
|
class JitLogger;
|
2013-11-25 06:44:23 +00:00
|
|
|
class PerfBasicLogger;
|
2013-07-15 11:35:39 +00:00
|
|
|
class LowLevelLogger;
|
2011-03-18 20:35:07 +00:00
|
|
|
class Sampler;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
class Logger {
|
|
|
|
public:
|
2014-07-16 08:14:50 +00:00
|
|
|
enum StartEnd { START = 0, END = 1 };
|
|
|
|
|
2010-12-07 13:24:22 +00:00
|
|
|
#define DECLARE_ENUM(enum_item, ignore) enum_item,
|
2009-06-08 13:39:48 +00:00
|
|
|
enum LogEventsAndTags {
|
|
|
|
LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM)
|
|
|
|
NUMBER_OF_LOG_EVENTS
|
|
|
|
};
|
|
|
|
#undef DECLARE_ENUM
|
|
|
|
|
2009-05-05 15:57:47 +00:00
|
|
|
// Acquires resources for logging if the right flags are set.
|
2013-04-24 14:44:08 +00:00
|
|
|
bool SetUp(Isolate* isolate);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2012-08-28 14:43:28 +00:00
|
|
|
// Sets the current code event handler.
|
|
|
|
void SetCodeEventHandler(uint32_t options,
|
|
|
|
JitCodeEventHandler event_handler);
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Sampler* sampler();
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2012-01-13 13:09:52 +00:00
|
|
|
// Frees resources acquired in SetUp.
|
2011-07-13 11:31:22 +00:00
|
|
|
// When a temporary file is used for the log, returns its stream descriptor,
|
|
|
|
// leaving the file open.
|
|
|
|
FILE* TearDown();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Emits an event with a string value -> (name, value).
|
2011-03-18 20:35:07 +00:00
|
|
|
void StringEvent(const char* name, const char* value);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Emits an event with an int value -> (name, value).
|
2011-03-18 20:35:07 +00:00
|
|
|
void IntEvent(const char* name, int value);
|
|
|
|
void IntPtrTEvent(const char* name, intptr_t value);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Emits an event with an handle value -> (name, location).
|
2011-03-18 20:35:07 +00:00
|
|
|
void HandleEvent(const char* name, Object** location);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Emits memory management events for C allocated structures.
|
2011-03-18 20:35:07 +00:00
|
|
|
void NewEvent(const char* name, void* object, size_t size);
|
|
|
|
void DeleteEvent(const char* name, void* object);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Emits an event with a tag, and some resource usage information.
|
|
|
|
// -> (name, tag, <rusage information>).
|
|
|
|
// Currently, the resource usage information is a process time stamp
|
|
|
|
// and a real time timestamp.
|
2011-03-18 20:35:07 +00:00
|
|
|
void ResourceEvent(const char* name, const char* tag);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Emits an event that an undefined property was read from an
|
|
|
|
// object.
|
2013-03-04 15:00:57 +00:00
|
|
|
void SuspectReadEvent(Name* name, Object* obj);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-08-06 10:02:49 +00:00
|
|
|
// Emits an event when a message is put on or read from a debugging queue.
|
|
|
|
// DebugTag lets us put a call-site specific label on the event.
|
2011-03-18 20:35:07 +00:00
|
|
|
void DebugTag(const char* call_site_tag);
|
|
|
|
void DebugEvent(const char* event_type, Vector<uint16_t> parameter);
|
2008-08-06 10:02:49 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// ==== Events logged by --log-api. ====
|
2015-02-26 10:34:44 +00:00
|
|
|
void ApiSecurityCheck();
|
2011-03-18 20:35:07 +00:00
|
|
|
void ApiNamedPropertyAccess(const char* tag, JSObject* holder, Object* name);
|
|
|
|
void ApiIndexedPropertyAccess(const char* tag,
|
|
|
|
JSObject* holder,
|
|
|
|
uint32_t index);
|
|
|
|
void ApiObjectAccess(const char* tag, JSObject* obj);
|
|
|
|
void ApiEntryCall(const char* name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ==== Events logged by --log-code. ====
|
2013-07-26 13:50:23 +00:00
|
|
|
void addCodeEventListener(CodeEventListener* listener);
|
|
|
|
void removeCodeEventListener(CodeEventListener* listener);
|
|
|
|
bool hasCodeEventListener(CodeEventListener* listener);
|
|
|
|
|
|
|
|
|
2009-11-20 12:15:46 +00:00
|
|
|
// Emits a code event for a callback function.
|
2013-03-04 15:00:57 +00:00
|
|
|
void CallbackEvent(Name* name, Address entry_point);
|
|
|
|
void GetterCallbackEvent(Name* name, Address entry_point);
|
|
|
|
void SetterCallbackEvent(Name* name, Address entry_point);
|
2008-07-03 15:10:15 +00:00
|
|
|
// Emits a code create event.
|
2016-02-26 11:04:04 +00:00
|
|
|
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
const char* source);
|
|
|
|
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, Name* name);
|
|
|
|
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
SharedFunctionInfo* shared, CompilationInfo* info,
|
2013-03-04 15:00:57 +00:00
|
|
|
Name* name);
|
2016-02-26 11:04:04 +00:00
|
|
|
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
SharedFunctionInfo* shared, CompilationInfo* info,
|
2013-08-23 17:20:54 +00:00
|
|
|
Name* source, int line, int column);
|
2016-02-26 11:04:04 +00:00
|
|
|
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
int args_count);
|
2014-05-22 05:36:27 +00:00
|
|
|
// Emits a code deoptimization event.
|
2016-02-26 11:04:04 +00:00
|
|
|
void CodeDisableOptEvent(AbstractCode* code, SharedFunctionInfo* shared);
|
2011-03-18 20:35:07 +00:00
|
|
|
void CodeMovingGCEvent();
|
2009-03-31 09:06:37 +00:00
|
|
|
// Emits a code create event for a RegExp.
|
2016-02-26 11:04:04 +00:00
|
|
|
void RegExpCodeCreateEvent(AbstractCode* code, String* source);
|
2008-07-03 15:10:15 +00:00
|
|
|
// Emits a code move event.
|
2016-02-26 11:04:04 +00:00
|
|
|
void CodeMoveEvent(AbstractCode* from, Address to);
|
2013-02-18 18:06:12 +00:00
|
|
|
// Emits a code line info add event with Postion type.
|
|
|
|
void CodeLinePosInfoAddPositionEvent(void* jit_handler_data,
|
|
|
|
int pc_offset,
|
|
|
|
int position);
|
|
|
|
// Emits a code line info add event with StatementPostion type.
|
|
|
|
void CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data,
|
|
|
|
int pc_offset,
|
|
|
|
int position);
|
|
|
|
// Emits a code line info start to record event
|
|
|
|
void CodeStartLinePosInfoRecordEvent(PositionsRecorder* pos_recorder);
|
|
|
|
// Emits a code line info finish record event.
|
|
|
|
// It's the callee's responsibility to dispose the parameter jit_handler_data.
|
2016-02-26 11:04:04 +00:00
|
|
|
void CodeEndLinePosInfoRecordEvent(AbstractCode* code,
|
|
|
|
void* jit_handler_data);
|
2011-02-22 16:31:24 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
void SharedFunctionInfoMoveEvent(Address from, Address to);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-07-26 13:50:23 +00:00
|
|
|
void CodeNameEvent(Address addr, int pos, const char* code_name);
|
2016-03-02 20:10:21 +00:00
|
|
|
void SnapshotPositionEvent(HeapObject* obj, int pos);
|
2010-01-18 16:04:25 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// ==== Events logged by --log-gc. ====
|
|
|
|
// Heap sampling events: start, end, and individual types.
|
2011-03-18 20:35:07 +00:00
|
|
|
void HeapSampleBeginEvent(const char* space, const char* kind);
|
|
|
|
void HeapSampleEndEvent(const char* space, const char* kind);
|
|
|
|
void HeapSampleItemEvent(const char* type, int number, int bytes);
|
|
|
|
void HeapSampleJSConstructorEvent(const char* constructor,
|
|
|
|
int number, int bytes);
|
|
|
|
void HeapSampleJSRetainersEvent(const char* constructor,
|
2009-09-18 12:05:18 +00:00
|
|
|
const char* event);
|
2011-03-18 20:35:07 +00:00
|
|
|
void HeapSampleJSProducerEvent(const char* constructor,
|
|
|
|
Address* stack);
|
|
|
|
void HeapSampleStats(const char* space, const char* kind,
|
|
|
|
intptr_t capacity, intptr_t used);
|
|
|
|
|
2014-06-12 17:06:24 +00:00
|
|
|
void SharedLibraryEvent(const std::string& library_path,
|
2011-03-18 20:35:07 +00:00
|
|
|
uintptr_t start,
|
|
|
|
uintptr_t end);
|
2012-11-28 11:01:10 +00:00
|
|
|
|
2015-03-09 14:43:29 +00:00
|
|
|
void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta);
|
2014-06-13 09:07:56 +00:00
|
|
|
void CurrentTimeEvent();
|
2013-07-03 10:10:27 +00:00
|
|
|
|
2013-01-28 13:55:40 +00:00
|
|
|
void TimerEvent(StartEnd se, const char* name);
|
2012-11-22 13:04:11 +00:00
|
|
|
|
2013-04-24 14:44:08 +00:00
|
|
|
static void EnterExternal(Isolate* isolate);
|
|
|
|
static void LeaveExternal(Isolate* isolate);
|
2012-11-28 15:11:21 +00:00
|
|
|
|
2014-10-15 11:16:42 +00:00
|
|
|
static void DefaultEventLoggerSentinel(const char* name, int event) {}
|
|
|
|
|
|
|
|
INLINE(static void CallEventLogger(Isolate* isolate, const char* name,
|
|
|
|
StartEnd se, bool expose_to_api));
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-09-11 11:24:45 +00:00
|
|
|
// ==== Events logged by --log-regexp ====
|
|
|
|
// Regexp compilation and execution events.
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache);
|
2008-09-11 11:24:45 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
bool is_logging() {
|
2013-08-29 10:42:55 +00:00
|
|
|
return is_logging_;
|
2009-06-24 13:09:34 +00:00
|
|
|
}
|
2009-01-06 13:24:52 +00:00
|
|
|
|
2012-08-28 14:43:28 +00:00
|
|
|
bool is_logging_code_events() {
|
2013-07-18 13:18:46 +00:00
|
|
|
return is_logging() || jit_logger_ != NULL;
|
2012-08-28 14:43:28 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 10:42:55 +00:00
|
|
|
// Stop collection of profiling data.
|
|
|
|
// When data collection is paused, CPU Tick events are discarded.
|
|
|
|
void StopProfiler();
|
2009-01-29 19:47:00 +00:00
|
|
|
|
2011-09-14 11:47:03 +00:00
|
|
|
void LogExistingFunction(Handle<SharedFunctionInfo> shared,
|
2016-02-26 11:04:04 +00:00
|
|
|
Handle<AbstractCode> code);
|
2009-05-20 09:04:13 +00:00
|
|
|
// Logs all compiled functions found in the heap.
|
2011-03-18 20:35:07 +00:00
|
|
|
void LogCompiledFunctions();
|
2009-11-25 16:39:18 +00:00
|
|
|
// Logs all accessor callbacks found in the heap.
|
2011-03-18 20:35:07 +00:00
|
|
|
void LogAccessorCallbacks();
|
2009-11-11 12:35:50 +00:00
|
|
|
// Used for logging stubs found in the snapshot.
|
2011-03-18 20:35:07 +00:00
|
|
|
void LogCodeObjects();
|
2016-03-09 16:51:02 +00:00
|
|
|
// Used for logging bytecode handlers found in the snapshot.
|
|
|
|
void LogBytecodeHandlers();
|
2009-05-20 09:04:13 +00:00
|
|
|
|
2010-04-07 14:18:26 +00:00
|
|
|
// Converts tag to a corresponding NATIVE_... if the script is native.
|
|
|
|
INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*));
|
|
|
|
|
2009-05-29 06:56:23 +00:00
|
|
|
// Profiler's sampling interval (in milliseconds).
|
2011-12-01 07:30:57 +00:00
|
|
|
#if defined(ANDROID)
|
|
|
|
// Phones and tablets have processors that are much slower than desktop
|
|
|
|
// and laptop computers for which current heuristics are tuned.
|
|
|
|
static const int kSamplingIntervalMs = 5;
|
|
|
|
#else
|
2009-05-29 06:56:23 +00:00
|
|
|
static const int kSamplingIntervalMs = 1;
|
2011-12-01 07:30:57 +00:00
|
|
|
#endif
|
2009-05-29 06:56:23 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
// Callback from Log, stops profiling in case of insufficient resources.
|
|
|
|
void LogFailure();
|
|
|
|
|
2010-04-15 11:37:29 +00:00
|
|
|
private:
|
2013-02-15 09:27:10 +00:00
|
|
|
explicit Logger(Isolate* isolate);
|
2011-03-18 20:35:07 +00:00
|
|
|
~Logger();
|
2010-04-15 11:37:29 +00:00
|
|
|
|
2009-05-29 06:56:23 +00:00
|
|
|
// Emits the profiler's first message.
|
2011-03-18 20:35:07 +00:00
|
|
|
void ProfilerBeginEvent();
|
2009-05-29 06:56:23 +00:00
|
|
|
|
2009-11-25 16:39:18 +00:00
|
|
|
// Emits callback event messages.
|
2011-03-18 20:35:07 +00:00
|
|
|
void CallbackEventInternal(const char* prefix,
|
2013-03-04 15:00:57 +00:00
|
|
|
Name* name,
|
2011-03-18 20:35:07 +00:00
|
|
|
Address entry_point);
|
2009-11-25 16:39:18 +00:00
|
|
|
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
// Internal configurable move event.
|
2011-03-18 20:35:07 +00:00
|
|
|
void MoveEventInternal(LogEventsAndTags event, Address from, Address to);
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
|
2010-02-04 21:34:03 +00:00
|
|
|
// Used for logging stubs found in the snapshot.
|
2011-03-18 20:35:07 +00:00
|
|
|
void LogCodeObject(Object* code_object);
|
2010-02-04 21:34:03 +00:00
|
|
|
|
2013-06-24 08:40:38 +00:00
|
|
|
// Helper method. It resets name_buffer_ and add tag name into it.
|
|
|
|
void InitNameBuffer(LogEventsAndTags tag);
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Emits a profiler tick event. Used by the profiler thread.
|
2011-03-18 20:35:07 +00:00
|
|
|
void TickEvent(TickSample* sample, bool overflow);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
void ApiEvent(const char* name, ...);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-02-11 07:38:31 +00:00
|
|
|
// Logs a StringEvent regardless of whether FLAG_log is true.
|
2011-03-18 20:35:07 +00:00
|
|
|
void UncheckedStringEvent(const char* name, const char* value);
|
2009-02-11 07:38:31 +00:00
|
|
|
|
2010-03-01 10:41:34 +00:00
|
|
|
// Logs an IntEvent regardless of whether FLAG_log is true.
|
2011-03-18 20:35:07 +00:00
|
|
|
void UncheckedIntEvent(const char* name, int value);
|
|
|
|
void UncheckedIntPtrTEvent(const char* name, intptr_t value);
|
2009-05-28 13:56:32 +00:00
|
|
|
|
2013-02-15 09:27:10 +00:00
|
|
|
Isolate* isolate_;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// The sampler used by the profiler and the sliding state window.
|
2011-03-18 20:35:07 +00:00
|
|
|
Ticker* ticker_;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// When the statistical profile is active, profiler_
|
|
|
|
// points to a Profiler, that handles collection
|
|
|
|
// of samples.
|
2011-03-18 20:35:07 +00:00
|
|
|
Profiler* profiler_;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
// An array of log events names.
|
|
|
|
const char* const* log_events_;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Internal implementation classes with access to
|
|
|
|
// private members.
|
|
|
|
friend class EventLog;
|
2011-03-18 20:35:07 +00:00
|
|
|
friend class Isolate;
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class TimeLog;
|
|
|
|
friend class Profiler;
|
2013-04-24 14:44:08 +00:00
|
|
|
template <StateTag Tag> friend class VMState;
|
2009-05-25 08:25:36 +00:00
|
|
|
friend class LoggerTestHelper;
|
2009-06-24 13:09:34 +00:00
|
|
|
|
2013-08-29 10:42:55 +00:00
|
|
|
bool is_logging_;
|
2011-03-18 20:35:07 +00:00
|
|
|
Log* log_;
|
2013-11-25 06:44:23 +00:00
|
|
|
PerfBasicLogger* perf_basic_logger_;
|
2013-07-15 11:35:39 +00:00
|
|
|
LowLevelLogger* ll_logger_;
|
2013-07-18 13:18:46 +00:00
|
|
|
JitLogger* jit_logger_;
|
2013-07-26 13:50:23 +00:00
|
|
|
List<CodeEventListener*> listeners_;
|
2011-04-29 16:06:25 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
// Guards against multiple calls to TearDown() that can happen in some tests.
|
2012-01-13 13:09:52 +00:00
|
|
|
// 'true' between SetUp() and TearDown().
|
2011-03-18 20:35:07 +00:00
|
|
|
bool is_initialized_;
|
|
|
|
|
2014-06-30 13:25:46 +00:00
|
|
|
base::ElapsedTimer timer_;
|
2012-11-22 13:04:11 +00:00
|
|
|
|
2010-04-06 10:36:38 +00:00
|
|
|
friend class CpuProfiler;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
2014-07-16 08:14:50 +00:00
|
|
|
#define TIMER_EVENTS_LIST(V) \
|
|
|
|
V(RecompileSynchronous, true) \
|
|
|
|
V(RecompileConcurrent, true) \
|
2016-03-18 15:34:00 +00:00
|
|
|
V(CompileIgnition, true) \
|
2014-07-16 08:14:50 +00:00
|
|
|
V(CompileFullCode, true) \
|
2016-02-05 12:22:01 +00:00
|
|
|
V(OptimizeCode, true) \
|
2016-02-15 17:29:22 +00:00
|
|
|
V(CompileCode, true) \
|
|
|
|
V(DeoptimizeCode, true) \
|
2014-07-16 08:14:50 +00:00
|
|
|
V(Execute, true) \
|
|
|
|
V(External, true) \
|
|
|
|
V(IcMiss, false)
|
|
|
|
|
|
|
|
#define V(TimerName, expose) \
|
|
|
|
class TimerEvent##TimerName : public AllStatic { \
|
|
|
|
public: \
|
|
|
|
static const char* name(void* unused = NULL) { return "V8." #TimerName; } \
|
|
|
|
static bool expose_to_api() { return expose; } \
|
|
|
|
};
|
|
|
|
TIMER_EVENTS_LIST(V)
|
|
|
|
#undef V
|
|
|
|
|
|
|
|
|
|
|
|
template <class TimerEvent>
|
|
|
|
class TimerEventScope {
|
|
|
|
public:
|
|
|
|
explicit TimerEventScope(Isolate* isolate) : isolate_(isolate) {
|
|
|
|
LogTimerEvent(Logger::START);
|
|
|
|
}
|
|
|
|
|
|
|
|
~TimerEventScope() { LogTimerEvent(Logger::END); }
|
|
|
|
|
|
|
|
void LogTimerEvent(Logger::StartEnd se);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Isolate* isolate_;
|
|
|
|
};
|
|
|
|
|
2016-03-02 02:10:03 +00:00
|
|
|
class PositionsRecorder BASE_EMBEDDED {
|
|
|
|
public:
|
|
|
|
PositionsRecorder() { jit_handler_data_ = NULL; }
|
|
|
|
|
|
|
|
void AttachJITHandlerData(void* user_data) { jit_handler_data_ = user_data; }
|
|
|
|
|
|
|
|
void* DetachJITHandlerData() {
|
|
|
|
void* old_data = jit_handler_data_;
|
|
|
|
jit_handler_data_ = NULL;
|
|
|
|
return old_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Currently jit_handler_data_ is used to store JITHandler-specific data
|
|
|
|
// over the lifetime of a PositionsRecorder
|
|
|
|
void* jit_handler_data_;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PositionsRecorder);
|
|
|
|
};
|
2014-07-16 08:14:50 +00:00
|
|
|
|
2013-07-26 13:50:23 +00:00
|
|
|
class CodeEventListener {
|
|
|
|
public:
|
|
|
|
virtual ~CodeEventListener() {}
|
|
|
|
|
2016-02-26 11:04:04 +00:00
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
2013-07-26 13:50:23 +00:00
|
|
|
const char* comment) = 0;
|
2016-02-26 11:04:04 +00:00
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
2013-07-26 13:50:23 +00:00
|
|
|
Name* name) = 0;
|
2016-02-26 11:04:04 +00:00
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
2013-07-26 13:50:23 +00:00
|
|
|
SharedFunctionInfo* shared,
|
2016-02-26 11:04:04 +00:00
|
|
|
CompilationInfo* info, Name* name) = 0;
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
2013-07-26 13:50:23 +00:00
|
|
|
SharedFunctionInfo* shared,
|
2016-02-26 11:04:04 +00:00
|
|
|
CompilationInfo* info, Name* source, int line,
|
|
|
|
int column) = 0;
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
2013-07-26 13:50:23 +00:00
|
|
|
int args_count) = 0;
|
|
|
|
virtual void CallbackEvent(Name* name, Address entry_point) = 0;
|
|
|
|
virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0;
|
|
|
|
virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0;
|
2016-02-26 11:04:04 +00:00
|
|
|
virtual void RegExpCodeCreateEvent(AbstractCode* code, String* source) = 0;
|
|
|
|
virtual void CodeMoveEvent(AbstractCode* from, Address to) = 0;
|
2013-07-26 13:50:23 +00:00
|
|
|
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0;
|
|
|
|
virtual void CodeMovingGCEvent() = 0;
|
2016-02-26 11:04:04 +00:00
|
|
|
virtual void CodeDisableOptEvent(AbstractCode* code,
|
|
|
|
SharedFunctionInfo* shared) = 0;
|
2013-07-26 13:50:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CodeEventLogger : public CodeEventListener {
|
|
|
|
public:
|
|
|
|
CodeEventLogger();
|
2016-02-26 11:04:04 +00:00
|
|
|
~CodeEventLogger() override;
|
|
|
|
|
|
|
|
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
const char* comment) override;
|
|
|
|
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
Name* name) override;
|
|
|
|
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
int args_count) override;
|
|
|
|
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
SharedFunctionInfo* shared, CompilationInfo* info,
|
|
|
|
Name* name) override;
|
|
|
|
void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code,
|
|
|
|
SharedFunctionInfo* shared, CompilationInfo* info,
|
|
|
|
Name* source, int line, int column) override;
|
|
|
|
void RegExpCodeCreateEvent(AbstractCode* code, String* source) override;
|
|
|
|
|
|
|
|
void CallbackEvent(Name* name, Address entry_point) override {}
|
|
|
|
void GetterCallbackEvent(Name* name, Address entry_point) override {}
|
|
|
|
void SetterCallbackEvent(Name* name, Address entry_point) override {}
|
|
|
|
void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
|
|
|
|
void CodeMovingGCEvent() override {}
|
2013-07-26 13:50:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
class NameBuffer;
|
|
|
|
|
2016-02-26 11:04:04 +00:00
|
|
|
virtual void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared,
|
|
|
|
const char* name, int length) = 0;
|
2013-07-26 13:50:23 +00:00
|
|
|
|
|
|
|
NameBuffer* name_buffer_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-04-06 10:36:38 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif // V8_LOG_H_
|