Skip to content

Commit 3ef8e96

Browse files
committed
Revert general-regs-only changes (#203)
1 parent 1872ddd commit 3ef8e96

11 files changed

+55
-119
lines changed

binding.gyp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"bindings/profilers/heap.cc",
1616
"bindings/profilers/wall.cc",
1717
"bindings/per-isolate-data.cc",
18-
"bindings/profile-translator.cc",
1918
"bindings/thread-cpu-clock.cc",
2019
"bindings/translate-heap-profile.cc",
2120
"bindings/translate-time-profile.cc",

bindings/general-regs-only.hh

Lines changed: 0 additions & 23 deletions
This file was deleted.

bindings/profile-translator.cc

Lines changed: 0 additions & 22 deletions
This file was deleted.

bindings/profile-translator.hh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ class ProfileTranslator {
3333
return v8::Boolean::New(isolate, x);
3434
}
3535

36-
v8::Local<v8::Number> NewNumber(int64_t x);
36+
template <typename T>
37+
v8::Local<v8::Number> NewNumber(T x) {
38+
return v8::Number::New(isolate, x);
39+
}
3740

3841
v8::Local<v8::Array> NewArray(int length) {
3942
return length == 0 ? emptyArray : v8::Array::New(isolate, length);

bindings/profilers/heap.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#pragma once
1818

1919
#include <nan.h>
20-
#include "general-regs-only.hh"
2120

2221
namespace dd {
2322

@@ -35,7 +34,7 @@ class HeapProfiler {
3534
// getAllocationProfile(): AllocationProfileNode
3635
static NAN_METHOD(GetAllocationProfile);
3736

38-
static NAN_METHOD(MonitorOutOfMemory) GENERAL_REGS_ONLY;
37+
static NAN_METHOD(MonitorOutOfMemory);
3938

4039
static NAN_MODULE_INIT(Init);
4140
};

bindings/profilers/wall.cc

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -366,17 +366,10 @@ static int64_t GetV8ToEpochOffset() {
366366
return V8toEpochOffset;
367367
}
368368

369-
Local<Number> NewNumberFromInt64(Isolate* isolate, int64_t value) {
370-
return Number::New(isolate, static_cast<double>(value));
371-
}
372-
373-
std::shared_ptr<ContextsByNode> CreateContextsByNode() {
374-
return std::make_shared<ContextsByNode>();
375-
}
376-
377-
std::shared_ptr<ContextsByNode> WallProfiler::GetContextsByNode(
378-
CpuProfile* profile, ContextBuffer& contexts, int64_t startCpuTime) {
379-
auto contextsByNode = CreateContextsByNode();
369+
ContextsByNode WallProfiler::GetContextsByNode(CpuProfile* profile,
370+
ContextBuffer& contexts,
371+
int64_t startCpuTime) {
372+
ContextsByNode contextsByNode;
380373

381374
auto sampleCount = profile->GetSamplesCount();
382375
if (contexts.empty() || sampleCount == 0) {
@@ -436,11 +429,11 @@ std::shared_ptr<ContextsByNode> WallProfiler::GetContextsByNode(
436429
break;
437430
} else {
438431
// This sample context is the closest to this sample.
439-
auto it = contextsByNode->find(sample);
432+
auto it = contextsByNode.find(sample);
440433
Local<Array> array;
441-
if (it == contextsByNode->end()) {
434+
if (it == contextsByNode.end()) {
442435
array = Array::New(isolate);
443-
(*contextsByNode)[sample] = {array, 1};
436+
contextsByNode[sample] = {array, 1};
444437
} else {
445438
array = it->second.contexts;
446439
++it->second.hitcount;
@@ -457,10 +450,10 @@ std::shared_ptr<ContextsByNode> WallProfiler::GetContextsByNode(
457450
if (strcmp(function_name, "(program)") != 0) {
458451
if (collectCpuTime_) {
459452
timedContext
460-
->Set(v8Context,
461-
cpuTimeKey,
462-
NewNumberFromInt64(isolate,
463-
sampleContext.cpu_time - lastCpuTime))
453+
->Set(
454+
v8Context,
455+
cpuTimeKey,
456+
Number::New(isolate, sampleContext.cpu_time - lastCpuTime))
464457
.Check();
465458
lastCpuTime = sampleContext.cpu_time;
466459
}
@@ -478,7 +471,7 @@ std::shared_ptr<ContextsByNode> WallProfiler::GetContextsByNode(
478471
timedContext
479472
->Set(v8Context,
480473
asyncIdKey,
481-
NewNumberFromInt64(isolate, sampleContext.async_id))
474+
Number::New(isolate, sampleContext.async_id))
482475
.Check();
483476
}
484477
}
@@ -893,7 +886,7 @@ Result WallProfiler::StopImpl(bool restart, v8::Local<v8::Value>& profile) {
893886

894887
profile = TranslateTimeProfile(v8_profile,
895888
includeLines_,
896-
contextsByNode,
889+
&contextsByNode,
897890
collectCpuTime_,
898891
nonJSThreadsCpuTime);
899892

@@ -1027,14 +1020,12 @@ NAN_METHOD(WallProfiler::Dispose) {
10271020
delete profiler;
10281021
}
10291022

1030-
int64_t GetAsyncIdNoGC(v8::Isolate* isolate) {
1031-
return isolate->InContext()
1032-
? static_cast<int64_t>(
1033-
node::AsyncHooksGetExecutionAsyncId(isolate))
1034-
: -1;
1023+
double GetAsyncIdNoGC(v8::Isolate* isolate) {
1024+
return isolate->InContext() ? node::AsyncHooksGetExecutionAsyncId(isolate)
1025+
: -1;
10351026
}
10361027

1037-
int64_t WallProfiler::GetAsyncId(v8::Isolate* isolate) {
1028+
double WallProfiler::GetAsyncId(v8::Isolate* isolate) {
10381029
if (!collectAsyncId_) {
10391030
return -1;
10401031
}
@@ -1069,7 +1060,7 @@ void WallProfiler::OnGCEnd() {
10691060
void WallProfiler::PushContext(int64_t time_from,
10701061
int64_t time_to,
10711062
int64_t cpu_time,
1072-
int64_t async_id) {
1063+
double async_id) {
10731064
// Be careful this is called in a signal handler context therefore all
10741065
// operations must be async signal safe (in particular no allocations).
10751066
// Our ring buffer avoids allocations.

bindings/profilers/wall.hh

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#pragma once
1818

1919
#include "contexts.hh"
20-
#include "general-regs-only.hh"
2120
#include "thread-cpu-clock.hh"
2221

2322
#include <nan.h>
@@ -59,7 +58,7 @@ class WallProfiler : public Nan::ObjectWrap {
5958
std::atomic<ContextPtr*> curContext_;
6059

6160
std::atomic<int> gcCount = 0;
62-
int64_t gcAsyncId;
61+
double gcAsyncId;
6362

6463
std::atomic<CollectionMode> collectionMode_;
6564
std::atomic<uint64_t> noCollectCallCount_;
@@ -87,7 +86,7 @@ class WallProfiler : public Nan::ObjectWrap {
8786
int64_t time_from;
8887
int64_t time_to;
8988
int64_t cpu_time;
90-
int64_t async_id;
89+
double async_id;
9190
};
9291

9392
using ContextBuffer = std::vector<SampleContext>;
@@ -100,10 +99,9 @@ class WallProfiler : public Nan::ObjectWrap {
10099
// to work around https://bugs.chromium.org/p/v8/issues/detail?id=11051.
101100
v8::CpuProfiler* CreateV8CpuProfiler();
102101

103-
std::shared_ptr<ContextsByNode> GetContextsByNode(v8::CpuProfile* profile,
104-
ContextBuffer& contexts,
105-
int64_t startCpuTime)
106-
GENERAL_REGS_ONLY;
102+
ContextsByNode GetContextsByNode(v8::CpuProfile* profile,
103+
ContextBuffer& contexts,
104+
int64_t startCpuTime);
107105

108106
bool waitForSignal(uint64_t targetCallCount = 0);
109107

@@ -129,11 +127,10 @@ class WallProfiler : public Nan::ObjectWrap {
129127
void PushContext(int64_t time_from,
130128
int64_t time_to,
131129
int64_t cpu_time,
132-
int64_t async_id);
130+
double async_id);
133131
Result StartImpl();
134132
std::string StartInternal();
135-
Result StopImpl(bool restart,
136-
v8::Local<v8::Value>& profile) GENERAL_REGS_ONLY;
133+
Result StopImpl(bool restart, v8::Local<v8::Value>& profile);
137134

138135
CollectionMode collectionMode() {
139136
auto res = collectionMode_.load(std::memory_order_relaxed);
@@ -154,16 +151,16 @@ class WallProfiler : public Nan::ObjectWrap {
154151
return threadCpuStopWatch_.GetAndReset();
155152
}
156153

157-
int64_t GetAsyncId(v8::Isolate* isolate);
154+
double GetAsyncId(v8::Isolate* isolate);
158155
void OnGCStart(v8::Isolate* isolate);
159156
void OnGCEnd();
160157

161-
static NAN_METHOD(New) GENERAL_REGS_ONLY;
158+
static NAN_METHOD(New);
162159
static NAN_METHOD(Start);
163160
static NAN_METHOD(Stop);
164161
static NAN_METHOD(V8ProfilerStuckEventLoopDetected);
165162
static NAN_METHOD(Dispose);
166-
static NAN_MODULE_INIT(Init) GENERAL_REGS_ONLY;
163+
static NAN_MODULE_INIT(Init);
167164
static NAN_GETTER(GetContext);
168165
static NAN_SETTER(SetContext);
169166
static NAN_GETTER(SharedArrayGetter);

bindings/translate-heap-profile.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class HeapProfileTranslator : ProfileTranslator {
4141

4242
public:
4343
v8::Local<v8::Value> TranslateAllocationProfile(
44-
v8::AllocationProfile::Node* node) GENERAL_REGS_ONLY {
44+
v8::AllocationProfile::Node* node) {
4545
v8::Local<v8::Array> children = NewArray(node->children.size());
4646
for (size_t i = 0; i < node->children.size(); i++) {
4747
Set(children, i, TranslateAllocationProfile(node->children[i]));
@@ -71,8 +71,7 @@ class HeapProfileTranslator : ProfileTranslator {
7171
v8::Local<v8::Integer> lineNumber,
7272
v8::Local<v8::Integer> columnNumber,
7373
v8::Local<v8::Array> children,
74-
v8::Local<v8::Array> allocations)
75-
GENERAL_REGS_ONLY {
74+
v8::Local<v8::Array> allocations) {
7675
v8::Local<v8::Object> js_node = NewObject();
7776
#define X(name) Set(js_node, str_##name, name);
7877
NODE_FIELDS
@@ -82,8 +81,7 @@ class HeapProfileTranslator : ProfileTranslator {
8281
}
8382

8483
v8::Local<v8::Object> CreateAllocation(v8::Local<v8::Number> count,
85-
v8::Local<v8::Number> sizeBytes)
86-
GENERAL_REGS_ONLY {
84+
v8::Local<v8::Number> sizeBytes) {
8785
v8::Local<v8::Object> js_alloc = NewObject();
8886
#define X(name) Set(js_alloc, str_##name, name);
8987
ALLOCATION_FIELDS

bindings/translate-heap-profile.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
#pragma once
1818

1919
#include <v8-profiler.h>
20-
#include "general-regs-only.hh"
2120

2221
namespace dd {
2322

2423
v8::Local<v8::Value> TranslateAllocationProfile(
25-
v8::AllocationProfile::Node* node) GENERAL_REGS_ONLY;
24+
v8::AllocationProfile::Node* node);
2625

2726
} // namespace dd

0 commit comments

Comments
 (0)