Skip to content

AOT: array callbacks in stubs, loops by array kind, run-time accessors, proxies, string searches - #1045

Merged
Jarred-Sumner merged 9 commits into
mainfrom
claude/aot-array-callbacks-in-stubs
Nov 13, 2026
Merged

Jarred-Sumner merged 9 commits into
mainfrom
claude/aot-array-callbacks-in-stubs

Conversation

@Jarred-Sumner

@Jarred-Sumner Jarred-Sumner commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

The JavaScriptCore side of a round of work on Bun's ahead-of-time compiler (bun build --compile --aot and bun test --aot, both experimental). Bun's side is a pull request that pins this one's preview. This follows #1042.

Merge order

This merges first; then Bun's pull request pins the merged commit and runs CI once more.

Wrong on main, fixed

Program On main
A function that loops over a generator it was passed is copied into its caller, and a function that the loop calls defines return on the generator's prototype under a computed name Leaving the loop calls the built-in return()
Reflect.set() of a class field that was deleted, where the prototype has a read-only property of that name Answers true and stores nothing
bun test --aot: a test file mocks a CommonJS file and also a file that it requires The next test file can get the CommonJS file as it was
A program stores a method again and again on a prototype to which it also adds elements under integer keys An older method can be called
x64: a loop stores eight or more numbers 4 KB apart into one typed array and carries a number from the iteration before That number can be stored as it was in front of the loop
x % y beside (x / y) | 0, where x is -2147483648 and y is -1 Can be -4294967296 instead of -0
A helper applies a generator function that it is given, and its catch names the generator The generator does not see what was added to the function's own prototype
x64: an outer loop sums integers around a relaxation over the rows of a grid The build can abort
Reflect.get() or getOwnPropertyDescriptor() is handed on, bound or inherited, and asked for a built-in by a name that is made while the program runs The executable ends with an abort where nothing else uses that built-in
A loop sets a field that is written as a number to undefined, and the class has a name that its constructor does not store The next turn can read a number
A new object without an optional field is stored, and an accessor of another new object reads that field before it is filled The accessor can read 0 for undefined
The prototype of a constructor function is a primitive for some constructions Objects that it makes later can have Object.prototype instead of its own one
A function that a loop calls multiplies a BigInt with itself under a modulus out of a list ((x * x) % m) The build can abort
The constructor of a base class returns an older object, and the heir defines a field (class Heir extends Back { x = 77 }) A read of that field around a call that makes an heir can give the value from before
A loop stores under a key that is only known at run time, and a property that the program adds behind the object's literal is read by name behind the store The read can give the value from in front of the loop
Bun.inspect() of an object of a base class with a symbol-keyed method From the second time that the class is made, that method is listed before the named ones
key in list where the key is a list, and the prototype of the list is a list The executable ends with an abort
The last capture of a pattern that is nested 257 deep or more is read The executable ends with an abort
A derived class with a private field, an arrow that returns this and an eval() behind super() The build can stop
Some programs with loops that carry objects and leave by side paths The build stops
--aot-harden=proof-checks: a CommonJS file with a counter that a function steps in a loop over two kinds of lists The build can stop
A for..in loop copies an object of many names The build's time grows with the square of their number
A private field that is written as a number and that a loop stores as null, in a program that holds an eval() The executable ends with an abort
A function sums the results of many calls in a loop The build's time grows about with the cube of the number of its statements (400: 7 s)
A function has about 800 values that are all read at its end The build stops

If you don't use --aot

  • [, ...list] with an empty list has the length that its holes give it: [, ...[]].length is 1 (0 on main).
  • replaceAll() on null or undefined says the same in optimized code as before it is optimized.

What's in it

723 files, +61,098 −6,183 against main. Most of it is the compiler's own directory:

Area Files + −
aot/walk: the main pass 102 14,623 1,502
aot/facts: the link 34 11,451 1,299
aot/codegen, stubs, machine: code generation 217 21,150 1,248
aot/runtime, builtins, object 145 6,051 1,264
aot/tests 113 4,709 247
The rest of aot/ 82 2,242 507
Outside aot/ 30 872 116

Outside aot/

Only compiled programs take these paths; plain Bun runs a few checks more and gives the same answers. Rows marked Plain Bun too change an answer.

