Skip to main content

Module v8

Module v8 

Source
Expand description

Node v8 module — a compatibility shim, NOT real V8 introspection.

node-js has no V8: JS is lowered to fusevm bytecode and runs on a Rust heap (see host.rs). There is therefore no V8 heap to measure and no V8 binary serialization format to emit. This module exists so code that calls the v8 surface (metrics collectors, v8.serialize-based caches) keeps working, with every deviation documented rather than faked:

  • getHeapStatistics / getHeapSpaceStatistics / getHeapCodeStatistics return the correct shape (all the keys Node produces) with zeroed values. They are not read from any live allocator — reporting a fabricated non-zero heap size would be a lie, so the honest answer is 0.
  • serialize / deserialize round-trip through JSON, not V8’s structured-clone binary format. The returned Buffer is UTF-8 JSON bytes and is byte-incompatible with Node’s v8.serialize; it cannot carry cyclic graphs, Map/Set, typed arrays, BigInt, or undefined the way the real format does. Use it only for plain JSON-representable values.
  • setFlagsFromString is a no-op (there are no V8 flags to set).
  • getHeapSnapshot throws: node-js cannot produce a V8 heap snapshot.

Constants§

DESERIALIZER_METHODS
Methods dispatched on an @@native = "Deserializer" object.
METHODS
SERIALIZER_METHODS
Methods dispatched on an @@native = "Serializer" object (JSON-backed shim; reported to the parent for instance_has_method / instance_call wiring).

Functions§

call
constant
Non-function members of the v8 namespace, exposed as constructor values so require('v8').Serializer (etc.) resolve and new reaches construct. Requires the parent to route "v8" into stdlib::constant.
construct
new v8.Serializer() / new v8.Deserializer(buffer) (and the Default* aliases). node-js has no V8 structured-clone binary format, so these are JSON-backed shims: a Serializer accumulates ONE writeValued value as JSON and hands it back from releaseBuffer as a UTF-8 Buffer; a Deserializer parses that JSON back with readValue. The granular byte writers/readers (writeUint32/writeDouble/writeRawBytes/…) are NOT modeled — they only make sense against the real binary layout (see the report’s deferred list).
instance_call
Dispatch a method on a Serializer/Deserializer instance.