Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3a8fc98f2190516aebf47e9bee7bb7609af8a4f5
      
https://github.com/WebKit/WebKit/commit/3a8fc98f2190516aebf47e9bee7bb7609af8a4f5
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-07-20 (Mon, 20 Jul 2026)

  Changed paths:
    A JSTests/microbenchmarks/for-await-of-array.js
    A JSTests/microbenchmarks/for-await-of-generic-iterable.js
    A JSTests/microbenchmarks/for-await-of-map.js
    A JSTests/microbenchmarks/for-await-of-promise-elements.js
    A JSTests/microbenchmarks/for-await-of-set.js
    A JSTests/stress/async-from-sync-fast-consumer-species-tamper-during.js
    A JSTests/stress/async-from-sync-fast-path-primordial-guard.js
    A JSTests/stress/async-from-sync-generic-next-getter-throws.js
    A JSTests/stress/async-from-sync-generic-next-memoized.js
    A JSTests/stress/async-from-sync-generic-next-read-once.js
    A JSTests/stress/async-from-sync-open-speculation-deopt.js
    A JSTests/stress/async-from-sync-throw-closes-and-rejects.js
    M JSTests/stress/async-generator-assertion.js
    A JSTests/stress/async-iterator-fast-consumer-cross-realm.js
    A JSTests/stress/async-iterator-fast-consumer-species-tamper-before-open.js
    A JSTests/stress/string-iterator-as-iterable.js
    M Source/JavaScriptCore/CMakeLists.txt
    M Source/JavaScriptCore/DerivedSources-input.xcfilelist
    M Source/JavaScriptCore/DerivedSources-output.xcfilelist
    M Source/JavaScriptCore/DerivedSources.make
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M Source/JavaScriptCore/builtins/ArrayConstructor.js
    R Source/JavaScriptCore/builtins/AsyncFromSyncIteratorPrototype.js
    M Source/JavaScriptCore/builtins/BuiltinNames.h
    M Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp
    M Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h
    M Source/JavaScriptCore/bytecode/IterationModeMetadata.h
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
    M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
    M Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
    M Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
    M Source/JavaScriptCore/dfg/DFGClobberize.h
    M Source/JavaScriptCore/dfg/DFGDoesGC.cpp
    M Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
    M Source/JavaScriptCore/dfg/DFGMayExit.cpp
    M Source/JavaScriptCore/dfg/DFGNodeType.h
    M Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.cpp
    M Source/JavaScriptCore/dfg/DFGOperations.h
    M Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
    M Source/JavaScriptCore/dfg/DFGSafeToExecute.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
    M Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
    M Source/JavaScriptCore/ftl/FTLCapabilities.cpp
    M Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
    M Source/JavaScriptCore/ftl/FTLOperations.cpp
    M Source/JavaScriptCore/jit/JITOperations.cpp
    M Source/JavaScriptCore/jit/JITOperations.h
    M Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
    M Source/JavaScriptCore/runtime/AsyncFromSyncIteratorPrototype.cpp
    M Source/JavaScriptCore/runtime/AsyncFromSyncIteratorPrototype.h
    M Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
    M Source/JavaScriptCore/runtime/Intrinsic.h
    M Source/JavaScriptCore/runtime/IteratorOperations.cpp
    M Source/JavaScriptCore/runtime/IteratorOperations.h
    M Source/JavaScriptCore/runtime/JSAsyncFromSyncIterator.cpp
    M Source/JavaScriptCore/runtime/JSAsyncFromSyncIterator.h
    M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
    M Source/JavaScriptCore/runtime/JSGlobalObject.h
    M Source/JavaScriptCore/runtime/JSMicrotask.cpp

  Log Message:
  -----------
  [JSC] Make AsyncFromSyncIterator handled in async_iterator_open / 
async_iterator_next
rdar://182251956
https://bugs.webkit.org/show_bug.cgi?id=319435

Reviewed by Yijia Huang.

This patch adds cooperative driving mechanism to AsyncFromSyncIterator.
This also moves all of functions of AsyncFromSyncIterator from builtin
JS to C++.

1. JSAsyncFromSyncIterator is now more complicated JS object. Since this
   is not observable to users, its currently-on-the-fly promise from
   `next()` etc., is only one! This means that we can do something
   similar to JSAsyncGenerator: having a current on-the-fly promise in
   JSAsyncFromSyncIterator and avoiding creating a new context each time.
   Furthermore, because JSAsyncFromSyncIterator's on-the-fly promise is
   only one at a time, we can have one slot in JSAsyncFromSyncIterator
   instead of a queue.
