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"
|
|
|
|
#include "log-utils.h"
|
|
|
|
|
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.
|
2011-04-29 16:06:25 +00:00
|
|
|
class LogMessageBuilder;
|
2008-07-03 15:10:15 +00:00
|
|
|
class Profiler;
|
|
|
|
class Semaphore;
|
|
|
|
class SlidingStateWindow;
|
2011-04-29 16:06:25 +00:00
|
|
|
class Ticker;
|
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") \
|
|
|
|
V(KEYED_LOAD_IC_TAG, "KeyedLoadIC") \
|
|
|
|
V(KEYED_LOAD_MEGAMORPHIC_IC_TAG, "KeyedLoadMegamorphicIC") \
|
|
|
|
V(KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, "KeyedExternalArrayLoadIC") \
|
|
|
|
V(KEYED_STORE_IC_TAG, "KeyedStoreIC") \
|
|
|
|
V(KEYED_STORE_MEGAMORPHIC_IC_TAG, "KeyedStoreMegamorphicIC") \
|
|
|
|
V(KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, "KeyedExternalArrayStoreIC") \
|
|
|
|
V(LAZY_COMPILE_TAG, "LazyCompile") \
|
|
|
|
V(LOAD_IC_TAG, "LoadIC") \
|
|
|
|
V(REG_EXP_TAG, "RegExp") \
|
|
|
|
V(SCRIPT_TAG, "Script") \
|
|
|
|
V(STORE_IC_TAG, "StoreIC") \
|
|
|
|
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
|
|
|
|
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.
|
2012-01-13 13:09:52 +00:00
|
|
|
bool SetUp();
|
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
|
|
|
void EnsureTickerStarted();
|
|
|
|
void EnsureTickerStopped();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
// Enable the computation of a sliding window of states.
|
2011-03-18 20:35:07 +00:00
|
|
|
void EnableSlidingStateWindow();
|
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.
|
2011-03-18 20:35:07 +00:00
|
|
|
void SuspectReadEvent(String* 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. ====
|
2009-11-20 12:15:46 +00:00
|
|
|
// Emits a code event for a callback function.
|
2011-03-18 20:35:07 +00:00
|
|
|
void CallbackEvent(String* name, Address entry_point);
|
|
|
|
void GetterCallbackEvent(String* name, Address entry_point);
|
|
|
|
void SetterCallbackEvent(String* 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,
|
|
|
|
Code* code, String* name);
|
|
|
|
void CodeCreateEvent(LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
|
|
|
String* name);
|
|
|
|
void CodeCreateEvent(LogEventsAndTags tag,
|
|
|
|
Code* code,
|
|
|
|
SharedFunctionInfo* shared,
|
|
|
|
String* source, int line);
|
|
|
|
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);
|
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
|
|
|
|
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);
|
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
|
2011-03-18 20:35:07 +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() {
|
2010-03-01 10:41:34 +00:00
|
|
|
return logging_nesting_ > 0;
|
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() {
|
|
|
|
return is_logging() || code_event_handler_ != NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-29 19:47:00 +00:00
|
|
|
// Pause/Resume collection of profiling data.
|
2009-08-04 14:14:01 +00:00
|
|
|
// When data collection is paused, CPU Tick events are discarded until
|
2009-01-29 19:47:00 +00:00
|
|
|
// data collection is Resumed.
|
2011-07-01 09:35:16 +00:00
|
|
|
void PauseProfiler();
|
|
|
|
void ResumeProfiler();
|
|
|
|
bool IsProfilerPaused();
|
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:
|
2011-04-29 16:06:25 +00:00
|
|
|
class NameBuffer;
|
|
|
|
class NameMap;
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Logger();
|
|
|
|
~Logger();
|
2010-04-15 11:37:29 +00:00
|
|
|
|
2012-08-28 14:43:28 +00:00
|
|
|
// Issue code notifications.
|
|
|
|
void IssueCodeAddedEvent(Code* code, const char* name, size_t name_len);
|
|
|
|
void IssueCodeMovedEvent(Address from, Address to);
|
|
|
|
void IssueCodeRemovedEvent(Address from);
|
|
|
|
|
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,
|
|
|
|
const char* name,
|
|
|
|
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
|
|
|
|
|
|
|
// Internal configurable move event.
|
2011-03-18 20:35:07 +00:00
|
|
|
void DeleteEventInternal(LogEventsAndTags event, Address from);
|
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
|
|
|
|
2010-10-19 16:45:11 +00:00
|
|
|
// Emits general information about generated code.
|
2011-03-18 20:35:07 +00:00
|
|
|
void LogCodeInfo();
|
2010-10-19 16:45:11 +00:00
|
|
|
|
2011-04-29 16:06:25 +00:00
|
|
|
void RegisterSnapshotCodeName(Code* code, const char* name, int name_size);
|
|
|
|
|
|
|
|
// Low-level logging support.
|
|
|
|
|
|
|
|
void LowLevelCodeCreateEvent(Code* code, const char* name, int name_size);
|
|
|
|
|
|
|
|
void LowLevelCodeMoveEvent(Address from, Address to);
|
|
|
|
|
|
|
|
void LowLevelCodeDeleteEvent(Address from);
|
|
|
|
|
|
|
|
void LowLevelSnapshotPositionEvent(Address addr, int pos);
|
|
|
|
|
|
|
|
void LowLevelLogWriteBytes(const char* bytes, int size);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void LowLevelLogWriteStruct(const T& s) {
|
|
|
|
char tag = T::kTag;
|
|
|
|
LowLevelLogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag));
|
|
|
|
LowLevelLogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s));
|
|
|
|
}
|
2010-10-19 16:45:11 +00:00
|
|
|
|
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
|
|
|
|
2009-05-25 08:25:36 +00:00
|
|
|
// Returns whether profiler's sampler is active.
|
2011-03-18 20:35:07 +00:00
|
|
|
bool IsProfilerSamplerActive();
|
2009-05-25 08:25:36 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
// SlidingStateWindow instance keeping a sliding window of the most
|
|
|
|
// recent VM states.
|
2011-03-18 20:35:07 +00:00
|
|
|
SlidingStateWindow* sliding_state_window_;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
friend class LogMessageBuilder;
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class TimeLog;
|
|
|
|
friend class Profiler;
|
|
|
|
friend class SlidingStateWindow;
|
2009-11-23 14:43:00 +00:00
|
|
|
friend class StackTracer;
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class VMState;
|
2009-05-25 08:25:36 +00:00
|
|
|
|
|
|
|
friend class LoggerTestHelper;
|
2009-06-24 13:09:34 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
|
|
|
|
int logging_nesting_;
|
|
|
|
int cpu_profiler_nesting_;
|
|
|
|
|
|
|
|
Log* log_;
|
|
|
|
|
2011-04-29 16:06:25 +00:00
|
|
|
NameBuffer* name_buffer_;
|
|
|
|
|
|
|
|
NameMap* address_to_name_map_;
|
|
|
|
|
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_;
|
|
|
|
|
2012-08-28 14:43:28 +00:00
|
|
|
// The code event handler - if any.
|
|
|
|
JitCodeEventHandler code_event_handler_;
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
// Support for 'incremental addresses' in compressed logs:
|
|
|
|
// LogMessageBuilder::AppendAddress(Address addr)
|
|
|
|
Address last_address_;
|
|
|
|
// Logger::TickEvent(...)
|
|
|
|
Address prev_sp_;
|
|
|
|
Address prev_function_;
|
|
|
|
// Logger::MoveEventInternal(...)
|
|
|
|
Address prev_to_;
|
|
|
|
// Logger::FunctionCreateEvent(...)
|
|
|
|
Address prev_code_;
|
2010-04-06 10:36:38 +00:00
|
|
|
|
|
|
|
friend class CpuProfiler;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
// Process wide registry of samplers.
|
|
|
|
class SamplerRegistry : public AllStatic {
|
|
|
|
public:
|
|
|
|
enum State {
|
|
|
|
HAS_NO_SAMPLERS,
|
|
|
|
HAS_SAMPLERS,
|
|
|
|
HAS_CPU_PROFILING_SAMPLERS
|
|
|
|
};
|
|
|
|
|
2012-04-05 14:10:39 +00:00
|
|
|
static void SetUp();
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
typedef void (*VisitSampler)(Sampler*, void*);
|
|
|
|
|
|
|
|
static State GetState();
|
|
|
|
|
|
|
|
// Iterates over all active samplers keeping the internal lock held.
|
|
|
|
// Returns whether there are any active samplers.
|
|
|
|
static bool IterateActiveSamplers(VisitSampler func, void* param);
|
|
|
|
|
|
|
|
// Adds/Removes an active sampler.
|
|
|
|
static void AddActiveSampler(Sampler* sampler);
|
|
|
|
static void RemoveActiveSampler(Sampler* sampler);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool ActiveSamplersExist() {
|
|
|
|
return active_samplers_ != NULL && !active_samplers_->is_empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
static List<Sampler*>* active_samplers_;
|
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(SamplerRegistry);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-03-20 14:49:12 +00:00
|
|
|
// Class that extracts stack trace, used for profiling.
|
2009-06-02 09:33:17 +00:00
|
|
|
class StackTracer : public AllStatic {
|
2009-02-25 16:00:21 +00:00
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
static void Trace(Isolate* isolate, TickSample* sample);
|
2009-02-25 16:00:21 +00:00
|
|
|
};
|
|
|
|
|
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_
|