Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix perf issues with GetCurrentThreadHomeHeapNumber (#21150)
Browse files Browse the repository at this point in the history
  • Loading branch information
davmason authored Nov 30, 2018
1 parent 69b303c commit 71f259c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
15 changes: 6 additions & 9 deletions src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35215,17 +35215,14 @@ int GCHeap::GetNumberOfHeaps ()
int GCHeap::GetHomeHeapNumber ()
{
#ifdef MULTIPLE_HEAPS
Thread *pThread = GCToEEInterface::GetThread();
for (int i = 0; i < gc_heap::n_heaps; i++)
gc_alloc_context* ctx = GCToEEInterface::GetAllocContext();
if (!ctx)
{
if (pThread)
{
gc_alloc_context* ctx = GCToEEInterface::GetAllocContext();
GCHeap *hp = static_cast<alloc_context*>(ctx)->get_home_heap();
if (hp == gc_heap::g_heaps[i]->vm_heap) return i;
}
return 0;
}
return 0;

GCHeap *hp = static_cast<alloc_context*>(ctx)->get_home_heap();
return (hp ? hp->pGenGCHeap->heap_number : 0);
#else
return 0;
#endif //MULTIPLE_HEAPS
Expand Down
3 changes: 1 addition & 2 deletions src/gc/objecthandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,8 +1819,7 @@ int GetCurrentThreadHomeHeapNumber()
{
WRAPPER_NO_CONTRACT;

if (g_theGCHeap == nullptr)
return 0;
assert(g_theGCHeap != nullptr);
return g_theGCHeap->GetHomeHeapNumber();
}

Expand Down
6 changes: 5 additions & 1 deletion src/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ gc_alloc_context * GCToEEInterface::GetAllocContext()
WRAPPER_NO_CONTRACT;

Thread* pThread = ::GetThread();
assert(pThread != nullptr);
if (!pThread)
{
return nullptr;
}

return pThread->GetAllocContext();
}

Expand Down

0 comments on commit 71f259c

Please sign in to comment.