Changeset 75289 in webkit


Ignore:
Timestamp:
Jan 7, 2011 3:59:18 PM (13 years ago)
Author:
barraclough@apple.com
Message:

Bug 26276 - Need a mechanism to determine stack extent on WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE platforms

Reviewed by Geoff Garen.

Fix for win32. The base of the stack is stored in the "deallocation stack" field of the
Thread Information Block - see: http://en.wikipedia.org/wiki/Win32_Thread_Information_Block
for more information!

  • wtf/StackBounds.cpp:

(WTF::StackBounds::initialize):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r75269 r75289  
     12011-01-07  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Geoff Garen.
     4
     5        Bug 26276 - Need a mechanism to determine stack extent on WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE platforms
     6
     7        Fix for win32.  The base of the stack is stored in the "deallocation stack" field of the
     8        Thread Information Block - see: http://en.wikipedia.org/wiki/Win32_Thread_Information_Block
     9        for more information!
     10
     11        * wtf/StackBounds.cpp:
     12        (WTF::StackBounds::initialize):
     13
    1142011-01-07  Adam Roben  <aroben@apple.com>
    215
  • trunk/Source/JavaScriptCore/wtf/StackBounds.cpp

    r75190 r75289  
    6161//
    6262// These platforms should now be working correctly:
    63 //     DARWIN, QNX, UNIX
     63//     DARWIN, WINDOWS-CPU(X86), QNX, UNIX, WINCE
    6464// These platforms are not:
    65 //     WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE
     65//     WINDOWS-CPU(X86_64), SOLARIS, OPENBSD, SYMBIAN, HAIKU
    6666//
    6767// FIXME: remove this! - this code unsafely guesses at stack sizes!
    68 #if OS(WINDOWS) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU)
     68#if (OS(WINDOWS) && CPU(X86_64)) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU)
    6969// Based on the current limit used by the JSC parser, guess the stack size.
    7070static const ptrdiff_t estimatedStackSize = 128 * sizeof(void*) * 1024;
     
    248248}
    249249
    250 #elif OS(WINDOWS)
    251 
    252 void StackBounds::initialize()
    253 {
    254 #if CPU(X86) && COMPILER(MSVC)
    255     // offset 0x18 from the FS segment register gives a pointer to
    256     // the thread information block for the current thread
     250#elif OS(WINDOWS) && (CPU(X86) || CPU(X86_64))
     251
     252void StackBounds::initialize()
     253{
     254#if CPU(X86)
     255    // Offset 0x18 from the FS segment register gives a pointer to
     256    // the thread information block for the current thread.
    257257    NT_TIB* pTib;
     258#if COMPILER(MSVC)
    258259    __asm {
    259260        MOV EAX, FS:[18h]
    260261        MOV pTib, EAX
    261262    }
    262     m_origin = static_cast<void*>(pTib->StackBase);
    263 #elif CPU(X86) && COMPILER(GCC)
    264     // offset 0x18 from the FS segment register gives a pointer to
    265     // the thread information block for the current thread
    266     NT_TIB* pTib;
     263#else
    267264    asm ( "movl %%fs:0x18, %0\n"
    268265          : "=r" (pTib)
    269266        );
     267#endif
     268    // See http://en.wikipedia.org/wiki/Win32_Thread_Information_Block for more information!
     269    void* pDeallocationStack = reinterpret_cast<char*>(pTib) + 0xE0C;
    270270    m_origin = static_cast<void*>(pTib->StackBase);
     271    m_bound = *static_cast<void**>(pDeallocationStack);
    271272#elif CPU(X86_64)
    272273    PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb());
    273274    m_origin = reinterpret_cast<void*>(pTib->StackBase);
     275    m_bound = estimateStackBound(m_origin);
     276#endif
     277}
     278
    274279#else
    275 #error Need a way to get the stack bounds on this platform (Windows)
    276 #endif
    277     // Looks like we should be able to get pTib->StackLimit
    278     m_bound = estimateStackBound(m_origin);
    279 }
    280 
    281 #else
    282 #error Need a way to get the stack bounds on this platform
     280#error Need a way to get the stack bounds on this platform.
    283281#endif
    284282
Note: See TracChangeset for help on using the changeset viewer.