mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
bootstrap: refresh options in pre-execution
Refresh the options map during pre-execution to pave the way for user land snapshots which may need to access run-time options at snapshot-building time. The default embedded bootstrap snapshot is still prevented from accessing them at snapshot building time since it serves a wider audience and is ignorant of application states, while the user-land snapshots are meant to be application-specific and so it makes sense for them to access runtime states as long as the snapshotted-code works with re-initialized runtime states. PR-URL: https://github.com/nodejs/node/pull/42466 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
parent
1600869eb7
commit
8a297ba3a0
@ -14,6 +14,7 @@ const {
|
||||
const {
|
||||
getOptionValue,
|
||||
getEmbedderOptions,
|
||||
refreshOptions,
|
||||
} = require('internal/options');
|
||||
const { reconnectZeroFillToggle } = require('internal/buffer');
|
||||
const {
|
||||
@ -27,6 +28,8 @@ const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes;
|
||||
const assert = require('internal/assert');
|
||||
|
||||
function prepareMainThreadExecution(expandArgv1 = false) {
|
||||
refreshRuntimeOptions();
|
||||
|
||||
// TODO(joyeecheung): this is also necessary for workers when they deserialize
|
||||
// this toggle from the snapshot.
|
||||
reconnectZeroFillToggle();
|
||||
@ -87,6 +90,10 @@ function prepareMainThreadExecution(expandArgv1 = false) {
|
||||
initializeFrozenIntrinsics();
|
||||
}
|
||||
|
||||
function refreshRuntimeOptions() {
|
||||
refreshOptions();
|
||||
}
|
||||
|
||||
function patchProcessObject(expandArgv1) {
|
||||
const binding = internalBinding('process_methods');
|
||||
binding.patchProcessObject(process);
|
||||
@ -556,6 +563,7 @@ function loadPreloadModules() {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
refreshRuntimeOptions,
|
||||
patchProcessObject,
|
||||
setupCoverageHooks,
|
||||
setupWarningHandler,
|
||||
|
@ -36,6 +36,11 @@ function getEmbedderOptions() {
|
||||
return embedderOptions;
|
||||
}
|
||||
|
||||
function refreshOptions() {
|
||||
optionsMap = undefined;
|
||||
aliasesMap = undefined;
|
||||
}
|
||||
|
||||
function getOptionValue(optionName) {
|
||||
const options = getCLIOptionsFromBinding();
|
||||
if (optionName.startsWith('--no-')) {
|
||||
@ -68,5 +73,6 @@ module.exports = {
|
||||
},
|
||||
getOptionValue,
|
||||
getAllowUnauthorized,
|
||||
getEmbedderOptions
|
||||
getEmbedderOptions,
|
||||
refreshOptions
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user