2. We add similar mechanism to JSAsyncGenerator's cooperative driving.
3. We move all of AsyncFromSyncIterator implementation from builtin JS
   to C++.

All microbenchmarks are neutral: we moved all of them to C++ and we
added fast path in C++, so still maintaining efficiency of builtin JS's
inlined ones.

Tests: JSTests/microbenchmarks/for-await-of-array.js
       JSTests/microbenchmarks/for-await-of-generic-iterable.js
       JSTests/microbenchmarks/for-await-of-map.js
       JSTests/microbenchmarks/for-await-of-promise-elements.js
       JSTests/microbenchmarks/for-await-of-set.js
       JSTests/stress/async-from-sync-fast-consumer-species-tamper-during.js
       JSTests/stress/async-from-sync-fast-path-primordial-guard.js
       JSTests/stress/async-from-sync-generic-next-getter-throws.js
       JSTests/stress/async-from-sync-generic-next-memoized.js
       JSTests/stress/async-from-sync-generic-next-read-once.js
       JSTests/stress/async-from-sync-open-speculation-deopt.js
       JSTests/stress/async-from-sync-throw-closes-and-rejects.js
       JSTests/stress/async-iterator-fast-consumer-cross-realm.js
       JSTests/stress/async-iterator-fast-consumer-species-tamper-before-open.js
       JSTests/stress/string-iterator-as-iterable.js

* JSTests/microbenchmarks/for-await-of-array.js: Added.
(async values):
(async keys):
(async entries):
* JSTests/microbenchmarks/for-await-of-generic-iterable.js: Added.
(makeIterable):
(async run):
* JSTests/microbenchmarks/for-await-of-map.js: Added.
(async entries):
(async keys):
(async values):
* JSTests/microbenchmarks/for-await-of-promise-elements.js: Added.
(async run):
* JSTests/microbenchmarks/for-await-of-set.js: Added.
* JSTests/stress/async-from-sync-fast-consumer-species-tamper-during.js: Added.
(assert):
(armReadCounter):
(get restoreCtor):
(async asyncFromSyncTamperDuring):
(async main):
* JSTests/stress/async-from-sync-fast-path-primordial-guard.js: Added.
(assert):
(async pristine.set s):
(async pristine):
(async customOwnIterator.arr.Symbol.iterator):
(async customOwnIterator):
(async main):
* JSTests/stress/async-from-sync-generic-next-getter-throws.js: Added.
(assert):
(makeThrowingIterable.const.iterable.Symbol.iterator.return.get next):
(makeThrowingIterable):
(async run):
(async main):
(main.then):
* JSTests/stress/async-from-sync-generic-next-memoized.js: Added.
(assert):
(makeIterable.return.replaceNext.iterator.next):
(makeIterable):
(async run):
(async main):
(main.then):
* JSTests/stress/async-from-sync-generic-next-read-once.js: Added.
(assert):
(makeIterable.const.iterable.Symbol.iterator.return.get next):
(makeIterable):
(async run):
(async main):
(main.then):
* JSTests/stress/async-from-sync-open-speculation-deopt.js: Added.
(assert):
(syncIterable):
(asyncIterable):
(async driveGenericFirst):
(async driveAsyncFromSyncFirst):
(async main):
* JSTests/stress/async-from-sync-throw-closes-and-rejects.js: Added.
(assert):
(async throwInto.async wrapper):
(async throwInto):
(async runCases):
(async main):
* JSTests/stress/async-generator-assertion.js:
* JSTests/stress/async-iterator-fast-consumer-cross-realm.js: Added.
(assert):
(thenableRealmProbe.record):
(const.makeThenableGen.new.thenableRealmProbe.Function.return.async yield):
(const.makeThenableGen.new.thenableRealmProbe.Function.return):
(async main):
(async yield):
(mainConsumedInForeign.makeMainGen):
* JSTests/stress/async-iterator-fast-consumer-species-tamper-before-open.js: 
Added.
(assert):
(armReadCounter):
(get restoreCtor):
(async asyncGeneratorTamperBefore.async g):
(async asyncGeneratorTamperBefore):
(async asyncFromSyncTamperBefore):
(async main):
* JSTests/stress/string-iterator-as-iterable.js: Added.
(assert):
(forOfStringIterator):
(spreadStringIterator):
(arrayFromStringIterator):
(partiallyConsumed):
(async asyncDriver):
(asyncDriver.then):
* Source/JavaScriptCore/CMakeLists.txt:
* Source/JavaScriptCore/DerivedSources-input.xcfilelist:
* Source/JavaScriptCore/DerivedSources-output.xcfilelist:
* Source/JavaScriptCore/DerivedSources.make:
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/builtins/ArrayConstructor.js:
(fromAsync):
* Source/JavaScriptCore/builtins/AsyncFromSyncIteratorPrototype.js: Removed.
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h:
* Source/JavaScriptCore/bytecode/IterationModeMetadata.h:
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitEnumeration):
(JSC::BytecodeGenerator::emitGetAsyncIterator):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::emitIsDerivedArray):
(JSC::BytecodeGenerator::emitIsAsyncFromSyncIterator): Deleted.
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::asyncFromSyncIteratorInternalFieldIndex): Deleted.
(JSC::BytecodeIntrinsicNode::emit_intrinsic_getAsyncFromSyncIteratorInternalField):
 Deleted.
* Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleIntrinsicCall):
(JSC::DFG::ByteCodeParser::handleAsyncIteratorOpen):
* Source/JavaScriptCore/dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* Source/JavaScriptCore/dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* Source/JavaScriptCore/dfg/DFGMayExit.cpp:
* Source/JavaScriptCore/dfg/DFGNodeType.h:
* Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp:
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/dfg/DFGOperations.h:
* Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:
* Source/JavaScriptCore/dfg/DFGSafeToExecute.h:
(JSC::DFG::safeToExecute):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* Source/JavaScriptCore/ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileOpenAsyncFromSyncIterator):
(JSC::FTL::DFG::LowerDFGToB3::compileNewInternalFieldObject):
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
* Source/JavaScriptCore/ftl/FTLOperations.cpp:
(JSC::FTL::JSC_DEFINE_NOEXCEPT_JIT_OPERATION):
* Source/JavaScriptCore/jit/JITOperations.cpp:
* Source/JavaScriptCore/jit/JITOperations.h:
* Source/JavaScriptCore/llint/LLIntSlowPaths.cpp:
* Source/JavaScriptCore/runtime/AsyncFromSyncIteratorPrototype.cpp:
(JSC::AsyncFromSyncIteratorPrototype::finishCreation):
(JSC::AsyncFromSyncIteratorPrototype::create):
(JSC::awaitAndContinue):
(JSC::callSyncIteratorMethodAndExtract):
(JSC::driveFastSyncIterator):
(JSC::driveSyncIterator):
(JSC::asyncFromSyncIteratorNext):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::driveAsyncFromSyncIteratorWithDriver):
* Source/JavaScriptCore/runtime/AsyncFromSyncIteratorPrototype.h:
* Source/JavaScriptCore/runtime/CommonSlowPaths.cpp:
(JSC::iteratorOpenTryFastImpl):
(JSC::asyncIteratorOpenTryFastImpl):
* Source/JavaScriptCore/runtime/Intrinsic.h:
* Source/JavaScriptCore/runtime/IteratorOperations.cpp:
(JSC::createAsyncFromSyncIterator):
(JSC::fastSyncIteratorForIterable):
(JSC::createAsyncFromSyncIteratorForIterable):
(JSC::createAsyncFromSyncIteratorRecord):
(JSC::getAsyncIteratorImpl):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/IteratorOperations.h:
* Source/JavaScriptCore/runtime/JSAsyncFromSyncIterator.cpp:
(JSC::JSAsyncFromSyncIterator::create):
(JSC::JSAsyncFromSyncIterator::visitChildrenImpl):
(JSC::JSAsyncFromSyncIterator::finishCreation): Deleted.
(JSC::JSAsyncFromSyncIterator::createWithInitialValues): Deleted.
(JSC::JSC_DEFINE_HOST_FUNCTION): Deleted.
* Source/JavaScriptCore/runtime/JSAsyncFromSyncIterator.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildrenImpl):
* Source/JavaScriptCore/runtime/JSGlobalObject.h:
* Source/JavaScriptCore/runtime/JSMicrotask.cpp:
(JSC::asyncFromSyncIteratorContinueOrDone):
(JSC::asyncGeneratorCompleteStep):
(JSC::asyncIteratorNextWithDriver):
(JSC::runInternalMicrotask):

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



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

Reply via email to