From: Jan Kotas Date: Sat, 22 Oct 2016 05:07:29 +0000 (-0700) Subject: Port GC changes from CoreRT (#7764) X-Git-Tag: accepted/tizen/base/20180629.140029~3270 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0ae251eed00dfb5f5dc8dd3769c15c300c7502c;p=platform%2Fupstream%2Fcoreclr.git Port GC changes from CoreRT (#7764) 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 --- diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index 028a9f8..b8c7b78 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -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); diff --git a/src/gc/gccommon.cpp b/src/gc/gccommon.cpp index 3a951cc..2e6bfce 100644 --- a/src/gc/gccommon.cpp +++ b/src/gc/gccommon.cpp @@ -156,6 +156,7 @@ IGCHeap* InitializeGarbageCollector(IGCToCLR* clrToGC) assert(clrToGC != nullptr); g_theGCToCLR = clrToGC; #else + UNREFERENCED_PARAMETER(clrToGC); assert(clrToGC == nullptr); #endif diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h index d521dda..ac14332 100644 --- a/src/gc/gcinterface.h +++ b/src/gc/gcinterface.h @@ -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. =========================================================================== */ diff --git a/src/gc/sample/gcenv.h b/src/gc/sample/gcenv.h index 94d6939..4505f1a 100644 --- a/src/gc/sample/gcenv.h +++ b/src/gc/sample/gcenv.h @@ -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; } };