Port GC changes from CoreRT (#7764)
authorJan Kotas <jkotas@microsoft.com>
Sat, 22 Oct 2016 05:07:29 +0000 (22:07 -0700)
committerGitHub <noreply@github.com>
Sat, 22 Oct 2016 05:07:29 +0000 (22:07 -0700)
https://github.com/dotnet/corert/pull/2064: Add back limit for maximum object size
https://github.com/dotnet/corert/pull/2061: Fix retail build break

src/gc/gc.cpp
src/gc/gccommon.cpp
src/gc/gcinterface.h
src/gc/sample/gcenv.h

index 028a9f8..b8c7b78 100644 (file)
@@ -30487,18 +30487,20 @@ CObjectHeader* gc_heap::allocate_large_object (size_t jsize, int64_t& alloc_byte
 #endif //BACKGROUND_GC
 #endif // MARK_ARRAY
 
-    // these next few lines are not strictly necessary anymore - they are here
-    // to sanity check that we didn't get asked to create an object
-    // that's too large.
     #if BIT64
-    size_t maxObjectSize = (INT64_MAX - 7 - Align(min_obj_size)); 
+    size_t maxObjectSize = (INT64_MAX - 7 - Align(min_obj_size));
     #else
-    size_t maxObjectSize = (INT32_MAX - 7 - Align(min_obj_size)); 
+    size_t maxObjectSize = (INT32_MAX - 7 - Align(min_obj_size));
     #endif
 
-    // The VM should have thrown instead of passing us an allocation
-    // request that's too large.
-    assert(jsize < maxObjectSize);
+    if (jsize >= maxObjectSize)
+    {
+        if (g_pConfig->IsGCBreakOnOOMEnabled())
+        {
+            GCToOSInterface::DebugBreak();
+        }
+        return NULL;
+    }
 
     size_t size = AlignQword (jsize);
     int align_const = get_alignment_constant (FALSE);
index 3a951cc..2e6bfce 100644 (file)
@@ -156,6 +156,7 @@ IGCHeap* InitializeGarbageCollector(IGCToCLR* clrToGC)
     assert(clrToGC != nullptr);
     g_theGCToCLR = clrToGC;
 #else
+    UNREFERENCED_PARAMETER(clrToGC);
     assert(clrToGC == nullptr);
 #endif
 
index d521dda..ac14332 100644 (file)
@@ -393,14 +393,6 @@ public:
     Allocation routines. These all call into the GC's allocator and may trigger a garbage
     collection. All allocation routines return NULL when the allocation request
     couldn't be serviced due to being out of memory.
-
-    These allocation routines should not be called with allocation requests
-    larger than:
-       32-bit  -> 0x7FFFFFE0
-       64-bit  -> 0x7FFFFFFFFFFFFFE0
-
-    It is up to the caller of the API to raise appropriate errors if the amount
-    of requested memory is too large.
     ===========================================================================
     */
 
index 94d6939..4505f1a 100644 (file)
@@ -186,8 +186,6 @@ public:
     int     GetGCTrimCommit()               const { return 0; }
     int     GetGCLOHCompactionMode()        const { return 0; }
 
-    bool    GetGCAllowVeryLargeObjects()   const { return false; }
-
     bool    GetGCConservative()             const { return true; }
 };