Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: ccf0be33dc3b2f7d60c4cde045955933012e8101 https://github.com/WebKit/WebKit/commit/ccf0be33dc3b2f7d60c4cde045955933012e8101 Author: Mark Lam <mark....@apple.com> Date: 2025-08-19 (Tue, 19 Aug 2025)
Changed paths: M Source/JavaScriptCore/CMakeLists.txt M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj M Source/JavaScriptCore/Sources.txt M Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.cpp M Source/JavaScriptCore/heap/MarkedBlock.cpp M Source/JavaScriptCore/jsc.cpp M Source/JavaScriptCore/runtime/VM.cpp A Source/JavaScriptCore/runtime/VMManager.cpp A Source/JavaScriptCore/runtime/VMManager.h M Source/JavaScriptCore/tools/HeapVerifier.cpp M Source/JavaScriptCore/tools/Integrity.cpp M Source/JavaScriptCore/tools/IntegrityInlines.h M Source/JavaScriptCore/tools/VMInspector.cpp M Source/JavaScriptCore/tools/VMInspector.h M Source/JavaScriptCore/wasm/WasmCallee.cpp M Source/JavaScriptCore/wasm/WasmOMGPlan.cpp Log Message: ----------- Refactor VMManager out of VMInspector. https://bugs.webkit.org/show_bug.cgi?id=297578 rdar://158659702 Reviewed by Keith Miller and Yijia Huang. Previously, we only needed to enumerate VMs for debugging purposes. As a result, we implemented a container of VMs in VMInspector to support enumeration and inspection. However, since then, production code has come to rely on this container of VMs. Additionally, we will soon need to add more code in the area of VM management and coordination. Hence, it makes sense to refactor this container code out of VMInspector into a VMManager class of its own. Changes include: 1. Changing VMManager::forEachVM() to take a ScopedLambda instead of a Function. forEachVM() is an iteration mechanism, and the life cycle of the callback does not need to extend beyond the iteration operation. Hence, then context of the iteration function can live on the stack in a ScopedLambda instead of needing to be malloc'ed in a Function. 2. Some clients were previously using VMInspector's VM iteration simply for the purpose of finding a VM matching some criteria. Most of the time, the recent most added or searched for VM is the matching one. Hence, we have a s_recentVM cache for that. However, the iteration operation should still be holding the g_vmListLock to prevent the VM instance from being destructed before we call the client's callback with the VM in s_recentVM. Previously, this was done by requiring the client to manually acquire g_vmListLock before checking s_recentVM, and subsequently, using VMInspector::iterate() to iterate the VMs. This can be a source of bugs if the client does handle the lock correctly. Additionally, it requires a lot more of VM container implementation to be exposed as API. In VMManager, we introduce a findVM() operation that will encapsulate this synchronization, checking of s_recentVM, and thereafter, iterating the container if needed. This makes the interface more robust and simpler to use correctly. 3. Removed the dependency for VMInspector::isValidExecutableMemory() and VMInspector::codeBlockForMachinePC() on the VMInspector's lock. VMInspector::isValidExecutableMemory() never needed the VMInspector lock. The real lock that actually needs to be acquired belongs to the ExecutableAllocator instead. VMInspector::isValidExecutableMemory() already acquires that. VMInspector::codeBlockForMachinePC() now uses VMManager::forEachVM() which handles its locking internally. * Source/JavaScriptCore/CMakeLists.txt: * Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj: * Source/JavaScriptCore/Sources.txt: * Source/JavaScriptCore/disassembler/ARM64/A64DOpcode.cpp: (JSC::ARM64Disassembler::A64DOpcodeMoveWide::handlePotentialDataPointer): * Source/JavaScriptCore/heap/MarkedBlock.cpp: (JSC::MarkedBlock::dumpInfoAndCrashForInvalidHandleV2): * Source/JavaScriptCore/jsc.cpp: (startTimeoutTimer): * Source/JavaScriptCore/runtime/VM.cpp: (JSC::VM::VM): (JSC::VM::~VM): * Source/JavaScriptCore/runtime/VMManager.cpp: Added. (JSC::WTF_REQUIRES_LOCK): (JSC::VMManager::add): (JSC::VMManager::remove): (JSC::VMManager::isValidVMSlow): (JSC::VMManager::dumpVMs): (JSC::VMManager::findVMImpl): (JSC::VMManager::forEachVMImpl): (JSC::VMManager::forEachVMWithTimeoutImpl): * Source/JavaScriptCore/runtime/VMManager.h: Added. (JSC::VMManager::isValidVM): (JSC::VMManager::findVM): (JSC::VMManager::forEachVM): (JSC::VMManager::forEachVMWithTimeout): * Source/JavaScriptCore/tools/HeapVerifier.cpp: (JSC::HeapVerifier::checkIfRecorded): * Source/JavaScriptCore/tools/Integrity.cpp: (JSC::Integrity::Analyzer::analyzeVM): * Source/JavaScriptCore/tools/IntegrityInlines.h: (JSC::Integrity::doAudit): * Source/JavaScriptCore/tools/VMInspector.cpp: (JSC::VMInspector::vmForCallFrame): (JSC::VMInspector::codeBlockForMachinePC): (JSC::VMInspector::singleton): Deleted. (JSC::VMInspector::add): Deleted. (JSC::VMInspector::remove): Deleted. (JSC::VMInspector::isValidVMSlow): Deleted. (JSC::VMInspector::dumpVMs): Deleted. (JSC::VMInspector::forEachVM): Deleted. * Source/JavaScriptCore/tools/VMInspector.h: (JSC::VMInspector::isValidVM): Deleted. (JSC::VMInspector::WTF_RETURNS_LOCK): Deleted. (JSC::VMInspector::WTF_REQUIRES_LOCK): Deleted. * Source/JavaScriptCore/wasm/WasmCallee.cpp: (JSC::Wasm::Callee::reportToVMsForDestruction): * Source/JavaScriptCore/wasm/WasmOMGPlan.cpp: Canonical link: https://commits.webkit.org/298937@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes