harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r424858 [1/2] - in /incubator/harmony/enhanced/drlvm/trunk/vm/MMTk: ./ ext/ ext/vm/ ext/vm/HarmonyDRLVM/ ext/vm/HarmonyDRLVM/org/ ext/vm/HarmonyDRLVM/org/apache/ ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/ ext/vm/HarmonyDRLVM/org/apache/Ha...
Date Sun, 23 Jul 2006 23:37:22 GMT
Author: wjwashburn
Date: Sun Jul 23 16:37:20 2006
New Revision: 424858

URL: http://svn.apache.org/viewvc?rev=424858&view=rev
Log:
adding basic MMTk porting files

Added:
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ActivePlan.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Assert.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Barriers.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Collection.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Lock.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Memory.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ObjectModel.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Options.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ReferenceGlue.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Scanning.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedCollectorContext.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedMutatorContext.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedPlan.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedPlanConstraints.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Statistics.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Strings.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SynchronizedCounter.java
    incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/TraceInterface.java

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ActivePlan.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ActivePlan.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ActivePlan.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ActivePlan.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,129 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.mmtk.plan.Plan;
+import org.mmtk.plan.nogc.*;
+import org.mmtk.plan.CollectorContext;
+import org.mmtk.plan.MutatorContext;
+import org.mmtk.plan.PlanConstraints;
+
+import org.vmmagic.pragma.*;
+
+/**
+ * This class contains interfaces to access the current plan, plan local and
+ * plan constraints instances.
+ */
+public final class ActivePlan extends org.mmtk.vm.ActivePlan implements Uninterruptible {
+
+  /* Collector and Mutator Context Management */
+  private static final int MAX_CONTEXTS = 1;  //wjw -- just do single thread for starts
+  private static NoGCCollector[] collectors = new NoGCCollector[MAX_CONTEXTS];
+  private static int collectorCount = 0; // Number of collector instances 
+  private static NoGCMutator[] mutators = new NoGCMutator[MAX_CONTEXTS];
+  private static int mutatorCount = 0; // Number of mutator instances 
+  private static SynchronizedCounter mutatorCounter = new SynchronizedCounter();
+
+  /** @return The active Plan instance. */
+  public final Plan global() throws InlinePragma {
+    return SelectedPlan.get();  //wjw SelectedPlan is hardcoded for NoGC for now...
+  } 
+  
+  /** @return The active PlanConstraints instance. */
+  public final PlanConstraints constraints() throws InlinePragma {
+    return SelectedPlanConstraints.get();
+  } 
+  
+  /** @return The active CollectorContext instance. */
+  public final CollectorContext collector() throws InlinePragma {
+    return SelectedCollectorContext.get();
+  }
+  
+  /** @return The active MutatorContext instance. */
+  public final MutatorContext mutator() throws InlinePragma {
+    return SelectedMutatorContext.get();
+  }
+  
+  /**
+   * Return the MutatorContext instance given its unique identifier.
+   * 
+   * @param id The identifier of the MutatorContext to return
+   * @return The specified MutatorContext
+   */ 
+  public final MutatorContext mutator(int id) throws InlinePragma {
+    return mutators[id];
+  }
+
+  /** @return The number of registered CollectorContext instances. */
+  public final int collectorCount() throws InlinePragma {
+    return collectorCount;
+  }
+   
+  /** @return The number of registered MutatorContext instances. */
+  public final int mutatorCount() {
+    return mutatorCount;
+  }
+
+  /** Reset the mutator iterator */
+  public void resetMutatorIterator() {
+    mutatorCounter.reset();
+  }
+ 
+  /** 
+   * Return the next <code>MutatorContext</code> in a
+   * synchronized iteration of all mutators.
+   *  
+   * @return The next <code>MutatorContext</code> in a
+   *  synchronized iteration of all mutators, or
+   *  <code>null</code> when all mutators have been done.
+   */
+  public MutatorContext getNextMutator() {
+    int id = mutatorCounter.increment();
+    return id >= mutatorCount ? null : mutators[id];
+  } 
+
+  /**
+   * Register a new CollectorContext instance.
+   *
+   * FIXME: Possible race in allocation of ids. Should be synchronized.
+   *
+   * @param collector The CollectorContext to register
+   * @return The CollectorContext's unique identifier
+   */
+  public final int registerCollector(CollectorContext collector) throws InterruptiblePragma {
+    collectors[collectorCount] = (NoGCCollector)collector;
+    return collectorCount++;
+  }
+  
+  /**
+   * Register a new MutatorContext instance.
+   *
+   * FIXME: Possible race in allocation of ids. Should be synchronized.
+   *
+   * @param mutator The MutatorContext to register
+   * @return The MutatorContext's unique identifier
+   */
+    //wjw -- this needs to be called by VM when a new java thread is created
+  public final int registerMutator(MutatorContext mutator) throws InterruptiblePragma {
+    mutators[mutatorCount] = (NoGCMutator)mutator;
+    return mutatorCount++;
+  } 
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Assert.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Assert.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Assert.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Assert.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,128 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.mmtk.policy.Space;
+
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+
+public class Assert extends org.mmtk.vm.Assert implements Uninterruptible {
+  
+  protected final boolean getVerifyAssertionsConstant() { return true;}
+
+  /**
+   * This method should be called whenever an error is encountered.
+   *
+   * @param str A string describing the error condition.
+   */
+  public final void error(String str) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Assert.error(): " + str);
+    str = null;
+    str.notifyAll();  // this should cause a stack trace and exit
+  }
+
+  /**
+   * Logs a message and traceback, then exits.
+   *
+   * @param message the string to log
+   */
+  public final void fail(String message) { 
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Assert.fail(): " + message);
+      message = null;
+      message.notifyAll();  // this should cause a stack trace and exit 
+  }
+
+  public final void exit(int rc) throws UninterruptiblePragma {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Assert.exit(): " + rc);
+      Object obj = new Object();
+      obj = null;
+      obj.notifyAll();  // this should cause a stack trace and exit
+  }
+
+  /**
+   * Checks that the given condition is true.  If it is not, this
+   * method does a traceback and exits.
+   *
+   * @param cond the condition to be checked
+   */
+    public final void _assert(boolean cond) throws InlinePragma 
+    {
+        if (cond == false) 
+        {
+            System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Assert._assert(): ");
+            Object obj = new Object();
+            obj = null;
+            obj.notifyAll();  // this should cause a stack trace and exit
+        }
+    }
+
+
+  /**
+   * <code>true</code> if assertions should be verified
+   */
+ /* public static final boolean VerifyAssertions = VM.VerifyAssertions; */
+
+  public final void _assert(boolean cond, String s) throws InlinePragma {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Assert._assert(): " + s);
+      s.notifyAll();  // this should cause a stack trace and exit
+  }
+
+  public final void dumpStack() {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Assert.dumpStack(): ");
+      Object obj = new Object();
+      obj = null;
+      obj.notifyAll();  // this should cause a stack trace and exit
+  }
+
+  /**
+   * Throw an out of memory exception.  If the context is one where
+   * we're already dealing with a problem, first request some
+   * emergency heap space.
+   */
+  public final void failWithOutOfMemoryError()
+    throws LogicallyUninterruptiblePragma, NoInlinePragma {
+    failWithOutOfMemoryErrorStatic();
+  }
+
+  /**
+   * Throw an out of memory exception.  If the context is one where
+   * we're already dealing with a problem, first request some
+   * emergency heap space.
+   */
+  public static final void failWithOutOfMemoryErrorStatic()
+    throws LogicallyUninterruptiblePragma, NoInlinePragma {
+    throw new OutOfMemoryError();
+  }
+
+  /**
+   * Checks if the virtual machine is running.  This value changes, so
+   * the call-through to the VM must be a method.  In Jikes RVM, just
+   * returns VM.runningVM.
+   *
+   * @return <code>true</code> if the virtual machine is running
+   */
+  public final boolean runningVM() { return true; }
+
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Barriers.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Barriers.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Barriers.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Barriers.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,171 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+public class Barriers extends org.mmtk.vm.Barriers implements Uninterruptible {
+  /**
+   * Perform the actual write of the write barrier.
+   *
+   * @param ref The object that has the reference field
+   * @param slot The slot that holds the reference
+   * @param target The value that the slot will be updated to
+   * @param offset The offset from the ref (metaDataA)
+   * @param locationMetadata An index of the FieldReference (metaDataB)
+   * @param mode The context in which the write is occuring
+   */
+  public final void performWriteInBarrier(ObjectReference ref, Address slot, 
+                                           ObjectReference target, Offset offset, 
+                                           int locationMetadata, int mode) 
+    throws InlinePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+    //wjw turn this on when we need it -----> Object obj = ref.toObject();
+    //wjw    VM_Magic.setObjectAtOffset(obj, offset, target.toObject(), locationMetadata);  
+  }
+
+  /**
+   * Atomically write a reference field of an object or array and return 
+   * the old value of the reference field.
+   * 
+   * @param ref The object that has the reference field
+   * @param slot The slot that holds the reference
+   * @param target The value that the slot will be updated to
+   * @param offset The offset from the ref (metaDataA)
+   * @param locationMetadata An index of the FieldReference (metaDataB)
+   * @param mode The context in which the write is occuring
+   * @return The value that was replaced by the write.
+   */
+  public final ObjectReference performWriteInBarrierAtomic(
+                                           ObjectReference ref, Address slot,
+                                           ObjectReference target, Offset offset,
+                                           int locationMetadata, int mode)
+    throws InlinePragma { 
+     /*  wjw -- turn this on when we get to write barrier debug                         
+    Object obj = ref.toObject();
+    Object newObject = target.toObject();
+    Object oldObject;
+    do {
+      oldObject = VM_Magic.prepareObject(obj, offset);
+    } while (!VM_Magic.attemptObject(obj, offset, oldObject, newObject));
+    return ObjectReference.fromObject(oldObject); 
+    */
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+
+    return ref;  // keep the compiler happy
+  }
+
+  /**
+   * Sets an element of a char array without invoking any write
+   * barrier.  This method is called by the Log method, as it will be
+   * used during garbage collection and needs to manipulate character
+   * arrays without causing a write barrier operation.
+   *
+   * @param dst the destination array
+   * @param index the index of the element to set
+   * @param value the new value for the element
+   */
+  public final void setArrayNoBarrier(char [] dst, int index, char value) {
+    setArrayNoBarrierStatic(dst, index, value);
+  }
+  public static final void setArrayNoBarrierStatic(char [] dst, int index, char value) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+      dst[index] = value;
+  }
+
+  /**
+   * Gets an element of a char array without invoking any read barrier
+   * or performing bounds check.
+   *
+   * @param src the source array
+   * @param index the natural array index of the element to get
+   * @return the new value of element
+   */
+  public final char getArrayNoBarrier(char [] src, int index) {
+    return getArrayNoBarrierStatic(src, index);
+  }
+  public static final char getArrayNoBarrierStatic(char [] src, int index) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+      return src[index];
+  }
+
+  /**
+   * Gets an element of a byte array without invoking any read barrier
+   * or bounds check.
+   *
+   * @param src the source array
+   * @param index the natural array index of the element to get
+   * @return the new value of element
+   */
+  public final byte getArrayNoBarrier(byte [] src, int index) {
+    return getArrayNoBarrierStatic(src, index);
+  }
+  public static final byte getArrayNoBarrierStatic(byte [] src, int index) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+      return src[index];
+  }
+
+  /**
+   * Gets an element of an int array without invoking any read barrier
+   * or performing bounds checks.
+   *
+   * @param src the source array
+   * @param index the natural array index of the element to get
+   * @return the new value of element
+   */
+  public final int getArrayNoBarrier(int [] src, int index) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+      return src[index];
+  }
+
+  /**
+   * Gets an element of an Object array without invoking any read
+   * barrier or performing bounds checks.
+   *
+   * @param src the source array
+   * @param index the natural array index of the element to get
+   * @return the new value of element
+   */
+  public final Object getArrayNoBarrier(Object [] src, int index) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+      return src[index];
+  }
+  
+
+  /**
+   * Gets an element of an array of byte arrays without causing the potential
+   * thread switch point that array accesses normally cause.
+   *
+   * @param src the source array
+   * @param index the index of the element to get
+   * @return the new value of element
+   */
+  public final byte[] getArrayNoBarrier(byte[][] src, int index) {
+    return getArrayNoBarrierStatic(src, index);
+  }
+  public static final byte[] getArrayNoBarrierStatic(byte[][] src, int index) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Barrier -- something was called (but should not be)" );
+      return src[index];
+  }
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Collection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Collection.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Collection.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Collection.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,206 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.mmtk.plan.Plan;
+import org.mmtk.plan.CollectorContext;
+import org.mmtk.plan.MutatorContext;
+import org.mmtk.utility.Constants;
+import org.mmtk.utility.Finalizer;
+import org.mmtk.utility.heap.HeapGrowthManager;
+import org.mmtk.utility.ReferenceProcessor;
+import org.mmtk.utility.options.Options;
+
+/*  wjw we will need some analog to the below imports later on, keep the below as a reference
+import com.ibm.JikesRVM.VM;
+import com.ibm.JikesRVM.VM_CompiledMethod;
+import com.ibm.JikesRVM.VM_CompiledMethods;
+import com.ibm.JikesRVM.VM_Constants;
+import com.ibm.JikesRVM.VM_Magic;
+import com.ibm.JikesRVM.VM_Processor;
+import com.ibm.JikesRVM.VM_Scheduler;
+import com.ibm.JikesRVM.VM_Thread;
+import com.ibm.JikesRVM.VM_Time;
+import com.ibm.JikesRVM.classloader.VM_Atom;
+import com.ibm.JikesRVM.classloader.VM_Method;
+import com.ibm.JikesRVM.memoryManagers.mmInterface.VM_CollectorThread;
+import com.ibm.JikesRVM.memoryManagers.mmInterface.MM_Interface;
+import com.ibm.JikesRVM.memoryManagers.mmInterface.SelectedPlan;
+import com.ibm.JikesRVM.memoryManagers.mmInterface.SelectedCollectorContext;
+import com.ibm.JikesRVM.memoryManagers.mmInterface.SelectedMutatorContext;
+*/
+
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+public class Collection extends org.mmtk.vm.Collection implements Constants, Uninterruptible {
+
+  /****************************************************************************
+   *
+   * Class variables
+   */
+  /***********************************************************************
+   *
+   * Initialization
+   */
+
+  /**
+   * Initialization that occurs at <i>build</i> time.  The values of
+   * statics at the completion of this routine will be reflected in
+   * the boot image.  Any objects referenced by those statics will be
+   * transitively included in the boot image.
+   *
+   * This is called from MM_Interface.
+   */
+  public static final void init() throws InterruptiblePragma {
+        //wjw NoGC does not have a collector, do nothing for starts
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.init() has been called");
+  }
+
+  /**
+   * An enumerator used to forward root objects
+   */
+  /**
+   * Triggers a collection.
+   *
+   * @param why the reason why a collection was triggered.  0 to
+   * <code>TRIGGER_REASONS - 1</code>.
+   */
+  public final void triggerCollection(int why) throws InterruptiblePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.triggerCollection() has been called why = " + why);
+  }
+  
+    /* whw -- toss all of triggerCollectionStatic()
+  public static final void triggerCollectionStatic(int why) throws InterruptiblePragma {
+    if (VM.VerifyAssertions) VM._assert((why >= 0) && (why < TRIGGER_REASONS)); 
+    Plan.collectionInitiated();
+
+    if (Options.verbose.getValue() >= 4) {
+      VM.sysWriteln("Entered VM_Interface.triggerCollection().  Stack:");
+      VM_Scheduler.dumpStack();
+    }
+    if (why == EXTERNAL_GC_TRIGGER) {
+      SelectedPlan.get().userTriggeredGC();
+      if (Options.verbose.getValue() == 1 || Options.verbose.getValue() == 2) 
+        VM.sysWrite("[Forced GC]");
+    }
+    if (Options.verbose.getValue() > 2) 
+      VM.sysWriteln("Collection triggered due to ", triggerReasons[why]);
+    Extent sizeBeforeGC = HeapGrowthManager.getCurrentHeapSize();
+    long start = VM_Time.cycles();
+    VM_CollectorThread.collect(VM_CollectorThread.handshake, why);
+    long end = VM_Time.cycles();
+    double gcTime = VM_Time.cyclesToMillis(end - start);
+    if (Options.verbose.getValue() > 2) VM.sysWriteln("Collection finished (ms): ", gcTime);
+
+    if (SelectedPlan.get().isLastGCFull() && 
+   sizeBeforeGC.EQ(HeapGrowthManager.getCurrentHeapSize()))
+      checkForExhaustion(why, false);
+    
+    Plan.checkForAsyncCollection();
+  }
+  */
+
+  /**
+   * Triggers a collection without allowing for a thread switch.  This is needed
+   * for Merlin lifetime analysis used by trace generation 
+   *
+   * @param why the reason why a collection was triggered.  0 to
+   * <code>TRIGGER_REASONS - 1</code>.
+   */
+  public final void triggerCollectionNow(int why) 
+    throws LogicallyUninterruptiblePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.triggerCollection() has been called why = " + why);
+  }
+
+  /**
+   * Trigger an asynchronous collection, checking for memory
+   * exhaustion first.
+   */
+  public final void triggerAsyncCollection()
+    throws UninterruptiblePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.triggerAsyncCollection() has been called"); 
+  }
+
+  /**
+   * Determine whether a collection cycle has fully completed (this is
+   * used to ensure a GC is not in the process of completing, to
+   * avoid, for example, an async GC being triggered on the switch
+   * from GC to mutator thread before all GC threads have switched.
+   *
+   * @return True if GC is not in progress.
+   */
+ public final boolean noThreadsInGC() throws UninterruptiblePragma {
+   return true;   //wjw for starts, we are doing NoGC with single thread
+ }
+
+  /**
+   * Prepare a mutator for a collection.
+   *
+   * @param m the mutator to prepare
+   */
+  public final void prepareMutator(MutatorContext m) {
+        //wjw since its single thread NoGC for now, do nothing
+        //probably need to suspend the mutator at a safepoint
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.prepareMutator() has been called"); 
+  }
+  
+  /**
+   * Prepare a collector for a collection.
+   *
+   * @param c the collector to prepare
+   */
+  public final void prepareCollector(CollectorContext c) {
+      //wjw since its single thread NoGC for now, do nothing
+      //probably need to enumerate the roots (???)
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.prepareCollector() has been called");  
+  }
+
+  /**
+   * Rendezvous with all other processors, returning the rank
+   * (that is, the order this processor arrived at the barrier).
+   */
+  public final int rendezvous(int where) throws UninterruptiblePragma {
+      //wjw since its single thread NoGC for now, do nothing
+      //probably need to wait on a sync barrier before proceeding
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.rendezvous() has been called"); 
+    return 0;
+  }
+
+  /***********************************************************************
+   *
+   * Finalizers
+   */
+  
+  /**
+   * Schedule the finalizerThread, if there are objects to be
+   * finalized and the finalizerThread is on its queue (ie. currently
+   * idle).  Should be called at the end of GC after moveToFinalizable
+   * has been called, and before mutators are allowed to run.
+   */
+  public static final void scheduleFinalizerThread ()
+    throws UninterruptiblePragma {
+      //wjw since its single thread NoGC for now, do nothing
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Collection.rendezvous() has been called");
+    }
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Lock.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Lock.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Lock.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Lock.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,88 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+import org.mmtk.utility.Log;
+
+/**
+ * Simple, fair locks with deadlock detection.
+ *
+ * The implementation mimics a deli-counter and consists of two values: 
+ * the ticket dispenser and the now-serving display, both initially zero.
+ * Acquiring a lock involves grabbing a ticket number from the dispenser
+ * using a fetchAndIncrement and waiting until the ticket number equals
+ * the now-serving display.  On release, the now-serving display is
+ * also fetchAndIncremented.
+ * 
+ */
+public class Lock extends org.mmtk.vm.Lock implements Uninterruptible {
+
+
+  // Core Instance fields
+  private String name;        // logical name of lock
+  private int id;             // lock id (based on a non-resetting counter)
+
+  public Lock(String name) { 
+    this();
+    this.name = name;
+  }
+  
+  public Lock() { 
+
+  }
+
+  public void setName(String str) {
+    name = str;
+  }
+
+  public void acquire() {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Lock.acquire(): " + name);
+      try 
+      {
+          this.wait();
+      } 
+      catch (Exception e) 
+      { 
+          System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Lock.acquire() has a problem: " + e);
+      }
+  }
+
+  public void check (int w) {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Lock.check(), w = " + w + name);    
+  }
+
+  // Release the lock by incrementing serving counter.
+  // (1) The sync is needed to flush changes made while the lock is held and also prevent 
+  //        instructions floating into the critical section.
+  // (2) When verbose, the amount of time the lock is ehld is printed.
+  //
+  public void release() 
+  {
+       System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Lock.release(): " + name);
+       this.notify();
+  }
+
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Memory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Memory.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Memory.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Memory.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,200 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.mmtk.plan.Plan;
+import org.mmtk.policy.ImmortalSpace;
+import org.mmtk.utility.Constants;
+
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+
+public class Memory extends org.mmtk.vm.Memory
+  implements Constants, Uninterruptible {
+
+    protected final Address getHeapStartConstant() { return Address.fromInt(0x100); } //BOOT_IMAGE_DATA_START
+    protected final Address getHeapEndConstant() { return Address.fromInt(0xFFff0000); }  //MAXIMUM_MAPPABLE
+    protected final Address getAvailableStartConstant() 
+    { 
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.getAvailableStartConstant(), needs fixing now");
+        return Address.fromInt(0); //BOOT_IMAGE_CODE_END
+    }
+    protected final Address getAvailableEndConstant() 
+    { 
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.getAvailableEndConstant(), needs fixing now");      
+        return Address.fromInt(0); //MAXIMUM_MAPPABLE;
+    }
+  protected final byte getLogBytesInAddressConstant() { return 2; }
+  protected final byte getLogBytesInWordConstant() { return 2; }
+  protected final byte getLogBytesInPageConstant() { return 12; }
+  protected final byte getLogMinAlignmentConstant() { return 3;}
+  protected final byte getMaxAlignmentShiftConstant() { return 3; } //wjw -- I dont have a clue
+  protected final int getMaxBytesPaddingConstant() { return 8; } 
+  protected final int getAlignmentValueConstant() { return 0x01020304;}
+ 
+
+    public final ImmortalSpace getVMSpace() throws InterruptiblePragma
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.globalPrepareVMSpace() needs fixing");
+        return null;
+    }
+
+    public final void globalPrepareVMSpace() 
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.globalPrepareVMSpace() needs fixing");
+    }
+
+    public final void collectorPrepareVMSpace() 
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.collectorPrepareVMSpace() needs fixing");
+    }
+
+    public final void collectorReleaseVMSpace() 
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.collectorReleaseVMSpace() needs fixing");
+    }
+    public final void globalReleaseVMSpace() 
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.gobalReleaseVMSpace() needs fixing");
+    }
+    public final void setHeapRange(int id, Address start, Address end) 
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.setHeapRange() needs fixing");
+    }
+ /**
+   * Maps an area of virtual memory.
+   *
+   * @param start the address of the start of the area to be mapped
+   * @param size the size, in bytes, of the area to be mapped
+   * @return 0 if successful, otherwise the system errno
+   */
+  public final int mmap(Address start, int size) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.mmap() needs fixing");
+      /*
+    Address result = VM_Memory.mmap(start, Extent.fromIntZeroExtend(size),
+                                       VM_Memory.PROT_READ | VM_Memory.PROT_WRITE | VM_Memory.PROT_EXEC, 
+                                       VM_Memory.MAP_PRIVATE | VM_Memory.MAP_FIXED | VM_Memory.MAP_ANONYMOUS);
+    if (result.EQ(start)) return 0;
+    if (result.GT(Address.fromIntZeroExtend(127))) {
+      VM.sysWrite("mmap with MAP_FIXED on ", start);
+      VM.sysWriteln(" returned some other address", result);
+      VM.sysFail("mmap with MAP_FIXED has unexpected behavior");
+    }
+    */
+    return 99;
+  }
+  
+  /**
+   * Protects access to an area of virtual memory.
+   *
+   * @param start the address of the start of the area to be mapped
+   * @param size the size, in bytes, of the area to be mapped
+   * @return <code>true</code> if successful, otherwise
+   * <code>false</code>
+   */
+  public final boolean mprotect(Address start, int size) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.mprotect() needs fixing");
+    return false; //return VM_Memory.mprotect(start, Extent.fromIntZeroExtend(size), VM_Memory.PROT_NONE);
+  }
+
+  /**
+   * Allows access to an area of virtual memory.
+   *
+   * @param start the address of the start of the area to be mapped
+   * @param size the size, in bytes, of the area to be mapped
+   * @return <code>true</code> if successful, otherwise
+   * <code>false</code>
+   */
+  public final boolean munprotect(Address start, int size) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.mprotect() needs fixing");
+    return false; //VM_Memory.mprotect(start, Extent.fromIntZeroExtend(size), VM_Memory.PROT_READ | VM_Memory.PROT_WRITE | VM_Memory.PROT_EXEC);
+  }
+
+  /**
+   * Zero a region of memory.
+   * @param start Start of address range (inclusive)
+   * @param len Length in bytes of range to zero
+   * Returned: nothing
+   */
+  public final void zero(Address start, Extent len) {
+      byte zeroByte = 0;
+      int numberOfBytes = len.toInt();
+      for(int xx=0; xx < numberOfBytes; xx++) 
+      {
+        start.store(zeroByte);
+        start.plus(1);
+      }
+  }
+
+  /**
+   * Zero a range of pages of memory.
+   * @param start Start of address range (must be a page address)
+   * @param len Length in bytes of range (must be multiple of page size)
+   */
+  public final void zeroPages(Address start, int len) {
+      int zeroInt = 0;
+      for(int xx=0; xx < len; len+=4) 
+      {
+          start.store(zeroInt);
+          start.plus(4);
+      }
+  }
+
+  /**
+   * Logs the contents of an address and the surrounding memory to the
+   * error output.
+   *
+   * @param start the address of the memory to be dumped
+   * @param beforeBytes the number of bytes before the address to be
+   * included
+   * @param afterBytes the number of bytes after the address to be
+   * included
+   */
+  public final void dumpMemory(Address start, int beforeBytes,
+                                int afterBytes) {
+      Address low = start.minus(beforeBytes);
+      Address hi = start.plus(afterBytes);
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.dumpMemory() called -------------------------");
+      while (low.NE(hi) ) 
+      {
+        byte b1 = low.loadByte();
+        System.out.print(b1 + " ");
+        low.plus(1);
+      }
+      System.out.println();
+      System.out.println("--------------------------------------------dumpMemory finished");
+  }
+
+  /*
+   * Utilities from the VM class
+   */
+
+  public final void sync() throws InlinePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.sync() was called"); 
+  }
+
+  public final void isync() throws InlinePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Memory.isync() was called");
+  }
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ObjectModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ObjectModel.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ObjectModel.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ObjectModel.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,480 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.mmtk.utility.scan.MMType;
+import org.mmtk.utility.Constants;
+import org.mmtk.utility.alloc.Allocator;
+
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+/**
+ * $Id: ObjectModel.java,v 1.6 2006/06/19 06:08:15 steveb-oss Exp $ 
+ *
+ * @author Steve Blackburn
+ * @author Perry Cheng
+ *
+ * @version $Revision: 1.6 $
+ * @date $Date: 2006/06/19 06:08:15 $
+ */
+public final class ObjectModel extends org.mmtk.vm.ObjectModel implements Constants, Uninterruptible {
+  /**
+   * Copy an object using a plan's allocCopy to get space and install
+   * the forwarding pointer.  On entry, <code>from</code> must have
+   * been reserved for copying by the caller.  This method calls the
+   * plan's <code>getStatusForCopy()</code> method to establish a new
+   * status word for the copied object and <code>postCopy()</code> to
+   * allow the plan to perform any post copy actions.
+   *
+   * @param from the address of the object to be copied
+   * @return the address of the new object
+   */
+  public ObjectReference copy(ObjectReference from, int allocator)
+    throws InlinePragma {
+
+/*
+wjw --- need to call native method to do something like the below to get the object size
+unsigned int
+get_object_size_bytes(Partial_Reveal_Object *p_obj)
+{
+    bool arrayp = is_array (p_obj);
+    unsigned int sz;
+    if (arrayp) {
+        sz = vm_vector_size(p_obj->vt()->get_gcvt()->gc_clss, vector_get_length((Vector_Handle)p_obj));
+        return sz; 
+    } else {
+            return p_obj->vt()->get_gcvt()->gc_allocated_size;
+    }
+}
+
+ */
+
+/*
+    Object[] tib = VM_ObjectModel.getTIB(from);
+    VM_Type type = VM_Magic.objectAsType(tib[TIB_TYPE_INDEX]);
+    
+    if (type.isClassType())
+      return copyScalar(from, tib, type.asClass(), allocator);
+    else
+      return copyArray(from, tib, type.asArray(), allocator);
+  */
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.copy was called");
+      return from;  //wjw -- keep the compiler happy for now
+  }
+
+    /*
+  private ObjectReference copyScalar(ObjectReference from, Object[] tib,
+                                       VM_Class type, int allocator)
+    throws InlinePragma {
+    int bytes = VM_ObjectModel.bytesRequiredWhenCopied(from, type);
+    int align = VM_ObjectModel.getAlignment(type, from);
+    int offset = VM_ObjectModel.getOffsetForAlignment(type, from);
+    SelectedCollectorContext plan = SelectedCollectorContext.get();
+    allocator = plan.copyCheckAllocator(from, bytes, align, allocator);
+    Address region = MM_Interface.allocateSpace(plan, bytes, align, offset,
+                                                allocator, from);
+    Object toObj = VM_ObjectModel.moveObject(region, from, bytes, false, type);
+    ObjectReference to = ObjectReference.fromObject(toObj);
+    plan.postCopy(to, ObjectReference.fromObject(tib), bytes, allocator);
+    MMType mmType = (MMType) type.getMMType();
+    mmType.profileCopy(bytes);
+    return to;
+  }
+
+  private ObjectReference copyArray(ObjectReference from, Object[] tib,
+                                      VM_Array type, int allocator)
+    throws InlinePragma {
+    int elements = VM_Magic.getArrayLength(from);
+    int bytes = VM_ObjectModel.bytesRequiredWhenCopied(from, type, elements);
+    int align = VM_ObjectModel.getAlignment(type, from);
+    int offset = VM_ObjectModel.getOffsetForAlignment(type, from);
+    SelectedCollectorContext plan = SelectedCollectorContext.get();
+    allocator = plan.copyCheckAllocator(from, bytes, align, allocator);
+    Address region = MM_Interface.allocateSpace(plan, bytes, align, offset,
+                                                allocator, from);
+    Object toObj = VM_ObjectModel.moveObject(region, from, bytes, false, type);
+    ObjectReference to = ObjectReference.fromObject(toObj);
+    plan.postCopy(to, ObjectReference.fromObject(tib), bytes, allocator);
+    if (type == VM_Type.CodeArrayType) {
+      // sync all moved code arrays to get icache and dcache in sync
+      // immediately.
+      int dataSize = bytes - VM_ObjectModel.computeHeaderSize(VM_Magic.getObjectType(toObj));
+      VM_Memory.sync(to.toAddress(), dataSize);
+    }
+    MMType mmType = (MMType) type.getMMType();
+    mmType.profileCopy(bytes);
+    return to;
+  }
+ */
+
+  /**
+   * Copy an object to be pointer to by the to address. This is required 
+   * for delayed-copy collectors such as compacting collectors. During the 
+   * collection, MMTk reserves a region in the heap for an object as per
+   * requirements found from ObjectModel and then asks ObjectModel to 
+   * determine what the object's reference will be post-copy.
+   * 
+   * @param from the address of the object to be copied
+   * @param to The target location.
+   * @param region The start (or an address less than) the region that was reserved for this object.
+   * @return Address The address past the end of the copied object
+   */
+  public Address copyTo(ObjectReference from, ObjectReference to, Address region)
+    throws InlinePragma {
+/*
+    Object[] tib = VM_ObjectModel.getTIB(from);
+    VM_Type type = VM_Magic.objectAsType(tib[TIB_TYPE_INDEX]);
+    int bytes;
+    
+    boolean copy = (from != to);
+    
+    if (copy) {
+      if (type.isClassType()) {
+        VM_Class classType = type.asClass();
+        bytes = VM_ObjectModel.bytesRequiredWhenCopied(from, classType);
+        VM_ObjectModel.moveObject(from, to, bytes, false, classType);
+      } else {
+      VM_Array arrayType = type.asArray();
+        int elements = VM_Magic.getArrayLength(from);
+        bytes = VM_ObjectModel.bytesRequiredWhenCopied(from, arrayType, elements);
+        VM_ObjectModel.moveObject(from, to, bytes, false, arrayType);
+      }
+    } else {
+      bytes = getCurrentSize(to);
+    }
+    
+    Address start = VM_ObjectModel.objectStartRef(to);
+    Allocator.fillAlignmentGap(region, start);
+    
+    return start.plus(bytes);
+*/
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.copyTo() was called");
+      return Address.fromInt(0);
+  }
+
+  /**
+   * Return the reference that an object will be refered to after it is copied
+   * to the specified region. Used in delayed-copy collectors such as compacting
+   * collectors.
+   *
+   * @param from The object to be copied.
+   * @param to The region to be copied to.
+   * @return The resulting reference.
+   */
+  public ObjectReference getReferenceWhenCopiedTo(ObjectReference from, Address to) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getReferenceWhenCopiedTo() was called");
+    return from;  // keep the compiler happy -- xObjectReference.fromObject(VM_ObjectModel.getReferenceWhenCopiedTo(from, to));
+  }
+  
+  /**
+   * Gets a pointer to the address just past the end of the object.
+   * 
+   * @param object The objecty.
+   */
+  public Address getObjectEndAddress(ObjectReference object) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getObjectEndAddress() was called");
+    return Address.fromInt(0);  // keep the compiler happy
+  }
+  
+  /**
+   * Return the size required to copy an object
+   *
+   * @param object The object whose size is to be queried
+   * @return The size required to copy <code>obj</code>
+   */
+  public int getSizeWhenCopied(ObjectReference object) {
+    //need to use drlvm's get_object_size_bytes()
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getSizeWhenCopied() was called");
+    return 0;  // VM_ObjectModel.bytesRequiredWhenCopied(object);
+  }
+  
+  /**
+   * Return the alignment requirement for a copy of this object
+   *
+   * @param object The object whose size is to be queried
+   * @return The alignment required for a copy of <code>obj</code>
+   */
+  public int getAlignWhenCopied(ObjectReference object) {
+
+/*
+    Object[] tib = VM_ObjectModel.getTIB(object);
+    VM_Type type = VM_Magic.objectAsType(tib[TIB_TYPE_INDEX]);
+    if (type.isArrayType()) {
+      return VM_ObjectModel.getAlignment(type.asArray(), object);
+    } else {
+      return VM_ObjectModel.getAlignment(type.asClass(), object);
+    }
+*/
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getAlignWhenCopied() was called");
+    return 0;
+  }
+  
+  /**
+   * Return the alignment offset requirements for a copy of this object
+   *
+   * @param object The object whose size is to be queried
+   * @return The alignment offset required for a copy of <code>obj</code>
+   */
+  public int getAlignOffsetWhenCopied(ObjectReference object) {
+/*
+    Object[] tib = VM_ObjectModel.getTIB(object);
+    VM_Type type = VM_Magic.objectAsType(tib[TIB_TYPE_INDEX]);
+    if (type.isArrayType()) {
+      return VM_ObjectModel.getOffsetForAlignment(type.asArray(), object);
+    } else {
+      return VM_ObjectModel.getOffsetForAlignment(type.asClass(), object);
+    }
+    */
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getAlignOffsetWhenCopied() was called");
+      return 0;
+  }
+  
+  /**
+   * Return the size used by an object
+   *
+   * @param object The object whose size is to be queried
+   * @return The size of <code>obj</code>
+   */
+  public int getCurrentSize(ObjectReference object) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getCurrentSize() was called");
+      return 0;
+      // return VM_ObjectModel.bytesUsed(object);
+  }
+
+  /**
+   * Return the next object in the heap under contiguous allocation
+   */
+  public ObjectReference getNextObject(ObjectReference object) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getNextObject() was called");
+    return ObjectReference.fromObject(null);
+  }
+
+  /**
+   * Return an object reference from knowledge of the low order word
+   */
+  public ObjectReference getObjectFromStartAddress(Address start) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getObjectFromStartAddress() was called");
+    return ObjectReference.fromObject(null);
+  }
+  
+  /**
+   * Get the type descriptor for an object.
+   *
+   * @param ref address of the object
+   * @return byte array with the type descriptor
+   */
+  public byte [] getTypeDescriptor(ObjectReference ref) {
+    //VM_Atom descriptor = VM_Magic.getObjectType(ref).getDescriptor();
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getTypeDescriptor() was called");
+    return new byte[10]; // descriptor.toByteArray();
+  }
+
+  public int getArrayLength(ObjectReference object) 
+    throws InlinePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getArrayLength() was called");
+    //return VM_Magic.getArrayLength(object.toObject());
+    return 0;
+  }
+  /**
+   * Tests a bit available for memory manager use in an object.
+   *
+   * @param object the address of the object
+   * @param idx the index of the bit
+   */
+  public boolean testAvailableBit(ObjectReference object, int idx) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.testAvailableBit() was called");
+    //return VM_ObjectModel.testAvailableBit(object.toObject(), idx);
+    return false;
+  }
+
+  /**
+   * Sets a bit available for memory manager use in an object.
+   *
+   * @param object the address of the object
+   * @param idx the index of the bit
+   * @param flag <code>true</code> to set the bit to 1,
+   * <code>false</code> to set it to 0
+   */
+  public void setAvailableBit(ObjectReference object, int idx,
+                                     boolean flag) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.setAvailableBit() was called");
+    //VM_ObjectModel.setAvailableBit(object.toObject(), idx, flag);
+    return;
+  }
+
+  /**
+   * Attempts to set the bits available for memory manager use in an
+   * object.  The attempt will only be successful if the current value
+   * of the bits matches <code>oldVal</code>.  The comparison with the
+   * current value and setting are atomic with respect to other
+   * allocators.
+   *
+   * @param object the address of the object
+   * @param oldVal the required current value of the bits
+   * @param newVal the desired new value of the bits
+   * @return <code>true</code> if the bits were set,
+   * <code>false</code> otherwise
+   */
+  public boolean attemptAvailableBits(ObjectReference object,
+                                             Word oldVal, Word newVal) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.attemptAvailableBits() was called");
+    //return VM_ObjectModel.attemptAvailableBits(object.toObject(), oldVal, newVal);
+    return false;
+  }
+
+  /**
+   * Gets the value of bits available for memory manager use in an
+   * object, in preparation for setting those bits.
+   *
+   * @param object the address of the object
+   * @return the value of the bits
+   */
+  public Word prepareAvailableBits(ObjectReference object) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.attemptAvailableBits() was called");
+    //return VM_ObjectModel.prepareAvailableBits(object.toObject());
+    return Word.fromInt(0);
+  }
+
+  /**
+   * Sets the bits available for memory manager use in an object.
+   *
+   * @param object the address of the object
+   * @param val the new value of the bits
+   */
+  public void writeAvailableBitsWord(ObjectReference object, Word val) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.attemptAvailableBits() was called");
+    //VM_ObjectModel.writeAvailableBitsWord(object.toObject(), val);
+    return;
+  }
+
+  /**
+   * Read the bits available for memory manager use in an object.
+   *
+   * @param object the address of the object
+   * @return the value of the bits
+   */
+  public Word readAvailableBitsWord(ObjectReference object) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.readAvailableBitsWord() was called");
+      //return VM_ObjectModel.readAvailableBitsWord(object);
+      return Word.fromInt(0);
+  }
+
+  /**
+   * Gets the offset of the memory management header from the object
+   * reference address.  XXX The object model / memory manager
+   * interface should be improved so that the memory manager does not
+   * need to know this.
+   *
+   * @return the offset, relative the object reference address
+   */
+  /* AJG: Should this be a variable rather than method? */
+  public Offset GC_HEADER_OFFSET() {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.GC_HEADER_OFFSET() was called");
+    //return VM_ObjectModel.GC_HEADER_OFFSET;
+    return Offset.fromInt(0);
+  }
+
+  /**
+   * Returns the lowest address of the storage associated with an object.
+   *
+   * @param object the reference address of the object
+   * @return the lowest address of the object
+   */
+  public Address objectStartRef(ObjectReference object)
+    throws InlinePragma {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.objectStartRef() was called");
+    //return VM_ObjectModel.objectStartRef(object);
+    return Address.fromInt(0);
+  }
+
+  /**
+   * Returns an address guaranteed to be inside the storage assocatied
+   * with and object.
+   *
+   * @param object the reference address of the object
+   * @return an address inside the object
+   */
+  public Address refToAddress(ObjectReference object) {
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.objectStartRef() was called");
+    //return VM_ObjectModel.getPointerInMemoryRegion(object);
+    return Address.fromInt(0);
+  }
+
+  /**
+   * Checks if a reference of the given type in another object is
+   * inherently acyclic.  The type is given as a TIB.
+   *
+   * @return <code>true</code> if a reference of the type is
+   * inherently acyclic
+   */
+  public boolean isAcyclic(ObjectReference typeRef) 
+/*
+    throws InlinePragma {
+    Object type;
+    Object[] tib = VM_Magic.addressAsObjectArray(typeRef.toAddress());
+    if (true) {  // necessary to avoid an odd compiler bug
+      type = VM_Magic.getObjectAtOffset(tib, Offset.fromIntZeroExtend(TIB_TYPE_INDEX));
+    } else {
+      type = tib[TIB_TYPE_INDEX];
+    }
+    return VM_Magic.objectAsType(type).isAcyclicReference();
+*/
+  {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.isAcyclic() was called");
+      return false;
+  }
+
+  /**
+   * Return the type object for a give object
+   *
+   * @param object The object whose type is required
+   * @return The type object for <code>object</code>
+   */
+  public MMType getObjectType(ObjectReference object) 
+    throws InlinePragma {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ObjectModel.getObjectType() was called");
+    /*
+    Object obj = object.toObject();
+    Object[] tib = VM_ObjectModel.getTIB(obj);
+    if (VM.VerifyAssertions) {
+      if (tib == null || VM_ObjectModel.getObjectType(tib) != VM_Type.JavaLangObjectArrayType) {
+        VM.sysWriteln("getObjectType: objRef = ", object.toAddress(), "   tib = ", VM_Magic.objectAsAddress(tib));
+        VM.sysWriteln("               tib's type is not Object[]");
+        VM._assert(false);
+      }
+    }
+    VM_Type vmType = VM_Magic.objectAsType(tib[TIB_TYPE_INDEX]);
+    if (VM.VerifyAssertions) {
+      if (vmType == null) {
+        VM.sysWriteln("getObjectType: null type for object = ", object);
+        VM._assert(false);
+      }
+    }
+    if (VM.VerifyAssertions) VM._assert(vmType.getMMType() != null);
+    return (MMType) vmType.getMMType();
+  */
+    return new MMType(false, false, false, 0, null);
+  }
+}
+

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Options.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Options.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Options.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Options.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,336 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+package org.apache.HarmonyDRLVM.mm.mmtk;
+ 
+import org.vmmagic.unboxed.Extent;
+
+import org.mmtk.utility.options.*;
+
+
+/**
+ * Class to handle command-line arguments and options for GC.
+ */
+public final class Options extends org.mmtk.vm.Options {
+
+  /**
+   * Map a name into a key in the VM's format
+   *
+   * @param name the space delimited name. 
+   * @return the vm specific key.
+   */
+  public final String getKey(String name) {
+      /*
+    int space = name.indexOf(' ');
+    if (space < 0) return name.toLowerCase();
+
+    String word = name.substring(0, space); 
+    String key = word.toLowerCase();
+    
+    do {
+      int old = space+1;
+      space = name.indexOf(' ', old);
+      if (space < 0) {
+        key += name.substring(old);
+        return key;
+      }
+      key += name.substring(old, space);
+    } while (true);
+    */
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.getKey() was called");
+    return null;
+  }
+
+  /**
+   * Failure during option processing. This must never return.
+   *
+   * @param o The option that was being set.
+   * @param message The error message.
+   */
+  public final void fail(Option o, String message) {
+      System.out.println("ERROR: Option '" + o.getKey() + "' : " + 
+                 message);
+      Object obj = new Object();
+      obj = null;
+      try 
+      {
+          obj.wait();  // this should cause a system exit
+      } 
+      catch (Exception e) 
+      {
+          System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Options.fail has bugs");
+      }
+  }
+
+  /**
+   * Warning during option processing.
+   *
+   * @param o The option that was being set.
+   * @param message The warning message.
+   */
+  public final void warn(Option o, String message) {
+      System.out.println("WARNING: Option '" + o.getKey() + "' : " + 
+                    message);
+  }
+
+
+  /**
+   * Take a string (most likely a command-line argument) and try to proccess it
+   * as an option command.  Return true if the string was understood, false 
+   * otherwise.
+   *
+   * @param arg a String to try to process as an option command
+   * @return true if successful, false otherwise
+   */
+  public static boolean process(String arg) {
+
+    // First handle the "option commands"
+    if (arg.equals("help")) {
+       System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.process() help was called"); //printHelp();
+       return true;
+    }
+    if (arg.equals("printOptions")) {
+       System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.process() printOptions was called"); //printHelp();//printOptions();
+       return true;
+    }
+    if (arg.equals("")) {
+      System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.process() <zip> was called"); //printHelp();
+      //printHelp();
+      return true;
+    }
+
+    // Required format of arg is 'name=value'
+    // Split into 'name' and 'value' strings
+    int split = arg.indexOf('=');
+    if (split == -1) {
+      System.out.println("  Illegal option specification!\n  \""+arg+
+                  "\" must be specified as a name-value pair in the form of option=value");
+      return false;
+    }
+/*
+    String name = arg.substring(0,split);
+    String value = arg.substring(split+1);
+
+    Option o = Option.getOption(name); 
+
+    if (o == null) return false;
+
+    switch (o.getType()) {
+      case Option.BOOLEAN_OPTION:
+        if (value.equals("true")) {
+          ((BooleanOption)o).setValue(true);
+          return true;
+        } else if (value.equals("false")) {
+          ((BooleanOption)o).setValue(false);
+          return true;
+        }
+        return false;
+      case Option.INT_OPTION:
+        int ival = VM_CommandLineArgs.primitiveParseInt(value);
+        ((IntOption)o).setValue(ival);
+        return true;
+      case Option.FLOAT_OPTION:
+        float fval = VM_CommandLineArgs.primitiveParseFloat(value);
+        ((FloatOption)o).setValue(fval);
+        return true;
+      case Option.STRING_OPTION:
+        ((StringOption)o).setValue(value);
+        return true;
+      case Option.ENUM_OPTION:
+        ((EnumOption)o).setValue(value);
+        return true;
+      case Option.PAGES_OPTION:
+        long pval = VM_CommandLineArgs.parseMemorySize(
+          o.getName(),
+          ":gc:" + o.getKey() + "=",
+          "b",
+          1,
+          ":gc:" + o.getKey() + "=" + value,
+          value);
+        if (pval < 0) return false;
+        ((PagesOption)o).setBytes(Extent.fromIntSignExtend((int)pval));
+        return true;
+      case Option.MICROSECONDS_OPTION:
+        int mval = VM_CommandLineArgs.primitiveParseInt(value);
+        ((MicrosecondsOption)o).setMicroseconds(mval);
+        return true;
+    }
+
+    // None of the above tests matched, so this wasn't an option
+    */
+    return false;
+  }
+
+  /**
+   * Print a short description of every option
+   */
+
+    /*
+  public static void printHelp() {
+
+    VM.sysWriteln("Commands");
+    VM.sysWriteln("-X:gc[:help]\t\t\tPrint brief description of GC arguments");
+    VM.sysWriteln("-X:gc:printOptions\t\tPrint the current values of GC options");
+    VM.sysWriteln();
+
+    //Begin generated help messages
+    VM.sysWriteln("Boolean Options (-X:gc:<option>=true or -X:gc:<option>=false)");
+    VM.sysWriteln("Option                                 Description");
+
+    Option o = Option.getFirst();
+    while (o != null) {
+      if (o.getType() == Option.BOOLEAN_OPTION) {
+        String key = o.getKey();
+        VM.sysWrite(key);
+        for (int c = key.length(); c<39;c++) {
+          VM.sysWrite(" ");
+        }
+        VM.sysWriteln(o.getDescription()); 
+      }
+      o = o.getNext();
+    }
+
+    VM.sysWriteln("\nValue Options (-X:gc:<option>=<value>)");
+    VM.sysWriteln("Option                         Type    Description");
+    
+    o = Option.getFirst();
+    while (o != null) {
+      if (o.getType() != Option.BOOLEAN_OPTION &&
+          o.getType() != Option.ENUM_OPTION) {
+        String key = o.getKey();
+        VM.sysWrite(key);
+        for (int c = key.length(); c<31;c++) {
+          VM.sysWrite(" ");
+        }
+        switch (o.getType()) {
+          case Option.INT_OPTION:          VM.sysWrite("int     "); break;
+          case Option.FLOAT_OPTION:        VM.sysWrite("float   "); break;
+          case Option.MICROSECONDS_OPTION: VM.sysWrite("usec    "); break;
+          case Option.PAGES_OPTION:        VM.sysWrite("bytes   "); break;
+          case Option.STRING_OPTION:       VM.sysWrite("string  "); break;
+        }
+        VM.sysWriteln(o.getDescription()); 
+      }
+      o = o.getNext();
+    }
+
+    VM.sysWriteln("\nSelection Options (set option to one of an enumeration of possible values)");
+
+    o = Option.getFirst();
+    while (o != null) {
+      if (o.getType() == Option.ENUM_OPTION) { 
+        VM.sysWrite("\t\t");
+        VM.sysWriteln(o.getDescription());
+        String key = o.getKey();
+        VM.sysWrite(key);
+        for (int c = key.length(); c<31;c++) {
+          VM.sysWrite(" ");
+        }
+        String[] vals = ((EnumOption)o).getValues();
+        for(int j=0; j<vals.length; j++) {
+          VM.sysWrite(vals[j]);
+          VM.sysWrite(" ");
+        }
+        VM.sysWriteln();
+      }
+      o = o.getNext();
+    }
+
+    VM.sysExit(VM.EXIT_STATUS_PRINTED_HELP_MESSAGE);
+  }    
+*/
+
+
+  /**
+   * Print out the option values
+   */
+
+/*
+  public static void printOptions() {
+    VM.sysWriteln("Current value of GC options");
+
+    Option o = Option.getFirst();
+    while (o != null) {
+      if (o.getType() == Option.BOOLEAN_OPTION) {
+        String key = o.getKey();
+        VM.sysWrite("\t");
+        VM.sysWrite(key);
+        for (int c = key.length(); c<31;c++) {
+          VM.sysWrite(" ");
+        }
+        VM.sysWrite(" = ");
+        VM.sysWriteln(((BooleanOption)o).getValue());
+      }
+      o = o.getNext();
+    }
+
+    o = Option.getFirst();
+    while (o != null) {
+      if (o.getType() != Option.BOOLEAN_OPTION &&
+          o.getType() != Option.ENUM_OPTION) {
+        String key = o.getKey();
+        VM.sysWrite("\t");
+        VM.sysWrite(key);
+        for (int c = key.length(); c<31;c++) {
+          VM.sysWrite(" ");
+        }
+        VM.sysWrite(" = ");
+        switch (o.getType()) {
+          case Option.INT_OPTION:
+            VM.sysWriteln(((IntOption)o).getValue()); 
+            break;
+          case Option.FLOAT_OPTION:
+            VM.sysWriteln(((FloatOption)o).getValue()); 
+            break;
+          case Option.MICROSECONDS_OPTION:
+            VM.sysWrite(((MicrosecondsOption)o).getMicroseconds()); 
+            VM.sysWriteln(" usec");
+            break;
+          case Option.PAGES_OPTION:
+            VM.sysWrite(((PagesOption)o).getBytes());
+            VM.sysWriteln(" bytes");
+            break;
+          case Option.STRING_OPTION:
+            VM.sysWriteln(((StringOption)o).getValue()); 
+            break;
+        }
+      }
+      o = o.getNext();
+    }
+
+    o = Option.getFirst();
+    while (o != null) {
+      if (o.getType() == Option.ENUM_OPTION) {
+        String key = o.getKey();
+        VM.sysWrite("\t");
+        VM.sysWrite(key);
+        for (int c = key.length(); c<31;c++) {
+          VM.sysWrite(" ");
+        }
+        VM.sysWrite(" = ");
+        VM.sysWriteln(((EnumOption)o).getValueString());
+      }
+      o = o.getNext();
+    }
+  } 
+*/
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ReferenceGlue.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ReferenceGlue.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ReferenceGlue.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/ReferenceGlue.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,143 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+
+package org.apache.HarmonyDRLVM.mm.mmtk;
+ 
+import org.mmtk.utility.ReferenceProcessor;
+
+import org.vmmagic.pragma.*;
+import org.vmmagic.unboxed.*;
+
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.lang.ref.PhantomReference;
+
+
+/**
+ * This class manages SoftReferences, WeakReferences, and
+ * PhantomReferences. 
+ * 
+ * @author Chris Hoffmann
+ * @modified Andrew Gray
+ */
+public final class ReferenceGlue extends org.mmtk.vm.ReferenceGlue implements Uninterruptible 
+{
+
+    /**
+     * Scan through the list of references with the specified semantics.
+     * @param semantics the number representing the semantics
+     * @param True if it is safe to only scan new references.
+     */
+    public void scanReferences(int semantics, boolean nursery)
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ReferenceGlue.scanReferences() was called");
+    }
+
+    /**
+     * Scan through all references and forward. Only called when references
+     * are objects.
+     */
+    public void forwardReferences()
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ReferenceGlue.forwardReferences() was called");
+    }
+
+    /**
+     * Put this Reference object on its ReferenceQueue (if it has one)
+     * when its referent is no longer sufficiently reachable. The
+     * definition of "reachable" is defined by the semantics of the
+     * particular subclass of Reference. The implementation of this
+     * routine is determined by the the implementation of
+     * java.lang.ref.ReferenceQueue in GNU classpath. It is in this
+     * class rather than the public Reference class to ensure that Jikes
+     * has a safe way of enqueueing the object, one that cannot be
+     * overridden by the application program.
+     * 
+     * @see java.lang.ref.ReferenceQueue
+     * @param addr the address of the Reference object
+     * @param onlyOnce <code>true</code> if the reference has ever
+     * been enqueued previously it will not be enqueued
+     * @return <code>true</code> if the reference was enqueued
+     */
+    public boolean enqueueReference(Address addr, boolean onlyOnce)
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ReferenceGlue.enqueueReference() was called");
+        return false;
+    }
+
+    /***********************************************************************
+     * 
+     * Reference object field accesors
+     */
+
+    /**
+     * Get the referent from a reference.  For Java the reference
+     * is a Reference object.
+     * @param addr the address of the reference
+     * @return the referent address
+     */
+    public ObjectReference getReferent(Address addr)
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ReferenceGlue.getReferent() was called");
+        return ObjectReference.nullReference();
+    }
+
+    /**
+     * Set the referent in a reference.  For Java the reference is
+     * a Reference object.
+     * @param addr the address of the reference
+     * @param referent the referent address
+     */
+    public void setReferent(Address addr, ObjectReference referent)
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ReferenceGlue.setReferent() was called");
+    }
+ 
+    /**
+     * @return <code>true</code> if the references are implemented as heap
+     * objects (rather than in a table, for example).  In this context
+     * references are soft, weak or phantom references.
+     * 
+     * This must be implemented by subclasses, but is never called by MMTk users.
+     */
+    protected boolean getReferencesAreObjects()
+    {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.ReferenceGlue.getReferencesAreObjects() was called");
+        return false;
+    }
+  
+    /**
+     * NOTE: This method should not be called by anything other than the
+     * reflective mechanisms in org.mmtk.vm.VM, and is not implemented by
+     * subclasses.
+     * 
+     * This hack exists only to allow us to declare getVerifyAssertions() as 
+     * a protected method.
+     */
+    static boolean referencesAreObjectsTrapdoor(ReferenceGlue a) 
+    {
+        return a.getReferencesAreObjects();
+    }
+
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Scanning.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Scanning.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Scanning.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/Scanning.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,178 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2004
+ *
+ * (C) Copyright IBM Corp. 2001, 2003
+ */
+
+package org.apache.HarmonyDRLVM.mm.mmtk;
+ 
+
+import org.mmtk.plan.TraceLocal;
+import org.mmtk.utility.deque.*;
+import org.mmtk.utility.scan.*;
+import org.mmtk.utility.Constants;
+import org.mmtk.vm.VM;
+
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+public class Scanning extends org.mmtk.vm.Scanning implements Constants, Uninterruptible {
+  /****************************************************************************
+   *
+   * Class variables
+   */
+  private static final boolean TRACE_PRECOPY = false; // DEBUG
+
+  /** Counter to track index into thread table for root tracing.  */
+  private static SynchronizedCounter threadCounter = new SynchronizedCounter();
+
+  /**
+   * Delegated scanning of a object, processing each pointer field
+   * encountered. <b>Jikes RVM never delegates, so this is never
+   * executed</b>.
+   *
+   * @param object The object to be scanned.
+   */
+  public final void scanObject(TraceLocal trace, ObjectReference object) 
+    throws UninterruptiblePragma, InlinePragma {
+    // Never reached
+    VM.assertions._assert(false);
+  }
+  
+  /**
+   * Delegated precopying of a object's children, processing each pointer field
+   * encountered. <b>Jikes RVM never delegates, so this is never
+   * executed</b>.
+   *
+   * @param object The object to be scanned.
+   */
+  public final void precopyChildren(TraceLocal trace, ObjectReference object) 
+    throws UninterruptiblePragma, InlinePragma {
+    // Never reached
+   VM.assertions._assert(false);
+  }
+  
+  /**
+   * Delegated enumeration of the pointers in an object, calling back
+   * to a given plan for each pointer encountered. <b>Jikes RVM never
+   * delegates, so this is never executed</b>.
+   *
+   * @param object The object to be scanned.
+   * @param _enum the Enumerator object through which the trace
+   * is made
+   */
+  public final void enumeratePointers(ObjectReference object, Enumerator _enum) 
+    throws UninterruptiblePragma, InlinePragma {
+    // Never reached
+    VM.assertions._assert(false);
+  }
+
+  /**
+   * Prepares for using the <code>computeAllRoots</code> method.  The
+   * thread counter allows multiple GC threads to co-operatively
+   * iterate through the thread data structure (if load balancing
+   * parallel GC threads were not important, the thread counter could
+   * simply be replaced by a for loop).
+   */
+  public final void resetThreadCounter() {
+    threadCounter.reset();
+  }
+
+  /**
+   * Pre-copy all potentially movable instances used in the course of
+   * GC.  This includes the thread objects representing the GC threads
+   * themselves.  It is crucial that these instances are forwarded
+   * <i>prior</i> to the GC proper.  Since these instances <i>are
+   * not</i> enqueued for scanning, it is important that when roots
+   * are computed the same instances are explicitly scanned and
+   * included in the set of roots.  The existence of this method
+   * allows the actions of calculating roots and forwarding GC
+   * instances to be decoupled. 
+   * 
+   * The thread table is scanned in parallel by each processor, by striding
+   * through the table at a gap of chunkSize*numProcs.  Feel free to adjust
+   * chunkSize if you want to tune a parallel collector.
+   * 
+   * Explicitly no-inlined to prevent over-inlining of collectionPhase.
+   * 
+   * TODO Experiment with specialization to remove virtual dispatch ?
+   */
+  public final void preCopyGCInstances(TraceLocal trace) 
+  throws NoInlinePragma {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Scanning.preCopyGCInstances() was called");
+  }
+  
+ 
+  /**
+   * Enumerator the pointers in an object, calling back to a given plan
+   * for each pointer encountered. <i>NOTE</i> that only the "real"
+   * pointer fields are enumerated, not the TIB.
+   *
+   * @param trace The trace object to use to report precopy objects.
+   * @param object The object to be scanned.
+   */
+  private static void precopyChildren(TraceLocal trace, Object object) 
+    throws UninterruptiblePragma, InlinePragma {
+        System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Scanning.precopyChildren() was called");
+  }
+
+ /**
+   * Computes all roots.  This method establishes all roots for
+   * collection and places them in the root values, root locations and
+   * interior root locations queues.  This method should not have side
+   * effects (such as copying or forwarding of objects).  There are a
+   * number of important preconditions:
+   *
+   * <ul> 
+   * <li> All objects used in the course of GC (such as the GC thread
+   * objects) need to be "pre-copied" prior to calling this method.
+   * <li> The <code>threadCounter</code> must be reset so that load
+   * balancing parallel GC can share the work of scanning threads.
+   * </ul>
+   * 
+   * TODO rewrite to avoid the per-thread synchronization, like precopy.
+   *
+   * @param trace The trace object to use to report root locations.
+   */
+  public final void computeAllRoots(TraceLocal trace) {
+    //boolean processCodeLocations = MM_Interface.MOVES_OBJECTS;
+     /* scan statics */
+    //ScanStatics.scanStatics(trace);
+ 
+    /* scan all threads */
+    /* 
+     * while (true) {
+      int threadIndex = threadCounter.increment();
+      if (threadIndex > VM_Scheduler.threadHighWatermark) break;
+      
+      VM_Thread thread = VM_Scheduler.threads[threadIndex];
+      if (thread == null) continue;
+      
+      /* scan the thread (stack etc.) */
+      //ScanThread.scanThread(thread, trace, processCodeLocations);
+
+      /* identify this thread as a root */
+      //trace.addRootLocation(VM_Magic.objectAsAddress(VM_Scheduler.threads).plus(threadIndex<<LOG_BYTES_IN_ADDRESS));
+    //}
+    //VM_CollectorThread.gcBarrier.rendezvous(4200);
+    System.out.println("org.apache.HarmonyDRLVM.mm.mmtk.Scanning.computeAllRoots() was called");
+      return;
+  }
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedCollectorContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedCollectorContext.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedCollectorContext.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedCollectorContext.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2005
+ */
+
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.mmtk.plan.nogc.*;
+import org.vmmagic.pragma.*;
+
+public final class SelectedCollectorContext implements 
+  Uninterruptible {
+
+  public static final NoGCCollector singleton = new NoGCCollector();
+  
+  /**
+   * Return the instance of the SelectedPlan
+   */
+  public static final NoGCCollector get() throws InlinePragma {
+    return singleton;
+  }
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedMutatorContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedMutatorContext.java?rev=424858&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedMutatorContext.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/ext/vm/HarmonyDRLVM/org/apache/HarmonyDRLVM/mm/mmtk/SelectedMutatorContext.java Sun Jul 23 16:37:20 2006
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*
+ * (C) Copyright Department of Computer Science,
+ * Australian National University. 2005
+ */
+
+package org.apache.HarmonyDRLVM.mm.mmtk;
+
+import org.mmtk.plan.nogc.*;
+import org.vmmagic.pragma.*;
+
+public final class SelectedMutatorContext 
+  implements Uninterruptible {
+
+  public static final NoGCMutator singleton = new NoGCMutator();
+  
+  /**
+   * Return the instance of the SelectedPlan
+   */
+  public static final NoGCMutator get() throws InlinePragma {
+    return singleton;
+  }
+}



Mime
View raw message