File + − Change
assembler/AssemblerBuffer.h, assembler/X86Assembler.h and 1 more 5 5 Five functions are always inlined, for plain Bun too
bytecompiler/NodesCodegen.cpp 6 2 [, ...list]: the length where the list is empty. Plain Bun too
dfg/DFGOperations.cpp 1 1 The message of replaceAll() on null or undefined in optimized code. Plain Bun too
runtime/JSString.cpp 51 4 Short substrings of UTF-16 strings as Latin-1 strings
runtime/StringPrototypeInlines.h, runtime/StringReplaceCache.h and 2 more 289 6 replace() with tables of replacements, and the caches of replace() and split()
runtime/RegExp.h, runtime/RegExpCache.cpp and 1 more 28 0 Finds a pattern by a substring
runtime/ProxyObject.cpp, runtime/ProxyObject.h 118 55 Traps that proxies of one handler share
runtime/GetterSetter.h 12 0 What a getter that only returns a captured variable returns
runtime/DatePrototype.cpp, runtime/DatePrototype.h 9 2 Getters of dates whose class the build doesn't know
runtime/JSOrderedHashTable.h, runtime/WeakMapImpl.h 7 1 The first entry of a Map or Set; weak tables
runtime/Structure.cpp, runtime/VM.cpp 29 5 Notifies compiled code of prototypes that change or get elements
wasm/WasmCallingConvention.h, wasm/WasmOperations.cpp and 2 more 193 20 Calls between WebAssembly and compiled functions
yarr/YarrFlatProgram.h, yarr/YarrFlatProgramBuilder.cpp and 2 more 124 15 Compiled patterns: words, two prefixes

Changes

Arrays and loops

  • Callbacks of array methods (map(), filter(), some(), find(), reduce(), sort() and others) that read fields, compare, add or multiply run in stubs, also for arrays the build knows nothing about.
  • Loops and whole functions get a version for the kind of array they meet: int32s, doubles, objects, typed arrays.
  • The checks of an array are shared by the iterations, and made before the loop where they can be.
  • Loops that move elements within an array, rotate values through variables or search an array have their own machine code. Sums over several rows or filters run side by side.
  • The objects that a loop reaches through an array are prefetched.
  • Counters, remainders, positions and products by powers of two stay int32s in more loops, and numbers whose fraction is zero are converted once.

Objects and classes

  • Accessors that a program defines at run time are called from their places without a lookup. A getter that only returns a captured variable is read without a call.
  • Properties that an object has beyond its class are found by name in one step, and deleting one keeps the others.
  • A function that fills the fields of its argument, or passes its arguments on, is compiled for the object of the caller. Functions can have properties.
  • Classes whose parents are parameters, members or the results of calls keep their layouts. Objects with prototypes other than their class's (Object.create(), __proto__) are constructed from templates.
  • A Proxy is allocated in a stub, its traps are entered directly, and one handler may serve many proxies. Reflect.construct() runs in a stub. A get() or set() after has() uses the entry that was found.

Calls

  • f(...list), new C(...list) and push(...list) don't create an array for the arguments. Rest parameters that are only passed on aren't created.
  • Small recursive functions are inlined into themselves to a depth. A generator's next() is stepped in place where the generator is a local variable.

Strings, regular expressions, JSON

  • Short substrings of UTF-16 strings are shared as Latin-1 strings. Ropes are written by words, and equal strings are compared by words.
  • A switch over strings goes through a table. Numbers are converted to strings and back in place.
  • Searches for words, for two prefixes and for patterns created at run time test several characters at once, on arm64 too.
  • JSON.stringify() remembers the order of the keys of a structure, and JSON.parse() continues in its lexer behind a value.

Code from strings

  • Strings that are known when the program is built are compiled, with the names they see. Code that is interpreted stores into compiled objects in place.

Build

  • More steps of the link run in parallel, the largest first, and tables are created once. The new forms cost build time; this pays for part of it.

Known issues

What differs from bun run and bun test is listed in Bun's pull request.

Tests

IR tests and native tests are in aot/tests; stored programs are in Bun's pull request. CI's run of this pull request is the first of this tree.

…s, proxies, string searches

On #1042. 695 files, +59,955 -5,958: the rest of aot/ 557 files, +54,460 -5,602;
aot/tests 111 files, +4,687 -247; outside aot/ 27 files, +808 -109.

Arrays and loops

- Callbacks of array methods that read fields, compare, add or multiply run in stubs, also for
  arrays the build knows nothing about. Loops and functions get a version for the kind of array they
  meet. Checks of an array are shared by the iterations, and made before the loop where they can be.

- Loops that move elements, rotate values or search have their own machine code; sums over several
  rows run side by side. Objects that a loop reaches through an array are prefetched. Counters,
  remainders and positions stay int32s in more loops.

Objects and classes

- Accessors that a program defines at run time are called from their places without a lookup.
  Properties beyond an object's class are found by name in one step.

- A function that fills the fields of its argument is compiled for the object of the caller. Classes
  whose parents are parameters, members or results of calls keep their layouts.

- A Proxy is allocated in a stub and its traps are entered directly. Reflect.construct() runs in a
  stub. A get() or set() after has() uses the entry that was found.

Calls, strings and code from strings

- Spread calls don't create an array for the arguments. Small recursive functions are inlined into
  themselves.

- Short substrings of UTF-16 strings are shared as Latin-1 strings. A switch over strings goes
  through a table. Searches for words and for two prefixes test several characters at once.

- Strings that are known when the program is built are compiled, with the names they see.

Fixed

- A `return` that a loop's callee defines on a generator's prototype is called when the loop is
  left.

- Reflect.set() of a class field that was deleted stores nothing and answers false where the
  prototype has a read-only property of that name.

- Where the constructor of a base class returns an older object and the heir defines a field, a read
  of that field around a call that makes an heir gives the value that is there.

- A method that a program stores again and again on a prototype to which it also adds elements under
  integer keys is the one that is called; an older one could be.

- On x64, a loop that stores eight or more numbers 4 KB apart into one typed array stores the number
  that it carries from the iteration before. `x % y` beside `(x / y) | 0` is `-0` where `x` is
  `-2147483648` and `y` is `-1`.

- A generator function that a helper applies and its `catch` names keeps what was added to its own
  `prototype`.

- `in` with a list as a key, and the last capture of a pattern that is nested 257 deep, no longer
  end with an abort. Some builds no longer stop: derived classes with a private field and an eval()
  behind super(), loops that carry objects and leave by side paths, outer loops that sum integers
  around a relaxation over rows. A for-in copy of many names no longer takes time with the square of
  their number.

- `bun test --aot`: a CommonJS file that a test file mocked, with a file that it requires, is mocked
  no more in the next test file.

Plain Bun too

- The length of `[, ...list]` where the list is empty; the message of replaceAll() on null or
  undefined in optimized code.

`Wire::schemaHash` changes, so this engine and Bun's side go together.
22 files, +367 -117.

- The build of a function of many statements that reckon with what calls give takes time that grows
  with their number, not with its cube: 400 of them take 0.8 G instructions where they took 126. Its
  stack frame holds a value that several ways hand on in one place: 800 such values had a frame over
  the limit, so the build stopped.

- An object that a helper checks and that its `catch` names is one that other code sees, so its
  fields are read behind their stores.

- `Reflect.get()` or `getOwnPropertyDescriptor()` that a program hands on, bound or inherited, finds
  a built-in under a name that is made while the program runs; the executable ended with an abort
  where nothing else used it.

- A build with `--aot-harden=proof-checks` no longer stops where five or more functions out of a
  list are given a view and one of them has an arm for lists: nothing arrives at that arm.

- `join()` and counts of a character are right for texts whose parts were cut from texts with wide
  characters.

- A function of `ProxyObject` has a shorter name.
6 files, +138 -5.

