fix(node:v8): Serializer/Deserializer classes + lifecycle/diagnostic namespaces - #3763
Merged
Conversation
added 6 commits
May 31, 2026 15:05
# Conflicts: # docs/api/perry.d.ts # docs/src/api/reference.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3680
Closes #3679
Implementation
Builds on the existing
node:v8surface (v8.serialize/deserialize/heap-stats/GCProfiler) incrates/perry-runtime/src/node_v8.rs.#3680 —
v8.Serializer/v8.Deserializerclassesnew v8.Serializer()/new v8.DefaultSerializer()/new v8.Deserializer(buf)/new v8.DefaultDeserializer(buf)now construct real, stateful instances backed by the structured-clone codec that already powersv8.serialize/deserialize(child_process::v8_serde).NATIVE_MODULE_CLASS_IDnamespace object carrying a registry id in field[1] (mirrors thePerformanceObserverinstance pattern) — no new HIR/codegen variant. Instance method calls route throughdispatch_native_module_method.writeHeader/writeValue/writeUint32/writeUint64/writeDouble/writeRawBytes/releaseBufferandreadHeader/readValue/readUint32/readUint64/readDouble/readRawBytes.OwnedDeserializerkeeps the input buffer alive across method calls (the codec's internalDeserializeronly borrows). GC suppression wraps eachwriteValue/readValuewalk.typeof v8.Serializer === "function"via the native-callable-export path; construction is statically lowered inexpr/new_dynamic.rs.#3679 — lifecycle / diagnostic-control namespaces
Perry has no V8 engine to drive real snapshots / coverage / promise-lifecycle hooks, so these expose Node's observable shape only:
v8.startupSnapshotnamespace:isBuildingSnapshot()returns the number0(matching Node, not a boolean);addSerializeCallback/addDeserializeCallback/setDeserializeMainFunctionthrowERR_NOT_BUILDING_SNAPSHOTlike Node.v8.promiseHooksnamespace:onInit/onBefore/onAfter/onSettled/createHookreturn a no-op stop callable.setFlagsFromString/takeCoverage/stopCoverage/setHeapSnapshotNearHeapLimitare Node-shaped no-op callables returningundefined.NativeMethodCall { class_name: Some("startupSnapshot") }) and the value-read form (typeof v8.startupSnapshot.isBuildingSnapshot) are handled.Dropped (correctly): real
getHeapSnapshot/writeHeapSnapshotstream/file emission, real coverage capture, real promise-hook lifecycle — these require a V8 engine. They are coordinated with #3140 rather than faked here; only correctly-shaped no-op surface is exposed.Manifest + generated docs (
docs/api/perry.d.ts,docs/src/api/reference.md) updated;regen_api_docs.shre-run.Validation
test-files/test_gap_v8_2_3680plus.tsis byte-identical tonode --experimental-strip-typesunder the default auto-optimize compile (Serializer/Deserializer round-trip asserted via deepJSON.stringifyequality, not raw bytes).test_gap_node_v8_3137plus.tsremains IDENTICAL (no regression).cargo build --releasecold (clean).cargo fmt --all -- --checkclean../scripts/check_file_size.shexit 0.cargo test --releasepasses for perry-runtime, perry-codegen, perry-hir, perry-api-manifest.Exprvariant added.