Skip to content

Add builtin function executable bytecode encode/decode API#177

Draft
sosukesuzuki wants to merge 2 commits intomainfrom
claude/builtin-executable-bytecode-api
Draft

Add builtin function executable bytecode encode/decode API#177
sosukesuzuki wants to merge 2 commits intomainfrom
claude/builtin-executable-bytecode-api

Conversation

@sosukesuzuki
Copy link
Copy Markdown

@sosukesuzuki sosukesuzuki commented Mar 23, 2026

Adds JSC API for encoding/decoding UnlinkedFunctionExecutable (including
nested code blocks) as top-level bytecode cache entries. Used by Bun to
pre-generate bytecode for internal modules and builtin functions at build
time, so standalone executables can skip parsing at runtime.

Changes

CachedTypes.h/.cpp

  • BuiltinFunctionCacheEntry: simplified cache entry for builtin executables
    (skips SourceCodeKey validation since builtin sources are fixed at build
    time; only checks cache version)
  • encodeBuiltinFunctionExecutable(VM&, UnlinkedFunctionExecutable*): serialize
  • decodeBuiltinFunctionExecutable(VM&, Ref<CachedBytecode>): deserialize

CodeCache.h/.cpp

  • recursivelyGenerateUnlinkedCodeBlockForBuiltinFunction: parses a builtin
    source (with @-prefixed private identifiers) and recursively generates
    bytecode for all nested functions. Similar to the existing
    recursivelyGenerateUnlinkedCodeBlockForProgram/Module but for builtins.
    Metadata parameters (ImplementationVisibility, ConstructorKind,
    ConstructAbility, InlineAttribute) have default values matching what
    internal module wrappers need.

All additions are guarded by USE(BUN_JSC_ADDITIONS).

Companion Bun PR: oven-sh/bun#28461

@github-actions
Copy link
Copy Markdown

Preview Builds

Commit Release Date
20479c97 autobuild-preview-pr-177-20479c97 2026-03-23 09:39:22 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant