Exemple #1
0
inline void TimerBase::checkConsistency() const
{
    // Timers should be in the heap if and only if they have a non-zero next fire time.
    ASSERT(inHeap() == (m_nextFireTime != 0));
    if (inHeap())
        checkHeapIndex();
}
Exemple #2
0
/***
 * Prints the entire heap. Not currently used but useful for
 * debugging.
 ***/
void dumpHeap() {
  int i = 0;
  printf("Address   Contents\n");
  while (i<freeHeap) {
    int* start = heap+i;
    int* tag   = (int*)(*start);
    int  size  = *(tag - 1);
    int  isData = *(tag - 2);
    int* name  = (int *) *(tag - 3);
    i          = i + size + 1;
    if(isData)
      printf("%08x: [(%s)", start, name);
    else
      printf("%08x: [%08x ", start, *tag);

    while (size>0) {
      start++;
      if(inHeap(start))
        printf(" %08x", *start);
      else {
        // start - address of heap object
        // *start - heap object
        // **start - address stored at head of heap object
        // *** - info table about object
        tag = ((int *)*((int *) *start));
        name = (int *) *(tag - 3);
        printf(" %s", name);
      }
      size--;
    }
    printf("]\n");
  }
}
static inline void
flipRootLoc(int curGCType, ploc_t root)
{
  ptr_t primary = *root;
  if ((curGCType == Minor && inHeap(primary,nursery)) ||
      (curGCType == Major && inHeap(primary,fromSpace))) {
    ptr_t replica = (ptr_t) primary[-1];
    *root = replica;
  }
  else {
    fastAssert(IsGlobalData(primary) || 
	       IsTagData(primary) ||
	       inHeap(primary,(curGCType == Minor) ? fromSpace : toSpace) ||   /* Already flipped */
	       inHeap(primary,largeSpace));
  }
}
Exemple #4
0
inline void TimerBase::heapInsert()
{
    ASSERT(!inHeap());
    timerHeap().append(this);
    m_heapIndex = timerHeap().size() - 1;
    heapDecreaseKey();
}
Exemple #5
0
int
inHeaps(ptr_t v, Heap_t** legalHeaps, Bitmap_t** legalStarts)
{
	int i;
	Heap_t* heap;
	Bitmap_t* starts;
	int wordOffset;
	int validOffset;

	if(legalHeaps==NULL)	/* no check is performed */
		return 1;
	for(i=0; (heap = legalHeaps[i]) != NULL; i++){
		if(inHeap(v,heap)){
			if(legalStarts==NULL || (starts = legalStarts[i]) == NULL)
				return 1;
			wordOffset = ((mem_t)v) - heap->bottom;
			validOffset = IsSet(starts, wordOffset);
			if(0 && !validOffset)
				trace_error("%lx invalid wordOffset %d",
					(long)v, wordOffset);
			return validOffset;
		}
	}
	return 0;
}
Exemple #6
0
	void heapify ( Rank n )//Floyd建堆算法
	{
		for ( int i = lastInternal ( n ); inHeap ( n, i ); i-- ) //自底而上,依次
		{
			percolateDown ( n, i ); //下滤各内部节点
		}
	}
