find_object
authorMaoni0 <maonis@microsoft.com>
Wed, 23 May 2018 20:52:08 +0000 (13:52 -0700)
committerAndrew Au <cshung@gmail.com>
Wed, 7 Nov 2018 02:34:47 +0000 (18:34 -0800)
src/gc/gc.cpp
src/gc/gcpriv.h

index a8a47c7..5f653fa 100644 (file)
@@ -26099,7 +26099,7 @@ void gc_heap::background_mark_phase ()
 }
 
 void
-gc_heap::suspend_EE ()
+gc_heap::suspend_EE()
 {
     dprintf (2, ("suspend_EE"));
 #ifdef MULTIPLE_HEAPS
@@ -26110,46 +26110,45 @@ gc_heap::suspend_EE ()
 #endif //MULTIPLE_HEAPS
 }
 
-#ifdef MULTIPLE_HEAPS
 void
-gc_heap::bgc_suspend_EE ()
+gc_heap::restart_EE()
+{
+    dprintf (2, ("restart_EE"));
+    GCToEEInterface::RestartEE(FALSE);
+}
+
+void
+gc_heap::bgc_suspend_EE()
 {
+#ifdef MULTIPLE_HEAPS
     for (int i = 0; i < n_heaps; i++)
     {
         gc_heap::g_heaps[i]->reset_gc_done();
     }
+#else
+    reset_gc_done();
+#endif //MULTIPLE_HEAPS
+
     gc_started = TRUE;
     dprintf (2, ("bgc_suspend_EE"));
     GCToEEInterface::SuspendEE(SUSPEND_FOR_GC_PREP);
+}
 
+void
+gc_heap::bgc_restart_EE()
+{
     gc_started = FALSE;
+#ifdef MULTIPLE_HEAPS
     for (int i = 0; i < n_heaps; i++)
     {
         gc_heap::g_heaps[i]->set_gc_done();
     }
-}
 #else
-void
-gc_heap::bgc_suspend_EE ()
-{
-    reset_gc_done();
-    gc_started = TRUE;
-    dprintf (2, ("bgc_suspend_EE"));
-    GCToEEInterface::SuspendEE(SUSPEND_FOR_GC_PREP);
-    gc_started = FALSE;
     set_gc_done();
-}
 #endif //MULTIPLE_HEAPS
 
-void
-gc_heap::restart_EE ()
-{
-    dprintf (2, ("restart_EE"));
-#ifdef MULTIPLE_HEAPS
+    dprintf (2, ("bgc_restart_EE"));
     GCToEEInterface::RestartEE(FALSE);
-#else
-    GCToEEInterface::RestartEE(FALSE);
-#endif //MULTIPLE_HEAPS
 }
 
 inline uint8_t* gc_heap::high_page ( heap_segment* seg, BOOL concurrent_p)
@@ -31280,7 +31279,7 @@ void gc_heap::background_sweep()
 
     if (heap_number == 0)
     {
-        restart_EE ();
+        bgc_restart_EE ();
     }
 
     FIRE_EVENT(BGC2ndConBegin);
@@ -34437,6 +34436,8 @@ GCHeap::FixAllocContext (gc_alloc_context* context, bool lockp, void* arg, void
 Object*
 GCHeap::GetContainingObject (void *pInteriorPtr, bool fCollectedGenOnly)
 {
+    assert (g_fSuspensionPending > 0);
+
     uint8_t *o = (uint8_t*)pInteriorPtr;
 
     gc_heap* hp = gc_heap::heap_of (o);
@@ -34446,7 +34447,17 @@ GCHeap::GetContainingObject (void *pInteriorPtr, bool fCollectedGenOnly)
 
     if (o >= lowest && o < highest)
     {
+        if (!gc_heap::gc_started)
+        {
+            hp->fix_allocation_contexts (FALSE);
+        }
+
         o = hp->find_object (o, lowest);
+    
+        if (!gc_heap::gc_started)
+        {
+            hp->repair_allocation_contexts (TRUE);
+        }    
     }
     else
     {
index c2f7356..f0c9d03 100644 (file)
@@ -2597,13 +2597,16 @@ protected:
     void concurrent_scan_dependent_handles (ScanContext *sc);
 
     PER_HEAP_ISOLATED
-    void suspend_EE ();
+    void suspend_EE();
 
     PER_HEAP_ISOLATED
-    void bgc_suspend_EE ();
+    void bgc_suspend_EE();
 
     PER_HEAP_ISOLATED
-    void restart_EE ();
+    void restart_EE();
+
+    PER_HEAP_ISOLATED
+    void bgc_restart_EE();
 
     PER_HEAP
     void background_verify_mark (Object*& object, ScanContext* sc, uint32_t flags);