Reviewers: Yury Semikhatsky, Yang,
Description:
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
Please review this at https://codereview.chromium.org/19916002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/cpu-profiler.h
M src/cpu-profiler.cc
M src/log.cc
Index: src/cpu-profiler.cc
diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc
index
d3fadb52d4a1ada74c27dfa244c245c415adea4d..0d226cfb3f2b8af1d7bca601717c6e87bd9776eb
100644
--- a/src/cpu-profiler.cc
+++ b/src/cpu-profiler.cc
@@ -264,7 +264,7 @@ void
CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
- String* source, int line) {
+ Name* source, int line) {
if (FilterOutCodeCreateEvent(tag)) return;
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
Index: src/cpu-profiler.h
diff --git a/src/cpu-profiler.h b/src/cpu-profiler.h
index
44e63fed49f6bed50f6904d543eb0c8f95fe16f4..66e2b8bd18ca8b9d047a4f37585d2a9f07f5d4f8
100644
--- a/src/cpu-profiler.h
+++ b/src/cpu-profiler.h
@@ -173,14 +173,14 @@ class ProfilerEventsProcessor : public Thread {
};
-#define PROFILE(IsolateGetter, Call) \
- do { \
- Isolate* cpu_profiler_isolate = (IsolateGetter); \
- LOG_CODE_EVENT(cpu_profiler_isolate, Call); \
- CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \
- if (cpu_profiler->is_profiling()) { \
- cpu_profiler->Call; \
- } \
+#define PROFILE(IsolateGetter,
Call) \
+ do
{ \
+ Isolate* cpu_profiler_isolate =
(IsolateGetter); \
+ v8::internal::Logger* logger =
cpu_profiler_isolate->logger(); \
+ CpuProfiler* cpu_profiler =
cpu_profiler_isolate->cpu_profiler(); \
+ if (logger->is_logging_code_events() || cpu_profiler->is_profiling())
{ \
+
logger->Call; \
+
} \
} while (false)
@@ -223,7 +223,7 @@ class CpuProfiler {
Code* code,
SharedFunctionInfo* shared,
CompilationInfo* info,
- String* source, int line);
+ Name* source, int line);
void CodeCreateEvent(Logger::LogEventsAndTags tag,
Code* code, int args_count);
void CodeMovingGCEvent() {}
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index
d26279bb24ad03e9098683adbda34794b06505c9..77572cc3c02fce2760a2a624815dfd34aeccdb81
100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -54,6 +54,12 @@ static const char* const
kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
#undef DECLARE_EVENT
+#define PROFILER_LOG(Call) \
+ CpuProfiler* cpu_profiler = isolate_->cpu_profiler(); \
+ if (cpu_profiler->is_profiling()) { \
+ cpu_profiler->Call; \
+ }
+
// ComputeMarker must only be used when SharedFunctionInfo is known.
static const char* ComputeMarker(Code* code) {
switch (code->kind()) {
@@ -543,7 +549,7 @@ class JitLogger : public CodeEventLogger {
public:
explicit JitLogger(JitCodeEventHandler code_event_handler);
- void CodeMovedEvent(Address from, Address to);
+ void CodeMoveEvent(Address from, Address to);
void CodeDeleteEvent(Address from);
void AddCodeLinePosInfoEvent(
void* jit_handler_data,
@@ -588,7 +594,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));
JitCodeEvent event;
@@ -1209,7 +1215,7 @@ void Logger::DeleteEventStatic(const char* name,
void* object) {
void Logger::CallbackEventInternal(const char* prefix, Name* name,
Address entry_point) {
- if (!log_->IsEnabled() || !FLAG_log_code) return;
+ if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
msg.Append("%s,%s,-2,",
kLogEventsNames[CODE_CREATION_EVENT],
@@ -1235,19 +1241,22 @@ void Logger::CallbackEventInternal(const char*
prefix, Name* name,
void Logger::CallbackEvent(Name* name, Address entry_point) {
- if (!log_->IsEnabled() || !FLAG_log_code) return;
+ PROFILER_LOG(CallbackEvent(name, entry_point));
+ if (!FLAG_log_code || !log_->IsEnabled()) return;
CallbackEventInternal("", name, entry_point);
}
void Logger::GetterCallbackEvent(Name* name, Address entry_point) {
- if (!log_->IsEnabled() || !FLAG_log_code) return;
+ PROFILER_LOG(GetterCallbackEvent(name, entry_point));
+ if (!FLAG_log_code || !log_->IsEnabled()) return;
CallbackEventInternal("get ", name, entry_point);
}
void Logger::SetterCallbackEvent(Name* name, Address entry_point) {
- if (!log_->IsEnabled() || !FLAG_log_code) return;
+ PROFILER_LOG(SetterCallbackEvent(name, entry_point));
+ if (!FLAG_log_code || !log_->IsEnabled()) return;
CallbackEventInternal("set ", name, entry_point);
}
@@ -1268,11 +1277,10 @@ static void
AppendCodeCreateHeader(Log::MessageBuilder* msg,
void Logger::CodeCreateEvent(LogEventsAndTags tag,
Code* code,
const char* comment) {
- if (!is_logging_code_events()) return;
-
JIT_LOG(CodeCreateEvent(tag, code, comment));
LL_LOG(CodeCreateEvent(tag, code, comment));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, comment));
+ PROFILER_LOG(CodeCreateEvent(tag, code, comment));
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@@ -1286,11 +1294,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
void Logger::CodeCreateEvent(LogEventsAndTags tag,
Code* code,
Name* name) {
- if (!is_logging_code_events()) return;
-
JIT_LOG(CodeCreateEvent(tag, code, name));
LL_LOG(CodeCreateEvent(tag, code, name));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, name));
+ PROFILER_LOG(CodeCreateEvent(tag, code, name));
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@@ -1312,11 +1319,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
SharedFunctionInfo* shared,
CompilationInfo* info,
Name* name) {
- if (!is_logging_code_events()) return;
-
JIT_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));
+ PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name));
if (!FLAG_log_code || !log_->IsEnabled()) return;
if (code == isolate_->builtins()->builtin(
@@ -1348,11 +1354,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
SharedFunctionInfo* shared,
CompilationInfo* info,
Name* source, int line) {
- if (!is_logging_code_events()) return;
-
JIT_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));
+ PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line));
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@@ -1378,11 +1383,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
void Logger::CodeCreateEvent(LogEventsAndTags tag,
Code* code,
int args_count) {
- if (!is_logging_code_events()) return;
-
JIT_LOG(CodeCreateEvent(tag, code, args_count));
LL_LOG(CodeCreateEvent(tag, code, args_count));
CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, args_count));
+ PROFILER_LOG(CodeCreateEvent(tag, code, args_count));
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@@ -1394,6 +1398,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag,
void Logger::CodeMovingGCEvent() {
+ PROFILER_LOG(CodeMovingGCEvent());
if (!log_->IsEnabled() || !FLAG_ll_prof) return;
LL_LOG(CodeMovingGCEvent());
OS::SignalCodeMovingGC();
@@ -1401,11 +1406,10 @@ void Logger::CodeMovingGCEvent() {
void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
- if (!is_logging_code_events()) return;
-
JIT_LOG(RegExpCodeCreateEvent(code, source));
LL_LOG(RegExpCodeCreateEvent(code, source));
CODE_ADDRESS_MAP_LOG(RegExpCodeCreateEvent(code, source));
+ PROFILER_LOG(RegExpCodeCreateEvent(code, source));
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@@ -1419,21 +1423,23 @@ void Logger::RegExpCodeCreateEvent(Code* code,
String* source) {
void Logger::CodeMoveEvent(Address from, Address to) {
- JIT_LOG(CodeMovedEvent(from, to));
- if (!log_->IsEnabled()) return;
+ JIT_LOG(CodeMoveEvent(from, to));
LL_LOG(CodeMoveEvent(from, to));
CODE_ADDRESS_MAP_LOG(CodeMoveEvent(from, to));
+ PROFILER_LOG(CodeMoveEvent(from, to));
+ if (!log_->IsEnabled()) return;
+
MoveEventInternal(CODE_MOVE_EVENT, from, to);
}
void Logger::CodeDeleteEvent(Address from) {
JIT_LOG(CodeDeleteEvent(from));
- if (!log_->IsEnabled()) return;
LL_LOG(CodeDeleteEvent(from));
CODE_ADDRESS_MAP_LOG(CodeDeleteEvent(from));
+ PROFILER_LOG(CodeDeleteEvent(from));
- if (!log_->IsEnabled() || !FLAG_log_code) return;
+ if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]);
msg.AppendAddress(from);
@@ -1498,6 +1504,7 @@ void Logger::SnapshotPositionEvent(Address addr, int
pos) {
void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) {
+ PROFILER_LOG(SharedFunctionInfoMoveEvent(from, to));
MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to);
}
@@ -1505,7 +1512,7 @@ void Logger::SharedFunctionInfoMoveEvent(Address
from, Address to) {
void Logger::MoveEventInternal(LogEventsAndTags event,
Address from,
Address to) {
- if (!log_->IsEnabled() || !FLAG_log_code) return;
+ if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
msg.Append("%s,", kLogEventsNames[event]);
msg.AppendAddress(from);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.