Ticket #5909: evac.patch

File evac.patch, 1.7 KB (added by akio, 15 months ago)
  • rts/sm/Evac.c

    diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c
    index 4dfbad7..0b78e42 100644
    a b StgWord64 whitehole_spin = 0; 
    3535#define HEAP_ALLOCED_GC(p) HEAP_ALLOCED(p) 
    3636#endif 
    3737 
    38 #if !defined(PARALLEL_GC) 
     38#if !defined(PARALLEL_GC) || defined(PROFILING) 
    3939#define copy_tag_nolock(p, info, src, size, stp, tag) \ 
    4040        copy_tag(p, info, src, size, stp, tag) 
    4141#endif 
    copy_tag(StgClosure **p, const StgInfoTable *info, 
    113113        const StgInfoTable *new_info; 
    114114        new_info = (const StgInfoTable *)cas((StgPtr)&src->header.info, (W_)info, MK_FORWARDING_PTR(to)); 
    115115        if (new_info != info) { 
     116#ifdef PROFILING 
     117            // Another thread is workning on this object. We might have copied 
     118            // LDVW(from) after that thread used SET_EVACUAEE_FOR_LDV to 
     119            // modify it. This would confuse the retainer profiler, so we 
     120            // reset the field here. 
     121            LDVW(to) = 0; 
     122#endif 
    116123            return evacuate(p); // does the failed_to_evac stuff 
    117124        } else { 
    118125            *p = TAG_CLOSURE(tag,(StgClosure*)to); 
    copy_tag(StgClosure **p, const StgInfoTable *info, 
    126133#ifdef PROFILING 
    127134    // We store the size of the just evacuated object in the LDV word so that 
    128135    // the profiler can guess the position of the next object later. 
     136    // This is safe only if we are sure that no other thread evacuates 
     137    // the object again, so we cannot use copy_tag_nolock when PROFILING is set. 
    129138    SET_EVACUAEE_FOR_LDV(from, size); 
    130139#endif 
    131140} 
    132141 
    133 #if defined(PARALLEL_GC) 
     142#if defined(PARALLEL_GC) && !defined(PROFILING) 
    134143STATIC_INLINE void 
    135144copy_tag_nolock(StgClosure **p, const StgInfoTable *info,  
    136145         StgClosure *src, nat size, nat gen_no, StgWord tag)