|
|
@@ -56,10 +56,17 @@ X64WriteBarrierCardTableManager::OnThreadInit()
|
|
|
|
|
|
// xplat-todo: Replace this on Windows too with GetCurrentThreadStackBounds
|
|
|
#ifdef _WIN32
|
|
|
+ // check StackProber.cpp for the stack pages layout information
|
|
|
NT_TIB* teb = (NT_TIB*) ::NtCurrentTeb();
|
|
|
-
|
|
|
char* stackBase = (char*) teb->StackBase;
|
|
|
- char* stackEnd = (char*) teb->StackLimit;
|
|
|
+ char* stackEnd = (char*)__readgsqword(0x1478); // 0x1478 is offset of DeallocationStack field on ntdll!_TEB on x64
|
|
|
+ // this is undocumented, verifying with following code
|
|
|
+#if DBG
|
|
|
+ MEMORY_BASIC_INFORMATION memInfo;
|
|
|
+ VirtualQuery((LPCVOID)teb->StackLimit, &memInfo, sizeof(memInfo));
|
|
|
+ Assert((char*)memInfo.AllocationBase == stackEnd);
|
|
|
+ Assert(memInfo.AllocationProtect == PAGE_READWRITE);
|
|
|
+#endif
|
|
|
#else
|
|
|
ULONG_PTR stackBase = 0;
|
|
|
ULONG_PTR stackEnd = 0;
|
|
|
@@ -71,11 +78,6 @@ X64WriteBarrierCardTableManager::OnThreadInit()
|
|
|
this->_stacklimit = (char*)stackEnd;
|
|
|
#endif
|
|
|
|
|
|
- // on Windows server 2012 stack limit can expand with process running, and causes
|
|
|
- // accessing uncommitted card table page.
|
|
|
- // TODO: use VirtualQuery twice to get the max possible stack limit
|
|
|
- stackEnd -= AutoSystemInfo::PageSize * AutoSystemInfo::PageSize;
|
|
|
-
|
|
|
size_t numPages = (stackBase - stackEnd) / AutoSystemInfo::PageSize;
|
|
|
// stackEnd is the lower boundary
|
|
|
bool ret = OnSegmentAlloc((char*) stackEnd, numPages);
|