lts/src/node_process_methods.cc
// This is the legacy version of hrtime before BigInt was introduced in
// JavaScript.
// The value returned by uv_hrtime() is a 64-bit int representing nanoseconds,
// so this function instead fills in an Uint32Array with 3 entries,
// to avoid any integer overflow possibility.
// The first two entries contain the second part of the value
// broken into the upper/lower 32 bits to be converted back in JS,
// because there is no Uint64Array in JS.
// The third entry contains the remaining nanosecond part of the value.
This is the legacy version of hrtime before BigInt was introduced in
JavaScript.
The value returned by uv_hrtime() is a 64-bit int representing nanoseconds,
so this function instead fills in an Uint32Array with 3 entries,
to avoid any integer overflow possibility.
The first two entries contain the second part of the value
broken into the upper/lower 32 bits to be converted back in JS,
because there is no Uint64Array in JS.
The third entry contains the remaining nanosecond part of the value.
This is the legacy version of hrtime before BigInt was introduced in JavaScript . The value returned by uv_hrtime () is a 64 - bit int representing nanoseconds so this function instead fills in an Uint32Array with 3 entries to avoid any integer overflow possibility . The first two entries contain the second part of the value broken into the upper / lower 32 bits to be converted back in JS because there is no Uint64Array in JS . The third entry contains the remaining nanosecond part of the value .
static void Hrtime(const FunctionCallbackInfo<Value>& args) {
  uint64_t t = uv_hrtime();
  Local<ArrayBuffer> ab = args[0].As<Uint32Array>()->Buffer();
  uint32_t* fields = static_cast<uint32_t*>(ab->GetContents().Data());
  fields[0] = (t / NANOS_PER_SEC) >> 32;
  fields[1] = (t / NANOS_PER_SEC) & 0xffffffff;
  fields[2] = t % NANOS_PER_SEC;
}
static void Hrtime ( const FunctionCallbackInfo < Value > & args ) { uint64_t t = uv_hrtime ( ) ; Local < ArrayBuffer > ab = args [ 0 ] . As < Uint32Array > ( ) -> Buffer ( ) ; uint32_t * fields = static_cast < uint32_t * > ( ab -> GetContents ( ) . Data ( ) ) ; fields [ 0 ] = ( t / NANOS_PER_SEC ) >> 32 ; fields [ 1 ] = ( t / NANOS_PER_SEC ) & 0xffffffff ; fields [ 2 ] = t % NANOS_PER_SEC ; }
This is the legacy version of hrtime before BigInt was introduced in
JavaScript.
This is the legacy version of hrtime before BigInt was introduced in JavaScript .