Index: src/log.h |
diff --git a/src/log.h b/src/log.h |
index 021fd18961753164f16167e13c58f19350c92f1e..91331f04fc068c0ad3b16149a70bc85971896a14 100644 |
--- a/src/log.h |
+++ b/src/log.h |
@@ -11,6 +11,8 @@ |
#include "src/base/compiler-specific.h" |
#include "src/base/platform/elapsed-timer.h" |
#include "src/base/platform/platform.h" |
+#include "src/code-events.h" |
+#include "src/isolate.h" |
#include "src/objects.h" |
namespace v8 { |
@@ -71,94 +73,27 @@ struct TickSample; |
class RuntimeCallTimer; |
#undef LOG |
-#define LOG(isolate, Call) \ |
- do { \ |
- v8::internal::Logger* logger = \ |
- (isolate)->logger(); \ |
- if (logger->is_logging()) \ |
- logger->Call; \ |
+#define LOG(isolate, Call) \ |
+ do { \ |
+ v8::internal::Logger* logger = (isolate)->logger(); \ |
+ if (logger->is_logging()) logger->Call; \ |
} while (false) |
-#define LOG_CODE_EVENT(isolate, Call) \ |
- do { \ |
- v8::internal::Logger* logger = \ |
- (isolate)->logger(); \ |
- if (logger->is_logging_code_events()) \ |
- logger->Call; \ |
+#define LOG_CODE_EVENT(isolate, Call) \ |
+ do { \ |
+ v8::internal::Logger* logger = (isolate)->logger(); \ |
+ if (logger->is_logging_code_events()) logger->Call; \ |
} while (false) |
-#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_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(LOAD_INITIALIZE_TAG, "LoadInitialize") \ |
- V(LOAD_MEGAMORPHIC_TAG, "LoadMegamorphic") \ |
- V(STORE_INITIALIZE_TAG, "StoreInitialize") \ |
- 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(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_GLOBAL_IC_TAG, "LoadGlobalIC") \ |
- 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") |
-// Note that 'NATIVE_' cases for functions and scripts are mapped onto |
-// original tags when writing to the log. |
- |
- |
class JitLogger; |
class PerfBasicLogger; |
class LowLevelLogger; |
class PerfJitLogger; |
-class Logger { |
+class Logger : public CodeEventListener { |
public: |
enum StartEnd { START = 0, END = 1 }; |
-#define DECLARE_ENUM(enum_item, ignore) enum_item, |
- enum LogEventsAndTags { |
- LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) |
- NUMBER_OF_LOG_EVENTS |
- }; |
-#undef DECLARE_ENUM |
- |
// Acquires resources for logging if the right flags are set. |
bool SetUp(Isolate* isolate); |
@@ -212,28 +147,27 @@ class Logger { |
void ApiObjectAccess(const char* tag, JSObject* obj); |
void ApiEntryCall(const char* name); |
- |
// ==== Events logged by --log-code. ==== |
void addCodeEventListener(CodeEventListener* listener); |
void removeCodeEventListener(CodeEventListener* listener); |
- bool hasCodeEventListener(CodeEventListener* listener); |
- |
// Emits a code event for a callback function. |
void CallbackEvent(Name* name, Address entry_point); |
void GetterCallbackEvent(Name* name, Address entry_point); |
void SetterCallbackEvent(Name* name, Address entry_point); |
// Emits a code create event. |
- 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, Name* name); |
- void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
- SharedFunctionInfo* shared, Name* source, int line, |
- int column); |
- void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
- int args_count); |
+ void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, |
+ AbstractCode* code, const char* source); |
+ void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, |
+ AbstractCode* code, Name* name); |
+ void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, |
+ AbstractCode* code, SharedFunctionInfo* shared, |
+ Name* name); |
+ void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, |
+ AbstractCode* code, SharedFunctionInfo* shared, |
+ Name* source, int line, int column); |
+ void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, |
+ AbstractCode* code, int args_count); |
// Emits a code deoptimization event. |
void CodeDisableOptEvent(AbstractCode* code, SharedFunctionInfo* shared); |
void CodeMovingGCEvent(); |
@@ -260,6 +194,8 @@ class Logger { |
void CodeNameEvent(Address addr, int pos, const char* code_name); |
+ void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); |
+ |
// ==== Events logged by --log-gc. ==== |
// Heap sampling events: start, end, and individual types. |
void HeapSampleBeginEvent(const char* space, const char* kind); |
@@ -277,7 +213,6 @@ class Logger { |
void SharedLibraryEvent(const std::string& library_path, uintptr_t start, |
uintptr_t end, intptr_t aslr_slide); |
- void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); |
void CurrentTimeEvent(); |
void TimerEvent(StartEnd se, const char* name); |
@@ -319,7 +254,8 @@ class Logger { |
void LogBytecodeHandlers(); |
// Converts tag to a corresponding NATIVE_... if the script is native. |
- INLINE(static LogEventsAndTags ToNativeByScript(LogEventsAndTags, Script*)); |
+ INLINE(static CodeEventListener::LogEventsAndTags ToNativeByScript( |
+ CodeEventListener::LogEventsAndTags, Script*)); |
// Profiler's sampling interval (in milliseconds). |
#if defined(ANDROID) |
@@ -346,13 +282,14 @@ class Logger { |
Address entry_point); |
// Internal configurable move event. |
- void MoveEventInternal(LogEventsAndTags event, Address from, Address to); |
+ void MoveEventInternal(CodeEventListener::LogEventsAndTags event, |
+ Address from, Address to); |
// Used for logging stubs found in the snapshot. |
void LogCodeObject(Object* code_object); |
// Helper method. It resets name_buffer_ and add tag name into it. |
- void InitNameBuffer(LogEventsAndTags tag); |
+ void InitNameBuffer(CodeEventListener::LogEventsAndTags tag); |
// Emits a profiler tick event. Used by the profiler thread. |
void TickEvent(TickSample* sample, bool overflow); |
@@ -464,47 +401,20 @@ class PositionsRecorder BASE_EMBEDDED { |
DISALLOW_COPY_AND_ASSIGN(PositionsRecorder); |
}; |
-class CodeEventListener { |
- public: |
- virtual ~CodeEventListener() {} |
- |
- virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
- const char* comment) = 0; |
- virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
- Name* name) = 0; |
- virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
- SharedFunctionInfo* shared, Name* name) = 0; |
- virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
- SharedFunctionInfo* shared, Name* source, |
- int line, int column) = 0; |
- virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* 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(AbstractCode* code, String* source) = 0; |
- virtual void CodeMoveEvent(AbstractCode* from, Address to) = 0; |
- virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0; |
- virtual void CodeMovingGCEvent() = 0; |
- virtual void CodeDisableOptEvent(AbstractCode* code, |
- SharedFunctionInfo* shared) = 0; |
-}; |
- |
- |
class CodeEventLogger : public CodeEventListener { |
public: |
CodeEventLogger(); |
~CodeEventLogger() override; |
- void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
+ void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
const char* comment) override; |
- void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
+ void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
Name* name) override; |
- void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
+ void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
int args_count) override; |
- void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
+ void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
SharedFunctionInfo* shared, Name* name) override; |
- void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, |
+ void CodeCreateEvent(LogEventsAndTags tag, AbstractCode* code, |
SharedFunctionInfo* shared, Name* source, int line, |
int column) override; |
void RegExpCodeCreateEvent(AbstractCode* code, String* source) override; |
@@ -514,6 +424,7 @@ class CodeEventLogger : public CodeEventListener { |
void SetterCallbackEvent(Name* name, Address entry_point) override {} |
void SharedFunctionInfoMoveEvent(Address from, Address to) override {} |
void CodeMovingGCEvent() override {} |
+ void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) override {} |
private: |
class NameBuffer; |