Commit 5802e803 authored by barraclough@apple.com's avatar barraclough@apple.com

Bug 26276 - Need a mechanism to determine stack extent on WINDOWS, SOLARIS,...

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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bf7656ce
2011-01-07 Gavin Barraclough <barraclough@apple.com>
Reviewed by Geoff Garen.
Bug 26276 - Need a mechanism to determine stack extent on WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE platforms
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):
2011-01-07 Adam Roben <aroben@apple.com>
Update react-to-vsprops-changes.py after r74855
......
......@@ -60,12 +60,12 @@ namespace WTF {
// Bug 26276 - Need a mechanism to determine stack extent
//
// These platforms should now be working correctly:
// DARWIN, QNX, UNIX
// DARWIN, WINDOWS-CPU(X86), QNX, UNIX, WINCE
// These platforms are not:
// WINDOWS, SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE
// WINDOWS-CPU(X86_64), SOLARIS, OPENBSD, SYMBIAN, HAIKU
//
// FIXME: remove this! - this code unsafely guesses at stack sizes!
#if OS(WINDOWS) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU)
#if (OS(WINDOWS) && CPU(X86_64)) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU)
// Based on the current limit used by the JSC parser, guess the stack size.
static const ptrdiff_t estimatedStackSize = 128 * sizeof(void*) * 1024;
// This method assumes the stack is growing downwards.
......@@ -247,39 +247,37 @@ void StackBounds::initialize()
m_bound = isGrowingDownward ? lowerStackBound : upperStackBound;
}
#elif OS(WINDOWS)
#elif OS(WINDOWS) && (CPU(X86) || CPU(X86_64))
void StackBounds::initialize()
{
#if CPU(X86) && COMPILER(MSVC)
// offset 0x18 from the FS segment register gives a pointer to
// the thread information block for the current thread
#if CPU(X86)
// Offset 0x18 from the FS segment register gives a pointer to
// the thread information block for the current thread.
NT_TIB* pTib;
#if COMPILER(MSVC)
__asm {
MOV EAX, FS:[18h]
MOV pTib, EAX
}
m_origin = static_cast<void*>(pTib->StackBase);
#elif CPU(X86) && COMPILER(GCC)
// offset 0x18 from the FS segment register gives a pointer to
// the thread information block for the current thread
NT_TIB* pTib;
#else
asm ( "movl %%fs:0x18, %0\n"
: "=r" (pTib)
);
#endif
// See http://en.wikipedia.org/wiki/Win32_Thread_Information_Block for more information!
void* pDeallocationStack = reinterpret_cast<char*>(pTib) + 0xE0C;
m_origin = static_cast<void*>(pTib->StackBase);
m_bound = *static_cast<void**>(pDeallocationStack);
#elif CPU(X86_64)
PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb());
m_origin = reinterpret_cast<void*>(pTib->StackBase);
#else
#error Need a way to get the stack bounds on this platform (Windows)
#endif
// Looks like we should be able to get pTib->StackLimit
m_bound = estimateStackBound(m_origin);
#endif
}
#else
#error Need a way to get the stack bounds on this platform
#error Need a way to get the stack bounds on this platform.
#endif
} // namespace WTF
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment