gcOrdinal = VM_Synchronization.fetchAndAdd(participantCount, 0, 1) + 1;
gcOrdinal = VM_Synchronization.fetchAndAdd(participantCount, Offset.zero(), 1) + 1;
   public void run()       throws NoOptCompilePragma, // refs stored in registers by opt compiler will not be relocated by GC               LogicallyUninterruptiblePragma,  // due to call to snipObsoleteCompiledMethods              UninterruptiblePragma {    for (int count = 0; ; count++) {      /* suspend this thread: it will resume when scheduled by       * VM_Handshake initiateCollection().  while suspended,       * collector threads reside on the schedulers collectorQueue */      VM_Scheduler.collectorMutex.lock();      if (verbose >= 1) VM.sysWriteln("GC Message: VM_CT.run yielding");      if (count > 0) { // resume normal scheduling        VM_Processor.getCurrentProcessor().enableThreadSwitching();      }      VM_Thread.yield(VM_Scheduler.collectorQueue,                      VM_Scheduler.collectorMutex);            /* block mutators from running on the current processor */      VM_Processor.getCurrentProcessor().disableThreadSwitching();            if (verbose >= 2) VM.sysWriteln("GC Message: VM_CT.run waking up");      gcOrdinal = VM_Synchronization.fetchAndAdd(participantCount, 0, 1) + 1;      long startCycles = VM_Time.cycles();            if (verbose > 2) VM.sysWriteln("GC Message: VM_CT.run entering first rendezvous - gcOrdinal =", gcOrdinal);      /* wait for other collector threads to arrive or be made       * non-participants */      if (verbose >= 2) VM.sysWriteln("GC Message: VM_CT.run  initializing rendezvous");      gcBarrier.startupRendezvous();      /* actually perform the GC... */      if (verbose >= 2) VM.sysWriteln("GC Message: VM_CT.run  starting collection");      if (isActive) Plan.getInstance().collect(); // gc      if (verbose >= 2) VM.sysWriteln("GC Message: VM_CT.run  finished collection");            gcBarrier.rendezvous(5200);      if (gcOrdinal == 1) {        long elapsedCycles = VM_Time.cycles() - startCycles;        HeapGrowthManager.recordGCTime(VM_Time.cyclesToMillis(elapsedCycles));      }      if (gcOrdinal == 1 && Plan.isLastGCFull()) {        boolean heapSizeChanged = false;        if (Plan.variableSizeHeap.getValue() && handshake.gcTrigger != Collection.EXTERNAL_GC_TRIGGER) {          // Don't consider changing the heap size if gc was forced by System.gc()          heapSizeChanged = HeapGrowthManager.considerHeapSize();        }        HeapGrowthManager.reset();      }       /* Wake up mutators waiting for this gc cycle and reset       * the handshake object to be used for next gc cycle.       * Note that mutators will not run until after thread switching       * is enabled, so no mutators can possibly arrive at old       * handshake object: it's safe to replace it with a new one. */      if (gcOrdinal == 1) {        /* Snip reference to any methods that are still marked         * obsolete after we've done stack scans. This allows         * reclaiming them on next GC. */        VM_CompiledMethods.snipObsoleteCompiledMethods();        collectionCount += 1;        /* notify mutators waiting on previous handshake object -         * actually we don't notify anymore, mutators are simply in         * processor ready queues waiting to be dispatched. */        handshake.notifyCompletion();        handshake.reset();        /* schedule the FinalizerThread, if there is work to do & it is idle */        Collection.scheduleFinalizerThread();      }             /* wait for other collector threads to arrive here */      rendezvous(5210);      if (verbose > 2) VM.sysWriteln("VM_CollectorThread: past rendezvous 1 after collection");      /* final cleanup for initial collector thread */      if (gcOrdinal == 1) {        /* It is VERY unlikely, but possible that some RVM processors         * were found in C, and were BLOCKED_IN_NATIVE, during the         * collection, and now need to be unblocked. */        if (verbose >= 2) VM.sysWriteln("GC Message: VM_CT.run unblocking procs blocked in native during GC");        for (int i = 1; i <= VM_Scheduler.numProcessors; i++) {          VM_Processor vp = VM_Scheduler.processors[i];          if (VM.VerifyAssertions) VM._assert(vp != null);          if (vp.vpStatus == VM_Processor.BLOCKED_IN_NATIVE ) {            vp.vpStatus = VM_Processor.IN_NATIVE;            if (verbose >= 2) VM.sysWriteln("GC Message: VM_CT.run unblocking RVM Processor", vp.id);          }        }                /* clear the GC flags */        Plan.collectionComplete();        gcThreadRunning = false;      } // if designated thread      rendezvous(9999);    }  // end of while(true) loop      }  // run