001/* 002 * This file is part of the Jikes RVM project (http://jikesrvm.org). 003 * 004 * This file is licensed to You under the Eclipse Public License (EPL); 005 * You may not use this file except in compliance with the License. You 006 * may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/eclipse-1.0.php 009 * 010 * See the COPYRIGHT.txt file distributed with this work for information 011 * regarding copyright ownership. 012 */ 013package org.mmtk.plan.marksweep; 014 015import org.mmtk.plan.TraceLocal; 016import org.mmtk.plan.Trace; 017import org.mmtk.policy.Space; 018import org.mmtk.utility.HeaderByte; 019import org.mmtk.utility.deque.ObjectReferenceDeque; 020 021import org.vmmagic.pragma.*; 022import org.vmmagic.unboxed.*; 023 024/** 025 * This class implements the thread-local functionality for a transitive 026 * closure over a mark-sweep space. 027 */ 028@Uninterruptible 029public final class MSTraceLocal extends TraceLocal { 030 /**************************************************************************** 031 * Instance fields 032 */ 033 034 /** 035 * 036 */ 037 private final ObjectReferenceDeque modBuffer; 038 039 public MSTraceLocal(Trace trace, ObjectReferenceDeque modBuffer) { 040 super(MS.SCAN_MARK, trace); 041 this.modBuffer = modBuffer; 042 } 043 044 045 /**************************************************************************** 046 * Externally visible Object processing and tracing 047 */ 048 049 /** 050 * {@inheritDoc} 051 */ 052 @Override 053 public boolean isLive(ObjectReference object) { 054 if (object.isNull()) return false; 055 if (Space.isInSpace(MS.MARK_SWEEP, object)) { 056 return MS.msSpace.isLive(object); 057 } 058 return super.isLive(object); 059 } 060 061 /** 062 * {@inheritDoc}<p> 063 * 064 * In this instance, we refer objects in the mark-sweep space to the 065 * msSpace for tracing, and defer to the superclass for all others. 066 * 067 * @param object The object to be traced. 068 * @return The new reference to the same object instance. 069 */ 070 @Inline 071 @Override 072 public ObjectReference traceObject(ObjectReference object) { 073 if (object.isNull()) return object; 074 if (Space.isInSpace(MS.MARK_SWEEP, object)) 075 return MS.msSpace.traceObject(this, object); 076 return super.traceObject(object); 077 } 078 079 /** 080 * Process any remembered set entries. This means enumerating the 081 * mod buffer and for each entry, marking the object as unlogged 082 * (we don't enqueue for scanning since we're doing a full heap GC). 083 */ 084 @Override 085 protected void processRememberedSets() { 086 if (modBuffer != null) { 087 logMessage(5, "clearing modBuffer"); 088 while (!modBuffer.isEmpty()) { 089 ObjectReference src = modBuffer.pop(); 090 HeaderByte.markAsUnlogged(src); 091 } 092 } 093 } 094}