Repository navigation
[JSC] Less memory per function that never runs, and code that can be dropped and decoded again - #628
Conversation
|
Preview build of a1da8f1: |
209144a to
affb84c
Compare
Pins the preview release autobuild-preview-pr-628-affb84c2 (affb84c2ee68fe4d838fc819aef2830de30f4deb); to be replaced by the merged sha before this lands. What the new JavaScriptCore does differently: a module's function declarations are instantiated when their binding is first read and stay in the embedded bytecode until then; interpreter and Baseline call sites get their link record on their second execution, in either tier (a tail call on its first), and the collector is told about those records; value profile predictions and an unlinked code block's value and array profiles are only allocated for code that warms up; module and program code is released once it has run; code decoded from an embedded bytecode cache can be dropped and decoded again (JSC::VM::shrinkFootprintNow with flags); Heap::totalBytesAllocated() and sizeAfterLastCollection() for embedders; the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan. The bytecode cache format revision goes from 5 to 6.
affb84c to
72ea768
Compare
Pins the preview release autobuild-preview-pr-628-72ea768d (72ea768d10ca9b72c68f7154dc09a0ffbf8b49be); to be replaced by the merged sha before this lands. What the new JavaScriptCore does differently: a module's function declarations are instantiated when their binding is first read and stay in the embedded bytecode until then; interpreter and Baseline call sites get their link record on their second execution, in either tier (a tail call on its first), and the collector is told about those records; value profile predictions and an unlinked code block's value and array profiles are only allocated for code that warms up; module and program code is released once it has run; code decoded from an embedded bytecode cache can be dropped and decoded again (JSC::VM::shrinkFootprintNow with flags); Heap::totalBytesAllocated() and sizeAfterLastCollection() for embedders; the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan. The bytecode cache format revision goes from 5 to 6.
Pins the preview release autobuild-preview-pr-628-72ea768d (72ea768d10ca9b72c68f7154dc09a0ffbf8b49be); to be replaced by the merged sha before this lands. What the new JavaScriptCore does differently: a module's function declarations are instantiated when their binding is first read and stay in the embedded bytecode until then; interpreter and Baseline call sites get their link record on their second execution, in either tier (a tail call on its first), and the collector is told about those records; value profile predictions and an unlinked code block's value and array profiles are only allocated for code that warms up; module and program code is released once it has run; code decoded from an embedded bytecode cache can be dropped and decoded again (JSC::VM::shrinkFootprintNow with flags); Heap::totalBytesAllocated() and sizeAfterLastCollection() for embedders; the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan. The bytecode cache format revision goes from 5 to 6.
a2623f8 to
3c319eb
Compare
53095da to
7af47b5
Compare
There was a problem hiding this comment.
The latest push addresses the link-rollback issue — the rollback loop no longer clears the executable, and didFinishWithExecutable is now reached only from evaluate()'s exit paths and setEvaluationError(), so an initialized record whose link is rolled back keeps its executable for the retry. No new issues found; given the breadth of tiers and GC paths touched, a human pass is still warranted.
What was reviewed
- Commit 7af47b5: link rollback (CyclicModuleRecord.cpp:552-557) now only resets status; verified
willBeEvaluatedByAnotherRecord/didFinishEvaluationstay balanced across rollback → re-link → evaluate. evaluate()now checksevaluationError()before the null-executable assert and callsdidFinishWithExecutableon the throwing/rejecting paths, closing the earlier leak.- Confirmed the C_LOOP guard on
ASSERT_CALL_SLOW_PATH_RUNS_IN_CLEARED_STACKremains in place.
Extended reasoning...
Overview
This ~5,900-line series across 168 files adds lazy instantiation of module top-level function declarations, lazy CallLinkInfo/ArrayProfile/ValueProfile allocation in LLInt/Baseline metadata, releasable module/program CodeBlocks with re-decode from persistent bytecode caches, a KeepCodeInUse effort for shrinkFootprintNow, and assorted footprint reductions. It spans BytecodeGenerator, LLInt assembly, Baseline JIT, DFG/FTL, the heap, module linking, and the bytecode cache format. Since the previous review one commit landed (7af47b5), reworking how a record signals it is done with its ModuleProgramExecutable.
Security risks
No new attack surface is introduced from untrusted input; the changes are internal to the engine's memory management and tiering. The riskier classes of bug here are use-after-free or stale-pointer issues from releasing (Unlinked)CodeBlocks and RegExp code while other threads or suspended activations may reference them, and mis-linked scopes across module loaders sharing one symbol table. Those are correctness/stability concerns rather than direct security exposures, and each has an option gate and dedicated tests.
Level of scrutiny
High. New opcodes and DFG nodes must behave identically across four execution tiers; metadata layout and concurrent access between mutator, collector and compiler threads changed; module linking semantics were touched. This is well beyond the threshold for auto-approval regardless of the bug hunter's clean run.
Other factors
The one commit since the last review directly addresses the 🔴 finding I raised (link rollback clearing an initialized record's executable) by removing didFinishWithExecutable from the rollback loop and instead routing every "will never run (again)" case through setEvaluationError and the exception branches of evaluate(). I traced the willBeEvaluatedByAnotherRecord / didFinishEvaluation pairing through rollback + re-link and it balances. All four earlier findings (C_LOOP assertion, testLoopCount, throwing-body count leak, link-rollback executable clear) now read as addressed in the current diff. New stress tests cover the throwing/cycle cases. Deferring to a human for final sign-off on a change of this scope.
7af47b5 to
cb7f170
Compare
sosukesuzuki
left a comment
There was a problem hiding this comment.
comments for
- Allocate an UnlinkedCodeBlock's value and array profiles when it first reaches the Baseline JIT
| FixedVector<UnlinkedValueProfile> m_valueProfiles; | ||
| FixedVector<UnlinkedArrayProfile> m_arrayProfiles; | ||
| uint32_t m_cachedRecordOffset { 0 }; // of this block's own record in that payload, while m_cachedPayloadIndex is set | ||
| ValueAndArrayProfiles* m_valueAndArrayProfiles { nullptr }; |
There was a problem hiding this comment.
This can be std::unique_ptr<ValueAndArrayProfiles> m_valueAndArrayProfiles; instead of raw pointer?
There was a problem hiding this comment.
Done in bbf17c1: std::unique_ptr<ValueAndArrayProfiles> m_valueAndArrayProfiles; the delete in the destructor is gone and valueAndArrayProfiles() returns .get().
| ASSERT(!isCompilationThread() && !Thread::mayBeGCThread()); | ||
| if (m_valueAndArrayProfiles || isBuiltinFunction()) | ||
| return; | ||
| WTF::atomicStore(&m_valueAndArrayProfiles, ValueAndArrayProfiles::create(numberOfValueProfiles(), m_numberOfArrayProfiles).release(), std::memory_order_release); |
There was a problem hiding this comment.
And use WTF::storeStoreFence() here like
void UnlinkedCodeBlock::ensureValueAndArrayProfiles()
{
ASSERT(!isCompilationThread() && !Thread::mayBeGCThread());
if (m_valueAndArrayProfiles || isBuiltinFunction())
return;
auto profiles = ValueAndArrayProfiles::create(numberOfValueProfiles(), m_numberOfArrayProfiles);
WTF::storeStoreFence(); // collector and compiler threads read m_valueAndArrayProfiles without a lock
m_valueAndArrayProfiles = WTF::move(profiles);
}?
There was a problem hiding this comment.
Done in bbf17c1, as you wrote it: create, WTF::storeStoreFence(), move-assign; the atomic store / acquire-load pair is gone.
Pins the preview release autobuild-preview-pr-628-cb7f170f (cb7f170f63fcae199d785034c5d70b7a41fc609e); to be replaced by the merged sha before this lands. What the new JavaScriptCore does differently: a module's function declarations are instantiated when their binding is first read and stay in the embedded bytecode until then; interpreter and Baseline call sites get their link record on their second execution, in either tier (a tail call on its first), and the collector is told about those records; value profile predictions and an unlinked code block's value and array profiles are only allocated for code that warms up; module and program code is released once it has run; code decoded from an embedded bytecode cache can be dropped and decoded again (JSC::VM::shrinkFootprintNow with flags); Heap::totalBytesAllocated() and sizeAfterLastCollection() for embedders; the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan; code is not returned to the bytecode cache under a suspended generator or async function activation; a released RegExp keeps its atom; a module record that is not going to run its body is done with its executable's code. The bytecode cache format revision goes from 5 to 6.
sosukesuzuki
left a comment
There was a problem hiding this comment.
Comments for
- jsc shell: ASAN builds keep locals on the real stack
| int jscmain(int argc, char** argv); | ||
|
|
||
| #if ASAN_ENABLED | ||
| // detect_stack_use_after_return moves locals to a heap-backed fake stack the conservative root scan does not visit, |
There was a problem hiding this comment.
Can we add -fsanitize-address-use-after-return=never to Source/cmake/WebKitCompilerFlags.cmake like upstream WebKit for Apple platform?
There was a problem hiding this comment.
Done in 25a5048: the flag is added next to -fsanitize=address in Source/cmake/WebKitCompilerFlags.cmake (compile and link, not for Swift, not for clang-cl, which has no such option and whose runtime does not move locals by default), and the __asan_default_options() in jsc.cpp is gone. I am building an ASAN shell from this to confirm the module tests under --collectContinuously still pass without the runtime default.
There was a problem hiding this comment.
Confirmed on an ASAN shell built from 25a5048 (all 749 compile commands carry the flag, no ASAN_OPTIONS override): the module tests that import more than one module, run with --slowPathAllocsBetweenGCs=13 and with --collectContinuously=1 (the setups that died in JSPromise::pipeFrom before the shell-side default), pass 10 of 10, and so does stress/module-loaders-share-released-code.js with a collection every 13 slow-path allocations.
sosukesuzuki
left a comment
There was a problem hiding this comment.
comments for
- Keep the predictions of a MetadataTable's value profiles out of line, and only for code that has warmed up
| // never run again only gets them when a compiler asks; until then a collection leaves the samples where they are. | ||
| if (jitType() != JITType::InterpreterThunk || !m_metadata || m_metadata->valueProfilePredictions()) | ||
| return false; | ||
| return m_unlinkedCode->llintExecuteCounter().count() < Options::thresholdForValueProfilePredictions(); |
There was a problem hiding this comment.
Functions that can be tiered up to the DFG have a bytecode size limit. This means functions with bytecode that is too large will never be compiled by the DFG. There is no need to retain value profile predictions for such functions. I think it would be good to also add a bytecode size condition to the check that determines whether to retain value profile predictions.
There was a problem hiding this comment.
Done in dcc1775: CodeBlock::valueProfilePredictionsAreNeverRead() is !Options::useDFGJIT() || bytecodeCost() > Options::maximumOptimizationCandidateBytecodeCost() (the condition of DFG::mightCompile*); such code keeps its samples in the buckets at any tier and never gets the table, including at the Baseline plan's update, which asked for it unconditionally. New test stress/value-profile-predictions-not-for-code-too-large-to-optimize.js (with $vm.hasValueProfilePredictions): the table exists exactly when an optimizing compiler compiled the function.
…d decoded again
An UnlinkedFunctionExecutable decoded from a bytecode cache lets go of its Decoder and record offsets when its code is
first decoded, so the only way to get its unlinked code back after dropping it was to parse the function again, and
such code was therefore never dropped (Heap::deleteAllUnlinkedCodeBlocks does not even see it). In a process whose cache
payload stays mapped for its whole life a dropped block can instead be decoded again for a few thousand instructions.
- A code block decoded from a persistent payload remembers its payload (an index into the new per-VM
PersistentBytecodePayloads, two bytes in existing padding) and its record's offset (four bytes in existing padding).
sizeof(UnlinkedCodeBlock) and sizeof(UnlinkedFunctionExecutable) are unchanged.
- UnlinkedFunctionExecutable::returnCodeToCache() puts the executable back into its m_isCached state, naming the code
blocks' records (negative offsets) and a Decoder for the payload: the payload's live one if there still is one, so
that what it decoded stays shared. The live child executables of a dropped block are remembered weakly, in position
order under the parent's record offset (which the block carries, so dropping never reads the payload: at deep idle
the embedder has paged it out, and faulting it back cost ~28 MB of file pages for ~20 MB of heap released), and
adopted by the block decoded from the same record later, so closures made before and after share their unlinked
code. The registry prunes itself after each full collection like a WeakGCMap.
Only with the lean decoder: the other one remembers cells by record offset and would hand out a dead one.
- Heap::deleteAllUnlinkedCodeBlocks takes which kinds of unlinked code to drop (generated, recoverable from a cache,
only what nothing links against); Heap::deleteAllCodeBlocks and ScriptExecutable::clearCode can keep what would have
to be parsed again.
Compilations that are ready are finished (Heap::completeAllJITPlans allocates: DFG::LazyJSValue) and the set of unlinked
code that linked code refers to is collected before the heap is prepared for iteration, as in deleteAllCodeBlocks().
- VM::shrinkFootprintNow / shrinkFootprintWhenIdle take flags: KeepCodeThatNeedsParsing (linked code, recoverable
unlinked code, RegExp code and parser caches go; nothing that needs a re-parse, including the builtins),
KeepCodeInUse (additionally keeps all linked and RegExp code and the unlinked code of every function that still has
linked code) and LeaveCollectionToCaller. Without flags they behave as before.
- VM::entryCountFromOutside() and a public Heap::lastActiveCollectionTime() let an embedder tell whether the program
is really at rest before it asks for any of this.
- A slot of PersistentBytecodePayloads stands for one tree of unlinked code: the payload's bytes as decoded for one
SourceProvider (an embedder may wrap the same bytes in a new CachedBytecode and SourceProvider per load; what is decoded
for a provider names it, e.g. as the provider of class sources). Children remembered under one slot are never handed to
code decoded under another, and code that is private to one executable (a module whose loader has a module scope of its
own) is not registered at all: its Baseline code assumes one resolution of that scope. Every Decoder of a slot and every
code block that carries its index hold the slot; with the last of them the payload and provider references go and the
index is used again, so a process that loads the same file over and over does not accumulate them (was: one entry per
load until the VM died).
- shrinkFootprintNow also refuses when called from inside the collector, documents that the Keep modes wait for a running
collection while the flagless mode returns false instead, clears lastException (its stack kept dropped code alive in a
second generation), and clears the SourceProvider caches in every mode. VM::deleteAllCode (the flagless mode) now deletes
the code a cache can hand back as well: on a synthetic application the heap after shrink + GC is 5.4 MB instead of 31.7.
- Heap::deleteAllUnlinkedCodeBlocks defers collection from before it finishes the compiler threads' plans until it is done:
nothing marks while an executable's code block slots turn into {Decoder, offsets}. The two sides publish and read those
slots with m_isCached in the middle and fences on both sides. Heap::lastActiveCollectionTime() is atomic.
Options::useCodeRecoveryFromBytecodeCache (default on) gates the bookkeeping and with it the recovery.
On a large bundled CLI application (idle 250 s after a 20-turn session): RssAnon 152-154 MB -> 135-138 MB with
KeepCodeInUse, 131 MB when everything is dropped, RssFile unchanged; decoding a dropped block again costs ~2.5k
instructions against ~111k for a re-parse. Synthetic (2000 modules): unlinked code blocks 19,252 -> 2,383, GC heap
33 -> 23 MB.
A module body runs once per module record, but its ModuleProgramCodeBlock, UnlinkedModuleProgramCodeBlock and CodeCache entry stayed alive for as long as any function the module created (through FunctionExecutable::topLevelExecutable and the CodeCache's Strong), the linked code until a full collection found it past its TTL. Once JSModuleRecord::evaluate sees the body finished, ModuleProgramExecutable::didFinishEvaluation() drops the linked code, and the unlinked code together with its CodeCache entry if it was decoded from a persistent bytecode cache and can be decoded again; the environment's symbol table and the function declarations' executables stay, and a later getUnlinkedCodeBlock() keeps them, asks for the code generation mode of the code it dropped and refuses code that did not come from the payload. Records of several module loaders share one ModuleProgramExecutable, so the executable counts the records that have adopted it and not finished yet (JSModuleRecord::getOrMakeExecutable, didFinishEvaluation): the code goes when the last one is done, which covers a loader suspended at a top-level await while another runs the same module to its end. A loader that comes later adopts an executable that has only let go of recoverable unlinked code and has it decoded again. A body suspended at a top-level await is not finished and keeps its unlinked code, also in VM::shrinkFootprintNow. Interpreter::executeProgram, which creates its ProgramExecutable itself, clears it after the run. Code that left the interpreter, or has a baseline compile queued, is left to age out: a compiler thread may be looking at it (GlobalExecutable::canReleaseLinkedCodeNow). With useLazyModuleFunctionDeclarations a module record referred to the module's unlinked code so that a declaration nobody has read yet can be instantiated later; since most never are, that alone kept nearly every module's unlinked code alive. When the declarations were left in a persistent payload the record's ModuleFunctionDeclarationSlots can decode any of them on its own, so in that case the record does not reference the code block: a read links from the executable's code block while it has one and from the payload otherwise. Options::useRunOnceCodeRelease (default on). Options::useSharedModuleFunctionExpressionExecutables (default off): the FunctionExecutables of the function expressions and classes in a module's top-level code belong to the ModuleProgramExecutable instead of to each linked ModuleProgramCodeBlock, so their CodeBlocks and JIT code survive the module's own linked code and are shared by every evaluation of the module. Synthetic application of 2,000 modules: ModuleProgramCodeBlock 2,001 -> 1, UnlinkedModuleProgramCodeBlock 2,564 -> 2, GC heap 39.4 -> 24.3 MB, extra memory 11.8 -> 1.5 MB, startup instructions -4.4%. A large bundled CLI application: RssAnon 10 s after launch -3 MB.
…ated, for embedders An embedder that wants to tell an idle program from a busy one that happens not to grow its heap needs two numbers Heap keeps but does not hand out: - sizeAfterLastCollection(): m_sizeAfterLastCollect, the live size (cells and extra memory) as of the last finished collection, eden or full. - totalBytesAllocated(): everything the mutator has allocated, cells and reported extra memory, the current cycle included. The per-cycle counters are reset in updateAllocationLimits(); they are added to a running total right before that. Mutator thread only. Both are read once per embedder GC timer tick.
…to the collector Since call sites in LLInt / Baseline metadata keep their CallLinkInfo and ArrayProfile out of line (LazyCallLinkInfo), the 100-odd bytes per call site that the table used to hold inline, and report with its size, are separate allocations the collector does not know about: for a function with 20,000 call sites that is 2.2 MB per CodeBlock that neither paces eden collections nor counts towards the next full one. MetadataTable::LinkingData counts the CallSiteDatas its call sites own (in what is padding on 64-bit targets; only the mutator writes it, so a relaxed load and store). On the allocation side one record is below what Heap::reportExtraMemoryAllocated() takes note of, so LazyCallLinkInfo::ensureSlow() reports them 32 at a time, against the owning CodeBlock, which also covers a CodeBlock that is already marked. On the visiting side CodeBlock::visitChildren() and estimatedSize() add them for the CodeBlock the table was linked for; the optimized CodeBlocks that share the table of the one they replace do not, or a hot function's records would be counted three or four times in every collection. While here: MetadataTable::sizeInBytesForGC() took a reference on the UnlinkedMetadataTable (an atomic increment and decrement) from every marker thread for every CodeBlock; it reads it through the LinkingData now.
…+ function's frame is going to occupy The slow paths for calls (llint_default_call, llint_virtual_call, llint_polymorphic_call, llint_unlinked_call; operationDefaultCall, operationVirtualCall, operationPolymorphicCall) run with the stack pointer at the callee's frame: their own frame lies over whatever the last callee at that depth left there, and sanitizeStackForVM(), which they call first thing, can only clear what is below the function that calls it. What such a frame does not write stays in reach of the conservative scan of a later, shallower callee's native frames. How much stays depends on the size of that frame, which nothing controls: llint_unlinked_call()'s is 216 bytes against llint_default_call()'s 120, and that was enough to show. Seen as: `rewrite(); rewrite(); Bun.gc(true)` at the top level of a script keeps the HTMLRewriter that the last rewrite() made alive through that collection (Bun's html-rewriter-leak test). The wrapper's address sits in an unwritten slot of the host function's frame (bindgen_BunObject_jsGc), 176 bytes below the frame pointer of rewrite()'s and Bun.gc's common caller; a heap snapshot taken at that point has the wrapper with no incoming edge and no root; SlotVisitor::append(ConservativeRoots) is what marks it; clearing that one word in a debugger lets it die. The first call of the `pf()` site went through llint_unlinked_call(), whose frame covers that address; through llint_default_call() the address is below the frame and cleared. Rather than keep one of eight frames small, which only the optimizer decides (and which a different ABI, or no optimization, decides differently), the thunks that call these functions now clear the stackBytesClearedForCallSlowPath bytes that the C++ frame is going to occupy before it exists: the linkFor macro in the LLInt, and emitCallSlowPath() for the JIT's thunks, which is what the default, virtual and polymorphic call thunks had four copies of. Nothing is written below the stack pointer (no ABI we target promises that memory, and a signal handler's frame goes there): the stack pointer moves down over the window, a multiple of 16 bytes, the window is cleared above it, and it moves back. 256 bytes in a release build (the largest of these frames is 152 bytes on x86_64; everything the function calls is below what it clears itself), 32 straight-line stores, 16 stp on ARM64; 2 KB, in a loop, with assertions or ASan, where ASSERT_CALL_SLOW_PATH_RUNS_IN_CLEARED_STACK() checks in each slow path that its frame does not reach below the window. The LLInt's linkFor clears 64 bytes per iteration of its loop. That is 36 instructions per call that takes one of these slow paths with the JIT, 49 without. sanitizeStackForVM(), which each of them calls, spends about 55 on two thread-local lookups to find the bounds of the current thread's stack and to check that the thread holds the API lock; these slow paths run in the middle of JS, on the thread that holds the lock, so sanitizeStackForVMInCallSlowPath() takes the bounds from the lock's owner and makes the same two checks of lastStackTop against them. A call site that takes a slow path on every call (3 M calls of Proxy callables): 3.715 G -> 3.652 G user instructions with the JIT, 4.889 G -> 4.862 G without; a plain call loop does not change.
…ns for the second time, as the LLInt does A CodeBlock that was set up with Baseline code got a CallSiteData for every call site that did not own one (CodeBlock::ensureCallLinkInfos), and that is every new CodeBlock of a function whose Baseline code is shared through its UnlinkedCodeBlock: a module or a CommonJS wrapper that is evaluated again, a function linked in another realm. For exactly the functions the lazy records are for, big ones whose call sites mostly run once per evaluation, that is a pass over the instruction stream, an allocation, an initialization and a free per call site per evaluation. A CommonJS module with 20,000 calls required 500 times: 7.2 G user instructions before call sites kept their records out of line, 10.8 G since; resident memory of the loop swings by 100-150 MB with it (the records are small allocations the allocator purges late, where one metadata allocation of several MB used to be unmapped at once). Nothing in Baseline code needs the record to be the site's own. It loads the pointer from the metadata on every execution, and the CallLinkInfo the unowned sites share looks like a polymorphic call whose destination is the unlinked call thunk. That was the LLInt's trampoline; with the JIT it is now a thunk like the default call thunk (LLInt::unlinkedCall() chooses, next to LLInt::defaultCall()), calling operationUnlinkedCall(), which returns the exception-throwing stub when the call threw. It and llint_unlinked_call() share LLInt::handleUnlinkedCall(). All the slow path gets is the shared CallLinkInfo, so the site is what the caller left in its frame (CallFrame::bytecodeIndex(); the LLInt and Baseline code store it the same way). handleUnlinkedCall() checks what that rests on: the caller's CodeBlock is LLInt / Baseline code, the instruction is one of FOR_EACH_OPCODE_WITH_LAZY_CALL_LINK_INFO (CodeBlock::lazyCallLinkInfoAt() crashes otherwise), it is not a tail call, and the site does point at a shared CallLinkInfo. A tail call has given up the caller's frame by then, so a tail call site gets its own record before it runs for the first time. The LLInt tested for that already (prepareCallSiteForTailCall). Baseline code pays nothing per tail call for it: tail call sites start out with a third shared record, whose CallLinkInfo looks unlinked rather than polymorphic, so their first execution takes the path of the inline cache that an unlinked call takes anyway, before the frame is given up, and that path now tests for a CallLinkInfo without an owner and calls operationEnsureCallLinkInfoForTailCall(). A direct eval whose callee is not eval makes a virtual call with the site's CallLinkInfo in Baseline code's slow case, which does the same test first. Nothing looks at the whole instruction stream any more. What compiler threads see: more CodeBlocks now have sites that get their record while an optimizing compile reads them. LazyCallLinkInfo::ownData() orders what it reads through the pointer after the pointer (the publisher already has a storeStoreFence), and CallLinkStatus::computeFor() looks the site up when the map it was given predates the record, so that what DFG::InliningPlan saw and what the parser sees agree. The ArrayProfile of |this|: both tiers note the structure in whatever CallSiteData the site has, so the first two executions went into the shared one, which nobody reads (arrayProfile() only returns a site's own); the record is now seeded with the structure of |this| when it is made. One CodeBlock::ensureCallLinkInfoAt() replaces four copies of the lookup, and $vm.numberOfOwnCallLinkInfos(function) lets a test see which sites own a record. User instructions, a standalone runtime built on this, 500 requires of a module (before: the current WebKit main; then this series without and with this change): - 20,000 plain calls in the CommonJS wrapper: 7.23 G 10.8 G 6.64 G - 20,000 tail calls in a switch, 4 of them run: 10.7 G 15.0 G 8.37 G - 2,000 strict functions, each with one tail call: 7.87 G - 7.29 G (with a small heap, --smol: 7.18 G, 8.57 G, 7.71 G; the difference to the line above is collections that find more CodeBlocks alive, not these paths) A large bundled CLI application: --help 554.6 M -> 494.4 M, a 20-request session 23.0-23.6 G -> 22.7-23.1 G.
…ps that are not in use (#633) After an interactive session of a large bundled CLI application the executable pool holds 5.0 MB of allocated code (6.7 MB of committed pages) two minutes after the last input, and 3.7 MB (4.7 MB) after the deep-idle VM::shrinkFootprintNow(KeepCodeInUse). By owner: Yarr code of 580 RegExps 3.85 MB (6.6 KB each), Baseline 0.56 MB in use + 0.60 MB cached on unlinked code blocks whose CodeBlocks are gone (released by its lease before the shrink), DFG 0.22 MB. The pool itself is fine: MetaAllocator decommits a page when its last allocation dies and only 1.0-1.7 MB of committed pages are partly used. What stays is RegExp code, which KeepCodeInUse never touches (KeepCodeThatNeedsParsing drops all of it). With Options::releaseIdleRegExpCodeWhenShrinkingFootprint (off by default) the KeepCodeInUse shrink calls RegExp::deleteCode() on every RegExp in the RegExpCache that has not matched since the last full collection began. The embedder shrinks after the program has been at rest well beyond its last idle collection, so that means "not during the quiet period"; a RegExp on a timer keeps its code. A RegExp whose code was dropped is in the NotCompiled state, exactly as after VM::deleteAllRegExpCode(), and compiles again from its pattern when it next matches. - In use: RegExp::compileIfNecessary[MatchOnly], which every match that runs the matcher goes through first (one that the minimum-length filter rejects does not count), stores the low byte of the heap's marking version (one per full collection) in the new RegExp::m_lastUseEpoch. A stale byte that happens to equal the current one after 256 full collections only keeps some code for another round. The byte takes one of the three bytes of padding between m_constructionErrorCode and m_numSubpatterns; RegExp stays in the 80-byte size class. - Optimized code: DFG and FTL never call a RegExp's Yarr code by address. RegExpExec/RegExpTest/... call operations that end up in RegExp::match; RegExpTestInline emits a fresh copy of the matcher into the DFG/FTL code (Yarr::jitCompileInlinedTest from SpeculativeJIT::compileRegExpTestInline and FTL::LowerDFGToB3::compileRegExpTestInline), built from the pattern; the get*MatchAddr() accessors of YarrCodeBlock are only used to print. The first-character bitmap that the fast paths in JIT code test belongs to the RegExp, not to its code; m_minimumSize goes back to 0, which sends their length check to the slow path, and a minimum size folded as a constant is a property of the pattern. So no machine code refers to what deleteCode() frees. What the compiler threads do read is the YarrCodeBlock's inline statistics (DFGStrengthReductionPhase, then compileRegExpTestInline asserts getRegExpJITCodeBlockConcurrently()), so the release only happens when VM::numberOfActiveJITPlans() is zero; plans are started by the mutator, i.e. not during the shrink. The KeepCodeThatNeedsParsing shrink gets the same guarantee from Heap::deleteAllCodeBlocks() completing all plans first. - Running matches: shrinkFootprintNow() refuses to run with a VMEntryScope (JS on the stack), and RegExp::match neither re-enters the run loop nor is called by the embedder outside of the API lock, so no Yarr code is on the native stack of this VM when the shrink runs. deleteCode() takes the RegExp's cellLock like every other state change. - RegExpCache: every RegExp is created through RegExpCache::lookupOrCreate() and, unless its pattern has a syntax error (no code then), is in its weak map for as long as it lives; entries whose RegExp is dead are skipped. The small strong cache (recently created patterns) is left alone: it only keeps RegExp cells alive, not their code. The same application, 20 inputs, idle 240 s, 10 more inputs, idle 240 s: executable pool after each shrink 3.67 MB allocated / 4.70 MB committed -> 0.13 / 0.97, RssAnon at rest 3.7-6 MB lower. The second session compiles ~450 RegExps again, and that is not free: user-mode instructions of the whole process, five interleaved pairs, 33.94 G (33.75-34.24) without and 34.91 G (34.46-35.34) with the option, +0.97 G (+2.9 %) for one wake-up. Three RegExps account for most of both the memory and the cost: patterns of 530 KB, 169 KB and 20 KB (machine-generated) compile to 1.97 MB, 0.71 MB and 0.17 MB of code in two variants each; the other 570 RegExps hold 1.0 MB together. Hence off by default.
…and only the VM's thread counts as a use deleteCode() cleared m_atom and m_specificPattern along with the code. Both describe the pattern: finishCreation() sets them without compiling anything, every compile sets them to the same values again, and none of their readers (the global-atom match, replace, split and trim fast paths, RegExpSubstringGlobalAtomCache) runs the code. Clearing them took those fast paths away from a RegExp that was only used through them, and broke RegExpCachedResult: a one-character match that has yet to be reified looks its character up in the atom, so after VM::deleteAllRegExpCode (the debugger, the inspector, a memory warning; also the new idle release) RegExp.leftContext and lastMatch were wrong in release builds and ASSERT(hasValidAtom()) failed in debug builds. They stay now. The epoch of the last use was stored by compileIfNecessary[MatchOnly], which a compiler thread also reaches through matchConcurrently(): an unsynchronized write to a byte the mutator writes too. It is stored by matchInlineOnce on the VM's thread only (RegExp::noteUse), at the same point of a match as before. * JSTests/stress/shrink-footprint-keeps-regexp-atom-and-specific-pattern.js: Added. Fails without the change in all three of its modes (RegExp.leftContext is "" where "xay" is expected), the one with the option off included.
…tivation
Heap::deleteAllUnlinkedCodeBlocks(RecoverableFromCache) returns the code of every decoded function that no CodeBlock
links against to the cache it came from. A generator or an async function that is suspended has no CodeBlock once that
was jettisoned for old age (it is not on the stack), yet it is about to link its code again when it resumes: decoding
that code again first costs the decode and the warm-up, and hands the resumed activation new copies of everything it
already has. Those functions are found through the objects that will resume in them (JSGenerator, JSAsyncGenerator and,
for an async function or arrow, JSAsyncFunctionGenerator: Field::Next of the ones whose state is a resume point) and
skipped; once the activation has finished, its code goes back with the next call.
* JSTests/stress/shrink-footprint-spares-the-code-of-suspended-activations.js: Added, with
$vm.isGeneratorBodyCodeInBytecodeCache. Fails without the change ("the suspended generator's code stays"; with only
the async functions' objects left out, 67 executables have their code in the cache while 30 of them are suspended,
where 37 do with the change).
…oop; the new tests use testLoopCount ASSERT_CALL_SLOW_PATH_RUNS_IN_CLEARED_STACK compares the stack pointer of the C++ function with the callee's frame. With the C loop that frame is in the CLoopStack, not on the native stack, and the call slow paths clear nothing there (linkFor's clearing loop is under `if not C_LOOP`), so the comparison was between unrelated addresses and could fail on the first call slow path of a debug C loop build. The tests this series adds counted their warm-up loops with literals (20000 to 200000); JSTests/README.md asks for testLoopCount, which the harness scales per configuration.
…lector module-loaders-share-released-code.js and module-lazy-function-declarations-outlive-released-code.js checked that a module's unlinked code was gone by counting the live UnlinkedModuleProgramCodeBlocks after a full collection. The collector scans the stack conservatively: in the LTO build of the x86-64 test lane a frame of the microtask loop keeps a word that points into the module's CodeBlock (nothing else refers to it: a heap snapshot shows no edge and no root, a debugger shows the word 24 bytes above that frame's return address), which keeps the block and its unlinked code alive across collections, so both tests failed there and nowhere else. What the change promises is that the executables let go of the code: $vm.codeBlockCensus() reports that too (moduleExecutablesWithUnlinkedCode), and the tests assert on it now. They still fail when ModuleProgramExecutable::releaseUnlinkedCodeIfRecoverable is made to do nothing.
…its executable's code ModuleProgramExecutable counts the records that have yet to finish evaluating (willBeEvaluatedByAnotherRecord, when a record is linked) and releases the code that has run once the count reaches zero. JSModuleRecord::evaluate only reported the end of a body that returned. A body that threw, a top-level await that rejected, an import that failed to resolve on the way in; a record that never ran because a module it depends on threw first, one left suspended at a top-level await when a sibling threw: each left the count up for good, and the executable, which later records share, never released its code again. None of them runs the body (again), so they report it too: JSModuleRecord::didFinishWithExecutable, from evaluate() and from CyclicModuleRecord::setEvaluationError (every place that gives a record an error goes through it). evaluate() also looks at the record's evaluation error before it looks for the executable, which the record has given up by then. A record whose link is rolled back keeps its executable, as it keeps its environment: the next attempt to link it does not make either again. * JSTests/stress/module-loaders-share-released-code.js: a loader whose body throws, one whose dependency throws, and one with a record suspended in a cycle when a sibling throws, each followed by a loader that runs to the end. The first fails without the evaluate() part, the other two without the setEvaluationError part.
…lished with a storeStoreFence Review feedback: own the lazily made profiles with a std::unique_ptr instead of a raw pointer and a delete in the destructor, and publish them the way the rest of the class does: fill, WTF::storeStoreFence(), assign. The collector and the compiler threads read the pointer without a lock and only dereference what it points to.
… for every binary Review feedback: -fsanitize-address-use-after-return=never in WebKitCompilerFlags.cmake, as OptionsCocoa.cmake has for the Apple ports, instead of an __asan_default_options() in the jsc shell. The instrumentation that moves address-taken locals to the heap-backed fake stack, which the conservative root scan does not visit, is then not emitted at all, for testapi and the other binaries as well as for jsc.
…never compile Review feedback: DFG::mightCompile* turns down code whose bytecode cost is over maximumOptimizationCandidateBytecodeCost, so nothing ever reads the predictions of such a function's value profiles, and the same goes for every function when the DFG is off. CodeBlock::valueProfilePredictionsAreNeverRead() says so; keepsValueProfileSamplesInBuckets() answers yes for that code at any tier and however often it has run, and the update the Baseline plan asks for (Record, whatever the code is) leaves its samples in the buckets too. * JSTests/stress/value-profile-predictions-not-for-code-too-large-to-optimize.js: Added, with $vm.hasValueProfilePredictions. A function has the table exactly when an optimizing compiler compiled it; without the change it has it in the too-large and the no-DFG modes as well.
…lling -fsanitize-address-use-after-return=never is a clang driver option and the block was only guarded by NOT MSVC inside the GCC-or-clang region, so an ASAN build with GCC stopped at the first file. It is COMPILER_IS_CLANG AND NOT MSVC now, and GCC gets --param=asan-use-after-return=0.
How much the mutator may allocate before the heap collects by itself: what updateAllocationLimits() decided after the last collection (effectiveMaxEdenSize()). For an embedder that wants to say "this program is allocating a lot" relative to the heap it has, and not in bytes per second of its own choosing.
0992ac3 to
a1da8f1
Compare
WEBKIT_VERSION 65513e295c73 -> c775a5dc527da387fd84cc444096af38f6810b44 (oven-sh/WebKit main: #628, #630, #635, #657 and two crash-instruction fixes, #316 and #485). No Bun source change is needed to build against it. What the new JavaScriptCore does differently (oven-sh/WebKit#628): a module's function declarations are instantiated when their binding is first read and stay in the embedded bytecode until then; interpreter and Baseline call sites get their link record on their second execution, in either tier, and the collector is told about those records; an unlinked code block's value and array profiles are allocated when it first reaches the Baseline JIT, and value profile predictions only for code that has warmed up; module and program code is released once it has run; code decoded from an embedded bytecode cache can be dropped and decoded again (VM::shrinkFootprintNow with flags; nothing calls it yet), not under a suspended generator or async function activation; the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan; Heap::totalBytesAllocated(), sizeAfterLastCollection() and allocationBudgetThisCycle() for embedders. #630: for-of and array destructuring over arrays without an Array Iterator object, one RegExpObject per /x/.test(s) literal site. #635: Heap::evacuateSparseAuxiliaryBlocks, a prototype nothing calls. #657: a suspended generator keeps its scopes' SymbolTables when its code is generated again. The bytecode cache format revision goes from 5 to 9 (#630 took 6-8, #628 9). test/bundler/bundler_bytecode_portable.test.ts: the inline snapshot of the encoder's output is regenerated with this build. What moved, checked entry by entry: the size and sha256 of every serialized cache (the revision is part of every header, and seven commits in the range change runtime/CachedTypes.cpp: when an unlinked code block's profiles are allocated, its out-of-line jump targets moving into its rare data, how the two-character atom table is indexed, module function declarations that stay in the payload and are instantiated on first read, code that can be decoded again, and #630's bytecode for for-of); the sha256 of the printed JavaScript next to each of them and the string corpus are unchanged. Bundles are 0.1-0.2% smaller (22,009,472 -> 21,977,536 bytes for libraries.js), vm.Script and vm.SourceTextModule caches 0-1.6% larger (typescript.js 11,684,048 -> 11,769,312; acorn.mjs 257,168 -> 261,216, its function declarations are in the payload now). The cases of that file that decode every corpus from its cache and compare the program's output pass, as does the one that encodes in a second process and compares the bytes. test/cli/inspect/compile-bytecode-tooling.test.ts: a module's function declaration now becomes a function object when its binding is first read, so the heap snapshot case takes one snapshot before anything has read hotWork (it is not in it) and one after (it is). [skip size check]: bun-windows-x64 grows by 576 KB, over the 0.5 MB gate (every other target by 64-144 KB). That is the new engine code of the WebKit range plus, on Windows x64 with LTO only, WebKit#316 (BCRASH becomes __builtin_trap on clang-cl), which is about a third of the growth of that target's prebuilt; there is no Bun code in this change to make smaller.
WEBKIT_VERSION 65513e295c73 -> c775a5dc527da387fd84cc444096af38f6810b44 (oven-sh/WebKit main: #628, #630, #635, #657 and two crash-instruction fixes, #316 and #485). No Bun source change is needed to build against it; one workaround in BunDebugger.cpp that the new JavaScriptCore makes redundant goes. What the new JavaScriptCore does differently (oven-sh/WebKit#628): a module's function declarations are instantiated when their binding is first read and stay in the embedded bytecode until then; interpreter and Baseline call sites get their link record on their second execution, in either tier, and the collector is told about those records; an unlinked code block's value and array profiles are allocated when it first reaches the Baseline JIT, and value profile predictions only for code that has warmed up; module and program code is released once it has run; code decoded from an embedded bytecode cache can be dropped and decoded again (VM::shrinkFootprintNow with flags; nothing calls it yet), not under a suspended generator or async function activation; the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan; Heap::totalBytesAllocated(), sizeAfterLastCollection() and allocationBudgetThisCycle() for embedders. #630: for-of and array destructuring over arrays without an Array Iterator object, one RegExpObject per /x/.test(s) literal site. #635: Heap::evacuateSparseAuxiliaryBlocks, a prototype nothing calls. #657: a suspended generator keeps its scopes' SymbolTables when its code is generated again. The bytecode cache format revision goes from 5 to 9 (#630 took 6-8, #628 9). test/bundler/bundler_bytecode_portable.test.ts: the inline snapshot of the encoder's output is regenerated with this build. What moved, checked entry by entry: the size and sha256 of every serialized cache (the revision is part of every header, and seven commits in the range change runtime/CachedTypes.cpp: when an unlinked code block's profiles are allocated, its out-of-line jump targets moving into its rare data, how the two-character atom table is indexed, module function declarations that stay in the payload and are instantiated on first read, code that can be decoded again, and #630's bytecode for for-of); the sha256 of the printed JavaScript next to each of them and the string corpus are unchanged. Bundles are 0.1-0.2% smaller (22,009,472 -> 21,977,536 bytes for libraries.js), vm.Script and vm.SourceTextModule caches 0-1.6% larger (typescript.js 11,684,048 -> 11,769,312; acorn.mjs 257,168 -> 261,216, its function declarations are in the payload now). The cases of that file that decode every corpus from its cache and compare the program's output pass, as does the one that encodes in a second process and compares the bytes. test/cli/inspect/compile-bytecode-tooling.test.ts: a module's function declaration now becomes a function object when its binding is first read, so the heap snapshot case takes one snapshot before anything has read hotWork (it is not in it) and one after (it is). src/jsc/bindings/BunDebugger.cpp: protectModuleExecutablesFromClearCode() took every module executable out of the VM's clearable-code set before the debugger's recompileAllJSFunctions, because ModuleProgramExecutable::clearCode used to drop the module environment's symbol table and regenerating the code in debugger mode no longer matched the live environment. At this WebKit a module executable keeps one environment symbol table and its function declarations for its whole life and its code-generation mode is pinned, so that cannot happen, and module code that has run is released by the engine itself anyway. Removed; test/cli/inspect (48 tests), test/js/node/inspector/inspector.test.ts (24, including the script that turns breakpoints on between two top-level awaits) and test/regression/issue/21654 pass without it. test/cli/inspect/compile-bytecode-tooling.test.ts, new case: Bun.shrink() (like a debugger attaching, or a Worker going away) now drops code that was decoded from a bytecode cache and decodes it again when it next runs; before, such code was never touched. Three rounds of Bun.shrink(), a tick and Bun.gc(true), then a function that had run, one that had not, a class method, a generator and an async function suspended across the shrinks with their captured locals: exact values, and the same output from source, from the --compile --bytecode executable and from NODE_COMPILE_CACHE on its second run. [skip size check]: bun-windows-x64 grows by 576 KB, over the 0.5 MB gate (every other target by 64-144 KB). That is the new engine code of the WebKit range plus, on Windows x64 with LTO only, WebKit#316 (BCRASH becomes __builtin_trap on clang-cl), which is about a third of the growth of that target's prebuilt; there is no Bun code in this change to make smaller.
WEBKIT_VERSION 65513e295c73 -> c775a5dc527da387fd84cc444096af38f6810b44 (oven-sh/WebKit main: #628, #630, #635, #657 and two crash-instruction fixes, #316 and #485). No Bun source change is needed to build against it; one workaround in BunDebugger.cpp that the new JavaScriptCore makes redundant goes. What the new JavaScriptCore does differently (oven-sh/WebKit#628): a module's function declarations are instantiated when their binding is first read and stay in the embedded bytecode until then; interpreter and Baseline call sites get their link record on their second execution, in either tier, and the collector is told about those records; an unlinked code block's value and array profiles are allocated when it first reaches the Baseline JIT, and value profile predictions only for code that has warmed up; module and program code is released once it has run; code decoded from an embedded bytecode cache can be dropped and decoded again (VM::shrinkFootprintNow with flags; nothing calls it yet), not under a suspended generator or async function activation; the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan; Heap::totalBytesAllocated(), sizeAfterLastCollection() and allocationBudgetThisCycle() for embedders. #630: for-of and array destructuring over arrays without an Array Iterator object, one RegExpObject per /x/.test(s) literal site. #635: Heap::evacuateSparseAuxiliaryBlocks, a prototype nothing calls. #657: a suspended generator keeps its scopes' SymbolTables when its code is generated again. The bytecode cache format revision goes from 5 to 9 (#630 took 6-8, #628 9). test/bundler/bundler_bytecode_portable.test.ts: the inline snapshot of the encoder's output is regenerated with this build. What moved, checked entry by entry: the size and sha256 of every serialized cache (the revision is part of every header, and seven commits in the range change runtime/CachedTypes.cpp: when an unlinked code block's profiles are allocated, its out-of-line jump targets moving into its rare data, how the two-character atom table is indexed, module function declarations that stay in the payload and are instantiated on first read, code that can be decoded again, and #630's bytecode for for-of); the sha256 of the printed JavaScript next to each of them and the string corpus are unchanged. Bundles are 0.1-0.2% smaller (22,009,472 -> 21,977,536 bytes for libraries.js), vm.Script and vm.SourceTextModule caches 0-1.6% larger (typescript.js 11,684,048 -> 11,769,312; acorn.mjs 257,168 -> 261,216, its function declarations are in the payload now). The cases of that file that decode every corpus from its cache and compare the program's output pass, as does the one that encodes in a second process and compares the bytes. test/cli/inspect/compile-bytecode-tooling.test.ts: a module's function declaration now becomes a function object when its binding is first read, so the heap snapshot case takes one snapshot before anything has read hotWork (it is not in it) and one after (it is). src/jsc/bindings/BunDebugger.cpp: protectModuleExecutablesFromClearCode() took every module executable out of the VM's clearable-code set before the debugger's recompileAllJSFunctions, because ModuleProgramExecutable::clearCode used to drop the module environment's symbol table and regenerating the code in debugger mode no longer matched the live environment. At this WebKit a module executable keeps one environment symbol table and its function declarations for its whole life and its code-generation mode is pinned, so that cannot happen, and module code that has run is released by the engine itself anyway. Removed; test/cli/inspect (48 tests), test/js/node/inspector/inspector.test.ts (24, including the script that turns breakpoints on between two top-level awaits) and test/regression/issue/21654 pass without it. test/cli/inspect/compile-bytecode-tooling.test.ts, new case: Bun.shrink() (like a debugger attaching, or a Worker going away) now drops code that was decoded from a bytecode cache and decodes it again when it next runs; before, such code was never touched. Three rounds of Bun.shrink(), a tick and Bun.gc(true), then a function that had run, one that had not, a class method, a generator and an async function suspended across the shrinks with their captured locals: exact values, and the same output from source, from the --compile --bytecode executable and from NODE_COMPILE_CACHE on its second run. [skip size check]: bun-windows-x64 grows by 576 KB, over the 0.5 MB gate (every other target by 64-144 KB). That is the new engine code of the WebKit range plus, on Windows x64 with LTO only, WebKit#316 (BCRASH becomes __builtin_trap on clang-cl), which is about a third of the growth of that target's prebuilt; there is no Bun code in this change to make smaller.
#42822) ### What does this PR do? Moves `WEBKIT_VERSION` from `65513e295c73` to `c775a5dc527da387fd84cc444096af38f6810b44` (oven-sh/WebKit main). No Bun source change is needed to build: main builds against it as it is. One workaround the new engine makes redundant is removed (`BunDebugger.cpp`, below); the other two files are tests. What comes with it, on the JavaScriptCore side: - oven-sh/WebKit#628, "less memory per function that never runs, and code that can be dropped and decoded again": - a module's function declarations are instantiated when their binding is first read, and stay in the embedded bytecode until then; - call sites in the interpreter and in Baseline code get their link record (and array profile) on their second execution, in either tier, and the collector is told about those records; - an unlinked code block's value and array profiles are allocated when it first reaches the Baseline JIT, and a metadata table's value-profile predictions are kept out of line and only for code that has warmed up; - module and program code that has run is released right away; a module record that is not going to run its body is done with its executable's code; - code decoded from an embedded bytecode cache (`bun build --compile --bytecode`) can be dropped and decoded again (`VM::shrinkFootprintNow` with flags; nothing in Bun calls it yet), not under a suspended generator or async activation; a released RegExp keeps its atom; - the thunks of the call slow paths clear the stack their C++ function's frame is going to occupy, so that what the last callee left there is not kept alive by a later conservative scan; - `Heap::totalBytesAllocated()`, `sizeAfterLastCollection()` and `allocationBudgetThisCycle()` for embedders; `$vm.codeBlockCensus()`. - Consequence for Bun: `Bun.shrink()`, a debugger attaching (`recompileAllJSFunctions`) and a Worker going away (`VM::deleteAllCode`) now also drop executables that were decoded from a persistent payload (`--compile --bytecode`, `NODE_COMPILE_CACHE`) and decode them again on their next call; before, such code was never touched. There is a test for it now (below). `Bun.shrink()` also returns early, without collecting or returning allocator memory, when a concurrent collection is in progress, and it clears `vm.lastException()`; both are benign. - oven-sh/WebKit#630: `for`-`of` and array destructuring over arrays without an Array Iterator object, and one RegExpObject per `/x/.test(s)` literal site. - oven-sh/WebKit#635: `Heap::evacuateSparseAuxiliaryBlocks` (a prototype; nothing calls it by default). - oven-sh/WebKit#657: a suspended generator or async function keeps its scopes' SymbolTables when its code is generated again. - The bytecode cache format revision goes from 5 to 9 (#630 took 6-8, #628 takes 9), so caches written by an older Bun are rejected and rebuilt, and `--compile --bytecode` executables must be rebuilt with the new Bun (as with every revision bump). The release `autobuild-c775a5dc527da387fd84cc444096af38f6810b44` is published with the same 42 assets, name for name, as the release of the current pin (`autobuild-65513e295c73...`), so every flavour `scripts/build/deps/webkit.ts` downloads today exists for this one: linux glibc, musl and android, macos, windows and freebsd, amd64 and arm64, each as release, `-lto` (not windows-arm64, as today) and `-debug`, plus `-asan` and `-debug-asan` for linux amd64/arm64 and macos-arm64 and `-asan` for windows-amd64. `src/jsc/bindings/BunDebugger.cpp`: `protectModuleExecutablesFromClearCode()` removed every module executable from the VM's clearable-code set before the debugger's `recompileAllJSFunctions`, because `ModuleProgramExecutable::clearCode` used to drop the module environment's symbol table, and code regenerated in debugger mode then no longer matched the live environment. At this WebKit a module executable keeps one environment symbol table and its function declarations for its whole life, its code-generation mode is pinned, and module code that has run is released by the engine itself, so the invariant the comment described no longer exists. The function and its call are deleted. ### What it gives A large bundled CLI application built as a standalone executable with embedded bytecode (`--compile --bytecode`), a scripted 20-request session against a local fake API, release builds (`--lto=off`) of main (782c402) and of this branch, same application commit. RSS in MB (anonymous + file-backed). | | main | this PR | |---|---|---| | parked at its first prompt, 10 s after it appears | 229 (133 + 95) | 207-213 (116 + 90-97) | | ... 30 s | 228-229 (133-134 + 95) | 206-213 (114-116 + 92-96) | | ... 2.5 min (after main's second idle collection and the page-out of the module graph) | 140-145 (108 + 32-36) | 136-140 (95-99 + 41) | | ... 10 min | 142-145 (108 + 33-37) | 135-141 (93-98 + 42-43) | | **peak of the 20-request session** (10 runs each, interleaved; the larger of the kernel's `VmHWM` and the highest `VmRSS` seen) | **median 474, range 452-490** | **median 453, range 434-472** | | what the highest sample of those runs is made of (medians) | 368 anonymous + 103 file | 342 anonymous + 105 file | | 30 s after the session | 385-391 (282-288 + 102-103) | 353-359 (259-260 + 94-98) | | ... 2.5 min | 215-216 (178 + 37-38) | 210-213 (167-171 + 42-43) | | ... 10 min | 225-231 (179-183 + 45-47) | 217-224 (168-171 + 49-52) | | `--help`, user-mode instructions (7 runs each, interleaved) | 548.5 M (543.0-548.8) | 507.9 M (506.6-528.8): -7.4% | Two runs per row unless said otherwise; the idle timer is main's on both sides (its defaults: collections after 10 s, 75 s and 140 s without heap growth). What it is: about 17 MB less anonymous memory from the moment the prompt is up (functions that are declared and never called no longer exist as objects, call sites that have run once or never carry no link record, code that never reached the Baseline JIT has no profiles), about 10 MB of that left once the idle collections have run on both sides, and 5-9 MB more file-backed memory at rest (the declarations that are not instantiated stay in the embedded bytecode, which is part of the executable's mapping). The peak is lower too, by about the same amount as the fresh prompt and a little more: 22 MB at the median, all of it anonymous; the spread between runs is 40 MB on both sides, and this PR is the lower one in 9 of the 10 interleaved pairs. So the lazily allocated metadata lowers the peak as well as the idle footprint, by roughly what it saves at the prompt; nothing here changes what a request allocates while it runs. ### Binary size Against main's canary (BuildKite's binary-size annotation on this PR's first build): | target | main | this PR | delta | |---|---|---|---| | bun-darwin-aarch64 | 59.95 MB | 60.07 MB | +129.2 KB | | bun-darwin-x64 | 65.83 MB | 65.97 MB | +144.3 KB | | bun-linux-aarch64 | 76.43 MB | 76.55 MB | +128.0 KB | | bun-linux-x64 | 76.38 MB | 76.51 MB | +128.0 KB | | bun-linux-aarch64-musl | 69.63 MB | 69.70 MB | +64.0 KB | | bun-linux-x64-musl | 70.51 MB | 70.59 MB | +80.0 KB | | bun-linux-aarch64-android | 83.40 MB | 83.47 MB | +64.0 KB | | bun-linux-x64-android | 85.84 MB | 85.95 MB | +112.0 KB | | bun-freebsd-x64 | 87.94 MB | 88.06 MB | +124.0 KB | | bun-freebsd-aarch64 | 91.29 MB | 91.41 MB | +128.0 KB | | **bun-windows-x64** | 82.58 MB | 83.14 MB | **+575.5 KB** | | bun-windows-aarch64 | 72.27 MB | 72.37 MB | +101.5 KB | `bun-windows-x64` is over the 0.5 MB gate, so the commit carries `[skip size check]`. Where that target's growth comes from, by the size of the published WebKit prebuilt (`.tar.gz` bytes, which are not linked bytes, but the shape is clear) at each commit of the range: | oven-sh/WebKit main at | windows-amd64-lto | step | linux-amd64-lto step | |---|---|---|---| | 65513e29 (current pin) | 646,774,059 | | | | a76e6b08 (#316: `BCRASH` is `__builtin_trap` on clang-cl) | 648,250,706 | +1.48 MB | +1.4 KB (windows-arm64: +19 KB) | | 03897bd1 (#630) | 649,000,141 | +0.75 MB | +0.31 MB | | 16a8ab73 (#635, #485) | 649,449,191 | +0.45 MB | +0.15 MB | | c775a5dc (#628) | 651,166,232 | +1.72 MB | +0.63 MB | About a third of the Windows x64 growth is #316, a crash-instruction fix that only shows on Windows x64 with LTO and that any upgrade past it brings; the rest is the new engine code (#628, #630, #635), which costs 64-144 KB on every other target. There is no Bun code in this PR to make smaller. #42383's earlier builds, on a preview of #628 alone, passed the gate. ### How did you verify your code works? Release build (`bun scripts/build.ts --profile=release --lto=off`) with the downloaded prebuilt; the same build of main next to it. - `test/bundler/bundler_bytecode_portable.test.ts`: the pinned encoder output changes on a WebKit upgrade that changes the cache format, and the file says to regenerate it then. Regenerated with this build and checked entry by entry: only the `bytes` and `sha256` of the serialized caches move (every one of them: the revision is in every header, and seven commits in the range change `runtime/CachedTypes.cpp`); the `sha256` of the printed JavaScript next to each and the string corpus are unchanged. Bundles are 0.1-0.2% smaller (`libraries.js` 22,009,472 -> 21,977,536 bytes), `vm.Script` / `vm.SourceTextModule` caches 0-1.6% larger (`typescript.js` 11,684,048 -> 11,769,312; `acorn.mjs` 257,168 -> 261,216: its function declarations are in the payload now). The cases that decode every corpus from its cache and compare the program's output, and the one that encodes in a second process and compares the bytes, pass: 22 of 22. CI runs the same snapshot on every platform, which is the point of the test. - `test/cli/inspect/compile-bytecode-tooling.test.ts`: the heap-snapshot case expected `hotWork`, a module function nobody had read, to be in the snapshot. A module's function declaration is now created when its binding is first read, so that cannot hold; the case now takes one snapshot before anything reads `hotWork` (it is absent) and one after (it is present). - New case in `compile-bytecode-tooling.test.ts`, "code dropped by Bun.shrink() is decoded again and runs the same": three rounds of `Bun.shrink()`, a tick and `Bun.gc(true)`, then a function that had run, one that had not, a class method, a generator suspended across the shrinks (its captured locals are the shape #657 fixes) and a pending async function. It asserts exact values, and that the output is identical from source, from the `--compile --bytecode` executable and from `NODE_COMPILE_CACHE` on its second run (the cache directory is checked to have been written). 5 of 5. - Without the `BunDebugger.cpp` workaround: `test/cli/inspect` 48 pass (one run had the port-collision flake of `websocket > bun --inspect=<port>`, which passed on the next), `test/js/node/inspector/inspector.test.ts` 24 of 24 (it has the script that turns breakpoints on between two top-level awaits, which is the case the workaround was for), `test/regression/issue/21654` 1 of 1; the same counts with it. - `test/cli/run/require-cache.test.ts` 18/18, `test/js/workerd/html-rewriter-leak.test.ts` 13 pass / 1 skip, `test/js/bun/jsc/heapStats-mimalloc.test.ts` 7 pass / 1 skip. - `test/js/bun/resolve` (41 files): 360 pass, 3 fail; `test/js/web/fetch/fetch.test.ts`: 361 pass, 4 fail; `test/js/bun/http/serve.test.ts`: 303 pass, 1 fail. The failures are the same ones, test for test, with the build of main on the same machine (they need a user that is not root: unreadable directories and files, a port below 1024). - No Rust changes, so there is nothing for clippy or the cross-target `cargo check` to look at; the C++ change is a deletion.
15 commits on
cf1b36ec8703. Each commit is one feature, builds on its own, and carries itstests; they are ordered by dependency and can be reviewed (and reverted) one at a time.
Why
A large bundled CLI application (ESM, ~1,800 modules in ~900 chunks, standalone executable with an embedded bytecode cache)
sits at an idle prompt with ~100 MB of anonymous memory of which JSC code structures are the largest part, and at ~170 MB
after a session. Almost all of it belongs to code that never runs or ran once:
ran at most once, 23% value-profile predictions nobody reads.
against ~111k for a re-parse; module bodies keep their linked and unlinked code although they run once.
Nothing here changes behaviour observable from JavaScript. Every feature has an option (all default on unless stated) so it can
be switched off individually.
Commits
1. A ModuleProgramExecutable keeps one module environment symbol table for its whole life
A fix for the base, found while testing this series against module loaders (#522), and the invariant the rest relies on.
sound only because every environment is made from the executable's ONE symbol table, so that the second environment
invalidates
SymbolTable::singleton()(the DFG folds the scope ofresolve_scopeclosure variables through the table in themetadata, and of imports through
topLevelExecutable->moduleEnvironmentSymbolTable()).ScriptExecutable::clearCode()cleared the table and
getUnlinkedCodeBlock()made a new one (and a new declarations vector) when it generated the codeagain. A record that had made its environment but not run yet when all code was deleted (waiting on a dependency suspended
at a top-level await) regenerates the code; the next loader adopts the executable with the new table; functions compiled
after that bake the newest loader's exporting environment into code the earlier loaders run too: an imported binding read
in loader a returns loader d's value (
JSTests/stress/module-loaders-share-one-environment-symbol-table.jsfails oncf1b36ec8703). With lazy declarations (commit 5) the same split would also hand a record executables specialised onanother record's environment, hence a
RELEASE_ASSERT(environment->symbolTable() == executable->moduleEnvironmentSymbolTable())on the lazy read path there.
its table alive anyway). Code fetched again is asked for in the code generation mode of the first (the environment's layout
depends on it);
getOrMakeExecutableonly adopts an executable whose mode is the one the record would ask for. An executablewhose code was deleted is still not adopted, and no longer sits in the clearable-code set for the sake of its table.
resolve_scopefolding,
tryGetConstantClosureVar,GetLazyClosureVar's fast case,FunctionExecutable::singleton()): all reduce to theone-table rule; details in the commit message.
2. Allocate an UnlinkedCodeBlock's value and array profiles when it first reaches the Baseline JIT
Options::useLazyUnlinkedValueAndArrayProfilesm_valueProfiles/m_arrayProfiles(two FixedVectors) become oneButterflyArray(ValueAndArrayProfiles) allocated when aBaselineJITPlanis first created for a CodeBlock of the unlinked code. The number of value profiles is derived(
numParameters + metadata.numValueProfiles), the number of array profiles is kept as a 32-bit count in existing padding.Builtins never get them. The bytecode cache no longer stores the value profile count (format revision 5 -> 6; this is the only
bump in the series, commits 3 and 5-7 change the format too and stay on 6).
and compiler threads that fold profiles (
CodeBlock::updateAll*Predictions) load it once per fold with acquire and skipfolding when it is null. Freed only in
~UnlinkedCodeBlock.3. Move UnlinkedCodeBlock's out-of-line jump targets into its RareData
An empty hash map per code block for a case few blocks have. With commit 2:
sizeof(UnlinkedCodeBlock)208 -> 192, one sizeclass down for all unlinked code blocks (
static_assertin release, 64-bit, non-Windows builds). No new RareData on thesynthetic app (902/3009 before and after).
4. Index the bytecode cache's two-character atom table by identifier character class
512 KB per VM (zeroed, so all touched) -> 32 KB: 64 x 64 classes (
$ 0-9 A-Z _ a-z); other pairs use the verifieddirect-mapped cache the three-character names use.
Commits 2-4 together, synthetic: RssAnon 184.4 -> 178.4 MB; startup instructions -0.5..-0.8%, exercise -1.0..-1.6%.
5. Instantiate module function declarations on first read
Options::useLazyModuleFunctionDeclarations(predictFunctionForUnprofiledLazyClosureVarForTestingfor tests)object and its FunctionExecutable are created when the binding is first read:
get_from_scopewith the newLazyClosureVarresolve type (LLInt, Baseline, LOL: load, test for empty, slow path; DFG
GetLazyClosureVar, FTL lowering with a slow pathcall), or
JSModuleEnvironment::readVariable()for by-name lookups, module namespace objects, WebAssembly imports and thedebugger.
ResolvedLazyClosureVaris what BytecodeGenerator emits for a module's own declarations; the linker turnsModuleVarand closure variables that are declaration slots intoLazyClosureVar. An empty slot that is not a declarationis still TDZ. The type/control-flow profilers keep the eager path.
ModuleProgramExecutableshare the declarations' FunctionExecutables(
linkedFunctionDeclaration/linkFunctionDeclarationnext tofunctionDeclaration); the record that reads a declarationfirst links it, each record fills its own environment with its own function objects. Whether a slot is a declaration slot
depends only on the module's code, so every CodeBlock of an UnlinkedCodeBlock links a given
get_from_scopethe same way.Optimized code that one loader warmed up meets empty slots when the next loader runs it:
JSTests/modules/module-loaders-lazy-function-declarations.jsdrives that through DFG/FTL code without the testing option.Graph::tryGetConstantClosureVargets no constant.GetLazyClosureVarclobberizes as a read of the slot that can firewatchpoints (
symbolTablePutTouchWatchpointSeton first instantiation) and allocate. The record's list of uninstantiateddeclarations is visited and released under
cellLock().-6.3 MB, RssAnon -7.2 MB. Synthetic (2,000 modules x 46 declarations): FunctionExecutable 154k -> 66k, heap 72.6 -> 59.1 MB,
startup instructions -6.5%.
6. LLInt get_from_scope: test for the closure variable resolve types first
Site mix at the prompt of the CLI application: ClosureVar 54.8%, LazyClosureVar 34.4%, GlobalProperty 9.8%, GlobalVar 1.0%.
Three compares fewer per closure variable read, two more per global one; pays for the empty check of commit 5.
7. Leave a module's uninstantiated function declarations in the bytecode cache payload
With commit 5, a module decoded from a payload that stays around does not create the UnlinkedFunctionExecutables of
declarations nobody read:
m_functionDecls[i]stays null,ModuleFunctionDeclarationSlotsremembers the Decoder and the recordarray,
UnlinkedCodeBlock::functionDecl()decodes on first request (mutator only; other threads usefunctionDeclIfDecoded()). A never-read module function: 256 B of cells -> an 8-byte empty slot + a 4-byte table entry.--helpof the CLI application: 505 M -> 470 M user instructions.8. jsc shell: ASAN builds keep locals on the real stack
detect_stack_use_after_return=0as the shell's default ASAN option: the fake stack is not scanned conservatively, so everymulti-module test died under
--collectContinuously/--slowPathAllocsBetweenGCsin ASAN builds.9. Call sites in LLInt / Baseline metadata get their CallLinkInfo and ArrayProfile on their second execution
Options::useLazyLLIntCallLinkInfosCallSiteData { DataOnlyCallLinkInfo, ArrayProfile }(96 B) allocated on the site's second execution; until then it points at one of two per-VM shared records ("never" /
"once") that look like a polymorphic call to the new
llint_unlinked_callthunk, so the LLInt fast path is the old one plusone load and no branch.
sizeof(Metadata): op_call / call_ignore_result / tail_call 96 -> 8, construct 80 -> 8, super_construct88 -> 16, iterator_open 120 -> 48, iterator_next 136 -> 64.
is fully initialized before a store-store fence publishes it and lives as long as the MetadataTable. Baseline code never
meets a shared record (
setupWithUnlinkedBaselineCodeallocates all of them first). Compiler threads and the collector gothrough
forEachLLIntOrBaselineCallLinkInfo()/getArrayProfile(), which skip sites without their own record ("noinformation").
10. Keep the predictions of a MetadataTable's value profiles out of line, and only for code that has warmed up
Options::useLazyValueProfilePredictions,thresholdForValueProfilePredictions(40)LinkingData, allocated by the firstmergePrediction()with something to record. A still-interpreted CodeBlock below the threshold keeps samples in its buckets: GCend only clears buckets whose cell died.
readers without an array see SpecNone.
11. op_get_from_scope does not need the global variable's watchpoint set in its metadata
24 -> 16 bytes; the DFG parser finds the set in the symbol table entry under the table's lock. Field names kept.
Commits 9-11, synthetic (31.8k interpreter-only blocks): metadata 28.2 -> 15.8 MB (+0.2 out of line), 887 -> 496 B per block,
RssAnon at startup 127.2 -> 113.8 MB. Per call site: never run -73, first run +48, second run +445 instructions.
12. VMInspector::codeBlockCensus and $vm.codeBlockCensus()
Counts used by the tests of commits 13-14 (and by embedders that want to see where code memory goes).
13. Code decoded from a persistent bytecode cache can be dropped and decoded again
Options::useCodeRecoveryFromBytecodeCachePersistentBytecodePayloads) and record offset (32 bits), both in existing padding (sizeofunchanged).UnlinkedFunctionExecutable::returnCodeToCache()puts an executable back into itsm_isCachedstate.VM::shrinkFootprintNow(flags)/shrinkFootprintWhenIdle:KeepCodeThatNeedsParsing,KeepCodeInUse,LeaveCollectionToCaller;Heap::deleteAllUnlinkedCodeBlockstakes which kinds to drop.VM::entryCountFromOutside()andHeap::lastActiveCollectionTime()let the embedder decide when the program is at rest.weakly under the parent's record offset and adopted by the block decoded from that record later, so closures made before and
after a drop share code.
PersistentBytecodePayloadsis one tree of unlinked code = the payload's bytes as decoded forone SourceProvider (embedders wrap the same bytes in a new CachedBytecode + SourceProvider per load). Nothing remembered under one
slot is handed to code decoded under another; code private to one executable (a module whose loader has its own module
scope) is not registered, since its Baseline code assumes one resolution of that scope. Every Decoder and every code block of
a slot hold it (
retain/release,~UnlinkedCodeBlock,~Decoder); with the last one the payload/provider references go and theindex is reused: reloading one file 50 times leaves 3 slots, not 52.
shrinkFootprintNowreturns false (nothing done) under JS or from inside the collector; the Keep modes wait for arunning collection, the flagless mode returns false instead;
lastExceptionis cleared (its stack kept dropped code alive twice);VM::deleteAllCode(flagless) now also deletes what a cache can hand back (heap after shrink + GC 5.4 MB instead of 31.7 MB on asynthetic application). A CodeCache entry decoded from a payload is committed and dropped in every mode: a provider that has
the payload decodes again, one with equal source text but no payload parses.
Heap::deleteAllUnlinkedCodeBlockscompletes the compiler threads' ready plans(that allocates) BEFORE its
HeapIterationScopeand underDeferGC, then re-asserts that no collection runs, so nothing markswhile
returnCodeToCacheturns an executable's two code block slots into {Decoder, offsets}; both directions publish withm_isCachedin the middle (fences), andvisitChildrenreads flag, slots, flag.OnlyWithoutLinkedCode(restricts therecoverable kind) skips blocks anything links against; otherwise all plans are completed first, so no compiler thread holds a
block that is dropped.
Heap::lastActiveCollectionTime()is atomic (zero until the first collection that saw the mutator busy).Lean decoder only.
33 -> 23 MB.
14. Module and program code that has run is released right away
Options::useRunOnceCodeRelease;useSharedModuleFunctionExpressionExecutables(default off)JSModuleRecord::evaluatesees the body finished, the executable drops its linked code, and its unlinked code andCodeCache entry if they can be decoded again; the environment symbol table and the declarations' executables stay.
Interpreter::executeProgramclears the ProgramExecutable it created.one (covers a loader suspended at a top-level await while another finishes). A later loader adopts an executable that only
released recoverable code and has it decoded again (the symbol table and
m_functionDeclarationsare the executable's forlife, commit 1;
ClearCode::Allwithdraws a released executable from adoption). With commit 5/7 the module record no longer referencesreleasable unlinked code for the sake of unread declarations (it decodes them from the payload).
(
GlobalExecutable::canReleaseLinkedCodeNow).extra memory 11.8 -> 1.5 MB, startup instructions -4.4%.
15. Heap: live size after the last collection and total bytes allocated, for embedders
Heap::sizeAfterLastCollection()andHeap::totalBytesAllocated()(running total kept inupdateAllocationLimits()right beforethe per-cycle counters are reset; mutator thread only). For an embedder's idle detection: a busy program whose heap does not grow
still allocates.
Not in this PR: dropping cold LLInt CodeBlocks in any collection and block sealing were written and measured; neither moved
resident memory on the application, both were off by default, so they were left out.
Numbers on the CLI application (RssAnon MB, RssFile 46-51 MB throughout; two to three runs each; rows 1-4 were measured with the series on the previous base
dfd696443b, row 5 on this branch; runs of one round are comparable, rounds differ by up to ~8 MB)shrinkFootprintWhenIdleat deep idle)cf1b36ec8703(same-run baseline 124-127 / 105-106 / 173 / 163-169)CPU (instruction counts; wall clock on the measuring box is noise):
--help, user instructions (like-for-like builds on the previous base)--help, this branch, same binary with every option of the series off / onuseConcurrentJIT=0)Tests
New:
JSTests/modules/lazy-function-declarations*.js(6, run under 32 option sets: tiers, eager thresholds, no-cjit validation,collectContinuously, bytecode cache fill/hit incl. persistent payload),
module-loaders-lazy-function-declarations.js;JSTests/stress/bytecode-cache-unlinked-value-and-array-profiles.js,llint-lazy-call-link-info{,-async,-relink}.js,value-profile-predictions-{on-demand,after-cold-collection}.js,get-from-scope-global-variable-watchpoint-lookup.js,shrink-footprint-recovers-code-from-bytecode-cache.js,module-code-released-after-evaluation.js,module-function-expression-executables-shared.js,module-lazy-function-declarations-outlive-released-code.js,module-loaders-share-released-code.js,module-loaders-share-one-environment-symbol-table.js,shrink-footprint-while-compilations-are-ready.js,shrink-footprint-decodes-code-again-repeatedly.js(also with--destroy-vm),bytecode-cache-persistent-payloads-are-released.js.Results on this branch, against a base list taken with
jscbuilt fromcf1b36ec8703itself (release, and Debug+ASANwhere noted); every difference from base was re-run on both binaries:
cf1b36ec8703)jsc) and passes the tests it adds or changes, at that commitJSTests/modules(122 files), default and no-cjit-validateJSTests/stressx {default, no-cjit-validate, no-JIT, collectContinuously, low thresholds, eager jettison, no concurrent JIT}module-loaders-share-one-environment-symbol-table.js, which fails on the base because of the bug commit 1 fixes); the only others are three tests that flip between runs on both binaries (recursive-try-catch.js,int8-repeat-in-then-out-of-bounds.js,codeblock-aging-ftl-idle.js)bytecode-cache-*.jsand the new cache tests, all their option variantsJSTests/modules, plain and with a persistent payloadmodule-loaders-changed-dependency.js, which writes new source files on every run and so cannot pass a forced cache hit on either binarySeen while testing, not caused by this series (reproduces on the base with no shrink):
ASSERTION FAILED: addResult.isNewEntryinCachedBytecode::copyLeafExecutableson the cache-filling run with--useJIT=0 --forceCodeBlockToJettisonDueToOldAge=1when generatedunlinked code is regenerated after a collection (stale raw-pointer keys in
m_leafExecutables).LowLevelInterpreter32_64.asmis not updated for commits 5 and 9-11 (no 32-bit target is built from this repository).