Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1a501dce9fa2e730808e6a4712a0ab4fb30e3302
      
https://github.com/WebKit/WebKit/commit/1a501dce9fa2e730808e6a4712a0ab4fb30e3302
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-06-15 (Thu, 15 Jun 2023)

  Changed paths:
    M Source/JavaScriptCore/heap/IncrementalSweeper.cpp
    M Source/JavaScriptCore/heap/IncrementalSweeper.h
    M Source/JavaScriptCore/runtime/DeferredWorkTimer.cpp
    M Source/JavaScriptCore/runtime/DeferredWorkTimer.h
    M Source/JavaScriptCore/runtime/VM.cpp
    M Source/JavaScriptCore/runtime/VM.h
    M Source/WebCore/page/Page.cpp

  Log Message:
  -----------
  Add a way to run incremental GC sweeps during runloop idle time in between 
rendering updates
https://bugs.webkit.org/show_bug.cgi?id=257622
rdar://110076652

Reviewed by Mark Lam.

Add a new (privately-exposed) hook on `VM`, which enables JavaScriptCore to 
perform periodically-
scheduled work (for now, just limited to incremental sweeping) when the runloop 
enters idle state,
in between rendering updates. When combined with <https://webkit.org/b/258032>, 
this will allow us
to move a significant chunk of our incremental sweeping into time intervals 
when the runloop has
entered idle state, and we're still waiting for the next rendering update to 
arrive.

* Source/JavaScriptCore/heap/IncrementalSweeper.cpp:
(JSC::IncrementalSweeper::doWorkUntil):
(JSC::IncrementalSweeper::doWork):
(JSC::IncrementalSweeper::doSweep):

Refactor this method, such that it may be called from either the periodic 100 
ms timer, or the
opportunistic task hook from VM. In the case of the latter, we avoid eagerly 
shrinking or freeing
`MarkedBlock`s that have been swept, in order to mitigate the potential for 
unnecessarily shrinking
the heap capacity by freeing marked blocks more often, only to grow it again 
immediately thereafter.

(JSC::IncrementalSweeper::sweepNextBlock):
* Source/JavaScriptCore/heap/IncrementalSweeper.h:
* Source/JavaScriptCore/runtime/DeferredWorkTimer.cpp:
(JSC::DeferredWorkTimer::hasAnyPendingWork const):

Add a helper method to return whether the `DeferredWorkTimer` has any scheduled 
tasks. If so, we
avoid performing any opportunistically scheduled cleanup; this prevents us from 
scheduling
opportunistic tasks right as a WASM module is being compiled, and thus block it 
from running right
away.

* Source/JavaScriptCore/runtime/DeferredWorkTimer.h:
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::performOpportunisticallyScheduledTasks):

See above for more details.

* Source/JavaScriptCore/runtime/VM.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::performOpportunisticallyScheduledTasks):

Adopt the new `VM` hook.

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to