feat: fork-frontier waves 1-3 — advanced V8 bindings#4
Open
yneves wants to merge 1 commit into
Open
Conversation
Implement the remaining fork-frontier techniques from doc 207 to give
er and blindfox fine-grained control over V8's runtime behavior.
Wave 1 — Cooperative GC & microtasks:
- AdjustExternalMemory: report Go-side allocations to V8's GC heuristic
- SetMicrotasksPolicy: control when V8 drains the microtask queue
- EnqueueMicrotask: schedule JS functions as microtasks without Promise
- SetOOMErrorHandler: observe OOM events via Go callback trampoline
Wave 2 — Zero-copy data & profiling:
- ArrayBuffer: NewArrayBuffer (copy), NewArrayBufferAlloc (V8-sandbox),
ArrayBufferGetBytes for single-copy Go↔JS data transfer
- ExternalStringResource: NewExternalOneByteString for zero-copy
Latin-1/ASCII string injection into V8
- Named property interceptors: getter/setter callbacks on ObjectTemplate
using isolate callback registry
- HeapProfiler: TakeHeapSnapshot returning DevTools-compatible JSON
Wave 3 — ES module support:
- CompileModule, Instantiate (with Go resolve callback), Evaluate,
GetNamespace, import request introspection, full ModuleStatus enum
Deferred to a future release:
- Fast API Callbacks (C++ CFunction templates impractical via CGO)
- Streaming Bundle Compile (requires background thread management)
35 tests across 9 new test files. Full regression suite passes.
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.
Summary
Implements the remaining fork-frontier techniques from doc 207, giving
erandblindfoxfine-grained control over V8's runtime behavior.Wave 1 — Cooperative GC & microtasks
AdjustExternalMemory— report Go-side allocations to V8's GC heuristic so it can schedule collections at the right timeSetMicrotasksPolicy— control when V8 drains the microtask queue (Explicit/Scoped/Auto)EnqueueMicrotask— schedule JS functions as microtasks without the overhead ofPromise.resolve().then()SetOOMErrorHandler— observe OOM events via a Go callback trampoline for diagnostics and graceful shutdownWave 2 — Zero-copy data & profiling
ArrayBuffer—NewArrayBuffer(copy),NewArrayBufferAlloc(V8-sandbox-allocated),ArrayBufferGetBytesfor single-copy Go↔JS binary data transferExternalStringResource—NewExternalOneByteStringfor zero-copy Latin-1/ASCII string injection into V8ObjectTemplateusing an isolate callback registry, enabling virtual-property patternsHeapProfiler—TakeHeapSnapshotreturning Chrome DevTools-compatible JSON for memory debuggingWave 3 — ES module support
CompileModule/Instantiate/Evaluate— full ESM lifecycle with Go-side resolve callbackGetNamespace— access module exports after evaluationGetModuleRequestsLength/GetModuleRequestto inspect import specifiers before instantiationModuleStatusenum — complete lifecycle trackingDeferred
CFunctiontemplates are impractical to bridge through CGOScriptStreamingTaskTest plan
go test ./...— 0 failures)api-reference.md,architecture.md,maintaining.md,CHANGELOG.md