277
277
/* Internal use only; lock held. */
278
static void GC_remove_root_at_pos(i)
281
GC_root_size -= (GC_static_roots[i].r_end - GC_static_roots[i].r_start);
282
GC_static_roots[i].r_start = GC_static_roots[n_root_sets-1].r_start;
283
GC_static_roots[i].r_end = GC_static_roots[n_root_sets-1].r_end;
284
GC_static_roots[i].r_tmp = GC_static_roots[n_root_sets-1].r_tmp;
288
#if !defined(MSWIN32) && !defined(MSWINCE)
289
static void GC_rebuild_root_index()
293
for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0;
294
for (i = 0; i < n_root_sets; i++)
295
add_roots_to_index(GC_static_roots + i);
299
/* Internal use only; lock held. */
278
300
void GC_remove_tmp_roots()
282
304
for (i = 0; i < n_root_sets; ) {
283
305
if (GC_static_roots[i].r_tmp) {
285
(GC_static_roots[i].r_end - GC_static_roots[i].r_start);
286
GC_static_roots[i].r_start = GC_static_roots[n_root_sets-1].r_start;
287
GC_static_roots[i].r_end = GC_static_roots[n_root_sets-1].r_end;
288
GC_static_roots[i].r_tmp = GC_static_roots[n_root_sets-1].r_tmp;
306
GC_remove_root_at_pos(i);
311
#if !defined(MSWIN32) && !defined(MSWINCE)
312
GC_rebuild_root_index();
316
#if !defined(MSWIN32) && !defined(MSWINCE)
317
void GC_remove_roots(b, e)
324
GC_remove_roots_inner(b, e);
329
/* Should only be called when the lock is held */
330
void GC_remove_roots_inner(b,e)
334
for (i = 0; i < n_root_sets; ) {
335
if (GC_static_roots[i].r_start >= (ptr_t)b && GC_static_roots[i].r_end <= (ptr_t)e) {
336
GC_remove_root_at_pos(i);
294
# if !defined(MSWIN32) && !defined(MSWINCE)
298
for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0;
299
for (i = 0; i < n_root_sets; i++)
300
add_roots_to_index(GC_static_roots + i);
341
GC_rebuild_root_index();
343
#endif /* !defined(MSWIN32) && !defined(MSWINCE) */
306
345
#if defined(MSWIN32) || defined(_WIN32_WCE_EMULATION)
307
346
/* Workaround for the OS mapping and unmapping behind our back: */
506
545
void GC_mark_thread_local_free_lists();
548
void GC_cond_register_dynamic_libraries()
550
# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \
551
|| defined(PCR)) && !defined(SRC_M3)
552
GC_remove_tmp_roots();
553
if (!GC_no_dls) GC_register_dynamic_libraries();
510
560
* Call the mark routines (GC_tl_push for a single pointer, GC_push_conditional
511
561
* on groups of pointers) on every top level accessible pointer.
520
570
ptr_t cold_gc_frame;
525
576
* Next push static data. This must happen early on, since it's
526
577
* not robust against mark stack overflow.
528
/* Reregister dynamic libraries, in case one got added. */
529
# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \
530
|| defined(PCR)) && !defined(SRC_M3)
531
GC_remove_tmp_roots();
532
if (!GC_no_dls) GC_register_dynamic_libraries();
579
/* Reregister dynamic libraries, in case one got added. */
580
/* There is some argument for doing this as late as possible, */
581
/* especially on win32, where it can change asynchronously. */
582
/* In those cases, we do it here. But on other platforms, it's */
583
/* not safe with the world stopped, so we do it earlier. */
584
# if !defined(REGISTER_LIBRARIES_EARLY)
585
GC_cond_register_dynamic_libraries();
537
588
/* Mark everything in static data areas */
541
592
GC_static_roots[i].r_end, all);
595
/* Mark all free list header blocks, if those were allocated from */
596
/* the garbage collected heap. This makes sure they don't */
597
/* disappear if we are not marking from static data. It also */
598
/* saves us the trouble of scanning them, and possibly that of */
599
/* marking the freelists. */
600
for (kind = 0; kind < GC_n_kinds; kind++) {
601
GC_PTR base = GC_base(GC_obj_kinds[kind].ok_freelist);
603
GC_set_mark_bit(base);
544
607
/* Mark from GC internal roots if those might otherwise have */
545
608
/* been excluded. */
546
609
if (GC_no_dls || roots_were_cleared) {
550
613
/* Mark thread local free lists, even if their mark */
551
614
/* descriptor excludes the link field. */
615
/* If the world is not stopped, this is unsafe. It is */
616
/* also unnecessary, since we will do this again with the */
552
618
# ifdef THREAD_LOCAL_ALLOC
553
GC_mark_thread_local_free_lists();
619
if (GC_world_stopped) GC_mark_thread_local_free_lists();