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/11/28 07:20:48 UTC

svn commit: r479926 - in /harmony/enhanced/drlvm/trunk: build/make/ build/make/components/vm/ vm/em/src/ vm/gc_cc/javasrc/ vm/gc_cc/javasrc/org/ vm/gc_cc/javasrc/org/apache/ vm/gc_cc/javasrc/org/apache/harmony/ vm/gc_cc/javasrc/org/apache/harmony/drlvm...

Author: wjwashburn
Date: Mon Nov 27 22:20:46 2006
New Revision: 479926

URL: http://svn.apache.org/viewvc?view=rev&rev=479926
Log:
Harmony-2008, jit helper inlining infrastructure.  Adds a "build update" dependency on downloading mmtk.jar
build and build test are OK on windows32 and linux32


Added:
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
Modified:
    harmony/enhanced/drlvm/trunk/build/make/build.xml
    harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_cc.xml
    harmony/enhanced/drlvm/trunk/build/make/components/vm/kernel_classes.xml
    harmony/enhanced/drlvm/trunk/build/make/deploy.xml
    harmony/enhanced/drlvm/trunk/build/make/lnx.properties
    harmony/enhanced/drlvm/trunk/build/make/setup.xml
    harmony/enhanced/drlvm/trunk/build/make/win.properties
    harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp
    harmony/enhanced/drlvm/trunk/vm/include/open/vm.h
    harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java

Modified: harmony/enhanced/drlvm/trunk/build/make/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/build.xml?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/build.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/build.xml Mon Nov 27 22:20:46 2006
@@ -478,15 +478,16 @@
                                            deploy.getting_started,
                                            deploy.copy_classlib,
                                            deploy.antlr,
+                                           deploy.mmtk,
                                            deploy.tweakname">
-    	
-    	<!-- copy our hythr for the launcher to use -->
-    	
-    	<copy todir="${build.deploy.dir}/bin">
-    		<fileset dir="${build.deploy.dir}/bin/default/">
-    			<include name="*hythr*"/>
-    		</fileset>
-    	</copy>
+        
+        <!-- copy our hythr for the launcher to use -->
+        
+        <copy todir="${build.deploy.dir}/bin">
+            <fileset dir="${build.deploy.dir}/bin/default/">
+                <include name="*hythr*"/>
+            </fileset>
+        </copy>
         
         <!-- copy the harmonyvm.properties to use too -->
         
@@ -507,7 +508,7 @@
                 </chmod>
             </then>
         </if>
-    	
+        
     </target>
 
     <!-- tweak the names of java -> java.exec and
@@ -539,7 +540,7 @@
         <copy todir="${canonical.deploy.dir}/jre">
             <fileset dir="${build.deploy.dir}"/>
         </copy>
-    	
+        
         <if>
             <isset property="if.lnx"/>
             <then>
@@ -568,6 +569,24 @@
 <concat append="true" destfile="${build.deploy.dir}/lib/boot/bootclasspath.properties">
 # Dependency for generics parser
 bootclasspath.99=antlr-2.7.5.jar
+</concat>
+<fixcrlf srcdir="${build.deploy.dir}/lib/boot" includes="bootclasspath.properties"/>
+        </then>
+        </if> 
+    </target>
+
+    <target name="deploy.mmtk">
+        <copy todir="${build.deploy.dir}/lib/boot">
+            <fileset dir="${build.MMTK.home}">
+                <include name="mmtk-20061012.jar" />
+            </fileset>
+        </copy>
+        <loadfile srcFile="${build.deploy.dir}/lib/boot/bootclasspath.properties" property="boot.jars.list" />
+        <if> <not><contains string="${boot.jars.list}" substring="=mmtk-20061012.jar"/></not>
+        <then>
+<concat append="true" destfile="${build.deploy.dir}/lib/boot/bootclasspath.properties">
+# Dependency for unboxed mmtk package
+bootclasspath.100=mmtk-20061012.jar
 </concat>
 <fixcrlf srcdir="${build.deploy.dir}/lib/boot" includes="bootclasspath.properties"/>
         </then>

Modified: harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_cc.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_cc.xml?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_cc.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/gc_cc.xml Mon Nov 27 22:20:46 2006
@@ -1,97 +1,115 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-    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.
--->
-<!--
-Author: Marina V. Goldburt, Dmitry B. Yershov
-Version: $Revision: 1.4.2.3 $
--->
-<!--
-    This is build descriptor for the component "vm.gc_cc".
-
-    Please refer to make/components/README.txt for details about the component
-    build descriptor structure.
-  -->
-
-<project name="vm.gc_cc">
-    <target name="init" depends="common_vm">
-        <property name="build.depends" value="extra.apr,vm.vmcore,vm.hythr" />
-        <property name="outtype" value="shared" />
-        <property name="libname" value="gc_cc" />
-        <property name="src" location="${build.vm.home}" />
-
-        <compiler id="cpp.compiler" extends="common.cpp.compiler">
-            <includepath>
-                <pathelement location="${extra.apr.includes}" />
-            </includepath>
-
-            <includepath>
-                <dirset dir="${build.vm.home}">
-                    <include name="include" />
-                    <include name="vmcore/include" />
-                    <include name="vm/interface" />
-                    <select os="win">
-                        <include name="vmcore/src/util/win/include" />
-                    </select>
-                    <select os="lnx">
-                        <include name="vmcore/src/util/linux/include" />
-                    </select>
-                </dirset>
-            </includepath>
-
-            <fileset dir="${src}/gc_cc/src">
-                <include name="*.cpp" />            
-            </fileset>
-
-            <defineset define="BUILDING_GC" />
-
-            <select os="win">
-                <defineset define="_USRDLL" />
-            </select>
-
-            <select os="win" cfg="release" cxx="icl">
-                <compilerarg value="/Qip" />
-            </select>
-        </compiler>
-
-        <select os="win" arch="ipf">
-            <fileset id="asm.fileset"
-                     dir="${build.vm.home}/gc_cc/src">
-                <include name="ini_ipf_low_level.asm" />
-            </fileset>
-        </select>
-
-        <linker id="linker" extends="common.linker">
-            <select os="win">
-                <syslibset libs="advapi32,odbc32,ws2_32,mswsock" />
-                <libset libs="${vm.vmcore.lib}" dir="${vm.vmcore.libdir}" />
-            </select>
-
-            <select os="win" arch="ipf">
-                <syslibset libs="AdvAPI32" />
-            </select>
-
-            <select os="win" cfg="debug">
-                <linkerarg value="/NODEFAULTLIB:libcmtd.lib" />
-                <syslibset libs="msvcrtd" />
-            </select>
-
-            <libset libs="${vm.hythr.lib}" dir="${vm.hythr.libdir}" />
-            <select os="lnx">
-                <linkerarg value="-Bsymbolic" />
-            </select>
-        </linker>
-    </target>
-</project>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+<!--
+Author: Marina V. Goldburt, Dmitry B. Yershov
+Version: $Revision: 1.4.2.3 $
+-->
+<!--
+    This is build descriptor for the component "vm.gc_cc".
+
+    Please refer to make/components/README.txt for details about the component
+    build descriptor structure.
+  -->
+
+<project name="vm.gc_cc">
+    <target name="init" depends="common_vm">
+        <property name="build.depends" value="extra.apr,vm.vmcore,vm.hythr,vm.kernel_classes" />
+        <property name="outtype" value="shared" />
+        <property name="libname" value="gc_cc" />
+        <property name="src" location="${build.vm.home}" />
+
+        <compiler id="cpp.compiler" extends="common.cpp.compiler">
+            <includepath>
+                <pathelement location="${extra.apr.includes}" />
+            </includepath>
+
+            <includepath>
+                <dirset dir="${build.vm.home}">
+                    <include name="include" />
+                    <include name="vmcore/include" />
+                    <include name="vm/interface" />
+                    <select os="win">
+                        <include name="vmcore/src/util/win/include" />
+                    </select>
+                    <select os="lnx">
+                        <include name="vmcore/src/util/linux/include" />
+                    </select>
+                </dirset>
+            </includepath>
+
+            <fileset dir="${src}/gc_cc/src">
+                <include name="*.cpp" />            
+            </fileset>
+
+            <defineset define="BUILDING_GC" />
+
+            <select os="win">
+                <defineset define="_USRDLL" />
+            </select>
+
+            <select os="win" cfg="release" cxx="icl">
+                <compilerarg value="/Qip" />
+            </select>
+        </compiler>
+
+        <select os="win" arch="ipf">
+            <fileset id="asm.fileset"
+                     dir="${build.vm.home}/gc_cc/src">
+                <include name="ini_ipf_low_level.asm" />
+            </fileset>
+        </select>
+
+        <linker id="linker" extends="common.linker">
+            <select os="win">
+                <syslibset libs="advapi32,odbc32,ws2_32,mswsock" />
+                <libset libs="${vm.vmcore.lib}" dir="${vm.vmcore.libdir}" />
+            </select>
+
+            <select os="win" arch="ipf">
+                <syslibset libs="AdvAPI32" />
+            </select>
+
+            <select os="win" cfg="debug">
+                <linkerarg value="/NODEFAULTLIB:libcmtd.lib" />
+                <syslibset libs="msvcrtd" />
+            </select>
+
+            <libset libs="${vm.hythr.lib}" dir="${vm.hythr.libdir}" />
+            <select os="lnx">
+                <linkerarg value="-Bsymbolic" />
+            </select>
+        </linker>
+
+         <!-- Java helpers -->
+        <property name="build.java.depends" value=""/>
+
+        <path id="java.source">
+            <pathelement location="${build.vm.home}/gc_cc/javasrc" />
+        </path>                 
+
+        <path id="java.class.path">
+            <pathelement location="${java.build.dir}"/>
+
+            <fileset dir="${external.dep.CLASSLIB.jardir}" includes="*.jar" />
+            <pathelement location="${vm.kernel_classes.jardir}/kernel.jar"/>
+            <fileset dir="${build.MMTK.home}" includes="mmtk-20061012.jar" />
+        </path>
+
+        <property name="jarname" value="gc_cc.jar"/>
+
+    </target>
+</project>

