Changeset 276069 in webkit
- Timestamp:
- Apr 15, 2021, 1:31:04 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 10 edited
-
JavaScriptCore/CMakeLists.txt (modified) (1 diff)
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
JavaScriptCore/jit/JITOperations.cpp (modified) (1 diff)
-
JavaScriptCore/jsc.cpp (modified) (1 diff)
-
JavaScriptCore/runtime/JSGlobalObject.cpp (modified) (1 diff)
-
JavaScriptCore/runtime/VMTraps.cpp (modified) (4 diffs)
-
JavaScriptCore/runtime/VMTraps.h (modified) (2 diffs)
-
JavaScriptCore/runtime/VMTrapsInlines.h (added)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/workers/WorkerOrWorkletScriptController.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r276039 r276069 1104 1104 runtime/VMInlines.h 1105 1105 runtime/VMTraps.h 1106 runtime/VMTrapsInlines.h 1106 1107 runtime/VarOffset.h 1107 1108 runtime/Watchdog.h -
trunk/Source/JavaScriptCore/ChangeLog
r276039 r276069 1 2021-04-15 Mark Lam <mark.lam@apple.com> 2 3 Optimize the DeferTermination scope to be more efficient. 4 https://bugs.webkit.org/show_bug.cgi?id=224619 5 6 Reviewed by Saam Barati. 7 8 This can be beneficial since we may be using DeferTermination in more places in 9 the code. 10 11 1. Added a VMTrapsInlines.h to hold the inline functions. 12 13 2. Split deferTermination() and undoDeferTermination() into fast and slow functions. 14 The fast functions are inlineable. 15 16 3. Remove the locking of VMTraps::m_lock in these functions. These functions only 17 modify the following: 18 a. VMTraps::m_deferTerminationCount 19 b. VMTraps::m_suspendedTerminationException 20 c. VMTraps::m_trapBits for setting the NeedTermination bit if needed. 21 d. VM::m_exception 22 23 Except for VMTraps::m_trapBits, all of these are only written to from the mutator 24 thread. VMTraps::m_trapBits is always written to using Atomics. There isn't 25 anything that needs to be guarded by VMTraps::m_lock. 26 27 4. Fix VMTraps::deferTermination() to only set m_suspendedTerminationException 28 and clear an existing TerminationException if it's being called from the 29 outermost DeferTermination (i.e. m_deferTerminationCount is 1 after incrementing). 30 These conditional operations are not done in VMTraps::deferTerminationSlow(). 31 32 In practice, it wouldn't have mattered anyway because we would never throw a 33 TerminationException while a DeferTermination scope is in effect. The 34 the vm.isTerminationException() in the original deferTermination() would 35 always have prevented the slow path operations from being executed anyway. 36 37 However, for the purpose of this patch, we want to avoid as much unnecessary 38 work as possible in the fast path. Hence, it is good to skip the slow path 39 if deferTermination() isn't called from the outermost scope. 40 41 * CMakeLists.txt: 42 * JavaScriptCore.xcodeproj/project.pbxproj: 43 * jit/JITOperations.cpp: 44 * jsc.cpp: 45 * runtime/JSGlobalObject.cpp: 46 * runtime/VMTraps.cpp: 47 (JSC::VMTraps::deferTerminationSlow): 48 (JSC::VMTraps::undoDeferTerminationSlow): 49 (JSC::VMTraps::vm const): Deleted. 50 (JSC::VMTraps::deferTermination): Deleted. 51 (JSC::VMTraps::undoDeferTermination): Deleted. 52 * runtime/VMTraps.h: 53 * runtime/VMTrapsInlines.h: Added. 54 (JSC::VMTraps::vm const): 55 (JSC::VMTraps::deferTermination): 56 (JSC::VMTraps::undoDeferTermination): 57 1 58 2021-04-15 Mark Lam <mark.lam@apple.com> 2 59 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r276039 r276069 2016 2016 FEF5B4272628ABD90016E776 /* JSWeakMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEF5B4262628ABD90016E776 /* JSWeakMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2017 2017 FEF5B4292628B5240016E776 /* JSSetInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEF5B4282628B5240016E776 /* JSSetInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2018 FEF5B42C2628CBC80016E776 /* VMTrapsInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEF5B42B2628CBC80016E776 /* VMTrapsInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2018 2019 FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2019 2020 /* End PBXBuildFile section */ … … 5426 5427 FEF5B4262628ABD90016E776 /* JSWeakMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWeakMapInlines.h; sourceTree = "<group>"; }; 5427 5428 FEF5B4282628B5240016E776 /* JSSetInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSetInlines.h; sourceTree = "<group>"; }; 5429 FEF5B42B2628CBC80016E776 /* VMTrapsInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMTrapsInlines.h; sourceTree = "<group>"; }; 5428 5430 FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = "<group>"; }; 5429 5431 /* End PBXFileReference section */ … … 7921 7923 FE6F56DC1E64E92000D17801 /* VMTraps.cpp */, 7922 7924 FE6F56DD1E64E92000D17801 /* VMTraps.h */, 7925 FEF5B42B2628CBC80016E776 /* VMTrapsInlines.h */, 7923 7926 FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */, 7924 7927 FED94F2C171E3E2300BE77A4 /* Watchdog.h */, … … 9822 9825 52EED7942492B870008F4C93 /* FunctionAllowlist.h in Headers */, 9823 9826 14AD910D1DCA92940014F9FE /* FunctionCodeBlock.h in Headers */, 9827 FEF5B42C2628CBC80016E776 /* VMTrapsInlines.h in Headers */, 9824 9828 BC18C4040E16F5CD00B34460 /* FunctionConstructor.h in Headers */, 9825 9829 147341D81DC02F9900AA29BA /* FunctionExecutable.h in Headers */, -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r276000 r276069 68 68 #include "TypeProfilerLog.h" 69 69 #include "VMInlines.h" 70 #include "VMTrapsInlines.h" 70 71 71 72 IGNORE_WARNINGS_BEGIN("frame-address") -
trunk/Source/JavaScriptCore/jsc.cpp
r275971 r276069 70 70 #include "TypedArrayInlines.h" 71 71 #include "VMInspector.h" 72 #include "VMTrapsInlines.h" 72 73 #include "WasmCapabilities.h" 73 74 #include "WasmFaultSignalHandler.h" -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r275845 r276069 202 202 #include "SymbolObject.h" 203 203 #include "SymbolPrototype.h" 204 #include "VMTrapsInlines.h" 204 205 #include "WasmCapabilities.h" 205 206 #include "WeakMapConstructor.h" -
trunk/Source/JavaScriptCore/runtime/VMTraps.cpp
r275969 r276069 37 37 #include "MachineContext.h" 38 38 #include "MacroAssemblerCodeRef.h" 39 #include "VM .h"39 #include "VMTrapsInlines.h" 40 40 #include "Watchdog.h" 41 41 #include <wtf/ProcessID.h> … … 44 44 45 45 namespace JSC { 46 47 ALWAYS_INLINE VM& VMTraps::vm() const48 {49 return *bitwise_cast<VM*>(bitwise_cast<uintptr_t>(this) - OBJECT_OFFSETOF(VM, m_traps));50 }51 46 52 47 #if ENABLE(SIGNAL_BASED_VM_TRAPS) … … 416 411 } 417 412 418 void VMTraps::deferTermination(DeferAction) 419 { 420 auto locker = holdLock(*m_lock); 421 m_deferTerminationCount++; 422 ASSERT(m_deferTerminationCount < UINT_MAX); 413 void VMTraps::deferTerminationSlow(DeferAction) 414 { 415 ASSERT(m_deferTerminationCount == 1); 423 416 424 417 VM& vm = this->vm(); 425 418 Exception* pendingException = vm.exception(); 426 if (pendingException && vm.isTerminationException(pendingException)) { 419 ASSERT(pendingException); 420 if (vm.isTerminationException(pendingException)) { 421 ASSERT(vm.terminationInProgress()); 427 422 vm.clearException(); 428 423 m_suspendedTerminationException = true; … … 430 425 } 431 426 432 void VMTraps::undoDeferTermination(DeferAction action) 433 { 434 auto locker = holdLock(*m_lock); 435 ASSERT(m_deferTerminationCount > 0); 436 if (--m_deferTerminationCount == 0) { 437 VM& vm = this->vm(); 438 if (m_suspendedTerminationException 439 || ((action == DeferAction::DeferUntilEndOfScope) && vm.terminationInProgress())) 440 vm.throwTerminationException(); 441 else if ((action == DeferAction::DeferForAWhile) && vm.terminationInProgress()) 442 setTrapBit(NeedTermination); // Let the next trap check handle it. 443 } 427 void VMTraps::undoDeferTerminationSlow(DeferAction deferAction) 428 { 429 ASSERT(m_deferTerminationCount == 0); 430 431 VM& vm = this->vm(); 432 ASSERT(vm.terminationInProgress()); 433 if (m_suspendedTerminationException || (deferAction == DeferAction::DeferUntilEndOfScope)) { 434 vm.throwTerminationException(); 435 m_suspendedTerminationException = false; 436 } else if (deferAction == DeferAction::DeferForAWhile) 437 setTrapBit(NeedTermination); // Let the next trap check handle it. 444 438 } 445 439 -
trunk/Source/JavaScriptCore/runtime/VMTraps.h
r275969 r276069 198 198 199 199 bool isDeferringTermination() const { return m_deferTerminationCount; } 200 JS_EXPORT_PRIVATEvoid deferTermination(DeferAction);201 JS_EXPORT_PRIVATEvoid undoDeferTermination(DeferAction);200 void deferTermination(DeferAction); 201 void undoDeferTermination(DeferAction); 202 202 203 203 void notifyGrabAllLocks() … … 227 227 VM& vm() const; 228 228 229 JS_EXPORT_PRIVATE void deferTerminationSlow(DeferAction); 230 JS_EXPORT_PRIVATE void undoDeferTerminationSlow(DeferAction); 229 231 Event takeTopPriorityTrap(BitField mask); 230 232 -
trunk/Source/WebCore/ChangeLog
r276052 r276069 1 2021-04-15 Mark Lam <mark.lam@apple.com> 2 3 Optimize the DeferTermination scope to be more efficient. 4 https://bugs.webkit.org/show_bug.cgi?id=224619 5 6 Reviewed by Saam Barati. 7 8 * workers/WorkerOrWorkletScriptController.cpp: 9 1 10 2021-04-15 Antoine Quint <graouts@webkit.org> 2 11 -
trunk/Source/WebCore/workers/WorkerOrWorkletScriptController.cpp
r275845 r276069 58 58 #include <JavaScriptCore/ScriptCallStack.h> 59 59 #include <JavaScriptCore/StrongInlines.h> 60 #include <JavaScriptCore/VMTrapsInlines.h> 60 61 61 62 namespace WebCore {
Note:
See TracChangeset
for help on using the changeset viewer.