summaryrefslogtreecommitdiff
path: root/src/gc
diff options
context:
space:
mode:
authorJan Vorlicek <janvorli@microsoft.com>2016-07-12 09:44:15 +0200
committerGitHub <noreply@github.com>2016-07-12 09:44:15 +0200
commit3a89fdacae800110064aaf7aa0c72456b97dcd42 (patch)
tree53c275db4d683c440fb14558147171dfe6e60892 /src/gc
parent0804d53c08804928e3b92e3c50b284453dab4944 (diff)
downloadcoreclr-3a89fdacae800110064aaf7aa0c72456b97dcd42.tar.gz
coreclr-3a89fdacae800110064aaf7aa0c72456b97dcd42.tar.bz2
coreclr-3a89fdacae800110064aaf7aa0c72456b97dcd42.zip
Fix exceptions in GC wave 2 (#6220)
I've removed blocks with PAL_TRY that were under CATCH_GC. I also had to fix contract problem in GCToEEInterface::GcStartWork that was marked as THROWS due to StubHelpers::ProcessByrefValidationList being marked as THROWS, but the StubHelpers::ProcessByrefValidationList in fact doesn't throw since it has body wrapped in EX_TRY / EX_CATCH. This also fixes a problem that started to appear after my previous exceptions fix change.
Diffstat (limited to 'src/gc')
-rw-r--r--src/gc/gc.cpp174
-rw-r--r--src/gc/gcpriv.h2
-rw-r--r--src/gc/gcscan.cpp65
3 files changed, 92 insertions, 149 deletions
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 7fd58f6cb6..ae4c55761d 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -35230,151 +35230,139 @@ GCHeap::GarbageCollectGeneration (unsigned int gen, gc_reason reason)
int gc_start = GetCycleCount32();
#endif //COUNT_CYCLES
-#if defined ( _DEBUG) && defined (CATCH_GC)
- __try
-#endif // _DEBUG && CATCH_GC
- {
#ifdef TRACE_GC
#ifdef COUNT_CYCLES
- AllocDuration += GetCycleCount32() - AllocStart;
+ AllocDuration += GetCycleCount32() - AllocStart;
#else
- AllocDuration += clock() - AllocStart;
+ AllocDuration += clock() - AllocStart;
#endif //COUNT_CYCLES
#endif //TRACE_GC
- gc_heap::g_low_memory_status = (reason == reason_lowmemory) ||
- (reason == reason_lowmemory_blocking) ||
- g_bLowMemoryFromHost;
+ gc_heap::g_low_memory_status = (reason == reason_lowmemory) ||
+ (reason == reason_lowmemory_blocking) ||
+ g_bLowMemoryFromHost;
- if (g_bLowMemoryFromHost)
- reason = reason_lowmemory_host;
+ if (g_bLowMemoryFromHost)
+ reason = reason_lowmemory_host;
- gc_trigger_reason = reason;
+ gc_trigger_reason = reason;
#ifdef MULTIPLE_HEAPS
- for (int i = 0; i < gc_heap::n_heaps; i++)
- {
- gc_heap::g_heaps[i]->reset_gc_done();
- }
+ for (int i = 0; i < gc_heap::n_heaps; i++)
+ {
+ gc_heap::g_heaps[i]->reset_gc_done();
+ }
#else
- gc_heap::reset_gc_done();
+ gc_heap::reset_gc_done();
#endif //MULTIPLE_HEAPS
- gc_heap::gc_started = TRUE;
+ gc_heap::gc_started = TRUE;
- {
- init_sync_log_stats();
+ {
+ init_sync_log_stats();
#ifndef MULTIPLE_HEAPS
- cooperative_mode = gc_heap::enable_preemptive (current_thread);
+ cooperative_mode = gc_heap::enable_preemptive (current_thread);
- dprintf (2, ("Suspending EE"));
- BEGIN_TIMING(suspend_ee_during_log);
- GCToEEInterface::SuspendEE(GCToEEInterface::SUSPEND_FOR_GC);
- END_TIMING(suspend_ee_during_log);
- gc_heap::proceed_with_gc_p = gc_heap::should_proceed_with_gc();
- gc_heap::disable_preemptive (current_thread, cooperative_mode);
- if (gc_heap::proceed_with_gc_p)
- pGenGCHeap->settings.init_mechanisms();
- else
- gc_heap::update_collection_counts_for_no_gc();
+ dprintf (2, ("Suspending EE"));
+ BEGIN_TIMING(suspend_ee_during_log);
+ GCToEEInterface::SuspendEE(GCToEEInterface::SUSPEND_FOR_GC);
+ END_TIMING(suspend_ee_during_log);
+ gc_heap::proceed_with_gc_p = gc_heap::should_proceed_with_gc();
+ gc_heap::disable_preemptive (current_thread, cooperative_mode);
+ if (gc_heap::proceed_with_gc_p)
+ pGenGCHeap->settings.init_mechanisms();
+ else
+ gc_heap::update_collection_counts_for_no_gc();
#endif //!MULTIPLE_HEAPS
- }
+ }
- // MAP_EVENT_MONITORS(EE_MONITOR_GARBAGE_COLLECTIONS, NotifyEvent(EE_EVENT_TYPE_GC_STARTED, 0));
+// MAP_EVENT_MONITORS(EE_MONITOR_GARBAGE_COLLECTIONS, NotifyEvent(EE_EVENT_TYPE_GC_STARTED, 0));
#ifdef TRACE_GC
#ifdef COUNT_CYCLES
- unsigned start;
- unsigned finish;
- start = GetCycleCount32();
+ unsigned start;
+ unsigned finish;
+ start = GetCycleCount32();
#else
- clock_t start;
- clock_t finish;
- start = clock();
+ clock_t start;
+ clock_t finish;
+ start = clock();
#endif //COUNT_CYCLES
- PromotedObjectCount = 0;
+ PromotedObjectCount = 0;
#endif //TRACE_GC
- unsigned int condemned_generation_number = gen;
+ unsigned int condemned_generation_number = gen;
- // We want to get a stack from the user thread that triggered the GC
- // instead of on the GC thread which is the case for Server GC.
- // But we are doing it for Workstation GC as well to be uniform.
- FireEtwGCTriggered((int) reason, GetClrInstanceId());
+ // We want to get a stack from the user thread that triggered the GC
+ // instead of on the GC thread which is the case for Server GC.
+ // But we are doing it for Workstation GC as well to be uniform.
+ FireEtwGCTriggered((int) reason, GetClrInstanceId());
#ifdef MULTIPLE_HEAPS
- GcCondemnedGeneration = condemned_generation_number;
-
- cooperative_mode = gc_heap::enable_preemptive (current_thread);
+ GcCondemnedGeneration = condemned_generation_number;
- BEGIN_TIMING(gc_during_log);
- gc_heap::ee_suspend_event.Set();
- gc_heap::wait_for_gc_done();
- END_TIMING(gc_during_log);
+ cooperative_mode = gc_heap::enable_preemptive (current_thread);
- gc_heap::disable_preemptive (current_thread, cooperative_mode);
+ BEGIN_TIMING(gc_during_log);
+ gc_heap::ee_suspend_event.Set();
+ gc_heap::wait_for_gc_done();
+ END_TIMING(gc_during_log);
- condemned_generation_number = GcCondemnedGeneration;
+ gc_heap::disable_preemptive (current_thread, cooperative_mode);
+
+ condemned_generation_number = GcCondemnedGeneration;
#else
- if (gc_heap::proceed_with_gc_p)
- {
- BEGIN_TIMING(gc_during_log);
- pGenGCHeap->garbage_collect (condemned_generation_number);
- END_TIMING(gc_during_log);
- }
+ if (gc_heap::proceed_with_gc_p)
+ {
+ BEGIN_TIMING(gc_during_log);
+ pGenGCHeap->garbage_collect (condemned_generation_number);
+ END_TIMING(gc_during_log);
+ }
#endif //MULTIPLE_HEAPS
#ifdef TRACE_GC
#ifdef COUNT_CYCLES
- finish = GetCycleCount32();
+ finish = GetCycleCount32();
#else
- finish = clock();
+ finish = clock();
#endif //COUNT_CYCLES
- GcDuration += finish - start;
- dprintf (3,
- ("<GC# %d> Condemned: %d, Duration: %d, total: %d Alloc Avg: %d, Small Objects:%d Large Objects:%d",
- VolatileLoad(&pGenGCHeap->settings.gc_index), condemned_generation_number,
- finish - start, GcDuration,
- AllocCount ? (AllocDuration / AllocCount) : 0,
- AllocSmallCount, AllocBigCount));
- AllocCount = 0;
- AllocDuration = 0;
+ GcDuration += finish - start;
+ dprintf (3,
+ ("<GC# %d> Condemned: %d, Duration: %d, total: %d Alloc Avg: %d, Small Objects:%d Large Objects:%d",
+ VolatileLoad(&pGenGCHeap->settings.gc_index), condemned_generation_number,
+ finish - start, GcDuration,
+ AllocCount ? (AllocDuration / AllocCount) : 0,
+ AllocSmallCount, AllocBigCount));
+ AllocCount = 0;
+ AllocDuration = 0;
#endif // TRACE_GC
#ifdef BACKGROUND_GC
- // We are deciding whether we should fire the alloc wait end event here
- // because in begin_foreground we could be calling end_foreground
- // if we need to retry.
- if (gc_heap::alloc_wait_event_p)
- {
- hpt->fire_alloc_wait_event_end (awr_fgc_wait_for_bgc);
- gc_heap::alloc_wait_event_p = FALSE;
- }
+ // We are deciding whether we should fire the alloc wait end event here
+ // because in begin_foreground we could be calling end_foreground
+ // if we need to retry.
+ if (gc_heap::alloc_wait_event_p)
+ {
+ hpt->fire_alloc_wait_event_end (awr_fgc_wait_for_bgc);
+ gc_heap::alloc_wait_event_p = FALSE;
+ }
#endif //BACKGROUND_GC
#ifndef MULTIPLE_HEAPS
#ifdef BACKGROUND_GC
- if (!gc_heap::dont_restart_ee_p)
- {
+ if (!gc_heap::dont_restart_ee_p)
+ {
#endif //BACKGROUND_GC
- BEGIN_TIMING(restart_ee_during_log);
- GCToEEInterface::RestartEE(TRUE);
- END_TIMING(restart_ee_during_log);
+ BEGIN_TIMING(restart_ee_during_log);
+ GCToEEInterface::RestartEE(TRUE);
+ END_TIMING(restart_ee_during_log);
#ifdef BACKGROUND_GC
- }
+ }
#endif //BACKGROUND_GC
#endif //!MULTIPLE_HEAPS
- }
-#if defined (_DEBUG) && defined (CATCH_GC)
- __except (CheckException(GetExceptionInformation(), NULL))
- {
- _ASSERTE(!"Exception during GarbageCollectGeneration()");
- }
-#endif // _DEBUG && CATCH_GC
-
#ifdef COUNT_CYCLES
printf ("GC: %d Time: %d\n", GcCondemnedGeneration,
GetCycleCount32() - gc_start);
diff --git a/src/gc/gcpriv.h b/src/gc/gcpriv.h
index a4305c7ac1..42ca64ce76 100644
--- a/src/gc/gcpriv.h
+++ b/src/gc/gcpriv.h
@@ -128,8 +128,6 @@ inline void FATAL_GC_ERROR()
//#define TRACE_GC //debug trace gc operation
//#define SIMPLE_DPRINTF
-//#define CATCH_GC //catches exception during GC
-
//#define TIME_GC //time allocation and garbage collection
//#define TIME_WRITE_WATCH //time GetWriteWatch and ResetWriteWatch calls
//#define COUNT_CYCLES //Use cycle counter for timing
diff --git a/src/gc/gcscan.cpp b/src/gc/gcscan.cpp
index 79ba2dc045..42989e0414 100644
--- a/src/gc/gcscan.cpp
+++ b/src/gc/gcscan.cpp
@@ -19,7 +19,6 @@
#include "gc.h"
#include "objecthandle.h"
-//#define CATCH_GC //catches exception during GC
#ifdef DACCESS_COMPILE
SVAL_IMPL_INIT(int32_t, GCScan, m_GcStructuresInvalidCnt, 1);
#else //DACCESS_COMPILE
@@ -168,20 +167,7 @@ void GCScan::GcShortWeakPtrScan(promote_func* fn, int condemned, int max_gen,
void GCScan::GcScanRoots(promote_func* fn, int condemned, int max_gen,
ScanContext* sc)
{
-#if defined ( _DEBUG) && defined (CATCH_GC)
- //note that we can't use EX_TRY because the gc_thread isn't known
- PAL_TRY
-#endif // _DEBUG && CATCH_GC
- {
- GCToEEInterface::GcScanRoots(fn, condemned, max_gen, sc);
- }
-#if defined ( _DEBUG) && defined (CATCH_GC)
- PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- _ASSERTE (!"We got an exception during scan roots");
- }
- PAL_ENDTRY
-#endif //_DEBUG
+ GCToEEInterface::GcScanRoots(fn, condemned, max_gen, sc);
}
/*
@@ -192,33 +178,18 @@ void GCScan::GcScanRoots(promote_func* fn, int condemned, int max_gen,
void GCScan::GcScanHandles (promote_func* fn, int condemned, int max_gen,
ScanContext* sc)
{
-
-#if defined ( _DEBUG) && defined (CATCH_GC)
- //note that we can't use EX_TRY because the gc_thread isn't known
- PAL_TRY
-#endif // _DEBUG && CATCH_GC
+ STRESS_LOG1(LF_GC|LF_GCROOTS, LL_INFO10, "GcScanHandles (Promotion Phase = %d)\n", sc->promotion);
+ if (sc->promotion)
{
- STRESS_LOG1(LF_GC|LF_GCROOTS, LL_INFO10, "GcScanHandles (Promotion Phase = %d)\n", sc->promotion);
- if (sc->promotion)
- {
- Ref_TracePinningRoots(condemned, max_gen, sc, fn);
- Ref_TraceNormalRoots(condemned, max_gen, sc, fn);
- }
- else
- {
- Ref_UpdatePointers(condemned, max_gen, sc, fn);
- Ref_UpdatePinnedPointers(condemned, max_gen, sc, fn);
- Ref_ScanDependentHandlesForRelocation(condemned, max_gen, sc, fn);
- }
+ Ref_TracePinningRoots(condemned, max_gen, sc, fn);
+ Ref_TraceNormalRoots(condemned, max_gen, sc, fn);
}
-
-#if defined ( _DEBUG) && defined (CATCH_GC)
- PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ else
{
- _ASSERTE (!"We got an exception during scan roots");
+ Ref_UpdatePointers(condemned, max_gen, sc, fn);
+ Ref_UpdatePinnedPointers(condemned, max_gen, sc, fn);
+ Ref_ScanDependentHandlesForRelocation(condemned, max_gen, sc, fn);
}
- PAL_ENDTRY
-#endif //_DEBUG
}
@@ -232,22 +203,8 @@ void GCScan::GcScanHandlesForProfilerAndETW (int max_gen, ScanContext* sc)
{
LIMITED_METHOD_CONTRACT;
-#if defined ( _DEBUG) && defined (CATCH_GC)
- //note that we can't use EX_TRY because the gc_thread isn't known
- PAL_TRY
-#endif // _DEBUG && CATCH_GC
- {
- LOG((LF_GC|LF_GCROOTS, LL_INFO10, "Profiler Root Scan Phase, Handles\n"));
- Ref_ScanPointersForProfilerAndETW(max_gen, (uintptr_t)sc);
- }
-
-#if defined ( _DEBUG) && defined (CATCH_GC)
- PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- _ASSERTE (!"We got an exception during scan roots for the profiler");
- }
- PAL_ENDTRY
-#endif //_DEBUG
+ LOG((LF_GC|LF_GCROOTS, LL_INFO10, "Profiler Root Scan Phase, Handles\n"));
+ Ref_ScanPointersForProfilerAndETW(max_gen, (uintptr_t)sc);
}
/*