@@ -24,7 +24,6 @@ using v8::Integer;
2424using v8::Isolate;
2525using v8::Local;
2626using v8::MaybeLocal;
27- using v8::Number;
2827using v8::Object;
2928using v8::ObjectTemplate;
3029using v8::PropertyAttribute;
@@ -254,7 +253,7 @@ void Notify(const FunctionCallbackInfo<Value>& args) {
254253void LoopIdleTime (const FunctionCallbackInfo<Value>& args) {
255254 Environment* env = Environment::GetCurrent (args);
256255 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 );
258257}
259258
260259void CreateELDHistogram (const FunctionCallbackInfo<Value>& args) {
@@ -278,12 +277,6 @@ void CreateELDHistogram(const FunctionCallbackInfo<Value>& args) {
278277 args.GetReturnValue ().Set (histogram->object ());
279278}
280279
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-
287280void MarkBootstrapComplete (const FunctionCallbackInfo<Value>& args) {
288281 Realm* realm = Realm::GetCurrent (args);
289282 CHECK_EQ (realm->kind (), Realm::Kind::kPrincipal );
@@ -307,6 +300,23 @@ static void SlowPerformanceNow(const FunctionCallbackInfo<Value>& args) {
307300static v8::CFunction fast_performance_now (
308301 v8::CFunction::Make (FastPerformanceNow));
309302
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+
310320static void CreatePerIsolateProperties (IsolateData* isolate_data,
311321 Local<ObjectTemplate> target) {
312322 Isolate* isolate = isolate_data->isolate ();
@@ -324,11 +334,15 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
324334 RemoveGarbageCollectionTracking);
325335 SetMethod (isolate, target, " notify" , Notify);
326336 SetMethod (isolate, target, " loopIdleTime" , LoopIdleTime);
327- SetMethod (isolate, target, " getTimeOriginTimestamp" , GetTimeOriginTimeStamp);
328337 SetMethod (isolate, target, " createELDHistogram" , CreateELDHistogram);
329338 SetMethod (isolate, target, " markBootstrapComplete" , MarkBootstrapComplete);
330339 SetFastMethodNoSideEffect (
331340 isolate, target, " now" , SlowPerformanceNow, &fast_performance_now);
341+ SetFastMethodNoSideEffect (isolate,
342+ target,
343+ " getTimeOriginTimestamp" ,
344+ SlowGetTimeOriginTimeStamp,
345+ &fast_get_timeorigin_timestamp);
332346}
333347
334348void CreatePerContextProperties (Local<Object> target,
@@ -391,12 +405,14 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
391405 registry->Register (RemoveGarbageCollectionTracking);
392406 registry->Register (Notify);
393407 registry->Register (LoopIdleTime);
394- registry->Register (GetTimeOriginTimeStamp);
395408 registry->Register (CreateELDHistogram);
396409 registry->Register (MarkBootstrapComplete);
397410 registry->Register (SlowPerformanceNow);
398411 registry->Register (FastPerformanceNow);
399412 registry->Register (fast_performance_now.GetTypeInfo ());
413+ registry->Register (SlowGetTimeOriginTimeStamp);
414+ registry->Register (FastGetTimeOriginTimeStamp);
415+ registry->Register (fast_get_timeorigin_timestamp.GetTypeInfo ());
400416 HistogramBase::RegisterExternalReferences (registry);
401417 IntervalHistogram::RegisterExternalReferences (registry);
402418}
0 commit comments