Commit Graph

10 Commits

Author SHA1 Message Date
Joyee Cheung
33bbf3751b src: fixup Error.stackTraceLimit during snapshot building
When V8 creates a context for snapshot building, it does not
install Error.stackTraceLimit. As a result, error.stack would
be undefined in the snapshot builder script unless users
explicitly initialize Error.stackTraceLimit, which may be
surprising.

This patch initializes Error.stackTraceLimit based on the
value of --stack-trace-limit to prevent the surprise. If
users have modified Error.stackTraceLimit in the builder
script, the modified value would be restored during
deserialization. Otherwise, the fixed up limit would be
deleted since V8 expects to find it unset and re-initialize
it during snapshot deserialization.

PR-URL: https://github.com/nodejs/node/pull/55121
Fixes: https://github.com/nodejs/node/issues/55100
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2024-09-30 15:05:12 +00:00
Antoine du Hamel
231548b5cf
lib: enforce ASCII order in error code imports
PR-URL: https://github.com/nodejs/node/pull/52625
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2024-04-23 17:05:38 +00:00
Joyee Cheung
7df27582bb
bootstrap: throw ERR_NOT_SUPPORTED_IN_SNAPSHOT in unsupported operation
This patch adds a new ERR_NOT_SUPPORTED_IN_SNAPSHOT error and throw
it in the worker constructor.

PR-URL: https://github.com/nodejs/node/pull/47887
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-05-24 14:49:46 +02:00
Joyee Cheung
442dfc9b39
bootstrap: put is_building_snapshot state in IsolateData
Previously we modify the CLI options store to indicate whether the
isolate is created for building snapshot, which is a bit hacky and
makes it difficult to tell whether the snapshot is built from the
command line or through other APIs. This patch adds
is_building_snapshot to IsolateData and use this instead when we
need to know whether the isolate is created for building snapshot
(but do not care about where that request is coming from).

PR-URL: https://github.com/nodejs/node/pull/47887
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-05-24 14:49:44 +02:00
Chengzhong Wu
bddf341774
v8: fix ERR_NOT_BUILDING_SNAPSHOT is not a constructor
PR-URL: https://github.com/nodejs/node/pull/47721
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2023-04-29 16:50:42 +00:00
Joyee Cheung
209c803569
bootstrap: do not expand process.argv[1] for snapshot entry points
In applications with entry points deserialized from snapshots,
they don't need an additional CLI argument for the entry point script
so process.argv[1] is going to be other user-defiend arguments.
We could consider copying process.argv[0] as process.argv[1] like
what we do for single executable applications, but for now just
don't exapnd it so it's easier to backport to previous releases.

PR-URL: https://github.com/nodejs/node/pull/47466
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-04-10 16:15:03 +00:00
Antoine du Hamel
ab8942848b
lib: enforce use of trailing commas
PR-URL: https://github.com/nodejs/node/pull/46881
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-03-06 10:44:14 +01:00
Joyee Cheung
4f1a9fc7ea
bootstrap: fixup Error.stackTraceLimit for user-land snapshot
It's difficult for V8 to handle Error.stackTraceLimit in the snapshot,
so delete it from the Error constructor if it's present before
snapshot serialization, and re-install it after deserialization.
In addition try not to touch it from our internals during snapshot
building in the first place by updating
isErrorStackTraceLimitWritable().

PR-URL: https://github.com/nodejs/node/pull/44203
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-08-18 13:05:31 +00:00
Joyee Cheung
06f5d45647
bootstrap: support more builtins in the embedded code cache
This patch:

- Make NativeModuleLoader::LookupAndCompile() detect parameters based
  on module IDs. This allows us to compile more builtins when
  generating the embedded bootstrap, including
  - internal/per_context/*
  - internal/bootstrap/*
  - internal/main/*
- Move pre_execution.js to lib/internal/process as it needs to be
  compiled as a regular built-in module, unlike other scripts
  in lib/internal/bootstrap
- Move markBootstrapComplete() to the performance binding instead of
  making it a function-wrapper-based global to reduce number of
  special cases.

PR-URL: https://github.com/nodejs/node/pull/44018
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-08-05 01:11:20 +08:00
Joyee Cheung
a36a5469c2
v8: add v8.startupSnapshot utils
This adds several APIs under the `v8.startupSnapshot` namespace
for specifying hooks into the startup snapshot serialization
and deserialization.

- isBuildingSnapshot()
- addSerializeCallback()
- addDeserializeCallback()
- setDeserializeMainFunction()

PR-URL: https://github.com/nodejs/node/pull/43329
Fixes: https://github.com/nodejs/node/issues/42617
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-06-17 19:23:56 +08:00