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