1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-10 10:16:00 +02:00

Allows for stack base to change

This commit is contained in:
Brian Fiete 2020-05-16 10:07:17 -07:00
parent 2510c16389
commit 4472449cc4
6 changed files with 135 additions and 66 deletions

View file

@ -214,6 +214,8 @@ BFGC::ThreadInfo::~ThreadInfo()
{
if (mThreadHandle != NULL)
BfpThread_Release(mThreadHandle);
if (mThreadInfo != NULL)
BfpThreadInfo_Release(mThreadInfo);
}
bool BFGC::ThreadInfo::WantsSuspend()
@ -226,6 +228,14 @@ bool BFGC::ThreadInfo::WantsSuspend()
#endif
}
void BFGC::ThreadInfo::CalcStackStart()
{
intptr stackBase;
int stackLimit;
BfpThreadInfo_GetStackInfo(mThreadInfo, &stackBase, &stackLimit, BfpThreadInfoFlags_NoCache, NULL);
mStackStart = stackBase;
}
//////////////////////////////////////////////////////////////////////////
#ifdef BF_GC_LOG_ENABLED
@ -1447,6 +1457,7 @@ bool BFGC::ScanThreads()
mQueueMarkObjects = true;
ConservativeScan(regVals, regValCount * sizeof(intptr));
thread->CalcStackStart();
int length = thread->mStackStart - stackPtr;
AdjustStackPtr(stackPtr, length);
@ -1895,11 +1906,9 @@ void BFGC::ThreadStarted()
thread->mThreadHandle = BfpThread_GetCurrent();
thread->mThreadId = BfpThread_GetCurrentId();
thread->mTEB = GetTEB((HANDLE)thread->mThreadHandle);
intptr stackBase;
int stackLimit;
BfpThread_GetStackInfo(thread->mThreadHandle, &stackBase, &stackLimit, NULL);
thread->mStackStart = stackBase;
thread->mThreadInfo = BfpThreadInfo_Create();
thread->CalcStackStart();
mThreadList.Add(thread);