Modified: harmony/enhanced/drlvm/trunk/build/make/components/vm/kernel_classes.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/components/vm/kernel_classes.xml?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/kernel_classes.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/kernel_classes.xml Mon Nov 27 22:20:46 2006
@@ -42,12 +42,13 @@
 
             <fileset dir="${external.dep.CLASSLIB.jardir}" includes="*.jar" />
             <fileset dir="${build.ANTLR.home}" includes="antlr-2.7.5.jar" />
+            <fileset dir="${build.MMTK.home}" includes="mmtk-20061012.jar" />
         </path>
 
         <property name="jarname" value="kernel.jar"/>
         
         <property name="manifest.file" 
-	        location="${build.vm.home}/vmcore/src/kernel_classes/resource/MANIFEST.MF" />	
+            location="${build.vm.home}/vmcore/src/kernel_classes/resource/MANIFEST.MF" />   
         
     </target>
 </project>

Modified: harmony/enhanced/drlvm/trunk/build/make/deploy.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/deploy.xml?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/deploy.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/deploy.xml Mon Nov 27 22:20:46 2006
@@ -55,6 +55,7 @@
 
         <gc_cc>
             <shared>bin/default:gc_cc</shared>
+            <jar>bin/default:gc_cc</jar>
         </gc_cc>
 
         <vmi>

Modified: harmony/enhanced/drlvm/trunk/build/make/lnx.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/lnx.properties?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/lnx.properties (original)
+++ harmony/enhanced/drlvm/trunk/build/make/lnx.properties Mon Nov 27 22:20:46 2006
@@ -75,6 +75,10 @@
 remote.ANTLR.archive=http://www.antlr.org/download/antlr-2.7.5.jar
 remote.ANTLR.archive.type=asis
 
+# org.vmmagic unboxed package. Used to enable address arithmetic in Java
+remote.MMTK.archive=http://cs.anu.edu.au/people/Robin.Garner/mmtk-20061012.jar
+remote.MMTK.archive.type=asis
+
 # Xalan-Java version 2.7.0
 XALAN_HOME=${external.dep.CLASSLIB}/depends/jars/xalan-j_2.7.0
 

Modified: harmony/enhanced/drlvm/trunk/build/make/setup.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/setup.xml?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/setup.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/setup.xml Mon Nov 27 22:20:46 2006
@@ -107,6 +107,7 @@
         <property name="XALAN.check.file" value="xalan.jar" />
         <property name="VM.check.file" value="vmcore/src/init/vm_init.cpp" />
         <property name="ANTLR.check.file" value="antlr-2.7.5.jar" />
+        <property name="MMTK.check.file" value="mmtk-20061012.jar" />
         <property name="PATCHES.check.file" value="README.txt" />
     </target>
 
@@ -181,7 +182,7 @@
 
 
     <target name="setup.resources" depends="plugin.antcontrib">
-        <property name="common.resources" value="LOG4CXX,CPPTASKS,XALAN,VM,ANTLR,PATCHES,JASMIN" />
+        <property name="common.resources" value="LOG4CXX,CPPTASKS,XALAN,VM,ANTLR,PATCHES,JASMIN,MMTK" />
         <property name="build.resources" value="CPPTASKS" />
         <if>
             <isset property="if.lnx" />

Modified: harmony/enhanced/drlvm/trunk/build/make/win.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/win.properties?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/win.properties (original)
+++ harmony/enhanced/drlvm/trunk/build/make/win.properties Mon Nov 27 22:20:46 2006
@@ -74,6 +74,10 @@
 remote.ANTLR.archive=http://www.antlr.org/download/antlr-2.7.5.jar
 remote.ANTLR.archive.type=asis
 
+# org.vmmagic unboxed package. Used to enable address arithmetic in Java
+remote.MMTK.archive=http://cs.anu.edu.au/people/Robin.Garner/mmtk-20061012.jar
+remote.MMTK.archive.type=asis
+
 # Xalan-Java version 2.7.0
 XALAN_HOME=${external.dep.CLASSLIB}/depends/jars/xalan-j_2.7.0
 

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp Mon Nov 27 22:20:46 2006
@@ -179,7 +179,7 @@
     std::string fullPath = dll_name + ".dll";
     
     if (!library_path.empty()) { 
-    	fullPath = library_path + "\\" + fullPath;
+        fullPath = library_path + "\\" + fullPath;
     }
     
 #else
@@ -187,10 +187,10 @@
 //
 //    std::string fullPath = library_path + "/lib" + dll_name + ".so";
 
-	std::string fullPath = "lib" + dll_name + ".so";
-	
+    std::string fullPath = "lib" + dll_name + ".so";
+    
     if (!library_path.empty()) {
-  		fullPath = library_path + "/" + fullPath;
+        fullPath = library_path + "/" + fullPath;
     }
     
 #endif
@@ -214,8 +214,7 @@
 
     std::string path = origPath;
     if (path.find('/') == path.npos && path.find('\\') == path.npos ) {
-// $$$ GMJ        std::string dir = vm_get_property_value("vm.boot.library.path");
-        std::string dir = vm_get_property_value("org.apache.harmony.vm.vmdir");
+        std::string dir = vm_get_property_value(O_A_H_VM_VMDIR);
         if (libPrefix.length() > 0 && !startsWith(path, libPrefix)) {
             path = libPrefix + path;
         }

Added: harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java?view=auto&rev=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java Mon Nov 27 22:20:46 2006
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.
+ */
+/**
+ * @author Mikhail Y. Fursov
+ */ 
+
+package org.apache.harmony.drlvm.gc_cc;
+
+import org.apache.harmony.drlvm.VMHelper;
+import org.vmmagic.unboxed.*;
+
+public class GCHelper {
+
+    static {System.loadLibrary("gc_cc");}
+
+    public static final int TLS_CURRENT_OFFSET = getCurrentOffset();
+    public static final int TLS_CLEANED_OFFSET = getCleanedOffset();
+
+
+
+
+    public static Object alloc(int objSize, int allocationHandle) {
+        Address tlsAddr = VMHelper.getTlsBaseAddress();
+
+        Address tlsFreeFieldAddr = tlsAddr.plus(TLS_CURRENT_OFFSET);
+        Address tlsCleanedFieldAddr = tlsAddr.plus(TLS_CLEANED_OFFSET);
+
+        Address tlsFreeAddr = tlsFreeFieldAddr.loadAddress();
+        Address tlsCleanedAddr = tlsCleanedFieldAddr.loadAddress ();
+
+        Address tlsNewFreeAddr = tlsFreeAddr.plus(objSize);
+
+        // the fast path without cleaning
+        if (tlsNewFreeAddr.LE(tlsCleanedAddr)) {
+            tlsFreeFieldAddr.store (tlsNewFreeAddr);
+            tlsFreeAddr.store(allocationHandle);
+            return tlsFreeAddr;
+        }
+        return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);    
+    }
+
+    private static native int getCurrentOffset();
+    private static native int getCleanedOffset();
+}
\ No newline at end of file

