Commit 4744ea8b authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[log] Make log checks for Api log events inlineable

If any logging is enabled (for instance with --prof), the calls into
Logger:ApiEntryCall become quite expensive.

Move the FLAG_log_api checks to the header to speed up these
high-frequency events.

Change-Id: Iba718c856cd57a890ad6b63bcf4b6836bfd5d3f0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3024156Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75812}
parent 35e2b11b
......@@ -1075,8 +1075,8 @@ void Logger::HandleEvent(const char* name, Address* location) {
msg.WriteToLogFile();
}
void Logger::ApiSecurityCheck() {
if (!FLAG_log_api) return;
void Logger::WriteApiSecurityCheck() {
DCHECK(FLAG_log_api);
MSG_BUILDER();
msg << "api" << kNext << "check-security";
msg.WriteToLogFile();
......@@ -1146,34 +1146,34 @@ bool Logger::is_logging() {
TIMER_EVENTS_LIST(V)
#undef V
void Logger::ApiNamedPropertyAccess(const char* tag, JSObject holder,
Object property_name) {
void Logger::WriteApiNamedPropertyAccess(const char* tag, JSObject holder,
Object property_name) {
DCHECK(FLAG_log_api);
DCHECK(property_name.IsName());
if (!FLAG_log_api) return;
MSG_BUILDER();
msg << "api" << kNext << tag << kNext << holder.class_name() << kNext
<< Name::cast(property_name);
msg.WriteToLogFile();
}
void Logger::ApiIndexedPropertyAccess(const char* tag, JSObject holder,
uint32_t index) {
if (!FLAG_log_api) return;
void Logger::WriteApiIndexedPropertyAccess(const char* tag, JSObject holder,
uint32_t index) {
DCHECK(FLAG_log_api);
MSG_BUILDER();
msg << "api" << kNext << tag << kNext << holder.class_name() << kNext
<< index;
msg.WriteToLogFile();
}
void Logger::ApiObjectAccess(const char* tag, JSReceiver object) {
if (!FLAG_log_api) return;
void Logger::WriteApiObjectAccess(const char* tag, JSReceiver object) {
DCHECK(FLAG_log_api);
MSG_BUILDER();
msg << "api" << kNext << tag << kNext << object.class_name();
msg.WriteToLogFile();
}
void Logger::ApiEntryCall(const char* name) {
if (!FLAG_log_api) return;
void Logger::WriteApiEntryCall(const char* name) {
DCHECK(FLAG_log_api);
MSG_BUILDER();
msg << "api" << kNext << name;
msg.WriteToLogFile();
......
......@@ -173,12 +173,28 @@ class Logger : public CodeEventListener {
void ScriptDetails(Script script);
// ==== Events logged by --log-api. ====
void ApiSecurityCheck();
void ApiNamedPropertyAccess(const char* tag, JSObject holder, Object name);
void ApiSecurityCheck() {
if (!FLAG_log_api) return;
WriteApiSecurityCheck();
}
void ApiNamedPropertyAccess(const char* tag, JSObject holder, Object name) {
if (!FLAG_log_api) return;
WriteApiNamedPropertyAccess(tag, holder, name);
}
void ApiIndexedPropertyAccess(const char* tag, JSObject holder,
uint32_t index);
void ApiObjectAccess(const char* tag, JSReceiver obj);
void ApiEntryCall(const char* name);
uint32_t index) {
if (!FLAG_log_api) return;
WriteApiIndexedPropertyAccess(tag, holder, index);
}
void ApiObjectAccess(const char* tag, JSReceiver obj) {
if (!FLAG_log_api) return;
WriteApiObjectAccess(tag, obj);
}
void ApiEntryCall(const char* name) {
if (!FLAG_log_api) return;
WriteApiEntryCall(name);
}
// ==== Events logged by --log-code. ====
V8_EXPORT_PRIVATE void AddCodeEventListener(CodeEventListener* listener);
......@@ -312,6 +328,14 @@ class Logger : public CodeEventListener {
Handle<SharedFunctionInfo> shared);
void LogCodeDisassemble(Handle<AbstractCode> code);
void WriteApiSecurityCheck();
void WriteApiNamedPropertyAccess(const char* tag, JSObject holder,
Object name);
void WriteApiIndexedPropertyAccess(const char* tag, JSObject holder,
uint32_t index);
void WriteApiObjectAccess(const char* tag, JSReceiver obj);
void WriteApiEntryCall(const char* name);
int64_t Time();
Isolate* isolate_;
......
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