static uint64_t get_rand()
{
- x = (314159269*x+278281) & 0x7FFFFFFF;
- return x;
+ x = (314159269*x+278281) & 0x7FFFFFFF;
+ return x;
}
// obtain random number in the range 0 .. r-1
static uint64_t get_rand(uint64_t r) {
- // require r >= 0
- uint64_t x = (uint64_t)((get_rand() * r) >> 31);
- return x;
+ // require r >= 0
+ uint64_t x = (uint64_t)((get_rand() * r) >> 31);
+ return x;
}
};
#endif //BACKGROUND_GC
#endif //DACCESS_COMPILE
-
-#if defined(COUNT_CYCLES)
-#ifdef _MSC_VER
-#pragma warning(disable:4035)
-#endif //_MSC_VER
-
-static
-unsigned GetCycleCount32() // enough for about 40 seconds
-{
-__asm push EDX
-__asm _emit 0x0F
-__asm _emit 0x31
-__asm pop EDX
-};
-
-#pragma warning(default:4035)
-
-#endif //COUNT_CYCLES
-
-#ifdef TIME_GC
-int mark_time, plan_time, sweep_time, reloc_time, compact_time;
-#endif //TIME_GC
-
#ifndef MULTIPLE_HEAPS
#endif // MULTIPLE_HEAPS
uint8_t* g_addresses [array_size+2]; // to get around the bug in GetWriteWatch
-#ifdef TIME_WRITE_WATCH
-static unsigned int tot_cycles = 0;
-#endif //TIME_WRITE_WATCH
-
#ifdef CARD_BUNDLE
inline void gc_heap::verify_card_bundle_bits_set(size_t first_card_word, size_t last_card_word)
if (base_address < high_address)
{
region_size = high_address - base_address;
-
-#ifdef TIME_WRITE_WATCH
- unsigned int time_start = GetCycleCount32();
-#endif //TIME_WRITE_WATCH
dprintf (3, ("h%d: soh ww: [%Ix(%Id)", heap_number, (size_t)base_address, region_size));
//reset_ww_by_chunk (base_address, region_size);
reset_write_watch_for_gc_heap(base_address, region_size);
-
-#ifdef TIME_WRITE_WATCH
- unsigned int time_stop = GetCycleCount32();
- tot_cycles += time_stop - time_start;
- printf ("ResetWriteWatch Duration: %d, total: %d\n",
- time_stop - time_start, tot_cycles);
-#endif //TIME_WRITE_WATCH
-
switch_on_reset (concurrent_p, &reset_size, region_size);
}
if (base_address < high_address)
{
region_size = high_address - base_address;
-
-#ifdef TIME_WRITE_WATCH
- unsigned int time_start = GetCycleCount32();
-#endif //TIME_WRITE_WATCH
dprintf (3, ("h%d: loh ww: [%Ix(%Id)", heap_number, (size_t)base_address, region_size));
//reset_ww_by_chunk (base_address, region_size);
reset_write_watch_for_gc_heap(base_address, region_size);
-
-#ifdef TIME_WRITE_WATCH
- unsigned int time_stop = GetCycleCount32();
- tot_cycles += time_stop - time_start;
- printf ("ResetWriteWatch Duration: %d, total: %d\n",
- time_stop - time_start, tot_cycles);
-#endif //TIME_WRITE_WATCH
-
switch_on_reset (concurrent_p, &reset_size, region_size);
}
concurrent_print_time_delta ("CRWW loh");
}
-
-#ifdef DEBUG_WRITE_WATCH
- debug_write_watch = (uint8_t**)~0;
-#endif //DEBUG_WRITE_WATCH
}
#endif //WRITE_WATCH
assert (settings.concurrent == (uint32_t)(bgc_thread_id.IsCurrentThread()));
#endif //BACKGROUND_GC
-#ifdef TIME_GC
- mark_time = plan_time = reloc_time = compact_time = sweep_time = 0;
-#endif //TIME_GC
-
verify_soh_segment_list();
int n = settings.condemned_generation;
dd_gc_elapsed_time(dynamic_data_of(settings.condemned_generation)));
#endif // GC_STATS
-#ifdef TIME_GC
- fprintf (stdout, "%d,%d,%d,%d,%d,%d\n",
- n, mark_time, plan_time, reloc_time, compact_time, sweep_time);
-#endif //TIME_GC
-
#ifdef BACKGROUND_GC
assert (settings.concurrent == (uint32_t)(bgc_thread_id.IsCurrentThread()));
#endif //BACKGROUND_GC
#endif //BACKGROUND_GC
#endif //MULTIPLE_HEAPS
- BOOL should_evaluate_elevation = TRUE;
- BOOL should_do_blocking_collection = FALSE;
+ BOOL should_evaluate_elevation = TRUE;
+ BOOL should_do_blocking_collection = FALSE;
#ifdef MULTIPLE_HEAPS
- int gen_max = condemned_generation_num;
- for (int i = 0; i < n_heaps; i++)
- {
- if (gen_max < g_heaps[i]->condemned_generation_num)
- gen_max = g_heaps[i]->condemned_generation_num;
- if (should_evaluate_elevation && !(g_heaps[i]->elevation_requested))
- should_evaluate_elevation = FALSE;
- if ((!should_do_blocking_collection) && (g_heaps[i]->blocking_collection))
- should_do_blocking_collection = TRUE;
- }
+ int gen_max = condemned_generation_num;
+ for (int i = 0; i < n_heaps; i++)
+ {
+ if (gen_max < g_heaps[i]->condemned_generation_num)
+ gen_max = g_heaps[i]->condemned_generation_num;
+ if (should_evaluate_elevation && !(g_heaps[i]->elevation_requested))
+ should_evaluate_elevation = FALSE;
+ if ((!should_do_blocking_collection) && (g_heaps[i]->blocking_collection))
+ should_do_blocking_collection = TRUE;
+ }
- settings.condemned_generation = gen_max;
+ settings.condemned_generation = gen_max;
#else //MULTIPLE_HEAPS
- settings.condemned_generation = generation_to_condemn (n,
- &blocking_collection,
- &elevation_requested,
- FALSE);
- should_evaluate_elevation = elevation_requested;
- should_do_blocking_collection = blocking_collection;
-#endif //MULTIPLE_HEAPS
-
- settings.condemned_generation = joined_generation_to_condemn (
- should_evaluate_elevation,
- n,
- settings.condemned_generation,
- &should_do_blocking_collection
- STRESS_HEAP_ARG(n)
- );
+ settings.condemned_generation = generation_to_condemn (n,
+ &blocking_collection,
+ &elevation_requested,
+ FALSE);
+ should_evaluate_elevation = elevation_requested;
+ should_do_blocking_collection = blocking_collection;
+#endif //MULTIPLE_HEAPS
+
+ settings.condemned_generation = joined_generation_to_condemn (
+ should_evaluate_elevation,
+ n,
+ settings.condemned_generation,
+ &should_do_blocking_collection
+ STRESS_HEAP_ARG(n)
+ );
- STRESS_LOG1(LF_GCROOTS|LF_GC|LF_GCALLOC, LL_INFO10,
- "condemned generation num: %d\n", settings.condemned_generation);
+ STRESS_LOG1(LF_GCROOTS|LF_GC|LF_GCALLOC, LL_INFO10,
+ "condemned generation num: %d\n", settings.condemned_generation);
- record_gcs_during_no_gc();
+ record_gcs_during_no_gc();
- if (settings.condemned_generation > 1)
- settings.promotion = TRUE;
+ if (settings.condemned_generation > 1)
+ settings.promotion = TRUE;
#ifdef HEAP_ANALYZE
- // At this point we've decided what generation is condemned
- // See if we've been requested to analyze survivors after the mark phase
- if (GCToEEInterface::AnalyzeSurvivorsRequested(settings.condemned_generation))
- {
- heap_analyze_enabled = TRUE;
- }
+ // At this point we've decided what generation is condemned
+ // See if we've been requested to analyze survivors after the mark phase
+ if (GCToEEInterface::AnalyzeSurvivorsRequested(settings.condemned_generation))
+ {
+ heap_analyze_enabled = TRUE;
+ }
#endif // HEAP_ANALYZE
GCToEEInterface::DiagGCStart(settings.condemned_generation, settings.reason == reason_induced);
//we are finished with this object
*place = 0;
*(place+1) = 0;
-
+
more_to_do:;
}
else
dprintf(2,("---- Mark Phase condemning %d ----", condemned_gen_number));
BOOL full_p = (condemned_gen_number == max_generation);
-#ifdef TIME_GC
- unsigned start;
- unsigned finish;
- start = GetCycleCount32();
-#endif //TIME_GC
-
int gen_to_init = condemned_gen_number;
if (condemned_gen_number == max_generation)
{
promoted_bytes (heap_number) -= promoted_bytes_live;
-#ifdef TIME_GC
- finish = GetCycleCount32();
- mark_time = finish - start;
-#endif //TIME_GC
-
dprintf(2,("---- End of mark phase ----"));
}
assert (settings.concurrent == FALSE);
// %type% category = quote (plan);
-#ifdef TIME_GC
- unsigned start;
- unsigned finish;
- start = GetCycleCount32();
-#endif //TIME_GC
dprintf (2,("---- Plan Phase ---- Condemned generation %d, promotion: %d",
condemned_gen_number, settings.promotion ? 1 : 0));
dprintf (2,("Fragmentation: %Id", fragmentation));
dprintf (2,("---- End of Plan phase ----"));
-#ifdef TIME_GC
- finish = GetCycleCount32();
- plan_time = finish - start;
-#endif //TIME_GC
-
// We may update write barrier code. We assume here EE has been suspended if we are on a GC thread.
assert(IsGCInProgress());
void gc_heap::make_free_lists (int condemned_gen_number)
{
-#ifdef TIME_GC
- unsigned start;
- unsigned finish;
- start = GetCycleCount32();
-#endif //TIME_GC
-
//Promotion has to happen in sweep case.
assert (settings.promotion);
uint8_t* start2 = generation_allocation_start (youngest_generation);
alloc_allocated = start2 + Align (size (start2));
}
-
-#ifdef TIME_GC
- finish = GetCycleCount32();
- sweep_time = finish - start;
-#endif //TIME_GC
}
void gc_heap::make_free_list_in_brick (uint8_t* tree, make_free_args* args)
sc.promotion = FALSE;
sc.concurrent = FALSE;
-
-#ifdef TIME_GC
- unsigned start;
- unsigned finish;
- start = GetCycleCount32();
-#endif //TIME_GC
-
// %type% category = quote (relocate);
dprintf (2,("---- Relocate phase -----"));
//join all threads to make sure they are synchronized
dprintf(3, ("Joining after end of relocation"));
gc_t_join.join(this, gc_join_relocate_phase_done);
-
#endif //MULTIPLE_HEAPS
-#ifdef TIME_GC
- finish = GetCycleCount32();
- reloc_time = finish - start;
-#endif //TIME_GC
-
dprintf(2,( "---- End of Relocate phase ----"));
}
BOOL clear_cards)
{
// %type% category = quote (compact);
-#ifdef TIME_GC
- unsigned start;
- unsigned finish;
- start = GetCycleCount32();
-#endif //TIME_GC
generation* condemned_gen = generation_of (condemned_gen_number);
uint8_t* start_address = first_condemned_address;
size_t current_brick = brick_of (start_address);
recover_saved_pinned_info();
-#ifdef TIME_GC
- finish = GetCycleCount32();
- compact_time = finish - start;
-#endif //TIME_GC
-
concurrent_print_time_delta ("compact end");
dprintf(2,("---- End of Compact phase ----"));
assert (settings.concurrent);
-#ifdef TIME_GC
- unsigned start;
- unsigned finish;
- start = GetCycleCount32();
-#endif //TIME_GC
-
if (gen0_must_clear_bricks > 0)
gen0_must_clear_bricks--;
// we can't let the user code consume the left over parts in these alloc contexts.
repair_allocation_contexts (FALSE);
-#ifdef TIME_GC
- finish = GetCycleCount32();
- mark_time = finish - start;
-#endif //TIME_GC
-
dprintf (2, ("end of bgc mark: gen2 free list space: %d, free obj space: %d",
generation_free_list_space (generation_of (max_generation)),
generation_free_obj_space (generation_of (max_generation))));
// our caller should still be in one of the previous segments
#ifdef _DEBUG
for (heap_segment* cur_seg = seg; cur_seg != segment; cur_seg = heap_segment_next_in_range(cur_seg))
- {
+ {
assert(cur_seg);
}
#endif //_DEBUG
return !!hs;
}
-#ifdef STRESS_PINNING
-static n_promote = 0;
-#endif //STRESS_PINNING
// promote an object
void GCHeap::Promote(Object** ppObject, ScanContext* sc, uint32_t flags)
{
Object* newAlloc = NULL;
-#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- AllocStart = GetCycleCount32();
- unsigned finish;
-#elif defined(ENABLE_INSTRUMENTATION)
- unsigned AllocStart = GetInstLogTime();
- unsigned finish;
-#endif //COUNT_CYCLES
-#endif //TRACE_GC
-
if (size < loh_size_threshold)
{
#ifdef TRACE_GC
CHECK_ALLOC_AND_POSSIBLY_REGISTER_FOR_FINALIZATION(newAlloc, size, flags & GC_ALLOC_FINALIZE);
#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- finish = GetCycleCount32();
- AllocDuration += finish - AllocStart;
-#elif defined(ENABLE_INSTRUMENTATION)
- finish = GetInstLogTime();
- AllocDuration += finish - AllocStart;
-#endif //COUNT_CYCLES
AllocCount++;
#endif //TRACE_GC
return newAlloc;
Object* newAlloc = NULL;
-#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- AllocStart = GetCycleCount32();
- unsigned finish;
-#elif defined(ENABLE_INSTRUMENTATION)
- unsigned AllocStart = GetInstLogTime();
- unsigned finish;
-#endif //COUNT_CYCLES
-#endif //TRACE_GC
-
#ifdef MULTIPLE_HEAPS
//take the first heap....
gc_heap* hp = gc_heap::g_heaps[0];
CHECK_ALLOC_AND_POSSIBLY_REGISTER_FOR_FINALIZATION(newAlloc, size, flags & GC_ALLOC_FINALIZE);
#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- finish = GetCycleCount32();
- AllocDuration += finish - AllocStart;
-#elif defined(ENABLE_INSTRUMENTATION)
- finish = GetInstLogTime();
- AllocDuration += finish - AllocStart;
-#endif //COUNT_CYCLES
AllocCount++;
#endif //TRACE_GC
return newAlloc;
Object* newAlloc = NULL;
alloc_context* acontext = static_cast<alloc_context*>(context);
-#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- AllocStart = GetCycleCount32();
- unsigned finish;
-#elif defined(ENABLE_INSTRUMENTATION)
- unsigned AllocStart = GetInstLogTime();
- unsigned finish;
-#endif //COUNT_CYCLES
-#endif //TRACE_GC
-
#ifdef MULTIPLE_HEAPS
if (acontext->get_alloc_heap() == 0)
{
CHECK_ALLOC_AND_POSSIBLY_REGISTER_FOR_FINALIZATION(newAlloc, size, flags & GC_ALLOC_FINALIZE);
#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- finish = GetCycleCount32();
- AllocDuration += finish - AllocStart;
-#elif defined(ENABLE_INSTRUMENTATION)
- finish = GetInstLogTime();
- AllocDuration += finish - AllocStart;
-#endif //COUNT_CYCLES
AllocCount++;
#endif //TRACE_GC
return newAlloc;
}
#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- AllocStart = GetCycleCount32();
-#else
AllocStart = GCToOSInterface::QueryPerformanceCounter();
-#endif //COUNT_CYCLES
#endif //TRACE_GC
#ifdef MULTIPLE_HEAPS
}
}
-#ifdef COUNT_CYCLES
- int gc_start = GetCycleCount32();
-#endif //COUNT_CYCLES
-
#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- AllocDuration += GetCycleCount32() - AllocStart;
-#else
AllocDuration += GCToOSInterface::QueryPerformanceCounter() - AllocStart;
-#endif //COUNT_CYCLES
#endif //TRACE_GC
gc_heap::g_low_memory_status = (reason == reason_lowmemory) ||
// 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();
-#else
int64_t start;
int64_t finish;
start = GCToOSInterface::QueryPerformanceCounter();
-#endif //COUNT_CYCLES
PromotedObjectCount = 0;
#endif //TRACE_GC
condemned_generation_number = GcCondemnedGeneration;
#else
- if (gc_heap::proceed_with_gc_p)
+ if (gc_heap::proceed_with_gc_p)
+ {
+ BEGIN_TIMING(gc_during_log);
+ pGenGCHeap->garbage_collect (condemned_generation_number);
+ if (gc_heap::pm_trigger_full_gc)
{
- BEGIN_TIMING(gc_during_log);
- pGenGCHeap->garbage_collect (condemned_generation_number);
- if (gc_heap::pm_trigger_full_gc)
- {
- pGenGCHeap->garbage_collect_pm_full_gc();
- }
- END_TIMING(gc_during_log);
+ pGenGCHeap->garbage_collect_pm_full_gc();
}
+ END_TIMING(gc_during_log);
+ }
#endif //MULTIPLE_HEAPS
#ifdef TRACE_GC
-#ifdef COUNT_CYCLES
- finish = GetCycleCount32();
-#else
finish = GCToOSInterface::QueryPerformanceCounter();
-#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",
#endif //BACKGROUND_GC
#endif //!MULTIPLE_HEAPS
-#ifdef COUNT_CYCLES
- printf ("GC: %d Time: %d\n", GcCondemnedGeneration,
- GetCycleCount32() - gc_start);
-#endif //COUNT_CYCLES
-
#ifndef MULTIPLE_HEAPS
process_sync_log_stats();
gc_heap::gc_started = FALSE;