Added: harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp?view=auto&rev=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp Mon Nov 27 22:20:46 2006
@@ -0,0 +1,32 @@
+#include <open/vm_gc.h>
+#include <jni.h>
+#include "gc_types.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Class:     org_apache_harmony_drlvm_gc_cc_GCHelper
+ * Method:    getGCTlsOffset
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1cc_GCHelper_getCurrentOffset(JNIEnv *e, jclass c)
+{
+    return (jint)tls_offset_current;
+}
+
+/*
+ * Class:     org_apache_harmony_drlvm_gc_cc_GCHelper
+ * Method:    getGCTlsOffset
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1cc_GCHelper_getCleanedOffset(JNIEnv *e, jclass c)
+{
+    return (jint)tls_offset_clean;
+}
+
+#ifdef __cplusplus
+}
+#endif

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/vm.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/vm.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/vm.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/vm.h Mon Nov 27 22:20:46 2006
@@ -34,6 +34,8 @@
 
 #include "open/types.h"
 
+#define O_A_H_VM_VMDIR         "org.apache.harmony.vm.vmdir"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -74,7 +76,7 @@
 
 // Loads a class of a given name.  If a class cannot be loaded, returns NULL
 VMEXPORT Class_Handle
-class_load_class_by_name_using_system_class_loader(const char *name);
+class_load_class_by_name_using_bootstrap_class_loader(const char *name);
 
 // The following three functions will be eventually renamed to
 // class_is_final, class_is_abstract and class_is_interface,

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h Mon Nov 27 22:20:46 2006
@@ -54,6 +54,8 @@
  */
 VMEXPORT void *vm_get_gc_thread_local();
 
