mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
deps: cherry-pick 814577e from upstream V8
Original commit message:
[tracing] allow embedders to provide own tracing timestamps
Make it possible for embedders to provide their own tracing timetamps by
providing an overridable virtual function on V8's tracing controller.
Bug:
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I727e633cb7f63d4b41c2e427ecca3c9174c90bfe
Reviewed-on: https://chromium-review.googlesource.com/847690
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Fadi Meawad <fmeawad@chromium.org>
Commit-Queue: Ali Ijaz Sheikh <ofrobots@google.com>
Cr-Commit-Position: refs/heads/master@{#50489}
Refs: https://github.com/v8/v8/commit/814577e3fd097ef772fd6d92a1ad3abd934506e6
Refs: https://github.com/nodejs/node/issues/17349
PR-URL: https://github.com/nodejs/node/pull/18196
Refs: https://github.com/nodejs/node/pull/18360
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
This commit is contained in:
1 parent
990959d2f6
commit
a1c5dddbb2
5 files changed
+30
-15
No files matched your search
+1
-1
@@ -27,7 +27,7 @@
|
||||
|
||||
# Reset this number to 0 on major V8 upgrades.
|
||||
# Increment by one for each non-official patch applied to deps/v8.
|
||||
'v8_embedder_string': '-node.1',
|
||||
'v8_embedder_string': '-node.2',
|
||||
|
||||
# Enable disassembler for `--print-code` v8 options
|
||||
'v8_enable_disassembler': 1,
|
||||
|
||||
+6
-2
@@ -43,8 +43,8 @@ class V8_PLATFORM_EXPORT TraceObject {
|
||||
const char** arg_names, const uint8_t* arg_types,
|
||||
const uint64_t* arg_values,
|
||||
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
|
||||
unsigned int flags);
|
||||
void UpdateDuration();
|
||||
unsigned int flags, int64_t timestamp, int64_t cpu_timestamp);
|
||||
void UpdateDuration(int64_t timestamp, int64_t cpu_timestamp);
|
||||
void InitializeForTesting(
|
||||
char phase, const uint8_t* category_enabled_flag, const char* name,
|
||||
const char* scope, uint64_t id, uint64_t bind_id, int num_args,
|
||||
@@ -259,6 +259,10 @@ class V8_PLATFORM_EXPORT TracingController
|
||||
|
||||
static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
|
||||
|
||||
protected:
|
||||
virtual int64_t CurrentTimestampMicroseconds();
|
||||
virtual int64_t CurrentCpuTimestampMicroseconds();
|
||||
|
||||
private:
|
||||
const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group);
|
||||
void UpdateCategoryGroupEnabledFlag(size_t category_index);
|
||||
|
||||
+6
-6
@@ -37,7 +37,7 @@ void TraceObject::Initialize(
|
||||
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, int64_t timestamp, int64_t cpu_timestamp) {
|
||||
pid_ = base::OS::GetCurrentProcessId();
|
||||
tid_ = base::OS::GetCurrentThreadId();
|
||||
phase_ = phase;
|
||||
@@ -47,8 +47,8 @@ void TraceObject::Initialize(
|
||||
id_ = id;
|
||||
bind_id_ = bind_id;
|
||||
flags_ = flags;
|
||||
ts_ = base::TimeTicks::HighResolutionNow().ToInternalValue();
|
||||
tts_ = base::ThreadTicks::Now().ToInternalValue();
|
||||
ts_ = timestamp;
|
||||
tts_ = cpu_timestamp;
|
||||
duration_ = 0;
|
||||
cpu_duration_ = 0;
|
||||
|
||||
@@ -103,9 +103,9 @@ void TraceObject::Initialize(
|
||||
|
||||
TraceObject::~TraceObject() { delete[] parameter_copy_storage_; }
|
||||
|
||||
void TraceObject::UpdateDuration() {
|
||||
duration_ = base::TimeTicks::HighResolutionNow().ToInternalValue() - ts_;
|
||||
cpu_duration_ = base::ThreadTicks::Now().ToInternalValue() - tts_;
|
||||
void TraceObject::UpdateDuration(int64_t timestamp, int64_t cpu_timestamp) {
|
||||
duration_ = timestamp - ts_;
|
||||
cpu_duration_ = cpu_timestamp - tts_;
|
||||
}
|
||||
|
||||
void TraceObject::InitializeForTesting(
|
||||
|
||||
+15
-4
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/base/platform/time.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace platform {
|
||||
@@ -48,6 +49,14 @@ void TracingController::Initialize(TraceBuffer* trace_buffer) {
|
||||
mutex_.reset(new base::Mutex());
|
||||
}
|
||||
|
||||
int64_t TracingController::CurrentTimestampMicroseconds() {
|
||||
return base::TimeTicks::HighResolutionNow().ToInternalValue();
|
||||
}
|
||||
|
||||
int64_t TracingController::CurrentCpuTimestampMicroseconds() {
|
||||
return base::ThreadTicks::Now().ToInternalValue();
|
||||
}
|
||||
|
||||
uint64_t TracingController::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,
|
||||
@@ -58,9 +67,10 @@ uint64_t TracingController::AddTraceEvent(
|
||||
uint64_t handle;
|
||||
TraceObject* trace_object = trace_buffer_->AddTraceEvent(&handle);
|
||||
if (trace_object) {
|
||||
trace_object->Initialize(phase, category_enabled_flag, name, scope, id,
|
||||
bind_id, num_args, arg_names, arg_types,
|
||||
arg_values, arg_convertables, flags);
|
||||
trace_object->Initialize(
|
||||
phase, category_enabled_flag, name, scope, id, bind_id, num_args,
|
||||
arg_names, arg_types, arg_values, arg_convertables, flags,
|
||||
CurrentTimestampMicroseconds(), CurrentCpuTimestampMicroseconds());
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
@@ -69,7 +79,8 @@ void TracingController::UpdateTraceEventDuration(
|
||||
const uint8_t* category_enabled_flag, const char* name, uint64_t handle) {
|
||||
TraceObject* trace_object = trace_buffer_->GetEventByHandle(handle);
|
||||
if (!trace_object) return;
|
||||
trace_object->UpdateDuration();
|
||||
trace_object->UpdateDuration(CurrentTimestampMicroseconds(),
|
||||
CurrentCpuTimestampMicroseconds());
|
||||
}
|
||||
|
||||
const uint8_t* TracingController::GetCategoryGroupEnabled(
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ TEST(TestTraceObject) {
|
||||
uint8_t category_enabled_flag = 41;
|
||||
trace_object.Initialize('X', &category_enabled_flag, "Test.Trace",
|
||||
"Test.Scope", 42, 123, 0, nullptr, nullptr, nullptr,
|
||||
nullptr, 0);
|
||||
nullptr, 0, 1729, 4104);
|
||||
CHECK_EQ('X', trace_object.phase());
|
||||
CHECK_EQ(category_enabled_flag, *trace_object.category_enabled_flag());
|
||||
CHECK_EQ(std::string("Test.Trace"), std::string(trace_object.name()));
|
||||
@@ -96,7 +96,7 @@ TEST(TestTraceBufferRingBuffer) {
|
||||
CHECK_NOT_NULL(trace_object);
|
||||
trace_object->Initialize('X', &category_enabled_flag, names[i].c_str(),
|
||||
"Test.Scope", 42, 123, 0, nullptr, nullptr,
|
||||
nullptr, nullptr, 0);
|
||||
nullptr, nullptr, 0, 1729, 4104);
|
||||
trace_object = ring_buffer->GetEventByHandle(handles[i]);
|
||||
CHECK_NOT_NULL(trace_object);
|
||||
CHECK_EQ('X', trace_object->phase());
|
||||
|
||||
Reference in new issue
Block a user