Commit ecd807b9 authored by loislo@chromium.org's avatar loislo@chromium.org

Move CpuProfiler code create events behind Logger code api.

CpuProfiler has almost the same api for CodeCreate* events
but it was calling separately.

BUG=260203
R=svenpanne@chromium.org, yurys@chromium.org

Review URL: https://codereview.chromium.org/19916002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15817 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 92537552
...@@ -264,7 +264,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, ...@@ -264,7 +264,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, Code* code,
SharedFunctionInfo* shared, SharedFunctionInfo* shared,
CompilationInfo* info, CompilationInfo* info,
String* source, int line) { Name* source, int line) {
if (FilterOutCodeCreateEvent(tag)) return; if (FilterOutCodeCreateEvent(tag)) return;
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
......
...@@ -173,14 +173,14 @@ class ProfilerEventsProcessor : public Thread { ...@@ -173,14 +173,14 @@ class ProfilerEventsProcessor : public Thread {
}; };
#define PROFILE(IsolateGetter, Call) \ #define PROFILE(IsolateGetter, Call) \
do { \ do { \
Isolate* cpu_profiler_isolate = (IsolateGetter); \ Isolate* cpu_profiler_isolate = (IsolateGetter); \
LOG_CODE_EVENT(cpu_profiler_isolate, Call); \ v8::internal::Logger* logger = cpu_profiler_isolate->logger(); \
CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \ CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \
if (cpu_profiler->is_profiling()) { \ if (logger->is_logging_code_events() || cpu_profiler->is_profiling()) { \
cpu_profiler->Call; \ logger->Call; \
} \ } \
} while (false) } while (false)
...@@ -223,7 +223,7 @@ class CpuProfiler { ...@@ -223,7 +223,7 @@ class CpuProfiler {
Code* code, Code* code,
SharedFunctionInfo* shared, SharedFunctionInfo* shared,
CompilationInfo* info, CompilationInfo* info,
String* source, int line); Name* source, int line);
void CodeCreateEvent(Logger::LogEventsAndTags tag, void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, int args_count); Code* code, int args_count);
void CodeMovingGCEvent() {} void CodeMovingGCEvent() {}
......
...@@ -54,6 +54,14 @@ static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { ...@@ -54,6 +54,14 @@ static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
#undef DECLARE_EVENT #undef DECLARE_EVENT
#define PROFILER_LOG(Call) \
do { \
CpuProfiler* cpu_profiler = isolate_->cpu_profiler(); \
if (cpu_profiler->is_profiling()) { \
cpu_profiler->Call; \
} \
} while (false);
// ComputeMarker must only be used when SharedFunctionInfo is known. // ComputeMarker must only be used when SharedFunctionInfo is known.
static const char* ComputeMarker(Code* code) { static const char* ComputeMarker(Code* code) {
switch (code->kind()) { switch (code->kind()) {
...@@ -543,7 +551,7 @@ class JitLogger : public CodeEventLogger { ...@@ -543,7 +551,7 @@ class JitLogger : public CodeEventLogger {
public: public:
explicit JitLogger(JitCodeEventHandler code_event_handler); explicit JitLogger(JitCodeEventHandler code_event_handler);
void CodeMovedEvent(Address from, Address to); void CodeMoveEvent(Address from, Address to);
void CodeDeleteEvent(Address from); void CodeDeleteEvent(Address from);
void AddCodeLinePosInfoEvent( void AddCodeLinePosInfoEvent(
void* jit_handler_data, void* jit_handler_data,
...@@ -588,7 +596,7 @@ void JitLogger::LogRecordedBuffer(Code* code, ...@@ -588,7 +596,7 @@ void JitLogger::LogRecordedBuffer(Code* code,
} }
void JitLogger::CodeMovedEvent(Address from, Address to) { void JitLogger::CodeMoveEvent(Address from, Address to) {
Code* from_code = Code::cast(HeapObject::FromAddress(from)); Code* from_code = Code::cast(HeapObject::FromAddress(from));
JitCodeEvent event; JitCodeEvent event;
...@@ -1209,7 +1217,7 @@ void Logger::DeleteEventStatic(const char* name, void* object) { ...@@ -1209,7 +1217,7 @@ void Logger::DeleteEventStatic(const char* name, void* object) {
void Logger::CallbackEventInternal(const char* prefix, Name* name, void Logger::CallbackEventInternal(const char* prefix, Name* name,
Address entry_point) { Address entry_point) {
if (!log_->IsEnabled() || !FLAG_log_code) return; if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_); Log::MessageBuilder msg(log_);
msg.Append("%s,%s,-2,", msg.Append("%s,%s,-2,",
kLogEventsNames[CODE_CREATION_EVENT], kLogEventsNames[CODE_CREATION_EVENT],
...@@ -1235,19 +1243,19 @@ void Logger::CallbackEventInternal(const char* prefix, Name* name, ...@@ -1235,19 +1243,19 @@ void Logger::CallbackEventInternal(const char* prefix, Name* name,
void Logger::CallbackEvent(Name* name, Address entry_point) { void Logger::CallbackEvent(Name* name, Address entry_point) {
if (!log_->IsEnabled() || !FLAG_log_code) return; PROFILER_LOG(CallbackEvent(name, entry_point));
CallbackEventInternal("", name, entry_point); CallbackEventInternal("", name, entry_point);
} }
void Logger::GetterCallbackEvent(Name* name, Address entry_point) { void Logger::GetterCallbackEvent(Name* name, Address entry_point) {
if (!log_->IsEnabled() || !FLAG_log_code) return; PROFILER_LOG(GetterCallbackEvent(name, entry_point));
CallbackEventInternal("get ", name, entry_point); CallbackEventInternal("get ", name, entry_point);
} }
void Logger::SetterCallbackEvent(Name* name, Address entry_point) { void Logger::SetterCallbackEvent(Name* name, Address entry_point) {
if (!log_->IsEnabled() || !FLAG_log_code) return; PROFILER_LOG(SetterCallbackEvent(name, entry_point));
CallbackEventInternal("set ", name, entry_point); CallbackEventInternal("set ", name, entry_point);
} }
...@@ -1268,8 +1276,9 @@ static void AppendCodeCreateHeader(Log::MessageBuilder* msg, ...@@ -1268,8 +1276,9 @@ static void AppendCodeCreateHeader(Log::MessageBuilder* msg,
void Logger::CodeCreateEvent(LogEventsAndTags tag, void Logger::CodeCreateEvent(LogEventsAndTags tag,
Code* code, Code* code,
const char* comment) { const char* comment) {
if (!is_logging_code_events()) return; PROFILER_LOG(CodeCreateEvent(tag, code, comment));
if (!is_logging_code_events()) return;
JIT_LOG(CodeCreateEvent(tag, code, comment)); JIT_LOG(CodeCreateEvent(tag, code, comment));
LL_LOG(CodeCreateEvent(tag, code, comment)); LL_LOG(CodeCreateEvent(tag, code, comment));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, comment)); CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, comment));
...@@ -1286,8 +1295,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -1286,8 +1295,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
void Logger::CodeCreateEvent(LogEventsAndTags tag, void Logger::CodeCreateEvent(LogEventsAndTags tag,
Code* code, Code* code,
Name* name) { Name* name) {
if (!is_logging_code_events()) return; PROFILER_LOG(CodeCreateEvent(tag, code, name));
if (!is_logging_code_events()) return;
JIT_LOG(CodeCreateEvent(tag, code, name)); JIT_LOG(CodeCreateEvent(tag, code, name));
LL_LOG(CodeCreateEvent(tag, code, name)); LL_LOG(CodeCreateEvent(tag, code, name));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, name)); CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, name));
...@@ -1312,8 +1322,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -1312,8 +1322,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
SharedFunctionInfo* shared, SharedFunctionInfo* shared,
CompilationInfo* info, CompilationInfo* info,
Name* name) { Name* name) {
if (!is_logging_code_events()) return; PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name));
if (!is_logging_code_events()) return;
JIT_LOG(CodeCreateEvent(tag, code, shared, info, name)); JIT_LOG(CodeCreateEvent(tag, code, shared, info, name));
LL_LOG(CodeCreateEvent(tag, code, shared, info, name)); LL_LOG(CodeCreateEvent(tag, code, shared, info, name));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, name)); CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, name));
...@@ -1348,8 +1359,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -1348,8 +1359,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
SharedFunctionInfo* shared, SharedFunctionInfo* shared,
CompilationInfo* info, CompilationInfo* info,
Name* source, int line) { Name* source, int line) {
if (!is_logging_code_events()) return; PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line));
if (!is_logging_code_events()) return;
JIT_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); JIT_LOG(CodeCreateEvent(tag, code, shared, info, source, line));
LL_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); LL_LOG(CodeCreateEvent(tag, code, shared, info, source, line));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, source, line));
...@@ -1378,8 +1390,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -1378,8 +1390,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
void Logger::CodeCreateEvent(LogEventsAndTags tag, void Logger::CodeCreateEvent(LogEventsAndTags tag,
Code* code, Code* code,
int args_count) { int args_count) {
if (!is_logging_code_events()) return; PROFILER_LOG(CodeCreateEvent(tag, code, args_count));
if (!is_logging_code_events()) return;
JIT_LOG(CodeCreateEvent(tag, code, args_count)); JIT_LOG(CodeCreateEvent(tag, code, args_count));
LL_LOG(CodeCreateEvent(tag, code, args_count)); LL_LOG(CodeCreateEvent(tag, code, args_count));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, args_count)); CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, args_count));
...@@ -1394,6 +1407,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -1394,6 +1407,9 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
void Logger::CodeMovingGCEvent() { void Logger::CodeMovingGCEvent() {
PROFILER_LOG(CodeMovingGCEvent());
if (!is_logging_code_events()) return;
if (!log_->IsEnabled() || !FLAG_ll_prof) return; if (!log_->IsEnabled() || !FLAG_ll_prof) return;
LL_LOG(CodeMovingGCEvent()); LL_LOG(CodeMovingGCEvent());
OS::SignalCodeMovingGC(); OS::SignalCodeMovingGC();
...@@ -1401,8 +1417,9 @@ void Logger::CodeMovingGCEvent() { ...@@ -1401,8 +1417,9 @@ void Logger::CodeMovingGCEvent() {
void Logger::RegExpCodeCreateEvent(Code* code, String* source) { void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
if (!is_logging_code_events()) return; PROFILER_LOG(RegExpCodeCreateEvent(code, source));
if (!is_logging_code_events()) return;
JIT_LOG(RegExpCodeCreateEvent(code, source)); JIT_LOG(RegExpCodeCreateEvent(code, source));
LL_LOG(RegExpCodeCreateEvent(code, source)); LL_LOG(RegExpCodeCreateEvent(code, source));
CODE_ADDRESS_MAP_LOG(RegExpCodeCreateEvent(code, source)); CODE_ADDRESS_MAP_LOG(RegExpCodeCreateEvent(code, source));
...@@ -1419,8 +1436,10 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) { ...@@ -1419,8 +1436,10 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
void Logger::CodeMoveEvent(Address from, Address to) { void Logger::CodeMoveEvent(Address from, Address to) {
JIT_LOG(CodeMovedEvent(from, to)); PROFILER_LOG(CodeMoveEvent(from, to));
if (!log_->IsEnabled()) return;
if (!is_logging_code_events()) return;
JIT_LOG(CodeMoveEvent(from, to));
LL_LOG(CodeMoveEvent(from, to)); LL_LOG(CodeMoveEvent(from, to));
CODE_ADDRESS_MAP_LOG(CodeMoveEvent(from, to)); CODE_ADDRESS_MAP_LOG(CodeMoveEvent(from, to));
MoveEventInternal(CODE_MOVE_EVENT, from, to); MoveEventInternal(CODE_MOVE_EVENT, from, to);
...@@ -1428,12 +1447,14 @@ void Logger::CodeMoveEvent(Address from, Address to) { ...@@ -1428,12 +1447,14 @@ void Logger::CodeMoveEvent(Address from, Address to) {
void Logger::CodeDeleteEvent(Address from) { void Logger::CodeDeleteEvent(Address from) {
PROFILER_LOG(CodeDeleteEvent(from));
if (!is_logging_code_events()) return;
JIT_LOG(CodeDeleteEvent(from)); JIT_LOG(CodeDeleteEvent(from));
if (!log_->IsEnabled()) return;
LL_LOG(CodeDeleteEvent(from)); LL_LOG(CodeDeleteEvent(from));
CODE_ADDRESS_MAP_LOG(CodeDeleteEvent(from)); CODE_ADDRESS_MAP_LOG(CodeDeleteEvent(from));
if (!log_->IsEnabled() || !FLAG_log_code) return; if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_); Log::MessageBuilder msg(log_);
msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]); msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]);
msg.AppendAddress(from); msg.AppendAddress(from);
...@@ -1498,6 +1519,9 @@ void Logger::SnapshotPositionEvent(Address addr, int pos) { ...@@ -1498,6 +1519,9 @@ void Logger::SnapshotPositionEvent(Address addr, int pos) {
void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) {
PROFILER_LOG(SharedFunctionInfoMoveEvent(from, to));
if (!is_logging_code_events()) return;
MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to);
} }
...@@ -1505,7 +1529,7 @@ void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { ...@@ -1505,7 +1529,7 @@ void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) {
void Logger::MoveEventInternal(LogEventsAndTags event, void Logger::MoveEventInternal(LogEventsAndTags event,
Address from, Address from,
Address to) { Address to) {
if (!log_->IsEnabled() || !FLAG_log_code) return; if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_); Log::MessageBuilder msg(log_);
msg.Append("%s,", kLogEventsNames[event]); msg.Append("%s,", kLogEventsNames[event]);
msg.AppendAddress(from); msg.AppendAddress(from);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment