/* * This file is part of the Jikes RVM project (http://jikesrvm.org). * * This file is licensed to You under the Eclipse Public License (EPL); * You may not use this file except in compliance with the License. You * may obtain a copy of the License at * * http://www.opensource.org/licenses/eclipse-1.0.php * * See the COPYRIGHT.txt file distributed with this work for information * regarding copyright ownership. */ package org.mmtk.plan.refcount.generational; import org.mmtk.plan.refcount.RCBase; import org.mmtk.plan.refcount.RCBaseMutator; import org.mmtk.policy.CopyLocal; import org.mmtk.policy.Space; import org.mmtk.utility.alloc.Allocator; import org.vmmagic.pragma.*; import org.vmmagic.unboxed.Address; import org.vmmagic.unboxed.ObjectReference; /** * This class implements the mutator context for a simple reference counting collector. */ @Uninterruptible public class GenRCMutator extends RCBaseMutator { /************************************************************************ * Instance fields */ /** * */ private final CopyLocal nursery; public GenRCMutator() { nursery = new CopyLocal(GenRC.nurserySpace); } /**************************************************************************** * * Mutator-time allocation */ /** * {@inheritDoc} */ @Override @Inline public Address alloc(int bytes, int align, int offset, int allocator, int site) { if (allocator == GenRC.ALLOC_NURSERY) { return nursery.alloc(bytes, align, offset); } return super.alloc(bytes, align, offset, allocator, site); } @Override @Inline public void postAlloc(ObjectReference ref, ObjectReference typeRef, int bytes, int allocator) { if (allocator == GenRC.ALLOC_NURSERY) { return; } super.postAlloc(ref, typeRef, bytes, allocator); } @Override public Allocator getAllocatorFromSpace(Space space) { if (space == GenRC.nurserySpace) return nursery; return super.getAllocatorFromSpace(space); } /**************************************************************************** * * Collection */ /** * {@inheritDoc} */ @Override public final void collectionPhase(short phaseId, boolean primary) { if (phaseId == RCBase.PREPARE) { nursery.rebind(GenRC.nurserySpace); super.collectionPhase(phaseId, primary); return; } super.collectionPhase(phaseId, primary); } }