Skip to content

Commit

Permalink
bootstrap: lazy-load Performance.prototype.timeOrigin
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node#46425
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
sercher committed Apr 25, 2024
1 parent 3d1e743 commit 2ef4d1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
29 changes: 14 additions & 15 deletions graal-nodejs/lib/internal/perf/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,24 @@ ObjectDefineProperties(Performance.prototype, {
enumerable: false,
value: timerify,
},
// This would be updated during pre-execution in case
// the process is launched from a snapshot.
// TODO(joyeecheung): we may want to warn about access to
// this during snapshot building.
timeOrigin: {
__proto__: null,
configurable: true,
enumerable: true,
value: getTimeOriginTimestamp(),
get() {
const value = getTimeOriginTimestamp();
ObjectDefineProperty(Performance.prototype, 'timeOrigin', {
__proto__: null,
value,
});
return value;
},
set(value) {
ObjectDefineProperty(Performance.prototype, 'timeOrigin', {
__proto__: null,
value,
});
},
},
toJSON: {
__proto__: null,
Expand All @@ -224,15 +233,6 @@ ObjectDefineProperties(Performance.prototype, {
},
});

function refreshTimeOrigin() {
ObjectDefineProperty(Performance.prototype, 'timeOrigin', {
__proto__: null,
configurable: true,
enumerable: true,
value: getTimeOriginTimestamp(),
});
}

const performance = new InternalPerformance();

function dispatchBufferFull(type) {
Expand All @@ -246,5 +246,4 @@ setDispatchBufferFull(dispatchBufferFull);
module.exports = {
Performance,
performance,
refreshTimeOrigin,
};
1 change: 0 additions & 1 deletion graal-nodejs/lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ function setupTraceCategoryState() {
}

function setupPerfHooks() {
require('internal/perf/performance').refreshTimeOrigin();
require('internal/perf/utils').refreshTimeOrigin();
}

Expand Down

0 comments on commit 2ef4d1a

Please sign in to comment.