Changeset 163661 in webkit


Ignore:
Timestamp:
Feb 7, 2014 4:24:13 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

Fix bug in stack limit adjustments in JSLock.
<https://webkit.org/b/128406>

Reviewed by Geoffrey Garen.

  1. JSLock::unlock() was only clearing the VM::stackPointerAtEntry when m_vm->stackPointerAtVMEntry == entryStackPointer. FYI, entryStackPointer is a field in JSLock.

When DropAllLocks::~DropAllLocks() will call JSLock::grabAllLocks()
to relock the JSLock, JSLock::grabAllLocks() will set a new
entryStackPointer value. Thereafter, DropAllLocks::~DropAllLocks() will
restore the saved VM::stackPointerAtEntry, which will now defer from
the JSLock's entryStackPointer value.

It turns out that when m_vm->stackPointerAtVMEntry was initialized,
it was set to whatever value entryStackPointer is set to. At no time
do we ever expect the 2 values to differ. The only time it differs is
when this bug manifests.

The fix is to remove the entryStackPointer field in JSLock and its uses
altogether.

  1. DropAllLocks was unconditionally clearing VM::stackPointerAtEntry in its constructor instead of letting JSLock::unlock() do the clearing.

However, DropAllLocks will not actually drop locks if it isn't required
to (e.g. when alwaysDropLocks is DontAlwaysDropLocks), and when we've
already drop locks once (i.e. JSLock::m_lockDropDepth is not 0).

We should not have cleared VM::stackPointerAtEntry here if we don't
actually drop the locks.

  • runtime/JSLock.cpp:

(JSC::JSLock::unlock):
(JSC::JSLock::DropAllLocks::DropAllLocks):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r163648 r163661  
     12014-02-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix bug in stack limit adjustments in JSLock.
     4        <https://webkit.org/b/128406>
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        1. JSLock::unlock() was only clearing the VM::stackPointerAtEntry when
     9           m_vm->stackPointerAtVMEntry == entryStackPointer. FYI,
     10           entryStackPointer is a field in JSLock.
     11
     12           When DropAllLocks::~DropAllLocks() will call JSLock::grabAllLocks()
     13           to relock the JSLock, JSLock::grabAllLocks() will set a new
     14           entryStackPointer value. Thereafter, DropAllLocks::~DropAllLocks() will
     15           restore the saved VM::stackPointerAtEntry, which will now defer from
     16           the JSLock's entryStackPointer value.
     17
     18           It turns out that when m_vm->stackPointerAtVMEntry was initialized,
     19           it was set to whatever value entryStackPointer is set to. At no time
     20           do we ever expect the 2 values to differ. The only time it differs is
     21           when this bug manifests.
     22
     23           The fix is to remove the entryStackPointer field in JSLock and its uses
     24           altogether.
     25
     26        2. DropAllLocks was unconditionally clearing VM::stackPointerAtEntry in
     27           its constructor instead of letting JSLock::unlock() do the clearing.
     28
     29           However, DropAllLocks will not actually drop locks if it isn't required
     30           to (e.g. when alwaysDropLocks is DontAlwaysDropLocks), and when we've
     31           already drop locks once (i.e. JSLock::m_lockDropDepth is not 0).
     32
     33           We should not have cleared VM::stackPointerAtEntry here if we don't
     34           actually drop the locks.
     35
     36        * runtime/JSLock.cpp:
     37        (JSC::JSLock::unlock):
     38        (JSC::JSLock::DropAllLocks::DropAllLocks):
     39
    1402014-02-07  Joseph Pecoraro  <pecoraro@apple.com>
    241
  • trunk/Source/JavaScriptCore/runtime/JSLock.cpp

    r163214 r163661  
    143143
    144144    if (!m_lockCount) {
    145         if (m_vm && m_vm->stackPointerAtVMEntry == entryStackPointer) {
     145        if (m_vm) {
    146146            m_vm->stackPointerAtVMEntry = nullptr;
    147147            m_vm->updateStackLimitWithReservedZoneSize(wtfThreadData().savedReservedZoneSize());
     
    313313    threadData.setSavedReservedZoneSize(m_vm->reservedZoneSize());
    314314
    315     m_vm->stackPointerAtVMEntry = nullptr;
    316 
    317315    if (alwaysDropLocks)
    318316        m_lockCount = m_vm->apiLock().dropAllLocksUnconditionally(spinLock);
     
    338336    threadData.setSavedReservedZoneSize(m_vm->reservedZoneSize());
    339337
    340     m_vm->stackPointerAtVMEntry = nullptr;
    341 
    342338    if (alwaysDropLocks)
    343339        m_lockCount = m_vm->apiLock().dropAllLocksUnconditionally(spinLock);
Note: See TracChangeset for help on using the changeset viewer.