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 2007/01/10 21:46:29 UTC

svn commit: r494972 - in /harmony/enhanced/drlvm/trunk: build/make/ vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/ vm/gc_gen/src/jni/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/optimizer/ vm/jitrino/src/translator/java/ vm/vmcore/src/kernel_...

Author: wjwashburn
Date: Wed Jan 10 12:46:28 2007
New Revision: 494972

URL: http://svn.apache.org/viewvc?view=rev&rev=494972
Log:
H2652, write barrier and inlining support for gc_gen "build test" runs on winxp and RHEL4 w/ gcc4.0.2

Modified:
    harmony/enhanced/drlvm/trunk/build/make/deploy.xml
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/helper.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java

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=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/deploy.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/deploy.xml Wed Jan 10 12:46:28 2007
@@ -51,6 +51,7 @@
 
         <gc_gen>
             <shared>bin/default:gc_gen</shared>
+            <jar>bin/default:gc_gen</jar>
         </gc_gen>
 
         <gc_cc>

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java?view=diff&rev=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java Wed Jan 10 12:46:28 2007
@@ -22,6 +22,7 @@
 
 import org.apache.harmony.drlvm.VMHelper;
 import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
 
 public class GCHelper {
 
@@ -29,7 +30,7 @@
 
     public static final int TLS_GC_OFFSET = TLSGCOffset();
 
-    public static Address alloc(int objSize, int allocationHandle) {
+    public static Address alloc(int objSize, int allocationHandle)   throws InlinePragma {
   
         Address TLS_BASE = VMHelper.getTlsBaseAddress();
 
@@ -49,6 +50,45 @@
                 
         return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);    
     }
+
+    private static final int ARRAY_LEN_OFFSET = 8;
+    private static final int GC_OBJECT_ALIGNMENT = 4; //TODO: EM64 or IPF could have 8!
+
+    public static Address allocArray(int arrayLen, int elemSize, int allocationHandle)  throws InlinePragma {
+        if (arrayLen >= 0) {
+            int firstElementOffset = ARRAY_LEN_OFFSET + (elemSize==8?8:4);
+            int size = firstElementOffset + elemSize*arrayLen;
+            size = (((size + (GC_OBJECT_ALIGNMENT - 1)) & (~(GC_OBJECT_ALIGNMENT - 1))));
+
+            Address arrayAddress = alloc(size, allocationHandle); //never null!
+            arrayAddress.store(arrayLen, Offset.fromInt(ARRAY_LEN_OFFSET));
+            return arrayAddress;
+        }
+        return VMHelper.newVectorUsingAllocHandle(arrayLen, elemSize, allocationHandle);
+    }
+
+
+
+    /** NOS (nursery object space) is higher in address than other spaces.
+       The boundary currently is produced in GC initialization. It can
+       be a constant in future.
+    */
+    public static final int NOS_BOUNDARY = getNosBoundary();
+
+    public static void write_barrier_slot_rem(Address p_objBase, Address p_objSlot, Address p_source)  throws InlinePragma {
+
+       /* If the slot is in NOS or the target is not in NOS, we simply return*/
+        if(p_objSlot.toInt() >= NOS_BOUNDARY || p_source.toInt() < NOS_BOUNDARY) {
+            p_objSlot.store(p_source);
+            return;
+        }
+
+        /* Otherwise, we need remember it in native code. */
+        VMHelper.writeBarrier(p_objBase, p_objSlot, p_source);
+    }
+
+
+    private static native int getNosBoundary();
     
     private static native int TLSGCOffset();
 }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/helper.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/helper.cpp?view=diff&rev=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/helper.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/jni/helper.cpp Wed Jan 10 12:46:28 2007
@@ -1,7 +1,7 @@
 #include <open/vm_gc.h>
 #include <jni.h>
 #include "../thread/gc_thread.h"
-
+#include "../gen/gen.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -16,6 +16,15 @@
 {
     return (jint)tls_gc_offset;
 }
