Commit 87043bbb authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

[diagnostics] Don't build system trace code on non-win non-mac

Bug: v8:11699
Change-Id: I286ea7d3a6455528c66eee3f479455bfc49f190c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2852039
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74232}
parent 2ec2bda8
......@@ -41,7 +41,7 @@ declare_args() {
v8_enable_future = false
# Sets -DSYSTEM_INSTRUMENTATION. Enables OS-dependent event tracing
v8_enable_system_instrumentation = true
v8_enable_system_instrumentation = is_win || is_mac
# Sets the GUID for the ETW provider
v8_etw_guid = ""
......@@ -4781,8 +4781,6 @@ v8_component("v8_libplatform") {
"src/libplatform/delayed-task-queue.h",
"src/libplatform/task-queue.cc",
"src/libplatform/task-queue.h",
"src/libplatform/tracing/recorder-default.cc",
"src/libplatform/tracing/recorder.h",
"src/libplatform/tracing/trace-buffer.cc",
"src/libplatform/tracing/trace-buffer.h",
"src/libplatform/tracing/trace-config.cc",
......@@ -4813,8 +4811,6 @@ v8_component("v8_libplatform") {
if (v8_use_perfetto) {
sources -= [
"//base/trace_event/common/trace_event_common.h",
"src/libplatform/tracing/recorder-default.cc",
"src/libplatform/tracing/recorder.h",
"src/libplatform/tracing/trace-buffer.cc",
"src/libplatform/tracing/trace-buffer.h",
"src/libplatform/tracing/trace-object.cc",
......@@ -4829,12 +4825,15 @@ v8_component("v8_libplatform") {
# TODO(skyostil): Switch TraceEventListener to protozero.
"//third_party/perfetto/protos/perfetto/trace:lite",
]
} else if (is_win) {
sources -= [ "src/libplatform/tracing/recorder-default.cc" ]
sources += [ "src/libplatform/tracing/recorder-win.cc" ]
} else if (is_mac) {
sources -= [ "src/libplatform/tracing/recorder-default.cc" ]
sources += [ "src/libplatform/tracing/recorder-mac.cc" ]
}
if (v8_enable_system_instrumentation) {
sources += [ "src/libplatform/tracing/recorder.h" ]
if (is_mac) {
sources += [ "src/libplatform/tracing/recorder-mac.cc" ]
} else if (is_win) {
sources += [ "src/libplatform/tracing/recorder-win.cc" ]
}
}
}
......
......@@ -4146,17 +4146,15 @@ bool Shell::SetOptions(int argc, char* argv[]) {
options.fuzzy_module_file_extensions = true;
argv[i] = nullptr;
#if defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
#if defined(V8_TARGET_OS_WIN) || defined(V8_TARGET_OS_MACOSX)
} else if (strcmp(argv[i], "--enable-system-instrumentation") == 0) {
options.enable_system_instrumentation = true;
options.trace_enabled = true;
#if defined(V8_TARGET_OS_WIN)
#if defined(V8_OS_WIN)
// Guard this bc the flag has a lot of overhead and is not currently used
// by macos
i::FLAG_interpreted_frames_native_stack = true;
#endif
argv[i] = nullptr;
#endif
#endif
}
}
......
......@@ -9,6 +9,10 @@
#include "src/diagnostics/system-jit-metadata-win.h"
#include "src/libplatform/tracing/recorder.h"
#if !defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
#error "This file is only compiled if v8_enable_system_instrumentation"
#endif
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wc++98-compat-extra-semi"
#endif
......
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_LIBPLATFORM_TRACING_RECORDER_DEFAULT_H_
#define V8_LIBPLATFORM_TRACING_RECORDER_DEFAULT_H_
#include "src/libplatform/tracing/recorder.h"
namespace v8 {
namespace platform {
namespace tracing {
Recorder::Recorder() {}
Recorder::~Recorder() {}
bool Recorder::IsEnabled() { return false; }
bool Recorder::IsEnabled(const uint8_t level) { return false; }
void Recorder::AddEvent(TraceObject* trace_event) {}
} // namespace tracing
} // namespace platform
} // namespace v8
#endif // V8_LIBPLATFORM_TRACING_RECORDER_DEFAULT_H_
......@@ -9,19 +9,17 @@
#include "include/libplatform/v8-tracing.h"
#ifdef V8_OS_MACOSX
#if !defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
#error V8_ENABLE_SYSTEM_INSTRUMENTATION is not defined
#error "only include this file if V8_ENABLE_SYSTEM_INSTRUMENTATION"
#endif
#if V8_OS_MACOSX
#include <os/signpost.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
#endif
#if V8_OS_WIN
#if !defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
#error V8_ENABLE_SYSTEM_INSTRUMENTATION is not defined
#endif
#ifndef V8_ETW_GUID
#define V8_ETW_GUID \
0x57277741, 0x3638, 0x4A4B, 0xBD, 0xBA, 0x0A, 0xC6, 0xE4, 0x5D, 0xA5, 0x6C
......@@ -49,7 +47,7 @@ class V8_PLATFORM_EXPORT Recorder {
void AddEvent(TraceObject* trace_event);
private:
#ifdef V8_OS_MACOSX
#if V8_OS_MACOSX
os_log_t v8Provider;
#endif
};
......@@ -58,7 +56,7 @@ class V8_PLATFORM_EXPORT Recorder {
} // namespace platform
} // namespace v8
#ifdef V8_OS_MACOSX
#if V8_OS_MACOSX
#pragma clang diagnostic pop
#endif
......
......@@ -9,7 +9,10 @@
#include "base/trace_event/common/trace_event_common.h"
#include "include/v8-platform.h"
#include "src/base/platform/platform.h"
#if defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
#include "src/libplatform/tracing/recorder.h"
#endif
namespace v8 {
namespace platform {
......@@ -191,6 +194,7 @@ TraceWriter* TraceWriter::CreateJSONTraceWriter(std::ostream& stream,
return new JSONTraceWriter(stream, tag);
}
#if defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
SystemInstrumentationTraceWriter::SystemInstrumentationTraceWriter() {
recorder_ = std::make_unique<Recorder>();
}
......@@ -211,6 +215,7 @@ void SystemInstrumentationTraceWriter::Flush() {}
TraceWriter* TraceWriter::CreateSystemInstrumentationTraceWriter() {
return new SystemInstrumentationTraceWriter();
}
#endif
} // namespace tracing
} // namespace platform
......
......@@ -29,6 +29,7 @@ class JSONTraceWriter : public TraceWriter {
bool append_comma_ = false;
};
#if defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
class SystemInstrumentationTraceWriter : public TraceWriter {
public:
SystemInstrumentationTraceWriter();
......@@ -39,6 +40,7 @@ class SystemInstrumentationTraceWriter : public TraceWriter {
private:
std::unique_ptr<Recorder> recorder_;
};
#endif
} // namespace tracing
} // namespace platform
......
......@@ -31,6 +31,8 @@ OUT_DIR = os.path.join(V8_DIR, 'check-header-includes')
AUTO_EXCLUDE = [
# flag-definitions.h needs a mode set for being included.
'src/flags/flag-definitions.h',
# recorder.h should only be included conditionally.
'src/libplatform/tracing/recorder.h',
]
AUTO_EXCLUDE_PATTERNS = [
'src/base/atomicops_internals_.*',
......
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