lib: remove unnecessary refreshHrtimeBuffer()

We now serialize/deseialize the hrtime buffers properly instead of
throwing them away at serialization and creating new ones at
pre-execution, so there is no need to reset the variables to
the binding property at pre-execution time.

PR-URL: https://github.com/nodejs/node/pull/51446
Refs: https://github.com/nodejs/node/pull/48655
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jithil P Ponnan <jithil@outlook.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
Joyee Cheung authored and Michaël Zasso committed 2024-02-15 12:05:41 +01:00
1 parent 129d3b3293
commit ec60639cc0
2 files changed
+7 -18

No files matched your search

+7 -16
View File
@@ -57,21 +57,13 @@ const { exitCodes: { kNoFailure } } = internalBinding('errors');
const binding = internalBinding('process_methods');
let hrValues;
let hrBigintValues;
function refreshHrtimeBuffer() {
// The 3 entries filled in by the original process.hrtime contains
// the upper/lower 32 bits of the second part of the value,
// and the remaining nanoseconds of the value.
hrValues = binding.hrtimeBuffer;
// Use a BigUint64Array in the closure because this is actually a bit
// faster than simply returning a BigInt from C++ in V8 7.1.
hrBigintValues = new BigUint64Array(binding.hrtimeBuffer.buffer, 0, 1);
}
// Create the buffers.
refreshHrtimeBuffer();
// The 3 entries filled in by the original process.hrtime contains
// the upper/lower 32 bits of the second part of the value,
// and the remaining nanoseconds of the value.
const hrValues = binding.hrtimeBuffer;
// Use a BigUint64Array because this is actually a bit
// faster than simply returning a BigInt from C++ in V8 7.1.
const hrBigintValues = new BigUint64Array(binding.hrtimeBuffer.buffer, 0, 1);
function hrtime(time) {
binding.hrtime();
@@ -425,5 +417,4 @@ module.exports = {
wrapProcessMethods,
hrtime,
hrtimeBigInt,
refreshHrtimeBuffer,
};
-2
View File
@@ -212,8 +212,6 @@ function patchProcessObject(expandArgv1) {
const binding = internalBinding('process_methods');
binding.patchProcessObject(process);
require('internal/process/per_thread').refreshHrtimeBuffer();
// Since we replace process.argv[0] below, preserve the original value in case the user needs it.
ObjectDefineProperty(process, 'argv0', {
__proto__: null,