+
+ 
+
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1gen_GCHelper_getNosBoundary(JNIEnv *e, jclass c)
+{
+    return (jint)nos_boundary;
+}
+
+
 
 #ifdef __cplusplus
 }

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=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Wed Jan 10 12:46:28 2007
@@ -143,13 +143,13 @@
         return fnan;
     } else if (!_finite(v1)){
         return v0;
-	}     
+    }     
     float result = v0-float(int64(v0/v1))*v1;
     if (result == 0 && v1 < 0) {
 #ifdef PLATFORM_POSIX
-		return copysign(result, v1);
+        return copysign(result, v1);
 #else
-		return (float)_copysign(result, v1);
+        return (float)_copysign(result, v1);
 #endif
     } else {
         return result;  
@@ -162,13 +162,13 @@
         return dnan;
     } else if (!_finite(v1)){
         return v0;
-	} 
+    } 
     double result = v0-double(int64(v0/v1))*v1;
     if (result == 0 && v1 < 0) {
 #ifdef PLATFORM_POSIX
-		return copysign(result, v1);
+        return copysign(result, v1);
 #else
-		return _copysign(result, v1);
+        return _copysign(result, v1);
 #endif
     } else {
         return result;  
@@ -1492,7 +1492,7 @@
 
 CG_OpndHandle*    InstCodeSelector::ldc_i8(uint64 val) 
 { 
-#ifndef _EM64T_	
+#ifndef _EM64T_ 
     return irManager.newImmOpnd(typeManager.getInt64Type(), val);
 #else
     Opnd * tmp = irManager.newOpnd(typeManager.getInt64Type());
@@ -2885,6 +2885,7 @@
     case CompilationInterface::Helper_NewVector_UsingVtable:
     case CompilationInterface::Helper_ObjMonitorEnter:
     case CompilationInterface::Helper_ObjMonitorExit:
+    case CompilationInterface::Helper_WriteBarrier:
     {
         dstOpnd = retType==NULL ? NULL: irManager.newOpnd(retType);
         CallInst * callInst=irManager.newRuntimeHelperCallInst(callId, numArgs, (Opnd**)args, dstOpnd);

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=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp Wed Jan 10 12:46:28 2007
@@ -1184,7 +1184,10 @@
                 regUsages.push_back(regUsage);
             }
 
-            assert(irManager->getLiveAtEntry(node)->isEqual(*lsCurrent));
+#ifdef _DEBUG
+            BitSet* entrySet = irManager->getLiveAtEntry(node);
+            assert(entrySet->isEqual(*lsCurrent));
+#endif
 
             StlVector<Opnd *> opndsAll(mm);
 

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=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp Wed Jan 10 12:46:28 2007
@@ -1876,8 +1876,8 @@
 // conversion
 Inst* InstFactory::makeConv(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src) {
     Opcode opcode = Op_Conv;
-    if (dst->getType()->isUnmanagedPtr() && src->getType()->isObject() 
-        || dst->getType()->isObject() && src->getType()->isUnmanagedPtr()) 
+    if ((dst->getType()->isUnmanagedPtr() && src->getType()->isObject()) 
+        || (dst->getType()->isObject() && src->getType()->isUnmanagedPtr())) 
     {
         opcode = Op_ConvUnmanaged;
     }

Modified: 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=diff&rev=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp Wed Jan 10 12:46:28 2007
@@ -44,6 +44,7 @@
 DECLARE_STANDARD_HELPER_FLAGS(newArray);
 DECLARE_STANDARD_HELPER_FLAGS(objMonEnter);
 DECLARE_STANDARD_HELPER_FLAGS(objMonExit);
+DECLARE_STANDARD_HELPER_FLAGS(wb);
     
 };
 
@@ -92,6 +93,10 @@
 
     READ_STANDARD_HELPER_FLAGS(objMonExit);
     flags.objMonExit_signature = "(Ljava/lang/Object;)V";
+
+    READ_STANDARD_HELPER_FLAGS(wb);
+    flags.wb_signature = "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;)V";
+
 }
 
 
@@ -152,6 +157,7 @@
 DECLARE_HELPER_INLINER(NewArrayHelperInliner, newArray)
 DECLARE_HELPER_INLINER(ObjMonitorEnterHelperInliner, objMonEnter)
 DECLARE_HELPER_INLINER(ObjMonitorExitHelperInliner, objMonExit)
+DECLARE_HELPER_INLINER(WriteBarrierHelperInliner, wb)
 
 void HelperInlinerSession::_run(IRManager& irm) {
     CompilationContext* cc = getCompilationContext();
@@ -193,6 +199,12 @@
                             helperInliners.push_back(new (tmpMM) ObjMonitorExitHelperInliner(this, tmpMM, cc, inst));
                         }
                         break;
+                    case Op_TauStRef:
+                        if (flags.wb_doInlining && nodePercent >= flags.wb_hotnessPercentToInline) {
+                            helperInliners.push_back(new (tmpMM) WriteBarrierHelperInliner(this, tmpMM, cc, inst));
+                        }
+                        break;
+
                     default: break;
                 }
             }
@@ -268,7 +280,7 @@
         //add all methods with pragma inline into the list.
         const Nodes& nodesInRegion = regionToInline->getIRManager().getFlowGraph().getNodes();
         for (Nodes::const_iterator it = nodesInRegion.begin(), end = nodesInRegion.end(); it!=end; ++it) {
-        	Node* node = *it;
+            Node* node = *it;
             for (Inst* inst = (Inst*)node->getFirstInst(); inst!=NULL; inst = inst->getNextInst()) {
                 if (inst->isMethodCall()) {
                     MethodCallInst* methodCall = inst->asMethodCallInst();
@@ -447,6 +459,49 @@
     inlineVMHelper(call);
 #endif
 }
+
+void WriteBarrierHelperInliner::doInline() {
+#if defined  (_EM64T_) || defined (_IPF_)
+    return;
+#else
+    assert(inst->getOpcode() == Op_TauStRef);
+
+    Opnd* srcOpnd = inst->getSrc(0);
+    Opnd* ptrOpnd = inst->getSrc(1);
+    Opnd* objBaseOpnd = inst->getSrc(2);
+    assert(srcOpnd->getType()->isObject());
+    assert(ptrOpnd->getType()->isPtr());
+    assert(objBaseOpnd->getType()->isObject());
+    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
+    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
+    Opnd* args[3] = {objBaseOpnd, ptrOpnd, srcOpnd};
+    MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 3, args, method)->asMethodCallInst();
+    call->insertBefore(inst);
+    inst->unlink();
+    
+    if (call != call->getNode()->getLastInst()) {
+        cfg->splitNodeAtInstruction(call, true, true, instFactory->makeLabel());
+    }
+
+    //every call must have exception edge -> add it
+    if (call->getNode()->getExceptionEdge() == NULL) {
+        Node* node = call->getNode();
+        Node* dispatchNode = node->getUnconditionalEdgeTarget()->getExceptionEdgeTarget();
+        if (dispatchNode == NULL) {
+            dispatchNode = cfg->getUnwindNode();
+            if (dispatchNode == NULL) {
+                dispatchNode = cfg->createDispatchNode(instFactory->makeLabel());
+                cfg->setUnwindNode(dispatchNode);
+                cfg->addEdge(dispatchNode, cfg->getExitNode());
+            }
+        }
+        cfg->addEdge(node, dispatchNode);
+    }
+
+    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=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp Wed Jan 10 12:46:28 2007
@@ -532,7 +532,15 @@
             {
                 Opnd* dst = inst->getDst(); 
                 Opnd* src = callInst->getSrc(j+2); // omit taus
-                Inst* copy = _instFactory.makeCopy(dst, src);
+                Inst* copy = NULL;
+                // todo: make translators isMagicClass and convertMagic2HIRType methods public
+                // use these methods here
+                if (dst->getType()->isUnmanagedPtr()==src->getType()->isUnmanagedPtr()) {
+                    copy = _instFactory.makeCopy(dst, src);
+                } else {
+                    Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
+                    copy = _instFactory.makeConv(mod, dst->getType()->tag, dst, src);
+                }
                 copy->insertBefore(inst);
                 inst->unlink();
                 inst = copy;

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=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Wed Jan 10 12:46:28 2007
@@ -4019,6 +4019,12 @@
         return;
     }
 
+    if (!strcmp(mname,"writeBarrier")) {
+        assert(numArgs == 3);
+        irBuilder.genVMHelperCall(CompilationInterface::Helper_WriteBarrier, resType, numArgs, srcOpnds);
+        return;
+    }
+
     assert(0);
 }
 

Modified: 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=diff&rev=494972&r1=494971&r2=494972
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java Wed Jan 10 12:46:28 2007
@@ -38,6 +38,7 @@
 
     public static void monitorExit(Object obj) {fail();}
 
+    public static void writeBarrier(Address objBase, Address objSlot, Address source) {fail();}
 
 
     protected static void fail() {throw new RuntimeException("Not supported!");}