- A text that is matched several times in an async function is read again behind each `await`. The
  check of machine code that tests ask for knows joins of such reads.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the inline findings, a few other candidates were examined and ruled out: the m => table[m] replace-callback keyed lookup in aot/runtime/AOTKeyedLookup.cpp (getter/Proxy/accessor cases fall back before the cached table is used), the row-sum loop over double arrays with holes in AOTCodeGeneratorRowLoops.cpp (hole-bearing shapes are still rejected before the vector path), the parseInt non-decimal radix path in AOTMathBuiltinEmitterNumbers.cpp (the inline number path is only taken for radix 10/absent), and the SourcesCompiledForMinimumSize.txt expansion (affects only compile options of the AOT compiler's own sources, not generated code).

Extended reasoning...

The change spans 701 files with roughly 60k insertions across the JSC AOT compiler, runtime, stubs, builtins and Yarr; two confirmed findings are posted inline, and this body only records the other concrete candidates that were investigated and did not hold up.

Findings marked 🟡 are optional suggestions and need no follow-up push.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

This review is incomplete: part of the automated analysis stopped early, so some of this change was not checked. The findings posted had already been confirmed.

Still open from earlier reviews (2):

If you have decided not to act on one of these findings, resolve its thread (a reply alone leaves it open) and the next review stops counting it. To review this commit again now, use Re-run on its "Claude Code Review" check.

…w objects

14 files, +75 -26.

- A loop that shifts an element, reads it plainly and stores to it stores the element as it is; it
  could be stored cut to an integer.

- A store of `undefined` into a field ends what a loop has asked of the written type of that field.

- A new object that is stored shows its optional fields to accessors of other new objects as they
  are.

- Objects of a constructor function whose `prototype` is a primitive for some constructions have its
  own one later.

- A callback of `forEach()` over listed names may also be called directly, with other names; the
  executable ended with an abort.

- `concat()` takes the prototype of arrays for the list that it is.

- The build of a remainder of a product of two `BigInt`s in a loop whose turns are laid out no
  longer stops.

- `JSON.parse()` tests the end of its text before it compares a repeated part.

- A debug build with assertions compiles `AOTEffects.cpp` again: the rows of its table are found by
  a hash, which takes 737,901 of the 1,048,576 steps that clang allows a constant; the search took
  1,074,534.

- `AOTLinkLayouts.cpp` includes the header of `JSFinalObject`; on Windows arm64 no other file of its
  unified source did.
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Preview build of 78430a3: autobuild-preview-pr-1045-78430a36

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beyond the inline finding, I also checked the new ReplacerByKeyedLookup path in Source/JavaScriptCore/runtime/StringPrototypeInlines.h for a stale StringImpl pointer in the recent-replacement cache, and for getters or Proxy traps running more than once per match via AOTKeyedLookup.cpp. Both are ruled out: operationAOTGetByValGeneric is a leaf operation that never runs user code (it returns empty, and the callback is then called), and findReplacement clears the cache on every call path.

Extended reasoning...

The candidate issues in the keyed-lookup replace fast path were ruled out from the code: KeyedLookup::tryGetFromObject only uses fastGetOwnProperty and the noexcept leaf operation operationAOTGetByValGeneric, so no getter or Proxy trap runs during a lookup, and every path that calls the user function resets m_recent, so a cached StringImpl pointer cannot outlive code that could free it.

The last 3 reviews of this pull request each found new blocking issues. Where they share a root cause, one fix may close them together.

…ths walked once more

21 files, +158 -57.

- A name that a list gave and that was deleted since is `undefined` where a loop copies it; the
  executable could end with an abort.

- A private field that is written as a number and that a loop stores as `null` no longer ends the
  executable with an abort where the program holds an `eval()`.

- What a loop has asked of the written types of fields has a heap of its own in the schema: a store
  of `undefined` or `null`, in a call too, ends that and no more, so a constructor whose copy fails
  a guard is walked in line once more again.

- `replace()` with a function that looks its match up makes the table of recent answers when there
  is an answer to remember, and clears the entries that were written. It cleared 64 KB behind each
  call of the function.

- An `eval()` in a static block that stores a static field no longer ends the executable with an
  abort.

- Two IR tests name no built-in of Bun.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the latest push (c2ed1b2) and didn't find any new bugs; since this is still a ~60k-line change across the AOT compiler, runtime and stubs, a human look remains worthwhile.

What was reviewed:

  • The ReplacerByKeyedLookup rework in Source/JavaScriptCore/runtime/StringPrototypeInlines.h: the recent-replacement table is now sized from the match count on the first remembered answer and only written entries are cleared after a call; long texts are ref'd in remember() and deref'd in clear() and the destructor.
  • Checked whether a lookup table with a getter or a Proxy could return a stale cached replacement, or run user code fewer times than the base — KeyedLookup::tryGetFromObject goes through the leaf readByKey, which answers nothing for any read that needs a slow path, so the callback is called and no user code runs inside a lookup.
  • Spot-checked the lookup/call balance logic: skipping a lookup only means the real callback is called, which is always the conservative choice.
Extended reasoning...

The diff spans 707 files with about 60k insertions, adding and reworking the JavaScriptCore AOT compiler (facts, codegen, machine, image), its runtime and stubs, plus YARR changes. The latest commit (c2ed1b2) is small (21 files) and reworks the keyed-lookup string replacer that an earlier inline comment flagged for a 64KB fill per callback call, along with several AOT walk fixes. No auth, crypto or injection surface is touched, but the code is a native JIT-adjacent compiler and runtime where memory-safety errors are the main risk. The hunt ran dry with no new findings, and both candidate issues on the rewritten replacer were ruled out from the code, but the sheer size and complexity of the change rule out approving without a human reviewer.

…exceptions

4 files, +49 -18.

- A loop over rows that only tests whether an element is there, or tests it and adds others up,
  leaves where the element is missing.

- Where a mock ends, the exception scope also covers what puts files out of the cache, so builds
  that check exception scopes no longer stop there.

- The allocator clears what takes a value in a plain loop. On Windows std::replace() over pointers
  needs a vectorized function of the standard library.

- The storage of a list is asked in front of a loop wherever its elements are read there.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-ran the review on the latest two commits and did not find any new bugs; given the size of this change (700+ files across the AOT compiler, runtime, stubs and Yarr), a human look is still worthwhile.

What was reviewed this run:

  • The new keyed-lookup replace path (AOTKeyedLookup.cpp / StringPrototypeInlines.h ReplacerByKeyedLookup): checked whether a Proxy trap or getter on the lookup table could fire twice per match (tryGetOwn bails to the generic get only when the fast own-property read misses, so one trap per lookup) and whether the recent-replacement cache could skip a trap for repeated match text (cache entries are only written for string results of successful lookups and are cleared on every callback call, so each match that needs a call still gets one).
  • Replacement cache invalidation now clears only the places written since the last call (m_usedPlaces) rather than the whole table.
Extended reasoning...

The diff spans 707 files with roughly 60k insertions, covering the AOT compiler (codegen, facts, machine, plan), its runtime and stubs, plus Yarr and StringPrototype changes; the latest two commits add keyed-lookup replace callbacks, exception checks for ended mocks, and element-test loops. It touches no auth or credential surface, but JSON parsing, regexp and string replacement are memory-safety-sensitive code paths generated by a JIT-adjacent compiler. The hunt ran dry this time with no findings on the new commits, and the two candidates about double or skipped trap invocation in the replace lookup path were ruled out by reading the code. The sheer scope and the earlier inline threads that were closed only by this bot's own session, not by an independent reviewer, are what keep this at defer rather than approve.

Jarred-Sumner added a commit to oven-sh/bun that referenced this pull request Nov 13, 2026
… now [skip size check]

Merges main. Beside it and the pin 29 files, +543 -126. Pins the preview build
`autobuild-preview-pr-1045-8f4d0f28`.

- A member of an `enum`, or of `process.env` with `--minify-syntax`, under a key that a call passes
  to a function that another one returns is read when the program runs.

- Nine findings of the Rust lints are gone.

- Programs of fixes in oven-sh/WebKit#1045: names that were deleted, fields that calls clear, values
  of no type that are stored twice, static fields that evaluated texts store, loops that only test
  an element.

- Tests of the engine say what is built now. `// STATISTIC on x64:` asks for a count on that
  processor alone; two counts that x64 alone makes are asked so.

- The test of removed code knows what an executable says that was not trimmed, the test of deep
  evaluations nests fewer levels under ASan, and the test of numbers in frames makes its first link
  below them.
…eration

- Tests of own names above a property access are looked up in a table of the function, not along
  all blocks above.

- The class under construction of a field initializer is listed once for the program, and is not
  asked for where no super() call may answer with an older object.

- The uses of a loop's counter are followed, where all operations of the loop were read for each
  counter.

- What an object is expected to be by the names that a loop reads is asked of the cheap facts first.

- Small functions of code generation, five of them in assembler/, are always inlined: builds of the
  engine that optimize for size called them by the million. The effects of a run-time operation are
  found once a call.

- The names of a literal that Object.assign() stores one by one count among the strings that a
  program can list as keys, as the names of other literals do.

- The values of such a literal, where there are many, are read from the literal. They stayed in the
  frame across a call behind them, and a deep recursion ran out of stack.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

…me keys

- A function in which over 4,096 values are alive at once keeps one callee-saved register, which
  holds the stack pointer plus a multiple of 16 or 32 KB. An access to a word of the frame out of
  reach of the stack pointer took two instructions each time, or three; it takes one off that
  register. The register is set before the first such access of a block where the ways into the
  block leave different values in it, and again behind what may have written it and at a landing
  pad. Functions with fewer values alive at once, and all functions on x64, are as before.

- A store or a read under a key that is known at run time alone was said to write or read the
  fields that a literal or class lists. Fields that the program adds later count too: a read by
  name behind such a store could have the value from in front of the loop.

- The stores of a loop's carried value that stand behind an unrolled turn are generated in the
  blocks they belong to. Where a turn has a rare arm, the build stopped.

- The layouts of a name are listed in one pass, and a layout under construction is asked for once a
  function. Four small functions are always inlined.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR through 8c5fe16 and didn't find any bugs; because it is a 700+-file change adding an AOT compiler front end, register allocator, machine encoder and runtime, a human look would still be worthwhile.

What was reviewed:

  • The newest commit's arm64 far-word base register (AOTMachineEncoder.cpp, addressOffBaseOfFarWords / settleBaseOfFarWordsAtHead): the base offset is dropped at landing pads and after any patch whose clobber mask covers the kept register, and only single-entry rare regions with no out-of-reach spill access skip re-settling it.
  • The keyed-lookup replacement cache in StringPrototypeInlines.h (findReplacement / remember): entries are cleared after every callback call and keyed on the atomized match impl, so a cached answer is reused only for an identical repeated match; a Proxy or accessor-backed lookup table with a side-effecting get would see fewer reads than the callback path, which is inherent to the cache rather than a defect.
  • AOT::KeyedLookup::tryGetFromObject: falls back to the generic get and rejects object-valued answers, so getters and Proxies are not bypassed.
Extended reasoning...

The diff adds roughly 61k lines across 723 files: the AOT compiler (facts, link, plan, codegen, machine allocator and encoder), its runtime (JSON parse/write, property caches, modules, string and regexp operations), builtins in TypeScript, and edits to shared JSC runtime headers such as StringPrototypeInlines.h and JSString.h. It touches no auth or credential surface, but it generates machine code and parses JSON in place over JSString buffers, which is memory-safety-sensitive. The bug hunt ran dry on this push and the one candidate it examined (lookup-table get traps running once per distinct match) is a consequence of the new replacement cache's design rather than a defect. The size and depth of the change, with no build or test run performed by this review, are what decide defer over approve.

Jarred-Sumner added a commit to oven-sh/bun that referenced this pull request Nov 13, 2026
…sors, counts for two loops [skip size check]

Beside the pin 15 files, +267 -16. Pins the preview build
`autobuild-preview-pr-1045-8c5fe16d`.

- Programs of fixes in oven-sh/WebKit#1045: a field that a program adds behind a literal is read by
  name behind a store under a key that is known at run time alone; a number that a loop carries is
  stored behind the turns that are laid out, beside another arm.

- CI runs three of the files that start test runs at once, and each of their tests starts two runs.
  The files count their runs together, so that not more runs stand beside one another than the
  machine has processors.

- Two loops whose twins got cheaper than them are held to a count of instructions: a static field
  that is written to 8.5, a key that a helper makes to 240, on arm64 to 275. A test that names don't
  decide how a function is compiled asks for exactly two bounds in front of its loop. Five tests ask
  for counts again that they had given up.

- The test of errors below many evaluations imports a thousand modules under ASan and four thousand
  elsewhere: its plain run met the five seconds that a test of `bun test` has.
… nest

- A generator is not walked in place of a loop that closes it where an iteration may store the
  `return` of its prototype. The executable ended with an internal error.

- A string that the copies of a nest of loops share is read inside the loop that takes it.

- A fix in a cache of the runtime.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

@Jarred-Sumner
Jarred-Sumner merged commit de04322 into main Nov 13, 2026
88 checks passed
Jarred-Sumner added a commit to oven-sh/bun that referenced this pull request Nov 13, 2026
Pins oven-sh/WebKit at `de043228c294c72404a687634e1943f549f39048`, where oven-sh/WebKit#1045 is merged.

throw-below-many-evaluations: the test loads its modules outside of its timed body.
Jarred-Sumner added a commit to oven-sh/bun that referenced this pull request Nov 13, 2026
… awaiting files, known strings (#48771)

Bun's side of a round of work on the ahead-of-time compiler (`bun build --compile --aot` and `bun
test --aot`, both experimental). The JavaScriptCore side is merged: oven-sh/WebKit#1045, as
`de043228c294c72404a687634e1943f549f39048`. This follows #48714.

1,718 files, +70,470 -2,660: test 1,466 files, +55,460 -853; src 250 files, +15,006 -1,803; docs 1
file, +3 -3; scripts 1 file, +1 -1.

[skip size check], as in 607519a.

Tests

- CI compiles a stored program with `--aot`, runs it and compares it with `bun run`; a stored test
  run likewise, with `bun test --aot` and `bun test`.

If you don't use `--aot`

- What oven-sh/WebKit#1045 lists: the length of `[, ...list]`, and the message of replaceAll() on
  null or undefined.

- `click(selector)` of `Bun.WebView` could click an element that was about to move. It looks once a
  frame now, and an element with a pending animation counts as moving.

Wrong on main, fixed

- Where an entry point imports a file only for its effects, the file's package says `"sideEffects":
  false`, and the file reads a member that an index of `export *` takes off a built-in module and
  passes the namespace on, the build stopped, or the member was undefined.

- Where a closure captures an alias of `globalThis`, beside a property `get`, `has` or `apply` of an
  unknown object, the build could stop.

- Where a `catch` behind a top-level `await`, or an operator, sets a path, the build did not warn
  that the program may read another file.

- Where the value of a destructuring assignment stores to a field that the pattern reads, or an
  attribute of an element to one that its `key` reads (JSX's automatic runtime), the field was read
  as it was before.

- With `--minify-syntax`, a function that another one returns and that reads `process.env[key]` gave
  the value of the build for the key `"NODE_ENV"`. A member of an `enum` under a key that a call
  passes to such a function was read as it was written, though the program stored into it.

Executables and builds

- Classes: parents that are parameters, members, results of calls or of `require()` are followed,
  also through the helpers of Babel, TypeScript and swc. Functions with prototypes assigned later,
  and decorated classes that are exported, are classes.

- Objects: prototypes written into literals, `Object.create()` with a literal, and accessors that a
  helper defines are read from the source.

- Bundles: universal wrappers (UMD), standalone output of Browserify, and exports that are getters
  are read directly. Requests beside `eval()` and `with` in a bundle are kept.

- Strings the build knows: scripts that are joined from constants, names that such code declares,
  and calls of constants are evaluated when the program is built.

- Files: an embedded file that a child process writes is read from the disk. A library that
  `dlopen()` opens stays the one that was embedded.

- Size: an executable leaves out the test runner where nothing in it can reach `Bun.jest`,
  `bun:test` or `node:test`. With `--trim` it leaves out what only mocks enter, too.

`bun test --aot`

- The original of a mocked file outlives later runs of the file, and a mock visits only the modules
  that it concerns.

Known issues

- #48677 lists what main has; what it says of typed arrays in a file's variable, of the
  defaults of parameters and of products under `--aot-harden=proof-checks` is fixed since or here.
  Of the rest, main has too:

- Executables, silent: Where a method of a constructor function gives many names to a few of its
  objects, all of them take the larger size (at most 128 bytes an object).

- Executables away from their sources, silent: A route of `Bun.serve()` that is a `Bun.file()` of a
  file embedded by `--asset` or an import keeps the build's bytes when the program writes or removes
  that file later by a `__dirname` path, and answers a `Range` request with the whole file (status
  200).

- Builds, loud: The build of a program whose object literals have more than about 65,000 different
  numbers as fields stops.

- Executables, loud: A method of lists called on a typed array whose prototype was set to that of a
  class that extends `Array` aborts where nothing else uses that method.

- Executables, loud: A store to `process.env` behind `Object.setPrototypeOf(process.env, {})` throws
  a `RangeError`.

- Executables, silent: A CommonJS file whose code threw and that is asked for again by
  `require.bind()`, `eval()`, `new Function()` or `node:vm` gives its first error instead of running
  again.

- Builds, loud: Under `--aot-harden=proof-checks`, the build of some loops over lists that may be
  buffers stops; with default flags the answer is right.
robobun added a commit that referenced this pull request Nov 13, 2026
main has #1045 (AOT). One file conflicts: aot/runtime/AOTTestRunImportTurns.cpp. #1045 keeps each
import() call whose text comes in a later turn in a heap object of its own (BatchedFetch, in the new
BatchedFetches) and fills the fields one by one. This side had added the async context of the call
to the old initializer list.

Resolved with main's code. holdTextOfCall() stores the async context in the new object, for a call
of the program. putCallsThatWaitApartInLine() moves it into the QueuedFetch, as before.
makeCallAgain() is unchanged: it makes the call under the stored context. A fetch that main now adds
for a static import of such a call (fetchImports()) is not a call and carries no context: the call
that waits for it is made again under its own.

main removes the two jobs that made such calls again (runJobOfRound(), runJobThatMakesCallsAgain()).
No code of this change was in them. main adds no job of the module loader and no loadModule() call.

de04322 is #1045 as merged. Bun's main pins it (oven-sh/bun d0f4fdd65f).
robobun added a commit to oven-sh/bun that referenced this pull request Nov 13, 2026
main has #48771: its pin is de043228c2, which is oven-sh/WebKit#1045 as merged. WEBKIT_VERSION is now the preview
build of the head of oven-sh/WebKit#941 (4ee8e65bd8), which is de043228c2 with the change.

Conflicts: the pin, and the end of test/parallel-allowlist.json (main's list, then the one test file of this change).
Jarred-Sumner added a commit that referenced this pull request Nov 14, 2026
…, generators that a loop closes (#1047)

The JavaScriptCore side of the next round of work on Bun's ahead-of-time compiler (`bun build
--compile --aot` and `bun test --aot`, both experimental). Bun's side is a pull request that pins
this one. This follows #1045.

50 files, +676 -572, all in Source/JavaScriptCore/aot/.

The text of functions

- An executable stores the source text of its functions for Function.prototype.toString(), and the
  source that error messages quote, as it is, where it stored both in compressed blocks. The text is
  read in place. The compressor's hooks between JavaScriptCore and Bun are gone.

- An executable is larger by what the compression saved: about 1.5% over 119 npm packages, and
  3.4 MB for the TypeScript compiler. With --no-compile-function-source nothing changes.

Reads through super, and generators

- `super.name` in a loop, where the parent of the home object may be a module namespace, asks the
  tables of the program first. It called the run time for each read after #1045.

- A loop that closes a generator is walked in place again in more places: the check for a store of
  the `return` of its prototype looks into the functions that an iteration calls.

Fixed

- Some builds no longer stop: under --aot-harden=proof-checks, loops with an await and loops that
  store into lists that may be views; nests of loops over the rows of a table where a condition
  joins two values that nothing reads; a nest that swaps elements with another loop behind it;
  loops that read and write an element under a constant key that the compiler holds as a double;
  a CommonJS file that defines module.exports by a getter; a loop that reads an element of a list in
  a field of an object of the file, compares it with a text and stores elsewhere.

- A loop over a generator that is left early aborted the program where a call in the loop runs a
  getter, a setter, a proxy, an iterator or an operator that stores the `return` of the generator's
  prototype under a computed key.

- In a loop over rows that came out of JSON, what a default does beside its number
  (`row.extra ?? (calls++, 0)`) did not run in an executable.

- `--aot-stored-strings` read an executable of an earlier Bun as one of its own. The format of the
  image is 5.

- `bun test --aot`: while the factory of a second mock over a loaded first one waits, imports keep
  the first until it settles; a load in flight gets the mock that it has fetched; a file that runs
  again behind the end of its own mock sees the mocks that came since over what it imports; and a
  run no longer aborts where a mock ends while the body of its file runs, behind a require() that
  could not wait for the mock's factory.
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