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