2012-02-23 09:12:57 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#ifndef V8_LOG_H_
|
|
|
|
#define V8_LOG_H_
|
|
|
|
|
2011-05-06 06:50:20 +00:00
|
|
|
#include "allocation.h"
|
2011-09-19 18:36:47 +00:00
|
|
|
#include "objects.h"
|
2009-06-24 13:09:34 +00:00
|
|
|
#include "platform.h"
|
2013-08-29 09:15:13 +00:00
|
|
|
#include "platform/elapsed-timer.h"
|
2009-06-24 13:09:34 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
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;
|
|
|
|
class Semaphore;
|
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)
|
|
|
|
|
|
|
|
|
2011-05-18 13:17:29 +00:00
|
|
|
#define LOG_EVENTS_AND_TAGS_LIST(V) \
|
|
|
|
V(CODE_CREATION_EVENT, "code-creation") \
|
|
|
|
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_IC_TAG, "CallIC") \
|
|
|
|
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(KEYED_CALL_DEBUG_BREAK_TAG, "KeyedCallDebugBreak") \
|
|
|
|
V(KEYED_CALL_DEBUG_PREPARE_STEP_IN_TAG, \
|
|
|
|
"KeyedCallDebugPrepareStepIn") \
|
|
|
|
V(KEYED_CALL_IC_TAG, "KeyedCallIC") \
|
|
|
|
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") \
|
2013-09-30 13:53:21 +00:00
|
|
|
V(HANDLER_TAG, "Handler") \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(KEYED_LOAD_IC_TAG, "KeyedLoadIC") \
|
2013-01-08 12:01:51 +00:00
|
|
|
V(KEYED_LOAD_POLYMORPHIC_IC_TAG, "KeyedLoadPolymorphicIC") \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, "KeyedExternalArrayLoadIC") \
|
|
|
|
V(KEYED_STORE_IC_TAG, "KeyedStoreIC") \
|
2013-01-08 12:01:51 +00:00
|
|
|
V(KEYED_STORE_POLYMORPHIC_IC_TAG, "KeyedStorePolymorphicIC") \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, "KeyedExternalArrayStoreIC") \
|
|
|
|
V(LAZY_COMPILE_TAG, "LazyCompile") \
|
|
|
|
V(LOAD_IC_TAG, "LoadIC") \
|
2013-03-04 14:03:27 +00:00
|
|
|
V(LOAD_POLYMORPHIC_IC_TAG, "LoadPolymorphicIC") \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(REG_EXP_TAG, "RegExp") \
|
|
|
|
V(SCRIPT_TAG, "Script") \
|
|
|
|
V(STORE_IC_TAG, "StoreIC") \
|
2013-03-13 14:11:05 +00:00
|
|
|
V(STORE_POLYMORPHIC_IC_TAG, "StorePolymorphicIC") \
|
2011-05-18 13:17:29 +00:00
|
|
|
V(STUB_TAG, "Stub") \
|
|
|
|
V(NATIVE_FUNCTION_TAG, "Function") \
|
|
|
|
V(NATIVE_LAZY_COMPILE_TAG, "LazyCompile") \
|
2010-12-07 13:24:22 +00:00
|
|
|
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;
|
2013-11-25 06:44:23 +00:00
|
|
|
class PerfJitLogger;
|
2011-03-18 20:35:07 +00:00
|
|
|
class Sampler;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
class Logger {
|
|
|
|
public:
|
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);
|
|
|
|
|
|
|
|
// Static versions of the above, operate on current isolate's logger.
|
|
|
|
// Used in TRACK_MEMORY(TypeName) defined in globals.h
|
|
|
|
static void NewEventStatic(const char* name, void* object, size_t size);
|
|
|
|
static void DeleteEventStatic(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. ====
|
2011-03-18 20:35:07 +00:00
|
|
|
void ApiNamedSecurityCheck(Object* key);
|
|
|
|
void ApiIndexedSecurityCheck(uint32_t index);
|
|
|
|
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.
|
2011-03-18 20:35:07 +00:00
|
|
|
void CodeCreateEvent(LogEventsAndTags tag,
|
|
|
|
Code* code, const char* source);
|
|
|
|
void CodeCreateEvent(LogEventsAndTags tag,
|
2013-03-04 15:00:57 +00:00
|
|
|
Code* code, Name* name);
|
2011-03-18 20:35:07 +00:00
|
|
|
void CodeCreateEvent(LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
2013-05-14 22:51:33 +00:00
|
|
|
CompilationInfo* info,
|
2013-03-04 15:00:57 +00:00
|
|
|
Name* name);
|
2011-03-18 20:35:07 +00:00
|
|
|
void CodeCreateEvent(LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
2013-05-14 22:51:33 +00:00
|
|
|
CompilationInfo* info,
|
2013-08-23 17:20:54 +00:00
|
|
|
Name* source, int line, int column);
|
2011-03-18 20:35:07 +00:00
|
|
|
void CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count);
|
|
|
|
void CodeMovingGCEvent();
|
2009-03-31 09:06:37 +00:00
|
|
|
// Emits a code create event for a RegExp.
|
2011-03-18 20:35:07 +00:00
|
|
|
void RegExpCodeCreateEvent(Code* code, String* source);
|
2008-07-03 15:10:15 +00:00
|
|
|
// Emits a code move event.
|
2011-03-18 20:35:07 +00:00
|
|
|
void CodeMoveEvent(Address from, Address to);
|
2008-07-03 15:10:15 +00:00
|
|
|
// Emits a code delete event.
|
2011-03-18 20:35:07 +00:00
|
|
|
void CodeDeleteEvent(Address from);
|
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.
|
|
|
|
void CodeEndLinePosInfoRecordEvent(Code* 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);
|
2011-03-18 20:35:07 +00:00
|
|
|
void SnapshotPositionEvent(Address addr, 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);
|
|
|
|
|
|
|
|
void SharedLibraryEvent(const char* library_path,
|
|
|
|
uintptr_t start,
|
|
|
|
uintptr_t end);
|
|
|
|
void SharedLibraryEvent(const wchar_t* library_path,
|
|
|
|
uintptr_t start,
|
|
|
|
uintptr_t end);
|
2012-11-28 11:01:10 +00:00
|
|
|
|
|
|
|
// ==== Events logged by --log-timer-events. ====
|
2013-01-28 13:55:40 +00:00
|
|
|
enum StartEnd { START, END };
|
|
|
|
|
2013-07-03 10:10:27 +00:00
|
|
|
void CodeDeoptEvent(Code* code);
|
|
|
|
|
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
|
|
|
|
2012-11-22 13:04:11 +00:00
|
|
|
class TimerEventScope {
|
|
|
|
public:
|
2012-11-26 08:56:59 +00:00
|
|
|
TimerEventScope(Isolate* isolate, const char* name)
|
2013-01-28 13:55:40 +00:00
|
|
|
: isolate_(isolate), name_(name) {
|
|
|
|
if (FLAG_log_internal_timer_events) LogTimerEvent(START);
|
2012-11-22 13:04:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~TimerEventScope() {
|
2013-01-28 13:55:40 +00:00
|
|
|
if (FLAG_log_internal_timer_events) LogTimerEvent(END);
|
2012-11-22 13:04:11 +00:00
|
|
|
}
|
|
|
|
|
2013-01-28 13:55:40 +00:00
|
|
|
void LogTimerEvent(StartEnd se);
|
2012-11-26 08:56:59 +00:00
|
|
|
|
2012-11-22 13:04:11 +00:00
|
|
|
static const char* v8_recompile_synchronous;
|
2013-08-22 16:14:37 +00:00
|
|
|
static const char* v8_recompile_concurrent;
|
2012-11-22 13:04:11 +00:00
|
|
|
static const char* v8_compile_full_code;
|
|
|
|
static const char* v8_execute;
|
2013-01-28 13:55:40 +00:00
|
|
|
static const char* v8_external;
|
2012-11-22 13:04:11 +00:00
|
|
|
|
|
|
|
private:
|
2012-11-26 08:56:59 +00:00
|
|
|
Isolate* isolate_;
|
2012-11-22 13:04:11 +00:00
|
|
|
const char* name_;
|
|
|
|
};
|
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
|
|
|
|
2009-01-06 13:24:52 +00:00
|
|
|
// Log an event reported from generated code
|
2013-04-08 15:16:55 +00:00
|
|
|
void LogRuntime(Vector<const char> format, JSArray* args);
|
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,
|
|
|
|
Handle<Code> 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();
|
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
|
|
|
|
2008-09-11 11:24:45 +00:00
|
|
|
// Emits the source code of a regexp. Used by regexp events.
|
2011-03-18 20:35:07 +00:00
|
|
|
void LogRegExpSource(Handle<JSRegExp> regexp);
|
2008-09-11 11:24:45 +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_;
|
|
|
|
PerfJitLogger* perf_jit_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_;
|
|
|
|
|
2013-08-29 09:15:13 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-07-26 13:50:23 +00:00
|
|
|
class CodeEventListener {
|
|
|
|
public:
|
|
|
|
virtual ~CodeEventListener() {}
|
|
|
|
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
const char* comment) = 0;
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
Name* name) = 0;
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
|
|
|
CompilationInfo* info,
|
|
|
|
Name* name) = 0;
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
|
|
|
CompilationInfo* info,
|
|
|
|
Name* source,
|
2013-10-10 13:15:47 +00:00
|
|
|
int line, int column) = 0;
|
2013-07-26 13:50:23 +00:00
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
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;
|
|
|
|
virtual void RegExpCodeCreateEvent(Code* code, String* source) = 0;
|
|
|
|
virtual void CodeMoveEvent(Address from, Address to) = 0;
|
|
|
|
virtual void CodeDeleteEvent(Address from) = 0;
|
|
|
|
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0;
|
|
|
|
virtual void CodeMovingGCEvent() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CodeEventLogger : public CodeEventListener {
|
|
|
|
public:
|
|
|
|
CodeEventLogger();
|
|
|
|
virtual ~CodeEventLogger();
|
|
|
|
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
const char* comment);
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
Name* name);
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
int args_count);
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
|
|
|
CompilationInfo* info,
|
|
|
|
Name* name);
|
|
|
|
virtual void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
|
|
|
CompilationInfo* info,
|
|
|
|
Name* source,
|
2013-10-10 13:15:47 +00:00
|
|
|
int line, int column);
|
2013-07-26 13:50:23 +00:00
|
|
|
virtual void RegExpCodeCreateEvent(Code* code, String* source);
|
|
|
|
|
|
|
|
virtual void CallbackEvent(Name* name, Address entry_point) { }
|
|
|
|
virtual void GetterCallbackEvent(Name* name, Address entry_point) { }
|
|
|
|
virtual void SetterCallbackEvent(Name* name, Address entry_point) { }
|
|
|
|
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) { }
|
|
|
|
virtual void CodeMovingGCEvent() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
class NameBuffer;
|
|
|
|
|
|
|
|
virtual void LogRecordedBuffer(Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
|
|
|
const char* name,
|
|
|
|
int length) = 0;
|
|
|
|
|
|
|
|
NameBuffer* name_buffer_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|
|
|
|
|
2010-04-06 10:36:38 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif // V8_LOG_H_
|