+VMEXPORT size_t vm_get_gc_thread_local_offset();
+
 
 /**
  * Acquire the lock that guards all GC-related operations in the VM.

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf Mon Nov 27 22:20:46 2006
@@ -56,7 +56,7 @@
 
 -Djit.SD2_OPT.path=opt_init,translator,optimizer,hir2lir,codegen
 
--Djit.SD2_OPT.path.optimizer=ssa,simplify,dce,uce,edge_annotate,devirt,inline,purge,simplify,dce,uce,lazyexc,dessa,statprof,peel,ssa,hvn,simplify,dce,uce,lower,dce,uce,memopt,reassoc,dce,uce,hvn,dce,uce,abcd,dce,uce,gcm,dessa,statprof,markglobals
+-Djit.SD2_OPT.path.optimizer=ssa,simplify,dce,uce,edge_annotate,devirt,inline,purge,simplify,dce,uce,lazyexc,inline_helpers,purge,simplify,uce,dce,dessa,statprof,peel,ssa,hvn,simplify,dce,uce,lower,dce,uce,memopt,reassoc,dce,uce,hvn,dce,uce,abcd,dce,uce,gcm,dessa,statprof,markglobals
 -Djit.SD2_OPT.path.codegen=lock_method,bbp,gcpoints,cafl,dce1,i8l,early_prop,itrace-,native,constraints,dce2,regalloc,spillgen,layout,copy,rce+,stack,break-,iprof-,emitter!,si_insts,gcmap,info,unlock_method
 -Djit.SD2_OPT.path.dce1=cg_dce
 -Djit.SD2_OPT.path.dce2=cg_dce
@@ -70,6 +70,16 @@
 -Djit.SD2_OPT.arg.optimizer.inline.pipeline=SD2_OPT_inliner_pipeline
 -Djit.SD2_OPT.arg.optimizer.inline.connect_early=false
 
+#helper inliner configuration
+-Djit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.filter=-
+-Djit.SD2_OPT.SD2_OPT_helper_inliner_pipeline.path=ssa
+-Djit.SD2_OPT.arg.optimizer.inline_helpers.pipeline=SD2_OPT_helper_inliner_pipeline
+
+-Djit.SD2_OPT.arg.optimizer.inline_helpers.newObj=on
+-Djit.SD2_OPT.arg.optimizer.inline_helpers.newObj_className=org/apache/harmony/drlvm/gc_cc/GCHelper
+-Djit.SD2_OPT.arg.optimizer.inline_helpers.newObj_methodName=alloc
+-Djit.SD2_OPT.arg.optimizer.inline_helpers.newObj_hotnessPercent=1
+
 
 -Djit.SD2_OPT.arg.codegen.dce1.early=yes
 -Djit.SD2_OPT.arg.codegen.regalloc.bp_regalloc1.regs=ALL_GP
@@ -78,3 +88,7 @@
 
 #system properties
 -Djava.compiler=server
+
+#GC properties
+-Dvm.components.gc_cc.startupclass=org.apache.harmony.drlvm.gc_cc.GCHelper
+-Dvm.components.gc_cc.classpath=gc_cc.jar

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h Mon Nov 27 22:20:46 2006
@@ -173,13 +173,6 @@
     };
 };
 
-class VMHelperCallOp {
-public:
-    enum Id {
-        ThrowLazy
-    };
-};
-
 class InstructionCallback {
 public:
     virtual ~InstructionCallback() {}
@@ -290,7 +283,8 @@
     virtual CG_OpndHandle*  callhelper(uint32 numArgs, CG_OpndHandle** args, Type* retType,
                                        JitHelperCallOp::Id callId) = 0;
     virtual CG_OpndHandle*  callvmhelper(uint32 numArgs, CG_OpndHandle** args, Type* retType,
-                                         VMHelperCallOp::Id callId, InlineInfo* ii = NULL) = 0;
+                                       CompilationInterface::RuntimeHelperId callId, InlineInfo* ii = NULL) = 0;
+
     virtual CG_OpndHandle*  ldc_i4(uint32 val) = 0;
     virtual CG_OpndHandle*  ldc_i8(uint64 val) = 0;
     virtual CG_OpndHandle*  ldc_s(float val) = 0;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Mon Nov 27 22:20:46 2006
@@ -2819,12 +2819,12 @@
 CG_OpndHandle* InstCodeSelector::callvmhelper(uint32              numArgs, 
                                               CG_OpndHandle**     args, 
                                               Type*               retType,
-                                              VMHelperCallOp::Id  callId,
+                                              CompilationInterface::RuntimeHelperId  callId,
                                               InlineInfo* ii) 
 {
     Opnd* dstOpnd=NULL;
     switch(callId) {
-    case ThrowLazy:
+    case CompilationInterface::Helper_Throw_Lazy:
     {
 
         Opnd **hlpArgs = new (memManager) Opnd* [numArgs+1];
@@ -2838,6 +2838,31 @@
                                                Opnd::RuntimeInfo::Kind_MethodRuntimeId, md);
         appendInsts(irManager.newRuntimeHelperCallInst(CompilationInterface::Helper_Throw_Lazy,
                                                        numArgs+1, (Opnd**)hlpArgs, dstOpnd, ii));
+        break;
+    }
+    case CompilationInterface::Helper_GetTLSBase:
+    {
+        assert(numArgs == 0);
+        Opnd * tlsBaseReg = irManager.newOpnd(typeManager.getUnmanagedPtrType(typeManager.getInt8Type()));
+#ifdef PLATFORM_POSIX
+        TypeManager& tm =irManager.getTypeManager();
+        Opnd * callAddrOpnd =irManager.newImmOpnd(tm.getUnmanagedPtrType(tm.getIntPtrType()),
+            Opnd::RuntimeInfo::Kind_HelperAddress, (void*)CompilationInterface::Helper_GetTLSBase);
+        appendInsts(irManager.newCallInst(callAddrOpnd, &CallingConvention_STDCALL, 0, NULL, tlsBaseReg));
+#else 
+        appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, tlsBaseReg,  
+            irManager.newMemOpnd(typeManager.getInt32Type(),  MemOpndKind_Any, NULL, 0x14, RegName_FS)));
+#endif
+        dstOpnd  = tlsBaseReg;        
+
+        break;
+    }
+    case CompilationInterface::Helper_NewObj_UsingVtable:
+    {
+        assert(numArgs == 2);
+        dstOpnd = irManager.newOpnd(retType);
+        CallInst * callInst=irManager.newRuntimeHelperCallInst(CompilationInterface::Helper_NewObj_UsingVtable, 2, (Opnd**)args, dstOpnd);
+        appendInsts(callInst);
         break;
     }
     default:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h Mon Nov 27 22:20:46 2006
@@ -226,7 +226,8 @@
     CG_OpndHandle* tau_callintr(uint32 numArgs, CG_OpndHandle** args, Type* retType,IntrinsicCallOp::Id callId,      CG_OpndHandle *tauNullsChecked, CG_OpndHandle *tauTypesChecked);
     CG_OpndHandle* callhelper(uint32 numArgs, CG_OpndHandle** args, Type* retType,JitHelperCallOp::Id callId);
     CG_OpndHandle* callvmhelper(uint32 numArgs, CG_OpndHandle** args, Type* retType,
-                VMHelperCallOp::Id callId, InlineInfo* ii = NULL);
+                                CompilationInterface::RuntimeHelperId callId, InlineInfo* ii = NULL);
+    
     CG_OpndHandle* box(ObjectType * boxedType, CG_OpndHandle* val);
     CG_OpndHandle* unbox(Type * dstType, CG_OpndHandle* objHandle);
     CG_OpndHandle* ldValueObj(Type* objType, CG_OpndHandle *srcAddr);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp Mon Nov 27 22:20:46 2006
@@ -532,6 +532,9 @@
         if (opnd->isPlacedIn(OpndKind_Reg)){
             os<<"("; printRegName(opnd->getRegName()); os<<")";
         }else if(opnd->isPlacedIn(OpndKind_Mem)){
+            if (opnd->getSegReg() != RegName_Null) {
+                os<<"(";printRegName(opnd->getSegReg());os<<":";
+            }
             os<<"[";
             uint32 oldOpndFlavor=opndFlavor;
             opndFlavor&=~OpndFlavor_Type;
@@ -551,6 +554,9 @@
             }
             opndFlavor=oldOpndFlavor;
             os<<"]";
+            if (opnd->getSegReg() != RegName_Null) {
+                os<<")";
+            }
         }else if(opnd->isPlacedIn(OpndKind_Imm)){
             os<<"("<<opnd->getImmValue();
             if (opndFlavor & OpndFlavor_RuntimeInfo){

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/main/PMF.cpp Mon Nov 27 22:20:46 2006
@@ -459,7 +459,7 @@
 
 static const char* deffmask     = "log/%jit%/%class%/%method%/%log%.log";
 static const char* ct_deffmask  = "log/%jit%/%class%/%method%/ct.log";
-static const char* dot_deffmask = "log/%jit%/%class%/%method%/.dot";
+static const char* dot_deffmask = "log/%jit%/%class%/%method%/dot/.dot";
 
 struct KnownStream 
 {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp Mon Nov 27 22:20:46 2006
@@ -446,13 +446,6 @@
         assert(0);
         return JitHelperCallOp::InitializeArray; // to keep compiler quiet
     }
-    VMHelperCallOp::Id convertVMHelperId(VMHelperCallId callId) {
-        switch(callId) {
-        case ThrowLazy: return VMHelperCallOp::ThrowLazy;
-        }
-        assert(0);
-        return VMHelperCallOp::ThrowLazy; // to keep compiler quiet
-    }
     CG_OpndHandle ** genCallArgs(Inst * call, uint32 arg0Pos) {
         uint32 nSrc = call->getNumSrcOperands();
         CG_OpndHandle ** args = new(memManager) CG_OpndHandle*[nSrc - arg0Pos];
@@ -941,12 +934,12 @@
         case Op_VMHelperCall:
             {
                 VMHelperCallInst* call = inst->asVMHelperCallInst();
-                VMHelperCallId callId = call->getVMHelperId();
+                CompilationInterface::RuntimeHelperId callId = call->getVMHelperId();
                 cgInst = 
                     instructionCallback.callvmhelper(inst->getNumSrcOperands(),
                                                      genCallArgs(call,0),
                                                      inst->getDst()->getType(),
-                                                     convertVMHelperId(callId));
+                                                     callId);
             }
             break;
         case Op_Return:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp Mon Nov 27 22:20:46 2006
@@ -1401,7 +1401,7 @@
 }
 
 Opnd*
-IRBuilder::genVMHelperCall(VMHelperCallId helperId,
+IRBuilder::genVMHelperCall(CompilationInterface::RuntimeHelperId helperId,
                             Type* returnType,
                             uint32 numArgs,
                             Opnd*  args[]) {
@@ -1412,6 +1412,7 @@
     appendInst(instFactory->makeVMHelperCall(dst, helperId, numArgs, args));
     return dst;
 }
+
 
 void
 IRBuilder::genTauTypeCompare(Opnd *arg0, MethodDesc *methodDesc, LabelInst *target,

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h Mon Nov 27 22:20:46 2006
@@ -156,11 +156,12 @@
                                   uint32 numArgs,
                                   Opnd*  args[]);
 
-    Opnd*  genVMHelperCall(VMHelperCallId helperId,
+    Opnd*  genVMHelperCall(CompilationInterface::RuntimeHelperId helperId,
                             Type* returnType,
                             uint32 numArgs,
                             Opnd*  args[]);
 
+    
     void       genReturn(Opnd* src, Type* retType);//TR
     void       genReturn();//TR
     Opnd*      genCatch(Type* exceptionType); // TR

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp Mon Nov 27 22:20:46 2006
@@ -478,15 +478,12 @@
 
 void VMHelperCallInst::handlePrintEscape(::std::ostream& os, char code) const {
     switch(code) {
-    case 'd':
-        switch(vmHelperId) {
-    case ThrowLazy:
-        {   os << "ThrowLazyException ";
-            break;
-        }
-    default:
-        assert(0); break;
-        }
+    case 'd': 
+        {
+            CompilationContext* cc = CompilationContext::getCurrentContext();
+            const char* name = cc->getVMCompilationInterface()->getRuntimeHelperName(vmHelperId);
+            os <<name<<" ";
+        } 
         break;
     default:
         Inst::handlePrintEscape(os, code);
@@ -494,6 +491,7 @@
     }
 }
 
+
 void TypeInst::handlePrintEscape(::std::ostream& os, char code) const {
     switch (code) {
     case 'd':  // typeDesc
@@ -1664,7 +1662,7 @@
                                     Opnd* dst,
                                     uint32 nArgs,
                                     Opnd** args_,
-                                    VMHelperCallId id,
+                                    CompilationInterface::RuntimeHelperId id,
                                     InlineInfo* inlInfo) {
     VMHelperCallInst * inst = 
         new (memManager) VMHelperCallInst(op, mod, type, dst, nArgs, args_, id);
@@ -2092,13 +2090,14 @@
 }
 
 Inst*
-InstFactory::makeVMHelperCall(Opnd* dst, VMHelperCallId id, uint32 numArgs,
+InstFactory::makeVMHelperCall(Opnd* dst, CompilationInterface::RuntimeHelperId id, uint32 numArgs,
                               Opnd** args, InlineInfo* inlInfo) {
     Type::Tag returnType = dst->isNull()? Type::Void : dst->getType()->tag;
     args = copyOpnds(args, numArgs);
     return makeVMHelperCallInst(Op_VMHelperCall, Modifier(Exception_Sometimes), 
                                 returnType, dst, numArgs, args, id, inlInfo);
 }
+
 
 // load, store, & move
 Inst*

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h Mon Nov 27 22:20:46 2006
@@ -1025,14 +1025,8 @@
 public:
     void visit(InstFormatVisitor& visitor)  {visitor.accept(this);}
     bool isVMHelperCallInst() const { return true; }
-    VMHelperCallId getVMHelperId() const {return vmHelperId;}
-    Opnd* getLEConstructor() const {
-        if (vmHelperId == ThrowLazy)
-            return args[numSrcs];
-        else
-            return NULL;
-    }
-    bool isThrowLazy() const {return vmHelperId == ThrowLazy;}
+    CompilationInterface::RuntimeHelperId getVMHelperId() const {return vmHelperId;}
+    bool isThrowLazy() const {return vmHelperId == CompilationInterface::Helper_Throw_Lazy;}
 InlineInfo* getInlineInfoPtr() { return inlInfo; }
 private:
     virtual void handlePrintEscape(::std::ostream&, char code) const;
@@ -1043,8 +1037,9 @@
                      Opnd* dst,
                      uint32 nArgs,
                      Opnd** args_,
-                     VMHelperCallId id) : Inst(op, mod, type, dst, nArgs),
-                                          vmHelperId(id), inlInfo(NULL) {
+                     CompilationInterface::RuntimeHelperId id) 
+                     : Inst(op, mod, type, dst, nArgs), vmHelperId(id), inlInfo(NULL) 
+    {
         args = args_;
         switch (nArgs) {
         default:
@@ -1060,10 +1055,11 @@
         args[srcIndex] = src;
     }
     Opnd**    args;
-    VMHelperCallId vmHelperId;
+    CompilationInterface::RuntimeHelperId vmHelperId;
     InlineInfo* inlInfo;
 };
 
+
 // phi instructions
 class PhiInst : public MultiSrcInst {
 public:
@@ -1153,8 +1149,10 @@
                                Opnd* tauNullChecked, Opnd* tauTypesChecked, 
                                uint32 numArgs, Opnd** args);
     Inst*    makeJitHelperCall(Opnd* dst, JitHelperCallId id, uint32 numArgs, Opnd** args);
-    Inst*    makeVMHelperCall(Opnd* dst, VMHelperCallId id, uint32 numArgs,
+    Inst*    makeVMHelperCall(Opnd* dst, CompilationInterface::RuntimeHelperId id, uint32 numArgs,
                                Opnd** args, InlineInfo* inlInfo = NULL);
+    
+
     Inst*    makeReturn(Opnd* src);
     Inst*    makeReturn();    // void return type
     Inst*    makeCatch(Opnd* dst);
@@ -1538,8 +1536,9 @@
                                            Opnd* dst,
                                            uint32 nArgs,
                                            Opnd** args_,
-                                           VMHelperCallId id,
+                                           CompilationInterface::RuntimeHelperId id,
                                            InlineInfo* inlInfo = NULL);
+
 
     PhiInst* makePhiInst(Type::Tag type, Opnd* dst, uint32 nArgs, Opnd** args_);
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h Mon Nov 27 22:20:46 2006
@@ -272,13 +272,9 @@
 enum JitHelperCallId {
     InitializeArray,
     PseudoCanThrow,
-    SaveThisState,
-    ReadThisState,
+    SaveThisState, //todo: replace with GetTLS + offset sequence
+    ReadThisState, //todo: replace with GetTLS + offset sequence
     LockedCompareAndExchange
-};
-
-enum VMHelperCallId {
-    ThrowLazy
 };
 
 enum Opcode {

Added: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp?view=auto&rev=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp Mon Nov 27 22:20:46 2006
@@ -0,0 +1,251 @@
+/*
+*  Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  See the NOTICE file distributed with
+*  this work for additional information regarding copyright ownership.
+*  The ASF licenses this file to You 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.
+*/
+
+/**
+* @author Intel, Mikhail Y. Fursov
+*/
+
+#include "PMFAction.h"
+#include "optpass.h"
+#include "inliner.h"
+
+namespace Jitrino {
+
+struct HelperInlinerFlags {
+    const char* inlinerPipelineName;
+
+    bool insertInitilizers;
+    bool doInlining;
+
+    bool  newObj_doInlining;
+    int   newObj_hotnessPercentToInline;
+    const char* newObj_className;
+    const char* newObj_methodName;
+    const char* newObj_signature;
+};
+
+class HelperInlinerAction: public Action {
+public:
+    void init();
+    HelperInlinerFlags& getFlags() {return flags;}
+protected:
+    HelperInlinerFlags flags;
+};
+
+DEFINE_SESSION_ACTION_WITH_ACTION(HelperInlinerSession, HelperInlinerAction, inline_helpers, "VM helpers inlining");
+
+void HelperInlinerAction::init() {
+    flags.inlinerPipelineName = getStringArg("pipeline", "inliner_pipeline");
+    flags.insertInitilizers = getBoolArg("insertInitilizers", false);
+    flags.doInlining = true;
+    
+    
+    //new obj inlining params;
+    flags.newObj_doInlining = getBoolArg("newObj", false);
+
+    flags.newObj_signature = "(II)Ljava/lang/Object;";
+    if (flags.newObj_doInlining) {
+        flags.newObj_className = getStringArg("newObj_className", NULL);
+        flags.newObj_methodName = getStringArg("newObj_methodName", NULL);
+        flags.newObj_hotnessPercentToInline = getIntArg("newObj_hotnessPercent", 0);
+        if (flags.newObj_className == NULL || flags.newObj_methodName == NULL) {
+            //TODO:? crash("Invalid newObj fast path helper name: %s::%s\n", flags.newObj_className, flags.newObj_methodName);
+            flags.newObj_doInlining = false;
+        }
+    }
+    
+    if (!flags.newObj_doInlining){
+        flags.newObj_className = NULL;
+        flags.newObj_methodName = NULL;
+    }
+
+}
+
+
+class HelperInliner {
+public:
+    HelperInliner(HelperInlinerSession* _sessionAction, MemoryManager& tmpMM, CompilationContext* _cc, Inst* _inst)  
+        : flags(((HelperInlinerAction*)_sessionAction->getAction())->getFlags()), localMM(tmpMM), 
+        cc(_cc), inst(_inst), action(_sessionAction)
+    {}
+    virtual ~HelperInliner(){};
+
+    virtual void doInline() = 0;
+protected:
+    MethodDesc* ensureClassIsResolvedAndInitialized(const char* className,  const char* methodName, const char* signature);
+    void inlineVMHelper(MethodCallInst* call);
+
+    HelperInlinerFlags& flags;
+    MemoryManager& localMM;
+    CompilationContext* cc;
+    Inst* inst;
+    HelperInlinerSession* action;
+};
+
+class NewObjHelperInliner : public HelperInliner {
+public:
+    NewObjHelperInliner(HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst) 
+        : HelperInliner(session, tmpMM, cc, inst){}
+        virtual void doInline();
+};
+
+
+void HelperInlinerSession::_run(IRManager& irm) {
+    CompilationContext* cc = getCompilationContext();
+    MemoryManager tmpMM(1024, "Inline VM helpers");
+    HelperInlinerAction* action = (HelperInlinerAction*)getAction();
+    HelperInlinerFlags& flags = action->getFlags();
+    if (!flags.doInlining) {
+        return;
+    }
+    //finding all helper calls
+    ControlFlowGraph& fg = irm.getFlowGraph();
+    double entryExecCount = fg.hasEdgeProfile() ? fg.getEntryNode()->getExecCount(): 1;
+    StlVector<HelperInliner*> helperInliners(tmpMM);
+    const Nodes& nodes = fg.getNodesPostOrder();//process checking only reachable nodes.
+    for (Nodes::const_iterator it = nodes.begin(), end = nodes.end(); it!=end; ++it) {
+        Node* node = *it;
+        int nodePercent = fg.hasEdgeProfile() ? (int)(node->getExecCount()*100/entryExecCount) : 0;
+        if (node->isBlockNode()) { //only block nodes can have helper calls today
+            for (Inst* inst = (Inst*)node->getFirstInst(); inst!=NULL; inst = inst->getNextInst()) {
+                Opcode opcode = inst->getOpcode();
+                switch(opcode) {
+                    case Op_NewObj:
+                        if (flags.newObj_doInlining && nodePercent >= flags.newObj_hotnessPercentToInline) {
+                            helperInliners.push_back(new (tmpMM) NewObjHelperInliner(this, tmpMM, cc, inst));
+                        }
+                        break;
+                    default: break;
+                }
+            }
+        }
+    }
+
+    //running all inliners
+    //TODO: set inline limit!
+    for (StlVector<HelperInliner*>::const_iterator it = helperInliners.begin(), end = helperInliners.end(); it!=end; ++it) {
+        HelperInliner* inliner = *it;
+        inliner->doInline();
+    }
+}
+
+
+MethodDesc* HelperInliner::ensureClassIsResolvedAndInitialized(const char* className, const char* methodName, const char* signature) 
+{
+    CompilationInterface* ci = cc->getVMCompilationInterface();
+    ObjectType* clazz = ci->resolveClassUsingBootstrapClassloader(className);
+    if (!clazz) {
+        if (Log::isEnabled()) Log::out()<<"Error: class not found:"<<className<<std::endl;
+        flags.doInlining=false;
+        return NULL;
+    }
+    //helper class is resolved here -> check if initialized
+    IRManager* irm = cc->getHIRManager();
+    InstFactory& instFactory = irm->getInstFactory();
+    if (clazz->needsInitialization()) {
+        if (flags.insertInitilizers) {
+            instFactory.makeInitType(clazz)->insertBefore(inst);
+        }
+        return NULL;
+    }
+    //helper class is initialized here -> inline it.
+    MethodDesc* method = ci->resolveMethod(clazz, methodName, signature);
+    if (!method) {
+        if (Log::isEnabled()) Log::out()<<"Error: method not found:"<<className<<"::"<<methodName<<signature<<std::endl;;
+        return NULL;
+    }
+    assert (method->isStatic());
+    return method;
+
+}
+
+void HelperInliner::inlineVMHelper(MethodCallInst* call) {
+    CompilationInterface* ci = cc->getVMCompilationInterface();
+    IRManager* irm = cc->getHIRManager();
+
+    //now inline the call
+    CompilationContext inlineCC(cc->getCompilationLevelMemoryManager(), ci, cc->getCurrentJITContext());
+    inlineCC.setPipeline(cc->getPipeline());
+
+    Inliner inliner(action, localMM, *irm, false);
+    InlineNode* regionToInline = inliner.createInlineNode(inlineCC, call);
+
+    inliner.connectRegion(regionToInline);
+
+    // Optimize inlined region before splicing
+    inlineCC.stageId = cc->stageId;
+    Inliner::runInlinerPipeline(inlineCC, flags.inlinerPipelineName);
+    cc->stageId = inlineCC.stageId;
+
+    inliner.inlineRegion(regionToInline, false);
+}
+
+void NewObjHelperInliner::doInline() {
+#ifdef _EM64T_
+    return;
+#else
+    if (Log::isEnabled())  {
+        Log::out() << "Processing inst:"; inst->print(Log::out()); Log::out()<<std::endl;
+    }
+    assert(inst->getOpcode() == Op_NewObj);
+
+    //find the method
+    MethodDesc* method = ensureClassIsResolvedAndInitialized(flags.newObj_className, flags.newObj_methodName, flags.newObj_signature);
+    if (!method) {
+        return;
+    }
+    
+    TypeInst *typeInst = (TypeInst*)inst;
+    Type * type = typeInst->getTypeInfo();
+    assert(type->isObject());
+    ObjectType* objType = type->asObjectType();
+
+    if (objType->isFinalizable()) {
+        if (Log::isEnabled()) Log::out()<<"Skipping as finalizable: "<<objType->getName()<<std::endl;
+        return;
+    }
+    //replace newObj with call to a method
+
+    //the method signature is (int objSize, int allocationHandle)
+    int allocationHandle= (int)objType->getAllocationHandle();
+    int objSize=objType->getObjectSize();
+
+    IRManager* irm = cc->getHIRManager();
+    InstFactory& instFactory = irm->getInstFactory();
+    OpndManager& opndManager = irm->getOpndManager();
+    TypeManager& typeManager = irm->getTypeManager();
+
+    Opnd* tauSafeOpnd = opndManager.createSsaTmpOpnd(typeManager.getTauType());
+    instFactory.makeTauSafe(tauSafeOpnd)->insertBefore(inst);
+    Opnd* res = inst->getDst();
+    Opnd* objSizeOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
+    Opnd* allocationHandleOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
+    instFactory.makeLdConst(objSizeOpnd, objSize)->insertBefore(inst);
+    instFactory.makeLdConst(allocationHandleOpnd, allocationHandle)->insertBefore(inst);
+    Opnd* args[2] = {objSizeOpnd, allocationHandleOpnd};
+    MethodCallInst* call = instFactory.makeDirectCall(res, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
+    call->insertBefore(inst);
+    inst->unlink();
+    assert(call == call->getNode()->getLastInst());
+
+    //inline the method
+    inlineVMHelper(call);
+#endif
+}
+
+}//namespace
+

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp Mon Nov 27 22:20:46 2006
@@ -731,7 +731,7 @@
 }
 
 void
-Inliner::inlineAndProcessRegion(InlineNode* inlineNode) {
+Inliner::inlineRegion(InlineNode* inlineNode, bool updatePriorityQueue) {
     IRManager &inlinedIRM = inlineNode->getIRManager();
     DominatorTree* dtree = inlinedIRM.getDominatorTree();
     LoopTree* ltree = inlinedIRM.getLoopTree();
@@ -755,7 +755,9 @@
     //
     // Update priority queue with calls in this region
     //
-    processRegion(inlineNode, dtree, ltree);
+    if (updatePriorityQueue) {
+        processRegion(inlineNode, dtree, ltree);
+    }
     
     //
     // If top level flowgraph 
@@ -919,12 +921,20 @@
     _instFactory.setMethodId(((uint64)id)<<32);
     
     
+    InlineNode* inlineNode = createInlineNode(inlineCC, call);
+    assert(inlineNode!=NULL);
+
+    inlineParentNode->addChild(inlineNode);
+
+    _currentByteSize = newByteSize;
+    return inlineNode;
+}
+
+InlineNode* Inliner::createInlineNode(CompilationContext& inlineCC, MethodCallInst* call) {
+    MethodDesc *methodDesc = call->getMethodDesc();
     IRManager* inlinedIRM = new (_tmpMM) IRManager(_tmpMM, _toplevelIRM, *methodDesc, NULL);
-    
     // Augment inline tree
-    InlineNode *inlineNode = new (_tmpMM) InlineNode(*inlinedIRM, call, callNode);
-    
-    inlineParentNode->addChild(inlineNode);
+    InlineNode *inlineNode = new (_tmpMM) InlineNode(*inlinedIRM, call, call->getNode());
     
     // Call a translator 
     if (isBCmapRequired) {
@@ -937,9 +947,6 @@
     inlineCC.setHIRManager(inlinedIRM);
     runTranslatorSession(inlineCC);
 
-    // Save state.
-    _currentByteSize = newByteSize;
-    assert(inlineNode);
     return inlineNode;
 }
 
@@ -1085,7 +1092,7 @@
     return (uint32) sum;
 }
 
-static void runInlinerPipeline(CompilationContext& inlineCC, const char* pipeName) {
+void Inliner::runInlinerPipeline(CompilationContext& inlineCC, const char* pipeName) {
     PMF::HPipeline p = inlineCC.getCurrentJITContext()->getPMF().getPipeline(pipeName);
     assert(p!=NULL);
     PMF::PipelineIterator pit(p);
@@ -1117,7 +1124,7 @@
     MemoryManager tmpMM(1024, "Inliner::tmp_mm");
     Inliner inliner(this, tmpMM, irm, irm.getFlowGraph().hasEdgeProfile());
     InlineNode* rootRegionNode = (InlineNode*) inliner.getInlineTree().getRoot();
-    inliner.inlineAndProcessRegion(rootRegionNode);
+    inliner.inlineRegion(rootRegionNode);
 
     // Inline calls
     do {
@@ -1138,7 +1145,7 @@
 
         // Optimize inlined region before splicing
         inlineCC.stageId = cc->stageId;
-        runInlinerPipeline(inlineCC, pipeName);
+        Inliner::runInlinerPipeline(inlineCC, pipeName);
         cc->stageId = inlineCC.stageId;
         
         // Splice into flow graph and find next region.
@@ -1146,7 +1153,7 @@
             inliner.connectRegion(regionNode);
         }
         OptPass::computeDominatorsAndLoops(regionManager);
-        inliner.inlineAndProcessRegion(regionNode);
+        inliner.inlineRegion(regionNode);
     } while (true);
     const OptimizerFlags& optimizerFlags = irm.getOptimizerFlags();
     // Print the results to logging / dot file

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h Mon Nov 27 22:20:46 2006
@@ -84,7 +84,7 @@
     // Inline this method into the current CFG and process it for further
     // inline candidates.  If the argument is the top level CFG, only processing
     // occurs.
-    void inlineAndProcessRegion(InlineNode* inlineNode);
+    void inlineRegion(InlineNode* inlineNode, bool updatePriorityQueue = true);
 
     // Connect input and return operands of the region to the top-level method.  Do not yet splice.
     void connectRegion(InlineNode* inlineNode);
@@ -97,7 +97,11 @@
 
     void reset();
 
+    InlineNode* createInlineNode(CompilationContext& inlineCC, MethodCallInst* call);
+
     static double getProfileMethodCount(CompilationInterface& compileIntf, MethodDesc& methodDesc); 
+    
+    static void runInlinerPipeline(CompilationContext& inlineCC, const char* pipeName);
 
 private:
     class CallSite {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp Mon Nov 27 22:20:46 2006
@@ -521,7 +521,7 @@
                 tinst = *it1;
                 assert(tinst != NULL);
                 tlinst=irManager.getInstFactory().makeVMHelperCall(  
-                        OpndManager::getNullOpnd(), ThrowLazy, opcount, 
+                        OpndManager::getNullOpnd(), CompilationInterface::Helper_Throw_Lazy, opcount, 
                         opnds, constrInlineInfo);
 #ifdef _DEBUG
                 if (Log::isEnabled()) {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp Mon Nov 27 22:20:46 2006
@@ -655,18 +655,6 @@
         }
         break;
     case Op_VMHelperCall:
-        {
-            VMHelperCallInst *vmcalli = i->asVMHelperCallInst();
-            VMHelperCallId callId = vmcalli->getVMHelperId();
-            switch (callId) {
-            case ThrowLazy:
-                assert(vmcalli->getNumSrcOperands() > 0);
-                break;
-            default:
-                assert(0);
-                break;
-            }
-        }
         break;
     case Op_JitHelperCall:
         {
@@ -1404,10 +1392,7 @@
         break;
     case Op_Conv: //the result of a conversion
     case Op_TauLdInd: // the result of static field load
-        {
-            assert(addr->getType()->isUnmanagedPtr());
-            break;
-        }
+        break;
     default:
         assert(0);
         break;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/optpass.h Mon Nov 27 22:20:46 2006
@@ -91,15 +91,19 @@
     unsigned id;
 };
 
-#define DEFINE_SESSION_ACTION(classname, tagname, fullname) \
+
+#define DEFINE_SESSION_ACTION_WITH_ACTION(classname, actionclass, tagname, fullname) \
 class classname : public OptPass { \
 protected: \
-           void _run(IRManager& irm); \
-           const char* getName() { return fullname; } \
-           const char* getTagName() { return #tagname; } \
+    void _run(IRManager& irm); \
+    const char* getName() { return fullname; } \
+    const char* getTagName() { return #tagname; } \
 }; \
-ActionFactory<classname> tagname##_(#tagname);
+ActionFactory<classname, actionclass> tagname##_(#tagname);
 
+
+#define DEFINE_SESSION_ACTION(classname, tagname, fullname) \
+DEFINE_SESSION_ACTION_WITH_ACTION(classname, Action, tagname, fullname)
 
 } //namespace Jitrino 
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Mon Nov 27 22:20:46 2006
@@ -38,15 +38,17 @@
 
 namespace Jitrino {
 
-    
+// magics support    
 static bool isMagicClass(Type* type) {
 #ifdef _EM64T_
     return false;//magics are not tested on EM64T.
 #else
-    static const char unboxedName[] = "org/vmmagic/unboxed/";
-    static const unsigned nameLen = sizeof(unboxedName)-1;
+    static const char magicPackage[] = "org/vmmagic/unboxed/";
+    static const unsigned magicPackageLen = sizeof(magicPackage)-1;
+
     const char* name = type->getName();
-    return !strncmp(name, unboxedName, nameLen);
+    bool res =  !strncmp(name, magicPackage, magicPackageLen);
+    return res;
 #endif    
 }
 
@@ -85,6 +87,24 @@
     return NULL;
 }
 
+//vm helpers support
+
+bool isVMHelperClass(NamedType* type) {
+#ifdef _EM64T_
+    return false;//natives are not tested on EM64T.
+#else
+    static const char vmhelperPackage[] = "org/apache/harmony/drlvm/VMHelper";
+    static const unsigned vmhelperPackageLen = sizeof(vmhelperPackage)-1;
+
+    const char* name = type->getName();
+    bool res =  !strncmp(name, vmhelperPackage, vmhelperPackageLen);
+    return res;
+#endif
+}
+
+bool isVMHelperMethod(MethodDesc* md) {
+    return isVMHelperClass(md->getParentType());
+} 
 
 
 //-----------------------------------------------------------------------------
@@ -1066,12 +1086,37 @@
 JavaByteCodeTranslator::getstatic(uint32 constPoolIndex) {
     FieldDesc* field = resolveStaticField(constPoolIndex, false);
     if (field && field->isStatic()) {
-        Type* fieldType = getFieldType(field,constPoolIndex);
-        assert(fieldType);
-        if (isMagicClass(fieldType)) {
-            fieldType = convertMagicType2HIR(typeManager, fieldType);
+        bool fieldValueInlined = false;
+        if (field->isInitOnly() && !field->getParentType()->needsInitialization()) {
+            //the final static field of the initialized class
+            Type* fieldType = field->getFieldType();
+            if (field->getFieldType()->isNumeric()) {
+                Opnd* constVal = NULL;
+                void* fieldAddr = field->getAddress();
+                switch(fieldType->tag) {
+                    case Type::Int8 :   constVal=irBuilder.genLdConstant(*(int8*)fieldAddr);break;
+                    case Type::Int16:   constVal=irBuilder.genLdConstant(*(int16*)fieldAddr);break;
+                    case Type::Char :   constVal=irBuilder.genLdConstant(*(uint16*)fieldAddr);break;
+                    case Type::Int32:   constVal=irBuilder.genLdConstant(*(int32*)fieldAddr);break;
+                    case Type::Int64:   constVal=irBuilder.genLdConstant(*(int64*)fieldAddr);break;
+                    case Type::Float:   constVal=irBuilder.genLdConstant(*(float*)fieldAddr);break;
+                    case Type::Double:  constVal=irBuilder.genLdConstant(*(double*)fieldAddr);break;
+                    default: assert(0); //??
+                }
+                if (constVal != NULL) {
+                    pushOpnd(constVal);
+                    fieldValueInlined = true;
+                }
+            }
+        } 
+        if (!fieldValueInlined){
+            Type* fieldType = getFieldType(field,constPoolIndex);
+            assert(fieldType);
+            if (isMagicClass(fieldType)) {
+                fieldType = convertMagicType2HIR(typeManager, fieldType);
+            }
+            pushOpnd(irBuilder.genLdStatic(fieldType,field));
         }
-        pushOpnd(irBuilder.genLdStatic(fieldType,field));
         return;
     }
     // generate helper call for throwing respective exception
@@ -2252,6 +2297,9 @@
 void 
 JavaByteCodeTranslator::genLdVar(uint32 varIndex,JavaLabelPrepass::JavaVarType javaType) {
     Opnd *var = getVarOpndLdVar(javaType,varIndex);
+    if (isMagicClass(var->getType())) {
+        var->setType(convertMagicType2HIR(typeManager, var->getType()));
+    }
     Opnd *opnd;
     if (var->isVarOpnd()) {
         opnd = irBuilder.genLdVar(var->getType(),(VarOpnd*)var);
@@ -2663,6 +2711,9 @@
     if (isMagicMethod(methodDesc)) {
         genMagic(methodDesc, numArgs, srcOpnds, returnType);    
         return;
+    } else if (isVMHelperMethod(methodDesc)) {
+        genVMHelper(methodDesc, numArgs, srcOpnds, returnType);
+        return;
     }
     if (inlineMethod(methodDesc)) {
         if(Log::isEnabled()) {
@@ -3873,6 +3924,28 @@
 
     assert(0);
     return;
+}
+
+
+void JavaByteCodeTranslator::genVMHelper(MethodDesc *md, uint32 numArgs, Opnd **srcOpnds, Type *returnType) {
+    Type* resType = isMagicClass(returnType) ? convertMagicType2HIR(typeManager, returnType) : returnType;
+    const char* mname = md->getName();
+
+    if (!strcmp(mname,"getTlsBaseAddress")) {
+        assert(numArgs == 0);
+        Opnd* res = irBuilder.genVMHelperCall(CompilationInterface::Helper_GetTLSBase, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return;
+    }
+
+    if (!strcmp(mname,"newResolvedUsingAllocHandleAndSize")) {
+        assert(numArgs == 2);
+        Opnd* res = irBuilder.genVMHelperCall(CompilationInterface::Helper_NewObj_UsingVtable, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return;
+    }
+
+    assert(0);
 }
 
 } //namespace Jitrino 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h Mon Nov 27 22:20:46 2006
@@ -316,6 +316,7 @@
     bool    needsReturnLabel(uint32 off);
     void    genInvokeStatic(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds,Type * returnType);
     void    genMagic(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds,Type * returnType);
+    void    genVMHelper(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds,Type * returnType);
     
     bool    methodIsArraycopy(MethodDesc * methodDesc);
     bool    arraycopyOptimizable(MethodDesc * methodDesc, uint32 numArgs, Opnd ** srcOpnds);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h Mon Nov 27 22:20:46 2006
@@ -289,12 +289,12 @@
      * Resolve a system class by its name. 
      * Returns NULL if no such class found.
      */
-    virtual ObjectType *    resolveSystemClass( const char * klassName ) = 0;
+    virtual ObjectType *    resolveClassUsingBootstrapClassloader( const char * klassName ) = 0;
     /**
      * Recursively looks up for a given method with a given signature in the given class.
      * Returns NULL if no such method found.
      */
-    virtual MethodPtrType * resolveMethod( ObjectType * klass, const char * methodName, const char * methodSig) = 0;
+    virtual MethodDesc* resolveMethod(ObjectType * klass, const char * methodName, const char * methodSig) = 0;
 
     // Class type is a subclass of ch=mh->getParentType()  The function returns
     // a method description for a method overriding mh in type or in the closest
@@ -553,7 +553,7 @@
      * @return runtime handle of the corresponding VM object for the method 
      */
     virtual void* getRuntimeMethodHandle(MethodDesc *method) = 0;
-    
+
     virtual CompilationContext* getCompilationContext() const {return compilationContext;}
 
 protected:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp Mon Nov 27 22:20:46 2006
@@ -1014,8 +1014,8 @@
 }
 
 
-ObjectType * DrlVMCompilationInterface::resolveSystemClass( const char * klassName ) {
-    Class_Handle cls = class_load_class_by_name_using_system_class_loader(klassName);
+ObjectType * DrlVMCompilationInterface::resolveClassUsingBootstrapClassloader( const char * klassName ) {
+    Class_Handle cls = class_load_class_by_name_using_bootstrap_class_loader(klassName);
     if( NULL == cls ) {
         return NULL;
     }
@@ -1023,20 +1023,21 @@
 };
 
 
-MethodPtrType * DrlVMCompilationInterface::resolveMethod( ObjectType* klass, const char * methodName, const char * methodSig) {
+MethodDesc* DrlVMCompilationInterface::resolveMethod( ObjectType* klass, const char * methodName, const char * methodSig) {
     Class_Handle cls = (Class_Handle)klass->getVMTypeHandle();
     assert( NULL != cls );  
     Method_Handle mh = class_lookup_method_recursively( cls, methodName, methodSig);
     if( NULL == mh ) {
         return NULL;
     }
-    return getTypeManager().getMethodPtrType(getMethodDesc(mh));
+    return getMethodDesc(mh, NULL);
 };
 
 JIT_Handle
 DrlVMCompilationInterface::getJitHandle() const {
     return getCompilationContext()->getCurrentJITContext()->getJitHandle();
 }
+
 
 
 } //namespace Jitrino

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.h Mon Nov 27 22:20:46 2006
@@ -460,8 +460,8 @@
     const char* methodSignatureString(MethodDesc* enclosingMethodDesc, uint32 methodToken);
 
         // resolve-by-name methods
-    virtual ObjectType *    resolveSystemClass( const char * klassName );
-    virtual MethodPtrType * resolveMethod( ObjectType * klass, const char * methodName, const char * methodSig);
+    virtual ObjectType * resolveClassUsingBootstrapClassloader( const char * klassName );
+    virtual MethodDesc * resolveMethod( ObjectType * klass, const char * methodName, const char * methodSig);
 
     void*        loadStringObject(MethodDesc* enclosingMethod,
                                  uint32 stringToken);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h Mon Nov 27 22:20:46 2006
@@ -377,7 +377,7 @@
         assert (k <= K_LAST_PRIMITIVE ); // primitive types are limited by K_LAST_PRIMITIVE bound
         return primitive_types[k];
     }
-
+    void SetBCPElement(const char *path, apr_pool_t *tmp_pool);
 protected:
     virtual Class* DoLoadClass(Global_Env* env, const String* name);
 
@@ -389,7 +389,6 @@
     Class* LoadFromJarFile( JarFile* jar_file,
         const char* class_name_in_jar, const String* class_name, bool* not_found);
     void SetClasspathFromProperty(const char* prop_string, apr_pool_t *tmp_pool);
-    void SetBCPElement(const char *path, apr_pool_t *tmp_pool);
     void SetClasspathFromJarFile(JarFile *jar, apr_pool_t *tmp_pool);
 
     BCPElements m_BCPElements;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Mon Nov 27 22:20:46 2006
@@ -924,13 +924,13 @@
 
 
 Class_Handle
-class_load_class_by_name_using_system_class_loader(const char *name)
+class_load_class_by_name_using_bootstrap_class_loader(const char *name)
 {
     Global_Env *env = VM_Global_State::loader_env;
     String *n = env->string_pool.lookup(name);
-    Class *clss = env->bootstrap_class_loader->LoadClass(env, n);
+    Class *clss = env->bootstrap_class_loader->LoadVerifyAndPrepareClass(env, n);
     return (Class_Handle)clss;
-} //class_load_class_by_name_using_system_class_loader
+} 
 
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm.cpp Mon Nov 27 22:20:46 2006
@@ -129,6 +129,8 @@
     {"vm.ee_dlls",                       "A ';'-delimited list of modular dlls (JIT/Interpreter/etc.) to load at startup."},
     {"vm.em_dll",                        "A ';'-execution manager (EM) dll to load at startup."},
     {"vm.other_natives_dlls",            "A " EXPAND(PORT_PATH_SEPARATOR) "-delimited list of dlls contained native methods implementations to load at startup."},
+    {"vm.components.<component>.classpath",     "Part of a <component>'s classpath to append to the JDK booclasspath"},
+    {"vm.components.<component>.startupclass",  "A <component> class to be initialized during startup"}
 };
 
 static const int numStandardProperties = sizeof(standardProperties) / sizeof(standardProperties[0]);
@@ -137,6 +139,9 @@
 
 void check_vm_standard_property(const char *propertyName, const char *propertyValue)
 {
+    if (!strncmp(propertyName, "vm.components.", strlen("vm.components."))) {
+        return;
+    }
     for (int i=0; i<numStandardProperties; i++)
     {
         if (!strcmp(propertyName, standardProperties[i].name))

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Mon Nov 27 22:20:46 2006
@@ -280,6 +280,52 @@
     }
 }
 
+
+/**
+* Extends bootstrap classpath with jars from components
+*/
+static void bootstrap_add_components_classpath(Global_Env *vm_env) {
+    static std::string VM_COMPONENT_BOOTSTRAP_PREFIX="vm.components.";
+    static std::string VM_COMPONENT_BOOTSTRAP_SUFFIX=".classpath";
+    
+    // create temp pool for apr functions
+    apr_pool_t *tmp_pool;
+    apr_pool_create(&tmp_pool, NULL);
+    
+    std::string kernel_dir_path = vm_get_property_value(O_A_H_VM_VMDIR);
+    
+    PropertiesIteratorHandle ph = vm_properties_iterator_create();
+    do {
+        const char* key = vm_properties_get_name(ph);
+        //check if the property name is VM_COMPONENT_BOOTSTRAP_PREFIX.*.VM_COMPONENT_BOOTSTRAP_SUFFIX form
+        if (strncmp(VM_COMPONENT_BOOTSTRAP_PREFIX.c_str(), key, VM_COMPONENT_BOOTSTRAP_PREFIX.length())) {
+            continue;
+        }
+        size_t len = strlen(key);
+        if (len < VM_COMPONENT_BOOTSTRAP_PREFIX.length()+ 2 + VM_COMPONENT_BOOTSTRAP_SUFFIX.length()) {
+            continue;
+        }
+        if (strcmp(VM_COMPONENT_BOOTSTRAP_SUFFIX.c_str(), key + len - VM_COMPONENT_BOOTSTRAP_SUFFIX.length())) {
+            continue;
+        }
+        //all checks passed
+        //extends boot class path with the property value
+        const char* path = vm_properties_get_string_value(ph);
+        // check if path must be extended
+        std::string absPath;
+        if (strstr(path, PORT_FILE_SEPARATOR_STR)==NULL) {
+            absPath = kernel_dir_path + path;
+        } else {
+            absPath = path;
+        }
+        vm_env->bootstrap_class_loader->SetBCPElement(absPath.c_str(), tmp_pool);
+    } while(vm_properties_iterator_advance(ph));
+
+    vm_properties_iterator_destroy(ph);
+    
+    apr_pool_destroy(tmp_pool);
+}
+
 /**
  * Loads initial classes. For example j.l.Object, j.l.Class, etc.
  */
@@ -289,6 +335,8 @@
     TRACE("bootstrapping initial java classes");
 
     vm_env->bootstrap_class_loader->Initialize();
+
+    bootstrap_add_components_classpath(vm_env);
 
     /*
      *  Bootstrap java.lang.Class class. This requires also loading the other classes 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java?view=diff&rev=479926&r1=479925&r2=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java Mon Nov 27 22:20:46 2006
@@ -26,6 +26,9 @@
 import java.lang.reflect.Modifier;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Properties;
+import java.util.Enumeration;
+
 
 /**
  * This class does the following:
@@ -44,7 +47,30 @@
         parseSystemProperties();
     }
 
+    /** 
+        Any component can ask VMStart to initialize it's class
+        using  vm.component.<component name>.startupclass property
+    */
+    private static final String STARTUP_CLASS_PREFIX="vm.components.";
+    private static final String STARTUP_CLASS_SUFFUX=".startupclass";
+
     public static void parseSystemProperties() {
+        //call class.forName for all startup classes 
+        Properties p = System.getProperties();
+        for (Enumeration it=p.propertyNames(); it.hasMoreElements();) {
+            String key = (String)it.nextElement();
+            if (key.startsWith(STARTUP_CLASS_PREFIX) && key.endsWith(STARTUP_CLASS_SUFFUX)) {
+                String className = p.getProperty(key);
+                try {
+                    Class.forName(className);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    //TODO: should be call System.exit() here?
+                }
+
+            }
+        }
+        
     }
     
     public static void startHelperThreads() {

Added: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java?view=auto&rev=479926
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java Mon Nov 27 22:20:46 2006
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.
+ */
+/**
+ * @author Mikhail Y. Fursov
+ */ 
+
+package org.apache.harmony.drlvm;
+
+import org.vmmagic.unboxed.Address;
+
+public class VMHelper {
+
+    private VMHelper() {}
+    
+
+
+    public static Address getTlsBaseAddress() {fail(); return null;}
+
+    public static Object newResolvedUsingAllocHandleAndSize(int objSize, int allocationHandle) {fail(); return null;}
+
+
+
+
+    protected static void fail() {throw new RuntimeException("Not supported!");}
+
+}