Changeset 74455 in webkit


Ignore:
Timestamp:
Dec 21, 2010 8:29:33 PM (13 years ago)
Author:
barraclough@apple.com
Message:

Bug 26276 - Need a mechanism to determine stack extent

Reviewed by Oliver Hunt.

This patch adds accurate stack size calculation for:

DARWIN, QNX, UNIX

We still need to fix:

WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE

  • wtf/StackBounds.cpp:

(WTF::StackBounds::initialize):

Location:
trunk/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r74454 r74455  
     12010-12-21  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Bug 26276 - Need a mechanism to determine stack extent
     6
     7        This patch adds accurate stack size calculation for:
     8            DARWIN, QNX, UNIX
     9        We still need to fix:
     10            WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE
     11
     12        * wtf/StackBounds.cpp:
     13        (WTF::StackBounds::initialize):
     14
    1152010-12-21  Gavin Barraclough  <barraclough@apple.com>
    216
  • trunk/JavaScriptCore/wtf/StackBounds.cpp

    r74415 r74455  
    5858namespace WTF {
    5959
     60// Bug 26276 - Need a mechanism to determine stack extent
     61//
     62// These platforms should now be working correctly:
     63//     DARWIN, QNX, UNIX
     64// These platforms are not:
     65//     WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE
     66//
     67// FIXME: remove this! - this code unsafely guesses at stack sizes!
     68#if OS(WINDOWS) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU) || OS(WINCE)
    6069// Based on the current limit used by the JSC parser, guess the stack size.
    6170static const ptrdiff_t estimatedStackSize = 128 * sizeof(void*) * 1024;
    62 
    6371// This method assumes the stack is growing downwards.
    6472static void* estimateStackBound(void* origin)
     
    6674    return static_cast<char*>(origin) - estimatedStackSize;
    6775}
     76#endif
    6877
    6978#if OS(DARWIN)
     
    7382    pthread_t thread = pthread_self();
    7483    m_origin = pthread_get_stackaddr_np(thread);
    75     m_bound = estimateStackBound(m_origin);
     84    m_bound = static_cast<char*>(m_origin) - pthread_get_stacksize_np(thread);
    7685}
    7786
     
    103112#error Need a way to get the stack bounds on this platform (Windows)
    104113#endif
     114    // Looks like we should be able to get pTib->StackLimit
    105115    m_bound = estimateStackBound(m_origin);
    106116}
     
    128138    ASSERT(stackBase);
    129139
     140    m_bound = stackBase;
    130141    m_origin = static_cast<char*>(stackBase) + stackSize;
    131     m_bound = estimateStackBound(m_origin);
    132142}
    133143
     
    195205    ASSERT(stackBase);
    196206    pthread_attr_destroy(&sattr);
     207    m_bound = stackBase;
    197208    m_origin = static_cast<char*>(stackBase) + stackSize;
    198     m_bound = estimateStackBound(m_origin);
    199209}
    200210
Note: See TracChangeset for help on using the changeset viewer.