Changeset 164018 in webkit
- Timestamp:
- Feb 12, 2014 10:50:09 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r164009 r164018 1 2014-02-12 Mark Lam <mark.lam@apple.com> 2 3 No need to save reservedZoneSize when dropping the JSLock. 4 <https://webkit.org/b/128719> 5 6 Reviewed by Geoffrey Garen. 7 8 The reservedZoneSize does not change due to the VM being run on a different 9 thread. Hence, there is no need to save and restore its value. Instead of 10 calling updateReservedZoneSize() to update the stack limit, we now call 11 setStackPointerAtVMEntry() to do the job. setStackPointerAtVMEntry() 12 will update the stackPointerAtVMEntry and delegate to updateStackLimit() to 13 update the stack limit based on the new stackPointerAtVMEntry. 14 15 * runtime/ErrorHandlingScope.cpp: 16 (JSC::ErrorHandlingScope::ErrorHandlingScope): 17 (JSC::ErrorHandlingScope::~ErrorHandlingScope): 18 - Previously, we initialize stackPointerAtVMEntry in VMEntryScope. This 19 means that the stackPointerAtVMEntry may not be initialize when we 20 instantiate the ErrorHandlingScope. And so, we needed to initialize the 21 stackPointerAtVMEntry in the ErrorHandlingScope constructor if it's not 22 already initialized. 23 24 Now that we initialize the stackPointerAtVMEntry when we lock the VM JSLock, 25 we are guaranteed that it will be initialized by the time we instantiate 26 the ErrorHandlingScope. Hence, we can change the ErrorHandlingScope code 27 to just assert that the stackPointerAtVMEntry is initialized instead. 28 29 * runtime/InitializeThreading.cpp: 30 (JSC::initializeThreading): 31 - We no longer need to save the reservedZoneSize. Remove the related code. 32 33 * runtime/JSLock.cpp: 34 (JSC::JSLock::lock): 35 - When we grab the JSLock mutex for the first time, there is no reason why 36 the stackPointerAtVMEntry should be initialized. By definition, grabbing 37 the lock for the first time equates to entering the VM for the first time. 38 Hence, we can just assert that stackPointerAtVMEntry is uninitialized, 39 and initialize it unconditionally. 40 41 The only exception to this is if we're locking to regrab the JSLock in 42 grabAllLocks(), but grabAllLocks() will take care of restoring the 43 stackPointerAtVMEntry in that case after lock() returns. stackPointerAtVMEntry 44 should still be 0 when we've just locked the JSLock. So, the above assertion 45 always holds true. 46 47 Note: VM::setStackPointerAtVMEntry() will take care of calling 48 VM::updateStackLimit() based on the new stackPointerAtVMEntry. 49 50 - There is no need to save the reservedZoneSize. The reservedZoneSize is 51 set to Options::reservedZoneSize() when the VM is initialized. Thereafter, 52 the ErrorHandlingScope will change it to Options::errorModeReservedZoneSize() 53 when we're handling an error, and it will restore it afterwards. There is 54 no other reason we should be changing the reservedZoneSize. Hence, we can 55 remove the unnecessary code to save it here. 56 57 (JSC::JSLock::unlock): 58 - Similarly, when the lockCount reaches 0 in unlock(), it is synonymous with 59 exiting the VM. Hence, we should just clear the stackPointerAtVMEntry and 60 update the stackLimit. Exiting the VM should have no effect on the VM 61 reservedZoneSize. Hence, we can remove the unnecessary code to "restore" it. 62 63 (JSC::JSLock::dropAllLocks): 64 - When dropping locks, we do not need to save the reservedZoneSize because 65 the reservedZoneSize should remain the same regardless of which thread 66 we are executing JS on. Hence, we can remove the unnecessary code to save 67 the reservedZoneSize here. 68 69 (JSC::JSLock::grabAllLocks): 70 - When re-grabbing locks, restoring the stackPointerAtVMEntry via 71 VM::setStackPointerAtVMEntry() will take care of updating the stack limit. 72 As explained above, there's no need to save the reservedZoneSize. Hence, 73 there's no need to "restore" it here. 74 75 * runtime/VM.cpp: 76 (JSC::VM::VM): 77 (JSC::VM::setStackPointerAtVMEntry): 78 - Sets the stackPointerAtVMEntry and delegates to updateStackLimit() to update 79 the stack limit based on the new stackPointerAtVMEntry. 80 (JSC::VM::updateStackLimit): 81 * runtime/VM.h: 82 (JSC::VM::stackPointerAtVMEntry): 83 - Renamed stackPointerAtVMEntry to m_stackPointerAtVMEntry and made it private. 84 Added a stackPointerAtVMEntry() function to read the value. 85 1 86 2014-02-12 Mark Hahnenberg <mhahnenberg@apple.com> 2 87 -
trunk/Source/JavaScriptCore/runtime/ErrorHandlingScope.cpp
r163964 r164018 36 36 : m_vm(vm) 37 37 { 38 if (!m_vm.stackPointerAtVMEntry) 39 m_vm.stackPointerAtVMEntry = this; 38 RELEASE_ASSERT(m_vm.stackPointerAtVMEntry()); 40 39 size_t newReservedZoneSize = Options::errorModeReservedZoneSize(); 41 40 m_savedReservedZoneSize = m_vm.updateReservedZoneSize(newReservedZoneSize); … … 47 46 ErrorHandlingScope::~ErrorHandlingScope() 48 47 { 49 if (m_vm.stackPointerAtVMEntry == this) 50 m_vm.stackPointerAtVMEntry = nullptr; 48 RELEASE_ASSERT(m_vm.stackPointerAtVMEntry()); 51 49 m_vm.updateReservedZoneSize(m_savedReservedZoneSize); 52 50 #if ENABLE(LLINT_C_LOOP) -
trunk/Source/JavaScriptCore/runtime/InitializeThreading.cpp
r163214 r164018 74 74 #endif 75 75 WTFThreadData& threadData = wtfThreadData(); 76 77 76 threadData.setSavedLastStackTop(threadData.stack().origin()); 78 threadData.setSavedReservedZoneSize(Options::reservedZoneSize());79 77 }); 80 78 } -
trunk/Source/JavaScriptCore/runtime/JSLock.cpp
r163964 r164018 124 124 WTFThreadData& threadData = wtfThreadData(); 125 125 126 if (!m_vm->stackPointerAtVMEntry) { 127 void* p = &p; 128 m_vm->stackPointerAtVMEntry = p; // A proxy for the current stack pointer. 129 threadData.setSavedReservedZoneSize(m_vm->updateReservedZoneSize(Options::reservedZoneSize())); 130 } 126 RELEASE_ASSERT(!m_vm->stackPointerAtVMEntry()); 127 void* p = &p; // A proxy for the current stack pointer. 128 m_vm->setStackPointerAtVMEntry(p); 131 129 132 130 m_vm->setLastStackTop(threadData.savedLastStackTop()); … … 146 144 147 145 if (!m_lockCount) { 148 if (m_vm) { 149 m_vm->stackPointerAtVMEntry = nullptr; 150 m_vm->updateReservedZoneSize(wtfThreadData().savedReservedZoneSize()); 151 } 146 if (m_vm) 147 m_vm->setStackPointerAtVMEntry(nullptr); 152 148 setOwnerThread(0); 153 149 m_lock.unlock(); … … 186 182 187 183 WTFThreadData& threadData = wtfThreadData(); 188 threadData.setSavedStackPointerAtVMEntry(m_vm->stackPointerAtVMEntry );184 threadData.setSavedStackPointerAtVMEntry(m_vm->stackPointerAtVMEntry()); 189 185 threadData.setSavedLastStackTop(m_vm->lastStackTop()); 190 threadData.setSavedReservedZoneSize(m_vm->reservedZoneSize());191 186 192 187 unsigned droppedLockCount = m_lockCount; … … 217 212 218 213 WTFThreadData& threadData = wtfThreadData(); 219 m_vm->s tackPointerAtVMEntry = threadData.savedStackPointerAtVMEntry();214 m_vm->setStackPointerAtVMEntry(threadData.savedStackPointerAtVMEntry()); 220 215 m_vm->setLastStackTop(threadData.savedLastStackTop()); 221 m_vm->updateReservedZoneSize(threadData.savedReservedZoneSize());222 216 } 223 217 -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r163964 r164018 174 174 , clientData(0) 175 175 , topCallFrame(CallFrame::noCaller()) 176 , stackPointerAtVMEntry(0)177 176 , arrayConstructorTable(adoptPtr(new HashTable(JSC::arrayConstructorTable))) 178 177 , arrayPrototypeTable(adoptPtr(new HashTable(JSC::arrayPrototypeTable))) … … 224 223 , m_initializingObjectClass(0) 225 224 #endif 225 , m_stackPointerAtVMEntry(0) 226 226 , m_stackLimit(0) 227 227 #if ENABLE(LLINT_C_LOOP) … … 733 733 } 734 734 735 void VM::setStackPointerAtVMEntry(void* sp) 736 { 737 m_stackPointerAtVMEntry = sp; 738 updateStackLimit(); 739 } 740 735 741 size_t VM::updateReservedZoneSize(size_t reservedZoneSize) 736 742 { … … 745 751 inline void VM::updateStackLimit() 746 752 { 747 if ( stackPointerAtVMEntry) {753 if (m_stackPointerAtVMEntry) { 748 754 ASSERT(wtfThreadData().stack().isGrowingDownward()); 749 char* startOfStack = reinterpret_cast<char*>( stackPointerAtVMEntry);755 char* startOfStack = reinterpret_cast<char*>(m_stackPointerAtVMEntry); 750 756 #if ENABLE(FTL_JIT) 751 757 m_stackLimit = wtfThreadData().stack().recursionLimit(startOfStack, Options::maxPerThreadStackUsage(), m_reservedZoneSize + m_largestFTLStackSize); -
trunk/Source/JavaScriptCore/runtime/VM.h
r163964 r164018 231 231 ClientData* clientData; 232 232 ExecState* topCallFrame; 233 void* stackPointerAtVMEntry;234 233 Watchdog watchdog; 235 234 … … 380 379 JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*); 381 380 381 void* stackPointerAtVMEntry() const { return m_stackPointerAtVMEntry; } 382 void setStackPointerAtVMEntry(void*); 383 382 384 size_t reservedZoneSize() const { return m_reservedZoneSize; } 383 385 size_t updateReservedZoneSize(size_t reservedZoneSize); … … 530 532 const ClassInfo* m_initializingObjectClass; 531 533 #endif 534 void* m_stackPointerAtVMEntry; 532 535 size_t m_reservedZoneSize; 533 536 #if ENABLE(LLINT_C_LOOP) -
trunk/Source/WTF/ChangeLog
r163887 r164018 1 2014-02-12 Mark Lam <mark.lam@apple.com> 2 3 No need to save reservedZoneSize when dropping the JSLock. 4 <https://webkit.org/b/128719> 5 6 Reviewed by Geoffrey Garen. 7 8 * wtf/WTFThreadData.cpp: 9 (WTF::WTFThreadData::WTFThreadData): 10 * wtf/WTFThreadData.h: 11 - removed unnneeded m_savedReservedZoneSize. 12 1 13 2014-02-11 Mark Hahnenberg <mhahnenberg@apple.com> 2 14 -
trunk/Source/WTF/wtf/WTFThreadData.cpp
r163214 r164018 52 52 , m_savedStackPointerAtVMEntry(0) 53 53 , m_savedLastStackTop(stack().origin()) 54 , m_savedReservedZoneSize(0)55 54 { 56 55 #if USE(WEB_THREAD) -
trunk/Source/WTF/wtf/WTFThreadData.h
r163214 r164018 127 127 } 128 128 129 size_t savedReservedZoneSize()130 {131 return m_savedReservedZoneSize;132 }133 134 void setSavedReservedZoneSize(size_t reservedZoneSize)135 {136 m_savedReservedZoneSize = reservedZoneSize;137 }138 139 129 void* m_apiData; 140 130 … … 151 141 void* m_savedStackPointerAtVMEntry; 152 142 void* m_savedLastStackTop; 153 size_t m_savedReservedZoneSize;154 143 155 144 static WTF_EXPORTDATA ThreadSpecific<WTFThreadData>* staticData;
Note: See TracChangeset
for help on using the changeset viewer.