aboutsummaryrefslogtreecommitdiff
path: root/deps/v8
diff options
context:
space:
mode:
authorMatt Loring <mattloring@google.com>2017-06-27 10:49:06 +0200
committerAnna Henningsen <anna@addaleax.net>2017-08-17 20:25:14 +0200
commit4f21834962c22c2d70f57a57e160e2abda84aaed (patch)
treef1b4160c46c77df10a3ab1e5539709e5cdf202b5 /deps/v8
parentc49dcb319b22ec5084384fe279e91a88108b10e9 (diff)
downloadandroid-node-v8-4f21834962c22c2d70f57a57e160e2abda84aaed.tar.gz
android-node-v8-4f21834962c22c2d70f57a57e160e2abda84aaed.tar.bz2
android-node-v8-4f21834962c22c2d70f57a57e160e2abda84aaed.zip
deps: backport c4852ea from upstream V8
Original commit message: Pull tracing related methods out of Platform This will allow for embedders to easily implement their own Platform without duplicating the tracing controller code. BUG=v8:6511 R=fmeawad@chromium.org Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I7c64933d12b2cf53f0636fbc87f6ad5d22019f5c Reviewed-on: https://chromium-review.googlesource.com/543015 Commit-Queue: Jochen Eisinger <jochen@chromium.org> Reviewed-by: Fadi Meawad <fmeawad@chromium.org> Cr-Commit-Position: refs/heads/master@{#46118} PR-URL: https://github.com/nodejs/node/pull/14001 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'deps/v8')
-rw-r--r--deps/v8/include/libplatform/v8-tracing.h32
-rw-r--r--deps/v8/include/v8-platform.h89
-rw-r--r--deps/v8/src/libplatform/default-platform.cc4
-rw-r--r--deps/v8/src/libplatform/default-platform.h1
-rw-r--r--deps/v8/src/libplatform/tracing/tracing-controller.cc8
-rw-r--r--deps/v8/test/cctest/heap/test-incremental-marking.cc23
6 files changed, 107 insertions, 50 deletions
diff --git a/deps/v8/include/libplatform/v8-tracing.h b/deps/v8/include/libplatform/v8-tracing.h
index 902f8ea93d..8c1febf762 100644
--- a/deps/v8/include/libplatform/v8-tracing.h
+++ b/deps/v8/include/libplatform/v8-tracing.h
@@ -209,7 +209,15 @@ class V8_PLATFORM_EXPORT TraceConfig {
void operator=(const TraceConfig&) = delete;
};
-class V8_PLATFORM_EXPORT TracingController {
+#if defined(_MSC_VER)
+#define V8_PLATFORM_NON_EXPORTED_BASE(code) \
+ __pragma(warning(suppress : 4275)) code
+#else
+#define V8_PLATFORM_NON_EXPORTED_BASE(code) code
+#endif // defined(_MSC_VER)
+
+class V8_PLATFORM_EXPORT TracingController
+ : public V8_PLATFORM_NON_EXPORTED_BASE(v8::TracingController) {
public:
enum Mode { DISABLED = 0, RECORDING_MODE };
@@ -227,25 +235,29 @@ class V8_PLATFORM_EXPORT TracingController {
};
TracingController();
- ~TracingController();
+ ~TracingController() override;
void Initialize(TraceBuffer* trace_buffer);
- const uint8_t* GetCategoryGroupEnabled(const char* category_group);
- static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
+
+ // v8::TracingController implementation.
+ const uint8_t* GetCategoryGroupEnabled(const char* category_group) override;
uint64_t AddTraceEvent(
char phase, const uint8_t* category_enabled_flag, const char* name,
const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
const char** arg_names, const uint8_t* arg_types,
const uint64_t* arg_values,
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
- unsigned int flags);
+ unsigned int flags) override;
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
- const char* name, uint64_t handle);
+ const char* name, uint64_t handle) override;
+ void AddTraceStateObserver(
+ v8::TracingController::TraceStateObserver* observer) override;
+ void RemoveTraceStateObserver(
+ v8::TracingController::TraceStateObserver* observer) override;
void StartTracing(TraceConfig* trace_config);
void StopTracing();
- void AddTraceStateObserver(Platform::TraceStateObserver* observer);
- void RemoveTraceStateObserver(Platform::TraceStateObserver* observer);
+ static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
private:
const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group);
@@ -255,7 +267,7 @@ class V8_PLATFORM_EXPORT TracingController {
std::unique_ptr<TraceBuffer> trace_buffer_;
std::unique_ptr<TraceConfig> trace_config_;
std::unique_ptr<base::Mutex> mutex_;
- std::unordered_set<Platform::TraceStateObserver*> observers_;
+ std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
Mode mode_ = DISABLED;
// Disallow copy and assign
@@ -263,6 +275,8 @@ class V8_PLATFORM_EXPORT TracingController {
void operator=(const TracingController&) = delete;
};
+#undef V8_PLATFORM_NON_EXPORTED_BASE
+
} // namespace tracing
} // namespace platform
} // namespace v8
diff --git a/deps/v8/include/v8-platform.h b/deps/v8/include/v8-platform.h
index 8f6d8042ab..0ab153492f 100644
--- a/deps/v8/include/v8-platform.h
+++ b/deps/v8/include/v8-platform.h
@@ -53,6 +53,66 @@ class ConvertableToTraceFormat {
};
/**
+ * V8 Tracing controller.
+ *
+ * Can be implemented by an embedder to record trace events from V8.
+ */
+class TracingController {
+ public:
+ virtual ~TracingController() = default;
+
+ /**
+ * Called by TRACE_EVENT* macros, don't call this directly.
+ * The name parameter is a category group for example:
+ * TRACE_EVENT0("v8,parse", "V8.Parse")
+ * The pointer returned points to a value with zero or more of the bits
+ * defined in CategoryGroupEnabledFlags.
+ **/
+ virtual const uint8_t* GetCategoryGroupEnabled(const char* name) {
+ static uint8_t no = 0;
+ return &no;
+ }
+
+ /**
+ * Adds a trace event to the platform tracing system. This function call is
+ * usually the result of a TRACE_* macro from trace_event_common.h when
+ * tracing and the category of the particular trace are enabled. It is not
+ * advisable to call this function on its own; it is really only meant to be
+ * used by the trace macros. The returned handle can be used by
+ * UpdateTraceEventDuration to update the duration of COMPLETE events.
+ */
+ virtual uint64_t AddTraceEvent(
+ char phase, const uint8_t* category_enabled_flag, const char* name,
+ const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
+ const char** arg_names, const uint8_t* arg_types,
+ const uint64_t* arg_values,
+ std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
+ unsigned int flags) {
+ return 0;
+ }
+
+ /**
+ * Sets the duration field of a COMPLETE trace event. It must be called with
+ * the handle returned from AddTraceEvent().
+ **/
+ virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
+ const char* name, uint64_t handle) {}
+
+ class TraceStateObserver {
+ public:
+ virtual ~TraceStateObserver() = default;
+ virtual void OnTraceEnabled() = 0;
+ virtual void OnTraceDisabled() = 0;
+ };
+
+ /** Adds tracing state change observer. */
+ virtual void AddTraceStateObserver(TraceStateObserver*) {}
+
+ /** Removes tracing state change observer. */
+ virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
+};
+
+/**
* V8 Platform abstraction layer.
*
* The embedder has to provide an implementation of this interface before
@@ -135,6 +195,20 @@ class Platform {
* the epoch.
**/
virtual double MonotonicallyIncreasingTime() = 0;
+ typedef void (*StackTracePrinter)();
+
+ /**
+ * Returns a function pointer that print a stack trace of the current stack
+ * on invocation. Disables printing of the stack trace if nullptr.
+ */
+ virtual StackTracePrinter GetStackTracePrinter() { return nullptr; }
+
+ /**
+ * Returns an instance of a v8::TracingController. This must be non-nullptr.
+ */
+ virtual TracingController* GetTracingController() { return nullptr; }
+
+ // DEPRECATED methods, use TracingController interface instead.
/**
* Called by TRACE_EVENT* macros, don't call this directly.
@@ -200,26 +274,13 @@ class Platform {
virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
const char* name, uint64_t handle) {}
- class TraceStateObserver {
- public:
- virtual ~TraceStateObserver() = default;
- virtual void OnTraceEnabled() = 0;
- virtual void OnTraceDisabled() = 0;
- };
+ typedef v8::TracingController::TraceStateObserver TraceStateObserver;
/** Adds tracing state change observer. */
virtual void AddTraceStateObserver(TraceStateObserver*) {}
/** Removes tracing state change observer. */
virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
-
- typedef void (*StackTracePrinter)();
-
- /**
- * Returns a function pointer that print a stack trace of the current stack
- * on invocation. Disables printing of the stack trace if nullptr.
- */
- virtual StackTracePrinter GetStackTracePrinter() { return nullptr; }
};
} // namespace v8
diff --git a/deps/v8/src/libplatform/default-platform.cc b/deps/v8/src/libplatform/default-platform.cc
index 6629072683..fce946ad6f 100644
--- a/deps/v8/src/libplatform/default-platform.cc
+++ b/deps/v8/src/libplatform/default-platform.cc
@@ -272,6 +272,10 @@ double DefaultPlatform::MonotonicallyIncreasingTime() {
static_cast<double>(base::Time::kMicrosecondsPerSecond);
}
+TracingController* DefaultPlatform::GetTracingController() {
+ return tracing_controller_.get();
+}
+
uint64_t DefaultPlatform::AddTraceEvent(
char phase, const uint8_t* category_enabled_flag, const char* name,
const char* scope, uint64_t id, uint64_t bind_id, int num_args,
diff --git a/deps/v8/src/libplatform/default-platform.h b/deps/v8/src/libplatform/default-platform.h
index 4026864749..3d91433132 100644
--- a/deps/v8/src/libplatform/default-platform.h
+++ b/deps/v8/src/libplatform/default-platform.h
@@ -58,6 +58,7 @@ class V8_PLATFORM_EXPORT DefaultPlatform : public NON_EXPORTED_BASE(Platform) {
void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) override;
bool IdleTasksEnabled(Isolate* isolate) override;
double MonotonicallyIncreasingTime() override;
+ TracingController* GetTracingController() override;
const uint8_t* GetCategoryGroupEnabled(const char* name) override;
const char* GetCategoryGroupName(
const uint8_t* category_enabled_flag) override;
diff --git a/deps/v8/src/libplatform/tracing/tracing-controller.cc b/deps/v8/src/libplatform/tracing/tracing-controller.cc
index c1a4057c05..4fff4be65d 100644
--- a/deps/v8/src/libplatform/tracing/tracing-controller.cc
+++ b/deps/v8/src/libplatform/tracing/tracing-controller.cc
@@ -98,7 +98,7 @@ const char* TracingController::GetCategoryGroupName(
void TracingController::StartTracing(TraceConfig* trace_config) {
trace_config_.reset(trace_config);
- std::unordered_set<Platform::TraceStateObserver*> observers_copy;
+ std::unordered_set<v8::TracingController::TraceStateObserver*> observers_copy;
{
base::LockGuard<base::Mutex> lock(mutex_.get());
mode_ = RECORDING_MODE;
@@ -113,7 +113,7 @@ void TracingController::StartTracing(TraceConfig* trace_config) {
void TracingController::StopTracing() {
mode_ = DISABLED;
UpdateCategoryGroupEnabledFlags();
- std::unordered_set<Platform::TraceStateObserver*> observers_copy;
+ std::unordered_set<v8::TracingController::TraceStateObserver*> observers_copy;
{
base::LockGuard<base::Mutex> lock(mutex_.get());
observers_copy = observers_;
@@ -196,7 +196,7 @@ const uint8_t* TracingController::GetCategoryGroupEnabledInternal(
}
void TracingController::AddTraceStateObserver(
- Platform::TraceStateObserver* observer) {
+ v8::TracingController::TraceStateObserver* observer) {
{
base::LockGuard<base::Mutex> lock(mutex_.get());
observers_.insert(observer);
@@ -207,7 +207,7 @@ void TracingController::AddTraceStateObserver(
}
void TracingController::RemoveTraceStateObserver(
- Platform::TraceStateObserver* observer) {
+ v8::TracingController::TraceStateObserver* observer) {
base::LockGuard<base::Mutex> lock(mutex_.get());
DCHECK(observers_.find(observer) != observers_.end());
observers_.erase(observer);
diff --git a/deps/v8/test/cctest/heap/test-incremental-marking.cc b/deps/v8/test/cctest/heap/test-incremental-marking.cc
index ce1fb34951..84415389cf 100644
--- a/deps/v8/test/cctest/heap/test-incremental-marking.cc
+++ b/deps/v8/test/cctest/heap/test-incremental-marking.cc
@@ -71,29 +71,6 @@ class MockPlatform : public v8::Platform {
delete task;
}
- using Platform::AddTraceEvent;
- uint64_t AddTraceEvent(char phase, const uint8_t* categoryEnabledFlag,
- const char* name, const char* scope, uint64_t id,
- uint64_t bind_id, int numArgs, const char** argNames,
- const uint8_t* argTypes, const uint64_t* argValues,
- unsigned int flags) override {
- return 0;
- }
-
- void UpdateTraceEventDuration(const uint8_t* categoryEnabledFlag,
- const char* name, uint64_t handle) override {}
-
- const uint8_t* GetCategoryGroupEnabled(const char* name) override {
- static uint8_t no = 0;
- return &no;
- }
-
- const char* GetCategoryGroupName(
- const uint8_t* categoryEnabledFlag) override {
- static const char* dummy = "dummy";
- return dummy;
- }
-
private:
v8::Platform* platform_;
Task* task_;