Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3b78627af7fadf9e392d0eb8a7bcdfa96e01a20d
https://github.com/WebKit/WebKit/commit/3b78627af7fadf9e392d0eb8a7bcdfa96e01a20d
Author: Mark Lam <[email protected]>
Date: 2023-03-06 (Mon, 06 Mar 2023)
Changed paths:
A JSTests/microbenchmarks/cpp-to-js-cached-call.js
A JSTests/microbenchmarks/cpp-to-js-call-as-first-entry.js
M Source/JavaScriptCore/dfg/DFGOSREntry.cpp
M Source/JavaScriptCore/jit/JITOperations.cpp
M Source/JavaScriptCore/runtime/JSDateMath.h
M Source/JavaScriptCore/runtime/VM.cpp
M Source/JavaScriptCore/runtime/VM.h
M Source/JavaScriptCore/runtime/VMEntryScope.cpp
M Source/JavaScriptCore/runtime/VMTraps.cpp
M Source/JavaScriptCore/runtime/VMTrapsInlines.h
M Source/JavaScriptCore/tools/JSDollarVM.cpp
Log Message:
-----------
Reduce unnecessary work in VMEntryScope to speed up first VM entry.
https://bugs.webkit.org/show_bug.cgi?id=253412
rdar://106258354
Reviewed by Yusuke Suzuki.
1. VMEntryScope entry and exit current check for the need to do a lot of work
that are usually not needed.
Instead of doing all these checks, we introduce a new VM::EntryScopeService
concept where if one of
these checks are needed, their sources will request an EntryScopeService.
With this, the VMEntryScope
will only check if any such services have been requested (with a single
bitfield), and can will only
incur the cost of the check if at least one such services have been
requested.
The only exception to using these service requests is the resetting of the
VM DateCache. That is
dependent on a global lastTimeZoneID because there is one DateCache per VM,
and there can be multiple
VMs. Hence, lastTimeZoneID needs to be updated in an atomic way. We also
don't want the EntryScope
service request to require a lock of any sort, nor have to deal with
iterating all VMs to request a
DateCache reset. So, we'll just do a hasTimeZoneChange() check instead in
addition to the service
request check on entry.
2. Moved the servicing of the "EntryScopeService"s out to
VM::executeEntryScopeServicesOnEntry() and
VM::executeEntryScopeServicesOnExit() instead of keeping them inlined in
VMEntryScope.
This appears to have improved the microbenchmark result by ~2-4%. Might be
due to improved cache
locality from moving the rare case out.
3. Rename VM::m_terminationInProgress to VM::m_hasTerminationRequest to better
describe what it represents.
I wrote this code, and I found even myself confused by it. So, I'm renaming
it for clarity, and
updating the comment about its treatment on VM exit for added clarity as
well.
4. Added cpp-to-js-cached-call.js and cpp-to-js-call-as-first-entry.js
microbenchmarks which tests
repeated calls using CachedCall, and repeated calls at the first entry
boundary.
The microbenchmark results are all follows, As expected, only first entry is
improved by this change.
base new
cpp-to-js-call-as-first-entry 96.8583+-0.1895 ^
75.9927+-0.6285 ^ definitely 1.2746x faster
cpp-to-js-call 69.6459+-0.1565
69.5432+-0.0586
cpp-to-js-cached-call 79.8228+-0.5376 ?
80.4139+-0.6115 ?
* JSTests/microbenchmarks/cpp-to-js-cached-call.js: Added.
(test):
* JSTests/microbenchmarks/cpp-to-js-call-as-first-entry.js: Added.
(test):
* Source/JavaScriptCore/jit/JITOperations.cpp:
(JSC::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/runtime/JSDateMath.h:
(JSC::DateCache::hasTimeZoneChange):
(JSC::DateCache::resetIfNecessary):
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::primitiveGigacageDisabled):
(JSC::VM::ensureWatchdog):
(JSC::VM::ensureSamplingProfiler):
(JSC::VM::whenIdle):
(JSC::VM::setException):
(JSC::VM::throwTerminationException):
(JSC::VM::assertScratchBuffersAreEmpty):
(JSC::VM::executeEntryScopeServicesOnEntry):
(JSC::VM::executeEntryScopeServicesOnExit):
(JSC::VM::clearScratchBuffers): Deleted.
* Source/JavaScriptCore/runtime/VM.h:
(JSC::VM::hasTerminationRequest const):
(JSC::VM::clearHasTerminationRequest):
(JSC::VM::setHasTerminationRequest):
(JSC::VM::hasAnyEntryScopeServiceRequest):
(JSC::VM::isValidEntryScopeService):
(JSC::VM::hasEntryScopeServiceRequest):
(JSC::VM::clearEntryScopeService):
(JSC::VM::requestEntryScopeService):
(JSC::VM::hasTimeZoneChange):
(JSC::VM::notifyNeedTermination):
(JSC::VM::terminationInProgress const): Deleted.
(JSC::VM::setTerminationInProgress): Deleted.
(JSC::VM::firePrimitiveGigacageEnabledIfNecessary): Deleted.
(JSC::VM::invokeDidPopListeners): Deleted.
(JSC::VM::resetDateCacheIfNecessary): Deleted.
* Source/JavaScriptCore/runtime/VMEntryScope.cpp:
(JSC::VMEntryScope::setUpSlow):
(JSC::VMEntryScope::tearDownSlow):
* Source/JavaScriptCore/runtime/VMTraps.cpp:
(JSC::VMTraps::handleTraps):
(JSC::VMTraps::deferTerminationSlow):
(JSC::VMTraps::undoDeferTerminationSlow):
* Source/JavaScriptCore/runtime/VMTrapsInlines.h:
(JSC::VMTraps::undoDeferTermination):
* Source/JavaScriptCore/tools/JSDollarVM.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSDollarVM::finishCreation):
Canonical link: https://commits.webkit.org/261260@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes