@@ -254,7 +254,7 @@ void Notify(const FunctionCallbackInfo<Value>& args) {
254
254
void LoopIdleTime (const FunctionCallbackInfo<Value>& args) {
255
255
Environment* env = Environment::GetCurrent (args);
256
256
uint64_t idle_time = uv_metrics_idle_time (env->event_loop ());
257
- args.GetReturnValue ().Set (1.0 * idle_time / 1e6 );
257
+ args.GetReturnValue ().Set (1.0 * idle_time / NANOS_PER_MILLIS );
258
258
}
259
259
260
260
void CreateELDHistogram (const FunctionCallbackInfo<Value>& args) {
@@ -278,12 +278,6 @@ void CreateELDHistogram(const FunctionCallbackInfo<Value>& args) {
278
278
args.GetReturnValue ().Set (histogram->object ());
279
279
}
280
280
281
- void GetTimeOriginTimeStamp (const FunctionCallbackInfo<Value>& args) {
282
- Environment* env = Environment::GetCurrent (args);
283
- args.GetReturnValue ().Set (Number::New (
284
- args.GetIsolate (), env->time_origin_timestamp () / MICROS_PER_MILLIS));
285
- }
286
-
287
281
void MarkBootstrapComplete (const FunctionCallbackInfo<Value>& args) {
288
282
Realm* realm = Realm::GetCurrent (args);
289
283
CHECK_EQ (realm->kind (), Realm::Kind::kPrincipal );
@@ -307,6 +301,23 @@ static void SlowPerformanceNow(const FunctionCallbackInfo<Value>& args) {
307
301
static v8::CFunction fast_performance_now (
308
302
v8::CFunction::Make (FastPerformanceNow));
309
303
304
+ static double GetTimeOriginTimeStampImpl () {
305
+ return static_cast <double >(performance_process_start_timestamp) /
306
+ MICROS_PER_MILLIS;
307
+ }
308
+
309
+ static double FastGetTimeOriginTimeStamp (v8::Local<v8::Value> receiver) {
310
+ return GetTimeOriginTimeStampImpl ();
311
+ }
312
+
313
+ static void SlowGetTimeOriginTimeStamp (
314
+ const FunctionCallbackInfo<Value>& args) {
315
+ args.GetReturnValue ().Set (GetTimeOriginTimeStampImpl ());
316
+ }
317
+
318
+ static v8::CFunction fast_get_timeorigin_timestamp (
319
+ v8::CFunction::Make (FastGetTimeOriginTimeStamp));
320
+
310
321
static void CreatePerIsolateProperties (IsolateData* isolate_data,
311
322
Local<ObjectTemplate> target) {
312
323
Isolate* isolate = isolate_data->isolate ();
@@ -324,11 +335,15 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
324
335
RemoveGarbageCollectionTracking);
325
336
SetMethod (isolate, target, " notify" , Notify);
326
337
SetMethod (isolate, target, " loopIdleTime" , LoopIdleTime);
327
- SetMethod (isolate, target, " getTimeOriginTimestamp" , GetTimeOriginTimeStamp);
328
338
SetMethod (isolate, target, " createELDHistogram" , CreateELDHistogram);
329
339
SetMethod (isolate, target, " markBootstrapComplete" , MarkBootstrapComplete);
330
340
SetFastMethodNoSideEffect (
331
341
isolate, target, " now" , SlowPerformanceNow, &fast_performance_now);
342
+ SetFastMethodNoSideEffect (isolate,
343
+ target,
344
+ " getTimeOriginTimestamp" ,
345
+ SlowGetTimeOriginTimeStamp,
346
+ &fast_get_timeorigin_timestamp);
332
347
}
333
348
334
349
void CreatePerContextProperties (Local<Object> target,
@@ -391,12 +406,14 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
391
406
registry->Register (RemoveGarbageCollectionTracking);
392
407
registry->Register (Notify);
393
408
registry->Register (LoopIdleTime);
394
- registry->Register (GetTimeOriginTimeStamp);
395
409
registry->Register (CreateELDHistogram);
396
410
registry->Register (MarkBootstrapComplete);
397
411
registry->Register (SlowPerformanceNow);
398
412
registry->Register (FastPerformanceNow);
399
413
registry->Register (fast_performance_now.GetTypeInfo ());
414
+ registry->Register (SlowGetTimeOriginTimeStamp);
415
+ registry->Register (FastGetTimeOriginTimeStamp);
416
+ registry->Register (fast_get_timeorigin_timestamp.GetTypeInfo ());
400
417
HistogramBase::RegisterExternalReferences (registry);
401
418
IntervalHistogram::RegisterExternalReferences (registry);
402
419
}
0 commit comments