@@ -53,18 +53,19 @@ void TearDownOncePerProcess();
53
53
namespace boxednode {
54
54
namespace {
55
55
struct TimingEntry {
56
+ const char * const category;
56
57
const char * const label;
57
58
uint64_t const time;
58
59
TimingEntry* next = nullptr ;
59
60
~TimingEntry () {
60
61
delete next;
61
62
}
62
63
};
63
- TimingEntry start_time_entry { " Process initialization" , uv_hrtime () };
64
+ TimingEntry start_time_entry { " Node.js Instance " , " Process initialization" , uv_hrtime () };
64
65
std::atomic<TimingEntry*> current_time_entry { &start_time_entry };
65
66
66
- void MarkTime (const char * label) {
67
- TimingEntry* new_entry = new TimingEntry { label, uv_hrtime () };
67
+ void MarkTime (const char * category, const char * label) {
68
+ TimingEntry* new_entry = new TimingEntry {category, label, uv_hrtime () };
68
69
do {
69
70
new_entry->next = current_time_entry.load ();
70
71
} while (!current_time_entry.compare_exchange_strong (new_entry->next , new_entry));
@@ -81,6 +82,7 @@ void GetTimingData(const FunctionCallbackInfo<Value>& info) {
81
82
std::vector<Local<Value>> entries;
82
83
while (head != nullptr ) {
83
84
Local<Value> elements[] = {
85
+ String::NewFromUtf8 (isolate, head->category ).ToLocalChecked (),
84
86
String::NewFromUtf8 (isolate, head->label ).ToLocalChecked (),
85
87
BigInt::NewFromUnsigned (isolate, head->time )
86
88
};
@@ -143,15 +145,15 @@ static MaybeLocal<Value> LoadBoxednodeEnvironment(Local<Context> context) {
143
145
String::NewFromUtf8Literal (isolate, BOXEDNODE_CODE_CACHE_MODE),
144
146
boxednode::GetBoxednodeCodeCacheBuffer (isolate),
145
147
};
146
- boxednode::MarkTime (" Calling entrypoint" );
148
+ boxednode::MarkTime (" Node.js Instance " , " Calling entrypoint" );
147
149
if (entrypoint_ret.As <Function>()->Call (
148
150
context,
149
151
Null (isolate),
150
152
sizeof (trampoline_args) / sizeof (trampoline_args[0 ]),
151
153
trampoline_args).IsEmpty ()) {
152
154
return {}; // JS exception.
153
155
}
154
- boxednode::MarkTime (" Called entrypoint" );
156
+ boxednode::MarkTime (" Node.js Instance " , " Called entrypoint" );
155
157
return Null (isolate);
156
158
}
157
159
#endif
@@ -208,18 +210,18 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
208
210
#else
209
211
loop = uv_default_loop ();
210
212
#endif
211
- boxednode::MarkTime (" Initialized Loop" );
213
+ boxednode::MarkTime (" Node.js Instance " , " Initialized Loop" );
212
214
213
215
std::shared_ptr<ArrayBufferAllocator> allocator =
214
216
ArrayBufferAllocator::Create ();
215
217
216
218
#ifdef BOXEDNODE_CONSUME_SNAPSHOT
217
219
std::vector<char > snapshot_blob_vec = boxednode::GetBoxednodeSnapshotBlobVector ();
218
- boxednode::MarkTime (" Decoded snapshot" );
220
+ boxednode::MarkTime (" Node.js Instance " , " Decoded snapshot" );
219
221
assert (EmbedderSnapshotData::CanUseCustomSnapshotPerIsolate ());
220
222
node::EmbedderSnapshotData::Pointer snapshot_blob =
221
223
EmbedderSnapshotData::FromBlob (snapshot_blob_vec);
222
- boxednode::MarkTime (" Read snapshot" );
224
+ boxednode::MarkTime (" Node.js Instance " , " Read snapshot" );
223
225
Isolate* isolate = NewIsolate (allocator, loop, platform, snapshot_blob.get ());
224
226
#elif NODE_VERSION_AT_LEAST(14, 0, 0)
225
227
Isolate* isolate = NewIsolate (allocator, loop, platform);
@@ -230,7 +232,7 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
230
232
fprintf (stderr, " %s: Failed to initialize V8 Isolate\n " , args[0 ].c_str ());
231
233
return 1 ;
232
234
}
233
- boxednode::MarkTime (" Created Isolate" );
235
+ boxednode::MarkTime (" Node.js Instance " , " Created Isolate" );
234
236
235
237
{
236
238
Locker locker (isolate);
@@ -246,7 +248,7 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
246
248
),
247
249
node::FreeIsolateData);
248
250
249
- boxednode::MarkTime (" Created IsolateData" );
251
+ boxednode::MarkTime (" Node.js Instance " , " Created IsolateData" );
250
252
HandleScope handle_scope (isolate);
251
253
Local<Context> context;
252
254
#ifndef BOXEDNODE_CONSUME_SNAPSHOT
@@ -262,7 +264,7 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
262
264
// node::LoadEnvironment() are being called.
263
265
Context::Scope context_scope (context);
264
266
#endif
265
- boxednode::MarkTime (" Created Context" );
267
+ boxednode::MarkTime (" Node.js Instance " , " Created Context" );
266
268
267
269
// Create a node::Environment instance that will later be released using
268
270
// node::FreeEnvironment().
@@ -276,7 +278,7 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
276
278
Context::Scope context_scope (context);
277
279
#endif
278
280
assert (isolate->InContext ());
279
- boxednode::MarkTime (" Created Environment" );
281
+ boxednode::MarkTime (" Node.js Instance " , " Created Environment" );
280
282
281
283
const void * node_mod;
282
284
const void * napi_mod;
@@ -297,7 +299,7 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
297
299
env.get (),
298
300
" boxednode_linked_bindings" ,
299
301
boxednode::boxednode_linked_bindings_register, nullptr );
300
- boxednode::MarkTime (" Added bindings" );
302
+ boxednode::MarkTime (" Node.js Instance " , " Added bindings" );
301
303
302
304
// Set up the Node.js instance for execution, and run code inside of it.
303
305
// There is also a variant that takes a callback and provides it with
@@ -311,7 +313,7 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
311
313
if (LoadBoxednodeEnvironment (context).IsEmpty ()) {
312
314
return 1 ; // There has been a JS exception.
313
315
}
314
- boxednode::MarkTime (" Loaded Environment, entering loop" );
316
+ boxednode::MarkTime (" Node.js Instance " , " Loaded Environment, entering loop" );
315
317
316
318
{
317
319
// SealHandleScope protects against handle leaks from callbacks.
@@ -396,13 +398,13 @@ static int BoxednodeMain(std::vector<std::string> args) {
396
398
if (args.size () > 1 )
397
399
args.insert (args.begin () + 1 , " --openssl-shared-config" );
398
400
#endif
399
- boxednode::MarkTime (" Start InitializeOncePerProcess" );
401
+ boxednode::MarkTime (" Node.js Instance " , " Start InitializeOncePerProcess" );
400
402
auto result = node::InitializeOncePerProcess (args, {
401
403
node::ProcessInitializationFlags::kNoInitializeV8 ,
402
404
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform ,
403
405
node::ProcessInitializationFlags::kNoPrintHelpOrVersionOutput
404
406
});
405
- boxednode::MarkTime (" Finished InitializeOncePerProcess" );
407
+ boxednode::MarkTime (" Node.js Instance " , " Finished InitializeOncePerProcess" );
406
408
for (const std::string& error : result->errors ())
407
409
fprintf (stderr, " %s: %s\n " , args[0 ].c_str (), error.c_str ());
408
410
if (result->exit_code () != 0 ) {
@@ -427,7 +429,7 @@ static int BoxednodeMain(std::vector<std::string> args) {
427
429
V8::InitializePlatform (platform.get ());
428
430
V8::Initialize ();
429
431
430
- boxednode::MarkTime (" Initialized V8" );
432
+ boxednode::MarkTime (" Node.js Instance " , " Initialized V8" );
431
433
// See below for the contents of this function.
432
434
int ret = RunNodeInstance (platform.get (), args, exec_args);
433
435
@@ -476,7 +478,7 @@ int wmain(int argc, wchar_t* wargv[]) {
476
478
int main (int argc, char ** argv) {
477
479
argv = uv_setup_args (argc, argv);
478
480
std::vector<std::string> args (argv, argv + argc);
479
- boxednode::MarkTime (" Enter BoxednodeMain" );
481
+ boxednode::MarkTime (" Node.js Instance " , " Enter BoxednodeMain" );
480
482
return BoxednodeMain (std::move (args));
481
483
}
482
484
#endif
0 commit comments