Skip to content

Commit

Permalink
Set the tlsCurrentThread value before calling SetTopOfStack. Only cal…
Browse files Browse the repository at this point in the history
…l onThreadAttach after tlsStackContext. For #576
  • Loading branch information
hughsando committed Feb 21, 2017
1 parent 9416e49 commit 65a2340
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/hx/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ THREAD_FUNC_TYPE hxThreadFunc( void *inInfo )
info[0] = (hxThreadInfo *)inInfo;
info[1] = 0;

hx::SetTopOfStack((int *)&info[1], true);

tlsCurrentThread = info[0];

hx::SetTopOfStack((int *)&info[1], true);

// Release the creation function
info[0]->mSemaphore->Set();

Expand Down
8 changes: 5 additions & 3 deletions src/hx/gc/Immix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4166,8 +4166,6 @@ class LocalAllocator : public hx::StackContext
#ifdef HX_WINDOWS
mID = GetCurrentThreadId();
#endif

onThreadAttach();
}

~LocalAllocator()
Expand All @@ -4194,7 +4192,6 @@ class LocalAllocator : public hx::StackContext
// It is in the free zone - wait for 'SetTopOfStack' to activate
mGCFreeZone = true;
mReadyForCollect.Set();
onThreadAttach();
}

void ReturnToPool()
Expand Down Expand Up @@ -4709,7 +4706,10 @@ void InitAlloc()
sgObject_root = stack[0];
//GCLOG("__root pointer %p\n", sgObject_root);
gMainThreadContext = new LocalAllocator();

tlsStackContext = gMainThreadContext;
gMainThreadContext->onThreadAttach();

for(int i=0;i<IMMIX_LINE_LEN;i++)
gImmixStartFlag[i] = 1<<( i>>2 ) ;
}
Expand Down Expand Up @@ -4893,7 +4893,9 @@ void RegisterCurrentThread(void *inTopOfStack)
{
local->AttachThread((int *)inTopOfStack);
}

tlsStackContext = local;
local->onThreadAttach();
}

void UnregisterCurrentThread()
Expand Down

1 comment on commit 65a2340

@hughsando
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually for For #567

Please sign in to comment.