Exemple #7
0
static logical saneList(heapPo H, listPo l) {
  if (inHeap(H, (termPo) l)) {
    basePo b = C_BASE(l->base);
    if (inHeap(H, (termPo) b)) {
      if (inHeap(H, (termPo) &b->els[b->max - 1])) {
        if (l->start >= b->min) {
          if (l->start + l->length <= b->max) {
            if (b->max >= b->min) {
              return b->length >= 0;
            }
          }
        }
      }
    }
  }
  return False;
}
Exemple #8
0
TimerBase::~TimerBase()
{
    stop();
    ASSERT(!inHeap());
#ifndef NDEBUG
    m_wasDeleted = true;
#endif
}
Exemple #9
0
void mark(void *p) {
	int *val = (int *) p;
	if (!inHeap(val)) {
		return;
	}
	int *pointer = getHeader(p);
	if (isMarked(pointer)) return;
	if (inHeap(val)) {
		//printf("%p\n",pointer);
		*pointer = (*pointer) + 2;
		while (pointer != nextBlock(pointer)) {
		pointer++;
		if (inHeap(pointer))
			mark(pointer);
		}
	}
}
Exemple #10
0
inline void TimerBase::heapInsert()
{
    ASSERT(!inHeap());
    if (!timerHeap)
        timerHeap = new Vector<TimerBase*>;
    timerHeap->append(this);
    m_heapIndex = timerHeap->size() - 1;
    heapDecreaseKey();
}
Exemple #11
0
void TimerBase::stop()
{
    m_repeatInterval = 0;
    setNextFireTime(0);

    ASSERT(m_nextFireTime == 0);
    ASSERT(m_repeatInterval == 0);
    ASSERT(!inHeap());
}
Exemple #12
0
int
inSomeHeap(ptr_t v)
{
	int i;
	for (i=0; i < NumHeap; i++) {
		if (Heaps[i].valid && Heaps[i].id==i && inHeap(v, &Heaps[i]))
			return 1;
	}
	return 0;
}
Exemple #13
0
void TimerBase::stop()
{
    ASSERT(canAccessThreadLocalDataForThread(m_thread));

    m_repeatInterval = 0;
    setNextFireTime(0);

    ASSERT(m_nextFireTime == 0);
    ASSERT(m_repeatInterval == 0);
    ASSERT(!inHeap());
}
Exemple #14
0
void TimerBase::stop()
{
    ASSERT(m_thread == currentThread());

    m_repeatInterval = 0;
    setNextFireTime(0);

    ASSERT(m_nextFireTime == 0);
    ASSERT(m_repeatInterval == 0);
    ASSERT(!inHeap());
}
void TimerBase::stop()
{
    ASSERT(m_thread == currentThread() || (isMainThread() || pthread_main_np()) && WebCoreWebThreadIsLockedOrDisabled());

    m_repeatInterval = 0;
    setNextFireTime(0);

    ASSERT(m_nextFireTime == 0);
    ASSERT(m_repeatInterval == 0);
    ASSERT(!inHeap());
}
Exemple #16
0
void sweepPhase() {
  printf("\nsweeping ...\n");
  word * block = heap;
  while(inHeap(block)) {
    int length = Length(block[0]);
    // Avoid zero length orphans
    if (length > 0) {
      sweepBlock(block);
    }
    block += length + 1;
  }
}
Exemple #17
0
/***
 * Prints heap objects for the value given. Tags are recognized and
 * their names are printed. All pointers in the object are followed
 * until a tag is found.
 **/
void dumpValue(int * start) {
  
  int* tag   = (int*)(*start);
  int  size  = *(tag - 1);
  int  isData = *(tag - 2);
  int* name  = (int *) *(tag - 3);

  int * k = start;
  int j = size;
  while(j>0) {
    k++;
    if(inHeap(k))
      dumpValue((int *)*k);
    j--;
  }

  if(isData)
    printf("%08x: [(%s)", start, name);
  else
    printf("%08x: [%08x ", start, *tag);
  
  while (size>0) {
    start++;
    if(inHeap(start))
      printf(" %08x", *start);
    else {
      // start - address of heap object
      // *start - heap object
      // **start - address stored at head of heap object
      // *** - info table about object
      tag = ((int *)*((int *) *start));
      name = (int *) *(tag - 3);
      printf(" %s", name);
    }
    size--;
  }
  printf("]\n");
}
Exemple #18
0
bool TimerBase::hasValidHeapPosition() const
{
    ASSERT(m_nextFireTime);
    if (!inHeap())
        return false;
    // Check if the heap property still holds with the new fire time. If it does we don't need to do anything.
    // This assumes that the STL heap is a standard binary heap. In an unlikely event it is not, the assertions
    // in updateHeapIfNeeded() will get hit.
    const Vector<TimerBase*>& heap = timerHeap();
    if (!parentHeapPropertyHolds(this, heap, m_heapIndex))
        return false;
    unsigned childIndex1 = 2 * m_heapIndex + 1;
    unsigned childIndex2 = childIndex1 + 1;
    return childHeapPropertyHolds(this, heap, childIndex1) && childHeapPropertyHolds(this, heap, childIndex2);
}
Exemple #19
0
/***************************
 ***************  Exercise 2
****************************/
void mark(word* block) {
  // Paint grey to signal unfinished business
  block[0] = Paint(block[0], Grey);
  int n;
  int length = Length(block[0]);

  for (n = 1; n <= length; n++) {
    word * child = block[n];
    if (inHeap(child) && Color(child[0]) != Grey) {
      mark(child);
    }
  }
  // Paint Black to signal we're done
  block[0] = Paint(block[0], Black);
}
Exemple #20
0
void gc() {
	int *end = (int *) stackBottom();
	int x = 3;
	int *p = &x;
	//printf("address of end is: %p\n",end);
	//printf("address of p + 1 is: %p\n",p+1);
	while (p != end) {
		if (inHeap(p)) {
			mark(p);
		}
		//printf("Address of p is: %p\n",p);
		p++;
	}
	//printf("Address of first block is: %p\n",firstBlock());
	//printf("Address of last block is: %p\n",lastBlock());
	sweep();
}
Exemple #21
0
void TimerBase::updateHeapIfNeeded(double oldTime)
{
    if (m_nextFireTime && hasValidHeapPosition())
        return;
#if ENABLE(ASSERT)
    int oldHeapIndex = m_heapIndex;
#endif
    if (!oldTime)
        heapInsert();
    else if (!m_nextFireTime)
        heapDelete();
    else if (m_nextFireTime < oldTime)
        heapDecreaseKey();
    else
        heapIncreaseKey();
    ASSERT(m_heapIndex != oldHeapIndex);
    ASSERT(!inHeap() || hasValidHeapPosition());
}
/* checkheap: Returns 0 if no errors were found, 
 * otherwise returns the error
 */
