コード例 #1
0
ファイル: m_machine.c プロジェクト: svn2github/valgrind-3
Addr VG_(get_SP) ( ThreadId tid )
{
   return STACK_PTR( VG_(threads)[tid].arch );
}
コード例 #2
0
ファイル: m_machine.c プロジェクト: svn2github/valgrind-3
void VG_(set_SP) ( ThreadId tid, Addr sp )
{
   STACK_PTR( VG_(threads)[tid].arch ) = sp;
}
コード例 #3
0
void _chpl_gc_copy_collect(void) {
  int i;
  _memory_space* tmp;
  char* scanptr;
  //fprintf(stderr, "Collection\n");
  for (i=0; i < totalRoots; i++) {
    if (STACK_PTR(rootlist[i])) {
      if (HEAP_AS_PTR(rootlist[i]) >= (void*)_to_space->head &&
          HEAP_AS_PTR(rootlist[i]) < (void*)_to_space->tail) {
        STACK_PTR(rootlist[i]) = HEAP_AS_PTR(rootlist[i]);
      } else {
        if (STACK_PTR(rootlist[i]) >= (void*)_from_space->head &&
            STACK_PTR(rootlist[i]) < (void*)_from_space->tail) {
          size_t size = cid2size(*(chpl__class_id*)STACK_PTR(rootlist[i]));
          memmove(_to_space->current, STACK_PTR(rootlist[i]), size);
          HEAP_AS_PTR(rootlist[i]) = (void*)_to_space->current;
          STACK_PTR(rootlist[i]) = (void*)_to_space->current;
          _to_space->current += size;
        } else {
          /* BAD - Something in the root set points at something that
             wasn't moved, but isn't in the from-space */
        }
      }
    }
  }

  /* Now that any root objects are moved, move sub-objects. */
  scanptr = _to_space->head;
  while (scanptr != _to_space->current) {
    size_t *offsets = cid2offsets(*(chpl__class_id*)scanptr);
    if (offsets[1] == (size_t)-1) {
      // data class (array)
      int i;
      // Bad, could be uint(64) index size
      int array_size = *(int*)(((char*)scanptr) + offsets[2]);
      void** data = *(void***)(((char*)scanptr) + offsets[3]);
      for (i=0; i < array_size; i++) {
        if (data[i]) {
          if (*(void**)data[i] >= (void*)_to_space->head &&
              *(void**)data[i] < (void*)_to_space->tail) {
            /* Update the pointer to point into the new heap */
            data[i] = *(void**)data[i];
          } else {
            if (data[i] >= (void*)_from_space->head &&
                data[i] < (void*)_from_space->tail) {
              size_t size = cid2size(*(chpl__class_id*)data[i]);
              memmove(_to_space->current, data[i], size);
              /* Put an update pointer on the heap */
              *(void**)data[i] = (void*)_to_space->current;
              /* Update the pointer in the array */
              data[i] = (void*)_to_space->current;
              _to_space->current += size;
            } else {
              /* Bad */
            }
          }
        }
      }
    } else {
      int i = 1;
      while (offsets[i] != 0) {
        void* current = (void*)(scanptr + offsets[i]);
        if (STACK_PTR(current)) {
          if (HEAP_AS_PTR(current) >= (void*)_to_space->head &&
              HEAP_AS_PTR(current) < (void*)_to_space->tail) {
            STACK_PTR(current) = HEAP_AS_PTR(current);
          } else {
            if (STACK_PTR(current) >= (void*)_from_space->head &&
                STACK_PTR(current) < (void*)_from_space->tail) {
              size_t size = cid2size(**(chpl__class_id**)current);
              memmove(_to_space->current, STACK_PTR(current), size);
              HEAP_AS_PTR(current) = (void*)_to_space->current;
              STACK_PTR(current) = (void*)_to_space->current;
              _to_space->current += size;
            } else {
              /* BAD - Something pointing at a non-forwarded object that isn't
                 isn't in the from-space or NULL */
            }
          }
        }
        i++;
      }
    }
    scanptr += offsets[0];
  }

  // Swap the _from_space and the _to_space
  _from_space->current = _from_space->head;
  tmp = _from_space;
  _from_space = _to_space;
  _to_space = tmp;
}