@@ -457,6 +457,12 @@ class FastHrtime : public BaseObject {
457
457
SET_MEMORY_INFO_NAME (FastHrtime)
458
458
SET_SELF_SIZE(FastHrtime)
459
459
460
+ static FastHrtime* FromV8ApiObject(v8::ApiObject api_object) {
461
+ v8::Object* v8_object = reinterpret_cast <v8::Object*>(&api_object);
462
+ return static_cast <FastHrtime*>(
463
+ v8_object->GetAlignedPointerFromInternalField (BaseObject::kSlot ));
464
+ }
465
+
460
466
// This is the legacy version of hrtime before BigInt was introduced in
461
467
// JavaScript.
462
468
// The value returned by uv_hrtime() is a 64-bit int representing nanoseconds,
@@ -466,26 +472,34 @@ class FastHrtime : public BaseObject {
466
472
// broken into the upper/lower 32 bits to be converted back in JS,
467
473
// because there is no Uint64Array in JS.
468
474
// The third entry contains the remaining nanosecond part of the value.
469
- static void FastNumber (FastHrtime* receiver) {
475
+ static void NumberImpl (FastHrtime* receiver) {
470
476
uint64_t t = uv_hrtime ();
471
477
uint32_t * fields = static_cast <uint32_t *>(receiver->backing_store_ ->Data ());
472
478
fields[0 ] = (t / NANOS_PER_SEC) >> 32 ;
473
479
fields[1 ] = (t / NANOS_PER_SEC) & 0xffffffff ;
474
480
fields[2 ] = t % NANOS_PER_SEC;
475
481
}
476
482
483
+ static void FastNumber (v8::ApiObject receiver) {
484
+ NumberImpl (FromV8ApiObject (receiver));
485
+ }
486
+
477
487
static void SlowNumber (const FunctionCallbackInfo<Value>& args) {
478
- FastNumber (FromJSObject<FastHrtime>(args.Holder ()));
488
+ NumberImpl (FromJSObject<FastHrtime>(args.Holder ()));
479
489
}
480
490
481
- static void FastBigInt (FastHrtime* receiver) {
491
+ static void BigIntImpl (FastHrtime* receiver) {
482
492
uint64_t t = uv_hrtime ();
483
493
uint64_t * fields = static_cast <uint64_t *>(receiver->backing_store_ ->Data ());
484
494
fields[0 ] = t;
485
495
}
486
496
497
+ static void FastBigInt (v8::ApiObject receiver) {
498
+ BigIntImpl (FromV8ApiObject (receiver));
499
+ }
500
+
487
501
static void SlowBigInt (const FunctionCallbackInfo<Value>& args) {
488
- FastBigInt (FromJSObject<FastHrtime>(args.Holder ()));
502
+ BigIntImpl (FromJSObject<FastHrtime>(args.Holder ()));
489
503
}
490
504
491
505
v8::Global<ArrayBuffer> array_buffer_;
@@ -563,17 +577,6 @@ void RegisterProcessMethodsExternalReferences(
563
577
564
578
} // namespace node
565
579
566
- namespace v8 {
567
- template <>
568
- class WrapperTraits <node::FastHrtime> {
569
- public:
570
- static const void * GetTypeInfo () {
571
- static const int tag = 0 ;
572
- return reinterpret_cast <const void *>(&tag);
573
- }
574
- };
575
- } // namespace v8
576
-
577
580
NODE_MODULE_CONTEXT_AWARE_INTERNAL (process_methods,
578
581
node::InitializeProcessMethods)
579
582
NODE_MODULE_EXTERNAL_REFERENCE(process_methods,
0 commit comments