Skip to content

Commit

Permalink
Contribution 015 from Robin Garner of ANU.
Browse files Browse the repository at this point in the history
Generalization of pointer enumeration mechanism
  • Loading branch information
steveblackburn committed Jun 24, 2003
1 parent 74ced16 commit e7195af
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 31 deletions.
2 changes: 2 additions & 0 deletions MMTk/src/org/mmtk/plan/BasePlan.java
Expand Up @@ -102,6 +102,7 @@ public abstract class BasePlan
//
private int id = 0; // Zero-based id of plan instance
public BumpPointer immortal;
public Enumerate enum;

////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -138,6 +139,7 @@ public abstract class BasePlan
id = planCount++;
plans[id] = (Plan) this;
immortal = new BumpPointer(immortalVM);
enum = new Enumerate((Plan) this);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion MMTk/src/org/mmtk/policy/RefCountLocal.java
Expand Up @@ -296,7 +296,7 @@ else if (Plan.refCountCycleDetection)
private final void release(VM_Address object)
throws VM_PragmaInline {
// this object is now dead, scan it for recursive decrement
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
if (!Plan.refCountCycleDetection || !RCBaseHeader.isBuffered(object))
free(object);
}
Expand Down
8 changes: 4 additions & 4 deletions MMTk/src/org/mmtk/utility/TrialDeletion.java
Expand Up @@ -376,7 +376,7 @@ private final void markGrey(VM_Address object)
visitCount++;
if (!RCBaseHeader.isGrey(object)) {
RCBaseHeader.makeGrey(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
}
object = workQueue.pop();
}
Expand All @@ -393,7 +393,7 @@ private final void scan(VM_Address object)
phase = SCAN;
} else {
RCBaseHeader.makeWhite(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
}
}
object = workQueue.pop();
Expand All @@ -407,7 +407,7 @@ private final void scanBlack(VM_Address object)
// if (!SimpleRCBaseHeader.isGreen(object)) {
if (!RCBaseHeader.isBlack(object)) { // FIXME can't this just be if (isGrey(object)) ??
RCBaseHeader.makeBlack(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
}
object = blackQueue.pop();
}
Expand All @@ -418,7 +418,7 @@ private final void collectWhite(VM_Address object)
while (!object.isZero()) {
if (RCBaseHeader.isWhite(object) && !RCBaseHeader.isBuffered(object)) {
RCBaseHeader.makeBlack(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
freeBuffer.push(object);
}
object = workQueue.pop();
Expand Down
2 changes: 2 additions & 0 deletions rvm/src/vm/memoryManagers/JMTk/plan/BasePlan.java
Expand Up @@ -102,6 +102,7 @@ public abstract class BasePlan
//
private int id = 0; // Zero-based id of plan instance
public BumpPointer immortal;
public Enumerate enum;

////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -138,6 +139,7 @@ public abstract class BasePlan
id = planCount++;
plans[id] = (Plan) this;
immortal = new BumpPointer(immortalVM);
enum = new Enumerate((Plan) this);
}

/**
Expand Down
33 changes: 33 additions & 0 deletions rvm/src/vm/memoryManagers/JMTk/plan/Enumerate.java
@@ -0,0 +1,33 @@
package com.ibm.JikesRVM.memoryManagers.JMTk;

import com.ibm.JikesRVM.VM_Address;
import com.ibm.JikesRVM.VM_PragmaInline;
import com.ibm.JikesRVM.VM_Uninterruptible;

//$Id:

/**
* Callbacks from ScanObject to Plan.enumeratePointerLocation are
* dispatched through an object of this class, so that we have the
* opportunity to change the behaviour through sub-classing. <p>
*
* @author Robin Garner
* @version $Revision$
* @date $Date$
*/

public class Enumerate implements VM_Uninterruptible {
private Plan plan;

/* Constructor
*/

Enumerate(Plan plan) {
this.plan = plan;
}

public void enumeratePointerLocation(VM_Address location)
throws VM_PragmaInline {
plan.enumeratePointerLocation(location);
}
}
2 changes: 1 addition & 1 deletion rvm/src/vm/memoryManagers/JMTk/policy/RefCountLocal.java
Expand Up @@ -296,7 +296,7 @@ else if (Plan.refCountCycleDetection)
private final void release(VM_Address object)
throws VM_PragmaInline {
// this object is now dead, scan it for recursive decrement
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
if (!Plan.refCountCycleDetection || !RCBaseHeader.isBuffered(object))
free(object);
}
Expand Down
8 changes: 4 additions & 4 deletions rvm/src/vm/memoryManagers/JMTk/utility/TrialDeletion.java
Expand Up @@ -376,7 +376,7 @@ private final void markGrey(VM_Address object)
visitCount++;
if (!RCBaseHeader.isGrey(object)) {
RCBaseHeader.makeGrey(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
}
object = workQueue.pop();
}
Expand All @@ -393,7 +393,7 @@ private final void scan(VM_Address object)
phase = SCAN;
} else {
RCBaseHeader.makeWhite(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
}
}
object = workQueue.pop();
Expand All @@ -407,7 +407,7 @@ private final void scanBlack(VM_Address object)
// if (!SimpleRCBaseHeader.isGreen(object)) {
if (!RCBaseHeader.isBlack(object)) { // FIXME can't this just be if (isGrey(object)) ??
RCBaseHeader.makeBlack(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
}
object = blackQueue.pop();
}
Expand All @@ -418,7 +418,7 @@ private final void collectWhite(VM_Address object)
while (!object.isZero()) {
if (RCBaseHeader.isWhite(object) && !RCBaseHeader.isBuffered(object)) {
RCBaseHeader.makeBlack(object);
ScanObject.enumeratePointers(object, plan);
ScanObject.enumeratePointers(object, plan.enum);
freeBuffer.push(object);
}
object = workQueue.pop();
Expand Down
12 changes: 6 additions & 6 deletions rvm/src/vm/memoryManagers/JMTk/vmInterface/ScanObject.java
Expand Up @@ -5,7 +5,7 @@

package com.ibm.JikesRVM.memoryManagers.vmInterface;

import com.ibm.JikesRVM.memoryManagers.JMTk.Plan;
import com.ibm.JikesRVM.memoryManagers.JMTk.Enumerate;

import com.ibm.JikesRVM.classloader.*;
import com.ibm.JikesRVM.VM;
Expand Down Expand Up @@ -61,9 +61,9 @@ public static void rootScan(Object objRef)
* @param object The object to be scanned.
* @param plan The plan with respect to which the callback should be made.
*/
public static void enumeratePointers(VM_Address object, Plan plan)
public static void enumeratePointers(VM_Address object, Enumerate enum)
throws VM_PragmaUninterruptible, VM_PragmaInline {
scan(object, false, plan, false);
scan(object, false, enum, false);
}

/**
Expand All @@ -72,7 +72,7 @@ public static void enumeratePointers(VM_Address object, Plan plan)
*
* @param objRef reference for object to be scanned (as int)
*/
private static void scan(VM_Address objRef, boolean root, Plan plan,
private static void scan(VM_Address objRef, boolean root, Enumerate enum,
boolean trace)
throws VM_PragmaUninterruptible, VM_PragmaInline {

Expand Down Expand Up @@ -109,7 +109,7 @@ private static void scan(VM_Address objRef, boolean root, Plan plan,
if (trace)
MM_Interface.processPtrField(objRef.add(referenceOffsets[i]), root);
else
VM_Interface.enumeratePtrLoc(objRef.add(referenceOffsets[i]), plan);
enum.enumeratePointerLocation(objRef.add(referenceOffsets[i]));
}
Statistics.profileScan(obj, 4 * referenceOffsets.length, tib);
}
Expand All @@ -125,7 +125,7 @@ private static void scan(VM_Address objRef, boolean root, Plan plan,
if (trace)
MM_Interface.processPtrField(location, root);
else
VM_Interface.enumeratePtrLoc(location, plan);
enum.enumeratePointerLocation(location);
location = location.add(WORD_SIZE); // is this size_of_pointer ?
}
Statistics.profileScan(obj, numBytes, tib);
Expand Down
15 changes: 0 additions & 15 deletions rvm/src/vm/memoryManagers/JMTk/vmInterface/VM_Interface.java
Expand Up @@ -299,21 +299,6 @@ public static void scheduleFinalizerThread () throws VM_PragmaUninterruptible {
}
}

/**
* A pointer location has been enumerated by ScanObject. This is
* the callback method, allowing the plan to perform an action with
* respect to that location.
*
* @param location An address known to contain a pointer. The
* location is within the object being scanned by ScanObject.
* @param plan The plan that initiated the object scan. A callback
* should be made to this plan.
*/
public static void enumeratePtrLoc(VM_Address location, Plan plan)
throws VM_PragmaUninterruptible, VM_PragmaInline {
plan.enumeratePointerLocation(location);
}

private static SynchronizedCounter threadCounter = new SynchronizedCounter();
public static void resetComputeAllRoots() {
threadCounter.reset();
Expand Down

0 comments on commit e7195af

Please sign in to comment.