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.immix; 014 015import static org.mmtk.policy.immix.ImmixConstants.MARK_LINE_AT_SCAN_TIME; 016 017import org.mmtk.plan.TraceLocal; 018import org.mmtk.plan.Trace; 019import org.mmtk.policy.Space; 020import org.mmtk.utility.HeaderByte; 021import org.mmtk.utility.deque.ObjectReferenceDeque; 022import org.mmtk.vm.VM; 023 024import org.vmmagic.pragma.*; 025import org.vmmagic.unboxed.*; 026 027/** 028 * This class implements the thread-local functionality for a transitive 029 * closure over an immix space. 030 */ 031@Uninterruptible 032public final class ImmixTraceLocal extends TraceLocal { 033 034 /**************************************************************************** 035 * 036 * Instance fields 037 */ 038 private final ObjectReferenceDeque modBuffer; 039 040 /** 041 * Constructor 042 * 043 * @param trace The trace associated with this trace local. 044 * @param modBuffer The modified objects buffer associated with this trace local. Possibly null. 045 */ 046 public ImmixTraceLocal(Trace trace, ObjectReferenceDeque modBuffer) { 047 super(Immix.SCAN_IMMIX, trace); 048 this.modBuffer = modBuffer; 049 } 050 051 /**************************************************************************** 052 * 053 * Externally visible Object processing and tracing 054 */ 055 056 /** 057 * {@inheritDoc} 058 */ 059 @Override 060 public boolean isLive(ObjectReference object) { 061 if (object.isNull()) return false; 062 if (Space.isInSpace(Immix.IMMIX, object)) { 063 return Immix.immixSpace.fastIsLive(object); 064 } 065 return super.isLive(object); 066 } 067 068 /** 069 * {@inheritDoc}<p> 070 * 071 * In this instance, we refer objects in the mark-sweep space to the 072 * immixSpace for tracing, and defer to the superclass for all others. 073 * 074 * @param object The object to be traced. 075 * @return The new reference to the same object instance. 076 */ 077 @Override 078 @Inline 079 public ObjectReference traceObject(ObjectReference object) { 080 if (object.isNull()) return object; 081 if (Space.isInSpace(Immix.IMMIX, object)) 082 return Immix.immixSpace.fastTraceObject(this, object); 083 return super.traceObject(object); 084 } 085 086 /** 087 * Ensure that the referenced object will not move from this point through 088 * to the end of the collection. This can involve forwarding the object 089 * if necessary. 090 */ 091 @Inline 092 @Override 093 public boolean willNotMoveInCurrentCollection(ObjectReference object) { 094 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(!Immix.immixSpace.inImmixDefragCollection()); 095 return true; 096 } 097 098 @Inline 099 @Override 100 protected void scanObject(ObjectReference object) { 101 super.scanObject(object); 102 if (MARK_LINE_AT_SCAN_TIME && Space.isInSpace(Immix.IMMIX, object)) 103 Immix.immixSpace.markLines(object); 104 } 105 106 /** 107 * Process any remembered set entries. This means enumerating the 108 * mod buffer and for each entry, marking the object as unlogged 109 * (we don't enqueue for scanning since we're doing a full heap GC). 110 */ 111 @Override 112 protected void processRememberedSets() { 113 if (modBuffer != null) { 114 logMessage(5, "clearing modBuffer"); 115 while (!modBuffer.isEmpty()) { 116 ObjectReference src = modBuffer.pop(); 117 HeaderByte.markAsUnlogged(src); 118 } 119 } 120 } 121}