@@ -380,16 +380,17 @@ ContextsByNode WallProfiler::GetContextsByNode(CpuProfile* profile,
380
380
}
381
381
382
382
auto isolate = Isolate::GetCurrent ();
383
+ auto v8Context = isolate->GetCurrentContext ();
383
384
auto contextIt = contexts.begin ();
384
385
385
386
// deltaIdx is the offset of the sample to process compared to current
386
387
// iteration index
387
388
int deltaIdx = 0 ;
388
389
389
- auto contextKey = Nan::New<v8::String>( " context" ). ToLocalChecked ( );
390
- auto timestampKey = Nan::New<v8::String>( " timestamp" ). ToLocalChecked ( );
391
- auto cpuTimeKey = Nan::New<v8::String>( " cpuTime" ). ToLocalChecked ( );
392
- auto asyncIdKey = Nan::New<v8::String>( " asyncId" ). ToLocalChecked ( );
390
+ auto contextKey = String::NewFromUtf8Literal (isolate, " context" );
391
+ auto timestampKey = String::NewFromUtf8Literal (isolate, " timestamp" );
392
+ auto cpuTimeKey = String::NewFromUtf8Literal (isolate, " cpuTime" );
393
+ auto asyncIdKey = String::NewFromUtf8Literal (isolate, " asyncId" );
393
394
auto V8toEpochOffset = GetV8ToEpochOffset ();
394
395
auto lastCpuTime = startCpuTime;
395
396
@@ -434,35 +435,43 @@ ContextsByNode WallProfiler::GetContextsByNode(CpuProfile* profile,
434
435
auto it = contextsByNode.find (sample);
435
436
Local<Array> array;
436
437
if (it == contextsByNode.end ()) {
437
- array = Nan ::New<Array>( );
438
+ array = Array ::New(isolate );
438
439
contextsByNode[sample] = {array, 1 };
439
440
} else {
440
441
array = it->second .contexts ;
441
442
++it->second .hitcount ;
442
443
}
443
444
if (sampleContext.context ) {
444
445
// Conforms to TimeProfileNodeContext defined in v8-types.ts
445
- v8::Local<v8::Object> timedContext = Nan::New<v8::Object>();
446
- Nan::Set (timedContext,
447
- contextKey,
448
- sampleContext.context .get ()->Get (isolate));
449
- Nan::Set (timedContext,
450
- timestampKey,
451
- BigInt::New (isolate, sampleTimestamp + V8toEpochOffset));
446
+ Local<Object> timedContext = Object::New (isolate);
447
+ timedContext
448
+ ->Set (v8Context,
449
+ contextKey,
450
+ sampleContext.context .get ()->Get (isolate))
451
+ .Check ();
452
+ timedContext
453
+ ->Set (v8Context,
454
+ timestampKey,
455
+ BigInt::New (isolate, sampleTimestamp + V8toEpochOffset))
456
+ .Check ();
452
457
453
458
// if current sample is idle/program, reports its cpu time to the next
454
459
// sample
455
460
if (collectCpuTime_ && !isIdleOrProgram (sample)) {
456
- Nan::Set (
457
- timedContext,
458
- cpuTimeKey,
459
- Nan::New<v8::Number>(sampleContext.cpu_time - lastCpuTime));
461
+ timedContext
462
+ ->Set (
463
+ v8Context,
464
+ cpuTimeKey,
465
+ Number::New (isolate, sampleContext.cpu_time - lastCpuTime))
466
+ .Check ();
460
467
lastCpuTime = sampleContext.cpu_time ;
461
468
}
462
- Nan::Set (timedContext,
463
- asyncIdKey,
464
- Nan::New<v8::Number>(sampleContext.async_id ));
465
- Nan::Set (array, array->Length (), timedContext);
469
+ timedContext
470
+ ->Set (v8Context,
471
+ asyncIdKey,
472
+ Number::New (isolate, sampleContext.async_id ))
473
+ .Check ();
474
+ array->Set (v8Context, array->Length (), timedContext).Check ();
466
475
}
467
476
468
477
// Sample context was consumed, fetch the next one
0 commit comments