Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ee4b2082674de598acc8179672ec2d833fdab266
      
https://github.com/WebKit/WebKit/commit/ee4b2082674de598acc8179672ec2d833fdab266
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-08-17 (Mon, 17 Aug 2026)

  Changed paths:
    A JSTests/stress/generator-and-async-body-without-parameters-hoisting.js
    M Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
    M Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
    M Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
    M Source/JavaScriptCore/runtime/CodeCache.cpp

  Log Message:
  -----------
  [JSC] Do not allocate `UnlinkedFunctionExecutable::RareData` for 
generator/async bodies whose wrapper has no parameters
https://bugs.webkit.org/show_bug.cgi?id=321845

Reviewed by Yusuke Suzuki.

When compiling a generator or async function wrapper, 
BytecodeGenerator::makeFunction() passes the
wrapper's parameter names to the body's UnlinkedFunctionExecutable so that the 
body does not create
locals shadowing them. The names were passed as 
std::optional<Vector<Identifier>>, and the optional
was engaged even when the wrapper had no parameters, so the constructor 
allocated a 64-byte RareData
just to hold an empty FixedVector. Every executed `async () => { await ... }`,
`async function f() {}` with await, or `function* g() {}` paid for it.

The only consumers call contains() on the list, so an empty list is 
indistinguishable from no list.
Pass a plain Vector<Identifier> and only touch RareData when it is non-empty; 
the two consumers in
BytecodeGenerator now treat a null list as empty instead of asserting it is 
present.

Measured with 100k parameterless async functions each executed once: process 
footprint drops by
~6.4 MB (64 bytes per function). No change for bodies whose wrapper has 
parameters.

Test: JSTests/stress/generator-and-async-body-without-parameters-hoisting.js

* JSTests/stress/generator-and-async-body-without-parameters-hoisting.js: Added.
(shouldBe):
(generatorNoParams.a):
(generatorNoParams):
(a):
(generatorWithParams):
(async asyncNoParams.a):
(async asyncNoParams):
(async asyncWithParams):
(asyncArrowNoParams.async a):
* Source/JavaScriptCore/builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
* Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h:
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::hoistSloppyModeFunctionIfNecessary):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::makeFunction):
* Source/JavaScriptCore/runtime/CodeCache.cpp:
(JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):

Canonical link: https://commits.webkit.org/319283@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to