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 */ 013 package org.mmtk.plan.marksweep; 014 015 import org.mmtk.plan.TraceLocal; 016 import org.mmtk.plan.Trace; 017 import org.mmtk.policy.Space; 018 import org.mmtk.utility.HeaderByte; 019 import org.mmtk.utility.deque.ObjectReferenceDeque; 020 021 import org.vmmagic.pragma.*; 022 import 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 029 public final class MSTraceLocal extends TraceLocal { 030 /**************************************************************************** 031 * Instance fields 032 */ 033 034 /** 035 * 036 */ 037 private final ObjectReferenceDeque modBuffer; 038 039 /** 040 * Constructor 041 */ 042 public MSTraceLocal(Trace trace, ObjectReferenceDeque modBuffer) { 043 super(MS.SCAN_MARK, trace); 044 this.modBuffer = modBuffer; 045 } 046 047 048 /**************************************************************************** 049 * Externally visible Object processing and tracing 050 */ 051 052 /** 053 * {@inheritDoc} 054 */ 055 @Override 056 public boolean isLive(ObjectReference object) { 057 if (object.isNull()) return false; 058 if (Space.isInSpace(MS.MARK_SWEEP, object)) { 059 return MS.msSpace.isLive(object); 060 } 061 return super.isLive(object); 062 } 063 064 /** 065 * {@inheritDoc}<p> 066 * 067 * In this instance, we refer objects in the mark-sweep space to the 068 * msSpace for tracing, and defer to the superclass for all others. 069 * 070 * @param object The object to be traced. 071 * @return The new reference to the same object instance. 072 */ 073 @Inline 074 @Override 075 public ObjectReference traceObject(ObjectReference object) { 076 if (object.isNull()) return object; 077 if (Space.isInSpace(MS.MARK_SWEEP, object)) 078 return MS.msSpace.traceObject(this, object); 079 return super.traceObject(object); 080 } 081 082 /** 083 * Process any remembered set entries. This means enumerating the 084 * mod buffer and for each entry, marking the object as unlogged 085 * (we don't enqueue for scanning since we're doing a full heap GC). 086 */ 087 @Override 088 protected void processRememberedSets() { 089 if (modBuffer != null) { 090 logMessage(5, "clearing modBuffer"); 091 while (!modBuffer.isEmpty()) { 092 ObjectReference src = modBuffer.pop(); 093 HeaderByte.markAsUnlogged(src); 094 } 095 } 096 } 097 }