You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by wj...@apache.org on 2006/07/24 02:00:51 UTC
svn commit: r424864 - in /incubator/harmony/enhanced/drlvm/trunk/vm/MMTk:
build.xml test.java
Author: wjwashburn
Date: Sun Jul 23 17:00:51 2006
New Revision: 424864
URL: http://svn.apache.org/viewvc?rev=424864&view=rev
Log:
adding basic MMTk porting files
Added:
incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/build.xml
incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/test.java
Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/build.xml?rev=424864&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/build.xml (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/build.xml Sun Jul 23 17:00:51 2006
@@ -0,0 +1,78 @@
+<!--
+ * Ant build file for MMTk
+ *
+ * - jar compiles from source and creates the jar file.
+ * $Date: 2006/07/08 01:51:44 $
+ * $Id: build.xml,v 1.19 2006/07/08 01:51:44 steveb Exp $
+-->
+
+<project name="MMTk" default="jar" basedir=".">
+ <description>MMTk</description>
+
+ <property name="src" location="src"/>
+ <property name="src.vm.stub" location="ext/vmmagic/stub"/>
+ <property name="src.gcspy.stub" location="ext/vm/stub"/>
+ <property name="ext.vm.HarmonyDRLVM" location="ext/vm/HarmonyDRLVM"/>
+ <property name="doc" location="doc"/>
+ <property name="extsrc" location="ext"/>
+ <property name="build" location="build"/>
+
+ <!-- =================================
+ target: initialize
+ ================================= -->
+ <target name="init">
+ <!-- Create the time stamp -->
+ <tstamp/>
+ <!-- Create the build directory structure used by compile -->
+ <mkdir dir="${build}"/>
+ </target>
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" description="clean up">
+ <delete dir="${build}"/>
+ <delete>
+ <fileset dir="${src}" includes="**/*.class"/>
+ <fileset dir="${src.vm.stub}" includes="**/*.class"/>
+ <fileset dir="${src.gcspy.stub}" includes="**/*.class"/>
+ <fileset dir="${src}" includes="**/*.class"/>
+ <fileset dir="${ext.vm.HarmonyDRLVM}" includes="**/*.class"/>
+ <fileset dir="." includes="mmtk.jar, *.class"/>
+ </delete>
+ </target>
+
+ <!-- =================================
+ target: compile all sources
+ ================================= -->
+ <target name="compile" depends="init" description="compile the MMTk sources" >
+ <!-- Compile the java code from ${src} into ${build} -->
+ <javac srcdir="${src.vm.stub}" destdir="${build}" classpath="junit-4.1.jar"/>
+ <javac srcdir="${src.gcspy.stub}" destdir="${build}" sourcepath="${vmstubsrc}:${src}" classpath="junit-4.1.jar"/>
+ <javac srcdir="${src}" destdir="${build}" sourcepath="${vmstubsrc}" classpath="junit-4.1.jar"/>
+ <javac srcdir="${ext.vm.HarmonyDRLVM}" destdir="${build}" sourcepath="${vmstubsrc}" classpath="junit-4.1.jar"/>
+ </target>
+
+ <!-- =================================
+ target: copy the sources, doc & licenses
+ ================================= -->
+ <target name="sources" depends="init" description="copy the sources" >
+ <copy todir="${build}">
+ <fileset dir="." includes="src/**"/>
+ <fileset dir="." includes="ext/**"/>
+ <fileset dir="." includes="doc/**"/>
+ <fileset file="LICENSE"/>
+ <fileset file="build.xml"/>
+ </copy>
+ </target>
+
+ <!-- =================================
+ target: jar
+ ================================= -->
+ <target name="jar" depends="compile,init,sources" description="generate the jar file" >
+ <!-- Put everything in ${build} into the mmtk-${DSTAMP}.jar file -->
+ <jar jarfile="mmtk.jar" basedir="${build}" index="true" />
+ <javac srcdir="." destdir="." includes="test.java" classpath="mmtk.jar"/>
+ </target>
+
+</project>
Added: incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/test.java?rev=424864&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/test.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/MMTk/test.java Sun Jul 23 17:00:51 2006
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+/**
+ * Few simple tests for magics Wb4J support in Jitrino.JET.
+ *
+ * @author Alexander V. Astapchuk
+ * @version $Revision$
+ */
+import org.vmmagic.unboxed.*;
+import org.apache.HarmonyDRLVM.mm.mmtk.*;
+import org.mmtk.vm.*;
+
+public class test {
+ public static void main(String[] args) {
+ VM vm_init = new VM();
+ System.out.println("top of test wjw------");
+ test0();
+ test1();
+ test2();
+ testWB();
+ }
+
+ static final int arrayLenOffset = 8;
+ static void test0()
+ {
+ Object [] arr = new Object[13];
+ ObjectReference ref = ObjectReference.fromObject(arr);
+ Address addr = ref.toAddress();
+ Address lenAddr = addr.plus(arrayLenOffset);
+ int len = lenAddr.loadInt();
+ if (len != arr.length) {
+ throw new Error("length does not match");
+ }
+ System.out.println("test0 - ok");
+ }
+ static void test1()
+ {
+ Object [] arr = new Object[17];
+ ObjectReference ref = ObjectReference.fromObject(arr);
+ Address addr = ref.toAddress();
+ Offset off = Offset.fromIntSignExtend(arrayLenOffset);
+ int len = addr.loadInt(off);
+ if (len != arr.length) {
+ throw new Error("length does not match");
+ }
+ System.out.println("test1 - ok");
+ }
+
+ static void test2()
+ {
+ Object obj = new Object();
+ ObjectReference ref = ObjectReference.fromObject(obj);
+ ObjectReferenceArray arr = ObjectReferenceArray.create(1);
+ arr.set(0, ref);
+ if (arr.get(0) != ref) {
+ throw new Error("Invalid ref read");
+ }
+ try {
+ // Even though these are magics, can't allow to
+ // write outside of array.
+ arr.set(10, ref);
+ // must not be here
+ throw new Error("Bounds check was not performed");
+ }
+ catch(ArrayIndexOutOfBoundsException e) {
+ // ok
+ }
+ System.out.println("test2 - ok");
+ }
+
+ static Object wbFldStatic = null;
+ Object wbFldInstance = null;
+ static void testWB()
+ {
+ Object obj = new Object();
+ test t = new test();
+ Object[] array = new Object[10];
+ //
+ wbFldStatic = obj;
+ //
+ t.wbFldInstance = obj;
+ //
+ array[3] = obj;
+ //
+ System.out.println("testWB - seems ok");
+ }
+
+}
\ No newline at end of file