int mm_checkheap(int verbose) {

    char *firstList = heap_listp + DSIZE;
    char *lastList = firstList + (LISTNUM-1) * DSIZE;
    char *curBlock = heap_listp + DSIZE;    
    size_t size = getSize(getHeader(curBlock)); 
    int freeCountHeap = 0;
    int freeCountList = 0;
    char *nextFreePtr;
    char *list;
    char *ptr;
    int  s,a;    
    size_t prevAlloc;

    verbose = verbose;

    /* check alignment padding*/
    if (get(mem_heap_lo()) != 0) {
        printf("Alignment padding error!\n");
    }

    /* check prologue */
    if (!getAlloc(getHeader(heap_listp+DSIZE))) {
        printf("Prologue error!\n");
    }

    
    /*     Check the heap    */
    while (size != 0){

        // Check whether the block is in heap
        if (!inHeap(curBlock)){
            dbg_printf("Block %p is not in the heap\n", curBlock);
        }

        // Check each blk's address alignment
        if (!aligned(curBlock)) {
            dbg_printf("Block %p is not aligned.\n", curBlock);
            exit(0);
        }
       
       
        if (!getAlloc(getHeader(curBlock))){
            freeCountHeap ++;
            // Check each blk's header and footer
            s = (getSize(getHeader(curBlock)) == getSize(getFooter(curBlock)));
            a = (getAlloc(getHeader(curBlock)) == getAlloc(getFooter(curBlock)));
            if (!s || !a) {
                dbg_printf("Header&Footer does not match in %p\n", curBlock);
            }

            // Check coalescing
            prevAlloc = getPrevAlloc(getHeader(curBlock));
	    if (!prevAlloc){
                dbg_printf("Coalescing error! \n");
            }

        }
        curBlock = nextBlock(curBlock);
        size = getSize(getHeader(curBlock));
    }



    /*     Check the free list     */
    for (list = firstList; list != (char *)lastList + DSIZE; 
        list = (char *)list + DSIZE){              
        for (ptr = nextFree(list); ptr != list; ptr = nextFree(ptr)){

            // Check the free list node is in heap
	    if (!inHeap(ptr)){
                dbg_printf("list node %p is not in the heap\n", ptr);
            }

            freeCountList ++;
            nextFreePtr = nextFree(ptr);

            // Check all next/prev pointers are consistent             
            if (prevFree(nextFreePtr) != (ptr)){
		dbg_printf("next/prev pointers is not consistent!\n");
	    }
                             	
        }
    }

    // Check free blocks by iterating thru every blk and traversing
    // free list by pointers and see if they match.
    if (freeCountHeap != freeCountList){
        dbg_printf("Free block count does not match!\n");
    }

    return 0;
}
void GCRelease_GenConc(Proc_t *proc)
{
  mem_t allocCurrent = proc->allocStart;
  mem_t allocStop = proc->allocCursor;
  ploc_t writelistCurrent = proc->writelistStart;
  ploc_t writelistStop = proc->writelistCursor;
  int isGCAgressive = (GCType == Major ? doAgressive : doMinorAgressive) ? 
                      (GCStatus == GCAgressive) || (GCStatus == GCPendingOn) : 0;
  int isGCOn = isGCAgressive || (GCStatus == GCOn) || (GCStatus == GCPendingOff);
  Heap_t *srcRange = (GCType == Minor) ? nursery : fromSpace;
  int numWrites = (proc->writelistCursor - proc->writelistStart) / 3;

  /* Reset cursors */
  proc->allocStart = proc->allocCursor;          
  proc->writelistCursor = proc->writelistStart;  


  /* Replicate objects allocated by mutator when the collector is on */
  if (isGCOn && !isGCAgressive) {
    procChangeState(proc, GCReplicate, 613);
    if (collectDiag >= 2)
      printf("GC %4d/%6d:   Double-allocating %lx to %lx\n",
	     NumGC, proc->segmentNumber, (long)allocCurrent,(long)allocStop);
    proc->segUsage.bytesReplicated += sizeof(val_t) * (allocStop - allocCurrent);
    while (allocCurrent + 1 <= allocStop) {  /* There may be no data for empty array */
      int objSize;
      ptr_t obj = allocCurrent;  /* Eventually becomes start of object */
      tag_t tag = *obj;
      if (IS_SKIP_TAG(tag)) {
	allocCurrent += GET_SKIPWORD(tag);
	continue;
      }
      while (tag == SEGPROCEED_TAG || tag == SEGSTALL_TAG)
	tag = *(++obj); /* Skip past segment tags */
      obj++;            /* Skip past object tag */
      alloc_copyCopySync_primarySet(proc,obj);
      objSize = proc->bytesCopied;
      if (objSize == 0) {
	mem_t dummy = NULL;
	objSize = objectLength(obj, &dummy);
	fastAssert(dummy == allocCurrent);
      }
      allocCurrent += objSize / sizeof(val_t);
    }
  }


  /* Process writes */
  if (collectDiag >= 2 && writelistCurrent < writelistStop)
    printf("Proc %d: Processing %d writes from %lx to %lx\n",
	   proc->procid,numWrites,(long)writelistCurrent,(long)writelistStop);
  procChangeState(proc, GCWrite, 614);
  while (writelistCurrent < writelistStop) {
    ptr_t mutatorPrimary = *writelistCurrent++;          /* Global, nursery, or fromSpace */
    int byteDisp = (int) *writelistCurrent++;
    ptr_t possPrevPtrVal = (ptr_t) *writelistCurrent++;  /* Pointer value only if pointer array was modified */
    int wordDisp = byteDisp / sizeof(val_t);
    int mirrorWordDisp = (primaryArrayOffset == 0) ? wordDisp + 1 : wordDisp - 1;
    int doubleWordDisp = byteDisp / (sizeof(double));
    int byteLen;  /* Length of data portion of array */
    int syncIndex;

    if (IsGlobalData(mutatorPrimary)) {
      add_global_root(proc,mutatorPrimary);
      continue;
    }
    if (inHeap(mutatorPrimary, largeSpace))
      continue;

    if (!isGCOn) {                                /* Record back-pointers when GC is off for roots of next GC */
      if (GCType == Minor &&                      /* If next GC is major, no backLocs needed */
	  inHeap(mutatorPrimary, fromSpace)) {
	tag_t tag = mutatorPrimary[-1];
	if (GET_TYPE(tag) == MIRROR_PTR_ARRAY_TYPE) {
	  SetPush(&proc->work.backLocs, (ptr_t) &mutatorPrimary[wordDisp]);
	  SetPush(&proc->work.nextBackLocs, (ptr_t) &mutatorPrimary[mirrorWordDisp]);
	}
	else 
	  fastAssert((GET_TYPE(tag) == WORD_ARRAY_TYPE ||
		      GET_TYPE(tag) == QUAD_ARRAY_TYPE));
      }
    }
    else {
      vptr_t nurseryPrimary = NULL;           /* Used if primary was in nursery */
      vptr_t fromSpaceEither = NULL;          /* Used for primaryReplica or (minor replica/major primary) */
      vptr_t toSpaceReplica = NULL;           /* Used only during major GC*/
      tag_t tag;                              /* Actual tag deteremined after traversing forwarding pointers */

      
      /* Make a copy of the modified arrays and get tag */
      if (inHeap(mutatorPrimary, nursery)) {
	fastAssert(GCType == Minor);
	nurseryPrimary = mutatorPrimary;
	tag = nurseryPrimary[-1];
	/* If object has not been copied, simply gray previous pointer value */
	switch (GET_TYPE(tag)) {
          case PTR_ARRAY_TYPE:
          case MIRROR_PTR_ARRAY_TYPE:
	    alloc1_copyCopySync_primarySet(proc,possPrevPtrVal, srcRange);
	    continue;
          case WORD_ARRAY_TYPE: 
          case QUAD_ARRAY_TYPE: 
	    continue;
	}
	while ((val_t)(fromSpaceEither = (ptr_t) nurseryPrimary[-1]) == STALL_TAG)
	  ;
	tag = fromSpaceEither[-1];
      }
      else if (inHeap(mutatorPrimary,fromSpace)) {
	fromSpaceEither = mutatorPrimary;
	if (GCType == Major) {
	  alloc1_copyCopySync_primarySet(proc,(ptr_t) fromSpaceEither,srcRange);
	  toSpaceReplica = (ptr_t) fromSpaceEither[-1];
	  tag = toSpaceReplica[-1];
	}
	else
	  tag = fromSpaceEither[-1];
      }
      else 
	DIE("mutatorPrimary in neither fromSpace nor nursery");

      /* Copy-Write synchronization on replica object */
      byteLen = GET_ANY_ARRAY_LEN(tag);
      syncIndex = (byteLen <= arraySegmentSize) ? -1 : -2-(DivideDown(byteDisp, arraySegmentSize));
      if (nurseryPrimary)
	while (fromSpaceEither[syncIndex] == SEGSTALL_TAG)
	    ;
      else if (toSpaceReplica)
	while (toSpaceReplica[syncIndex] == SEGSTALL_TAG)
	  ;

      switch (GET_TYPE(tag)) {
      case WORD_ARRAY_TYPE:
	if (nurseryPrimary) {
	  if (fromSpaceEither[0] == (val_t) nurseryPrimary) 	/* Backpointer present indicates object not yet scanned - can/must skip replica update */
	    break;
	  fromSpaceEither[wordDisp] = nurseryPrimary[wordDisp];
	}
	if (toSpaceReplica)
	  toSpaceReplica[wordDisp] = fromSpaceEither[wordDisp];
	break;
      case QUAD_ARRAY_TYPE: 
	if (nurseryPrimary) {
	  if (fromSpaceEither[0] == (val_t) nurseryPrimary) 	/* Backpointer present indicates object not yet scanned - can/must skip replica update */
	    break;
	  ((double *)fromSpaceEither)[doubleWordDisp] = ((double *)nurseryPrimary)[doubleWordDisp];
	}
	if (toSpaceReplica)
	  ((double *)toSpaceReplica)[doubleWordDisp] = ((double *)fromSpaceEither)[doubleWordDisp];
	break;
      case PTR_ARRAY_TYPE: 
	DIE("pointer array"); 
      case MIRROR_PTR_ARRAY_TYPE: {
	/* Snapshot-at-the-beginning (Yuasa) write barrier requires copying prevPtrVal 
	   even if it might die to prevent the mutator from hiding live data.

	   There are several cases:
	   (1) MinorGC: The original array is in nursery/fromSpace.
	       (i) (a) The field is in nursery.           Update new/existing array (replica entry) with new (fromSpace) field.
	           (b) The field is in fromSpace.         Update new/existing array (replica entry) with same field.
	           (c) The field is in global/largeSpace. Update new/existing array (replica entry) with same field.
	       (ii) If original array in fromSpace, add location to backLocs for replication. Same as when GC is off.
	   (3) MajorGC: The original array must be in fromSpace.
               (a) The field is in fromSpace. Update new array (replica entry) with new (toSpace) field.
	       (b) The field is in global/largeSpace. Update new array with field.  (toSpaceField is NULL).
	*/
	ptr_t mutatorField = (ptr_t) mutatorPrimary[wordDisp];
	
	fastAssert(((byteDisp - primaryArrayOffset) % (2 * sizeof(val_t))) == 0);

	/* Snapshot-at-the-beginning (Yuasa) write barrier requires copying prevPtrVal 
	   even if it might die to prevent the mutator from hiding live data */
	alloc1_copyCopySync_primarySet(proc,possPrevPtrVal,srcRange);


	if (GCType == Minor) {
	    ptr_t newField = mutatorField;
	    if (inHeap(newField, nursery)) {
	      alloc1_copyCopySync_primarySet(proc,mutatorField,srcRange);
	      newField = (ptr_t) mutatorField[-1];
	    }
	    fastAssert(!inHeap(newField, nursery));
	    if (fromSpaceEither[0] == (val_t) mutatorPrimary) /* Backpointer present indicates object not yet scanned - can/must skip replica update */
		break;
	    fromSpaceEither[mirrorWordDisp] = (val_t) newField;
	    if (inHeap(mutatorPrimary, nursery))
	      fromSpaceEither[wordDisp] = (val_t) newField;
	    else {
	      fastAssert(inHeap(mutatorPrimary, fromSpace));
	      SetPush(&proc->work.backLocs, (ptr_t) &mutatorPrimary[wordDisp]);
	      SetPush(&proc->work.nextBackLocs, (ptr_t) &mutatorPrimary[mirrorWordDisp]);
	    }
	}
	else {  /* GCType == Major */
	  ptr_t newField = mutatorField;
	  fastAssert(inHeap(mutatorPrimary,fromSpace));
	  if (inHeap(newField,fromSpace)) {
	    alloc1L_copyCopySync_primarySet(proc,mutatorField,srcRange,largeSpace);
	    newField = (ptr_t) mutatorField[-1];
	  }
	  if (toSpaceReplica[0] == (val_t) mutatorPrimary) /* Backpointer present indicates object not yet scanned - can/must skip replica update */
	    break;
	  toSpaceReplica[wordDisp] = (val_t) newField;
	  toSpaceReplica[mirrorWordDisp] = (val_t) newField;
	}
	break;
      }
      default:
	DIE("bad tag type");
      } /* else */
    } /* switch */
  } /* while */
  
  if (isGCOn) 
    pushSharedStack(1,workStack, &proc->work);
}
static void do_work(Proc_t *proc, int additionalWork)
{
  Heap_t *srcRange = (GCType == Minor) ? nursery : fromSpace;
  
  if (additionalWork <= 0)
    return;
  addMaxWork(proc, additionalWork);
  procChangeState(proc, GCWork, 612);
  proc->segmentType |= (GCType == Major) ? MajorWork : MinorWork;

  if (collectDiag >= 2)
    printf("GC %4d/%6d:  Entered do_work(%d)  updateWorkDone = %5d\n",
	   NumGC, proc->segmentNumber, additionalWork, updateGetWorkDone(proc));

  while (!reachMaxWork(proc)) {
    ploc_t rootLoc, globalLoc, backLoc;
    ptr_t backObj, gray;
    int largeStart, largeEnd;
    Stacklet_t *stacklet;

    /* Get shared work */
    popSharedStack(workStack, &proc->work);

    if ((GCStatus == GCPendingOn || GCStatus == GCPendingOff) &&
	isLocalWorkEmpty(&proc->work))
      break;

    /* Do the thread stacklets - we can afford to call updateWorkDone often */
    while (!reachCheckWork(proc) &&
	   ((stacklet = (Stacklet_t *) SetPop(&proc->work.stacklets)) != NULL)) {
      if (!work_root_scan(proc, stacklet))
	SetPush(&proc->work.stacklets, (ptr_t) stacklet);
    }

    /* Do the rootLocs */
    if (GCType == Minor) {
      while (!reachCheckWork(proc) &&
	     ((rootLoc = (ploc_t) SetPop(&proc->work.roots)) != NULL)) {
	locAlloc1_copyCopySync_primarySet(proc,rootLoc,srcRange);
	proc->segUsage.fieldsScanned++;
      }
    }
    else {
      while (!reachCheckWork(proc) && 
	     ((rootLoc = (ploc_t) SetPop(&proc->work.roots)) != NULL)) {
	locAlloc1L_copyCopySync_primarySet(proc,rootLoc,srcRange,largeSpace);
	proc->segUsage.fieldsScanned++;
      }
    }

    /* Do the backObjs and backLocs */
    if (GCType == Minor) {
      while (!updateReachCheckWork(proc) &&
	     ((backObj = (ptr_t) SetPop(&proc->work.backObjs)) != NULL)) {
	selfTransferScanObj_locAlloc1_copyCopySync_primarySet(proc,backObj,srcRange);
      }
      while (!reachCheckWork(proc) &&
	     ((backLoc = (ploc_t) SetPop(&proc->work.backLocs)) != NULL)) {
	ploc_t mirrorBackLoc = backLoc + ((primaryArrayOffset == 0) ? 1 : -1);
	*mirrorBackLoc = *backLoc;
	locAlloc1_copyCopySync_primarySet(proc,mirrorBackLoc,srcRange);
	proc->segUsage.fieldsScanned += 2;
      }
    }
    else {
      SetReset(&proc->work.backObjs);
      SetReset(&proc->work.backLocs);
    }

    /* Do the globalLocs */
    if (GCType == Minor) 
      while (!reachCheckWork(proc) && 
	     ((globalLoc = (ploc_t) SetPop(&proc->work.globals)) != NULL)) {
	ploc_t replicaLoc = (ploc_t) DupGlobal((ptr_t) globalLoc);
	locAlloc1_copyCopySync_primarySet(proc,replicaLoc,srcRange);
	proc->segUsage.globalsProcessed++;
      }
    else       
      while (!reachCheckWork(proc) &&
	     ((globalLoc = (ploc_t) SetPop(&proc->work.globals)) != NULL)) {
	ploc_t replicaLoc = (ploc_t) DupGlobal((ptr_t) globalLoc);
	locAlloc1L_copyCopySync_primarySet(proc,replicaLoc,srcRange,largeSpace);
	proc->segUsage.globalsProcessed++;
      }

    /* Do the large objects - don't need to optimize loop */
    while (!updateReachCheckWork(proc) &&
	   (gray = SetPop3(&proc->work.segments,(ptr_t *)&largeStart,(ptr_t *)&largeEnd))) {
      if (GCType == Minor) {
	int isMirrorPtrArray = (GET_TYPE(gray[-1]) == MIRROR_PTR_ARRAY_TYPE);
	if (isMirrorPtrArray) {
	  fastAssert(inHeap(gray, fromSpace));
	  selfTransferScanSegment_copyWriteSync_locAlloc1_copyCopySync_primarySet(proc,gray,largeStart,largeEnd,srcRange);
	}
	else
	    transferScanSegment_copyWriteSync_locAlloc1_copyCopySync_primarySet(proc,gray,largeStart,largeEnd,srcRange);
      }
      else
	 transferScanSegment_copyWriteSync_locAlloc1L_copyCopySync_primarySet(proc,gray,largeStart,largeEnd,srcRange, largeSpace);
    }

    /* Work on the gray objects */
    if (GCType == Minor)
      while (!reachCheckWork(proc) &&
	     ((gray = SetPop(&proc->work.objs)) != NULL)) 
	transferScanObj_copyWriteSync_locAlloc1_copyCopySync_primarySet(proc,gray,srcRange);
    else
      while (!reachCheckWork(proc) &&
	     ((gray = SetPop(&proc->work.objs)) != NULL))
	transferScanObj_copyWriteSync_locAlloc1L_copyCopySync_primarySet(proc,gray,srcRange,largeSpace);
    /* Put work back on shared stack */
    if (pushSharedStack(0,workStack,&proc->work)) {
      if (GCStatus == GCAgressive)
	GCStatus = GCPendingOn;
      else if (GCStatus == GCOn)
	GCStatus = GCPendingOff;
    }
  }

  assert(isLocalWorkEmpty(&proc->work));
  if (collectDiag >= 2)
    printf("GC %d Seg %d:  Completed do_work(%d)  segWork = %5d    sharedStack(%4ld items %2ld segs)     %ld alloc  %ld copied\n",
	   NumGC, proc->segmentNumber, additionalWork, updateGetWorkDone(proc), 
	   SetLength(&workStack->work.objs), SetLength(&workStack->work.segments),
	   proc->cycleUsage.bytesAllocated + proc->segUsage.bytesAllocated,
	   bytesCopied(&proc->cycleUsage) + bytesCopied(&proc->segUsage));

}
Exemple #25
0
TimerBase::~TimerBase()
{
    stop();
    ASSERT(!inHeap());
}
Exemple #26
0
	bool rChildValid(Rank n, Rank i)
	{
		return inHeap(n, rChild(i));
	}