Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 61a88753e9e4600b0c4f945f675f4435eec0823a
      
https://github.com/WebKit/WebKit/commit/61a88753e9e4600b0c4f945f675f4435eec0823a
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-04-27 (Mon, 27 Apr 2026)

  Changed paths:
    M Source/JavaScriptCore/builtins/BuiltinNames.h
    M Source/JavaScriptCore/bytecode/LinkTimeConstant.h
    M Source/JavaScriptCore/heap/Heap.h
    M Source/JavaScriptCore/interpreter/Interpreter.cpp
    M Source/JavaScriptCore/runtime/JSAsyncGenerator.cpp
    M Source/JavaScriptCore/runtime/JSCast.h
    M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
    M Source/JavaScriptCore/runtime/JSGlobalObject.h
    M Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h
    M Source/JavaScriptCore/runtime/JSMicrotask.cpp
    M Source/JavaScriptCore/runtime/JSPromise.cpp
    M Source/JavaScriptCore/runtime/JSPromiseReaction.cpp
    M Source/JavaScriptCore/runtime/JSPromiseReaction.h
    M Source/JavaScriptCore/runtime/JSType.cpp
    M Source/JavaScriptCore/runtime/JSType.h
    M Source/JavaScriptCore/runtime/Microtask.h
    M Source/JavaScriptCore/runtime/VM.cpp
    M Source/JavaScriptCore/runtime/VM.h

  Log Message:
  -----------
  [JSC] Add JSFullPromiseReaction and JSSlimPromiseReaction
https://bugs.webkit.org/show_bug.cgi?id=313302
rdar://175578451

Reviewed by Yijia Huang.

JSPromiseReaction was full featured, but it is too large for very common
`promise.then(...)` call case.

1. it does not offer context
2. it typically only offers one handler (fulfill / reject)

By using this characteristics, we can optimize them further. This patch
introduces JSFullPromiseReaction and JSSlimPromiseReaction.
JSFullPromiseReaction is basically what JSPromiseReaction was before.

JSSlimPromiseReaction removes the above two fields, making its
size 32 bytes. Whether single handler is for fulfill / reject is
recorded as perCellBit.

And for m_next field, we start embedding InternalMicrotask code by using
compact pointer. This allows us to use JSSlimPromiseReaction for
InternalMicrotask + context reaction too. As a result, we use
JSFullPromiseReaction only when we pass fulfill / reject handlers.

* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/bytecode/LinkTimeConstant.h:
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/interpreter/Interpreter.cpp:
(JSC::Interpreter::getAsyncStackTrace):
* Source/JavaScriptCore/runtime/JSAsyncGenerator.cpp:
(JSC::JSAsyncGenerator::enqueue):
* Source/JavaScriptCore/runtime/JSCast.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
* Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h:
(JSC::JSGlobalObject::promiseProtoThenFunction const):
(JSC::JSGlobalObject::promiseEmptyOnFulfilledFunction const): Deleted.
(JSC::JSGlobalObject::promiseEmptyOnRejectedFunction const): Deleted.
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::promiseResolveWithoutHandlerJobSlow):
(JSC::promiseResolveWithoutHandlerJob):
(JSC::runInternalMicrotask):
* Source/JavaScriptCore/runtime/JSPromise.cpp:
(JSC::JSPromise::performPromiseThen):
(JSC::JSPromise::performPromiseThenWithInternalMicrotask):
(JSC::JSPromise::triggerPromiseReactions):
* Source/JavaScriptCore/runtime/JSPromiseReaction.cpp:
(JSC::JSPromiseReaction::visitChildrenImpl):
(JSC::JSPromiseReaction::tryGetContext):
(JSC::JSSlimPromiseReaction::create):
(JSC::JSSlimPromiseReaction::visitChildrenImpl):
(JSC::JSSlimPromiseReaction::createStructure):
(JSC::JSFullPromiseReaction::create):
(JSC::JSFullPromiseReaction::visitChildrenImpl):
(JSC::JSFullPromiseReaction::createStructure):
(JSC::JSPromiseReaction::create): Deleted.
(JSC::JSPromiseReaction::createStructure): Deleted.
* Source/JavaScriptCore/runtime/JSPromiseReaction.h:
(JSC::JSPromiseReaction::promise const):
(JSC::JSPromiseReaction::internalMicrotask const):
(JSC::JSPromiseReaction::setPromise):
(JSC::JSPromiseReaction::setNext):
(JSC::JSPromiseReaction::JSPromiseReaction):
* Source/JavaScriptCore/runtime/JSType.cpp:
(WTF::printInternal):
* Source/JavaScriptCore/runtime/JSType.h:
* Source/JavaScriptCore/runtime/Microtask.h:
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::visitAggregateImpl):
* Source/JavaScriptCore/runtime/VM.h:

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



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

Reply via email to