You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2006/12/06 14:39:49 UTC

svn commit: r483073 - in /harmony/enhanced/drlvm/trunk/vm: gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/ gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/ jitrino/config/ia32/ jitrino/src/codegenerator/ia32/ jitrino/src/optimizer/ jitrino/src/translator/...

Author: varlax
Date: Wed Dec  6 05:39:48 2006
New Revision: 483073

URL: http://svn.apache.org/viewvc?view=rev&rev=483073
Log:
Applied HARMONY-2424 [drlvm] Inlining of array allocation helper.
Tested on SUSE9.

Modified:
    harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/GCHelper.java
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
    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/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java

Modified: 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=diff&rev=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/GCHelper.java Wed Dec  6 05:39:48 2006
@@ -22,18 +22,21 @@
 
 import org.apache.harmony.drlvm.VMHelper;
 import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
 
 public class GCHelper {
 
     static {System.loadLibrary("gc_cc");}
 
-    public static final int TLS_CURRENT_OFFSET = getCurrentOffset();
-    public static final int TLS_CLEANED_OFFSET = getCleanedOffset();
+    private static final int TLS_CURRENT_OFFSET = getCurrentOffset();
+    private static final int TLS_CLEANED_OFFSET = getCleanedOffset();
 
 
+    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 Object alloc(int objSize, int allocationHandle) {
+    public static Address alloc(int objSize, int allocationHandle) throws InlinePragma {
         Address tlsAddr = VMHelper.getTlsBaseAddress();
 
         Address tlsFreeFieldAddr = tlsAddr.plus(TLS_CURRENT_OFFSET);
@@ -53,6 +56,22 @@
         return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);    
     }
 
+
+   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);
+    }
+
+
+
     private static native int getCurrentOffset();
     private static native int getCleanedOffset();
-}
\ No newline at end of file
+}

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=483073&r1=483072&r2=483073
==============================================================================
--- 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 Dec  6 05:39:48 2006
@@ -29,7 +29,7 @@
 
     public static final int TLS_GC_OFFSET = TLSGCOffset();
 
-    public static Object alloc(int objSize, int allocationHandle) {
+    public static Address alloc(int objSize, int allocationHandle) {
   
         Address TLS_BASE = VMHelper.getTlsBaseAddress();
 

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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf Wed Dec  6 05:39:48 2006
@@ -80,6 +80,10 @@
 -XDjit.SD2_OPT.arg.optimizer.inline_helpers.newObj_methodName=alloc
 -XDjit.SD2_OPT.arg.optimizer.inline_helpers.newObj_hotnessPercent=1
 
+-XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray=on
+-XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray_className=org/apache/harmony/drlvm/gc_cc/GCHelper
+-XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray_methodName=allocArray
+-XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray_hotnessPercent=1
 
 -XDjit.SD2_OPT.arg.codegen.dce1.early=yes
 -XDjit.SD2_OPT.arg.codegen.regalloc.bp_regalloc1.regs=ALL_GP

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp?view=diff&rev=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp Wed Dec  6 05:39:48 2006
@@ -166,7 +166,10 @@
                         Opnd* origOpnd= irManager->getOpnd(i);
                         Opnd* replacementOpnd = irManager->getOpnd(opndInfos[i].sourceOpndId);
                         //TODO: extends possible convertions.
-                        if (origOpnd->getType()->isUnmanagedPtr() && replacementOpnd->getType()->isInteger()) {
+                        if ( (origOpnd->getType()->isUnmanagedPtr() && replacementOpnd->getType()->isInteger())
+                            //TODO: should we prohibit <type> <-> Mptr|Obj convertion when <type> is not Mptr|Obj ?
+                            || (origOpnd->getType()->isObject() || origOpnd->getType()->isManagedPtr()))
+                        {
                             replacementOpnd->setType(origOpnd->getType());
                         }
                         replacements[i] = replacementOpnd;

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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Wed Dec  6 05:39:48 2006
@@ -467,6 +467,9 @@
     } else if (srcType->isUnmanagedPtr() && !dstType->isUnmanagedPtr()) {
         dstOpnd = convertUnmanagedPtr(srcOpnd, dstType, dstOpnd);
         converted = true;
+    } else  if (srcType->isObject() && dstType->isUnmanagedPtr()) {
+        dstOpnd = convertToUnmanagedPtr(srcOpnd, dstType, dstOpnd);
+        converted = true;
     }
 
     if (!converted){
@@ -586,7 +589,8 @@
 Opnd * InstCodeSelector::simpleOp_I4(Mnemonic mn, Type * dstType, Opnd * src1, Opnd * src2)
 {
     Opnd * dst=irManager.newOpnd(dstType);
-    Opnd * srcOpnd1=(Opnd*)convert(src1, dstType), * srcOpnd2=src2==NULL?NULL:(Opnd*)convert(src2, dstType);
+    Opnd * srcOpnd1=(Opnd*)convert(src1, dstType);
+    Opnd * srcOpnd2=src2==NULL?NULL:(Opnd*)convert(src2, dstType);
     if (Encoder::getMnemonicProperties(mn)&Inst::Properties_Symmetric)
         swapIfLastIs(srcOpnd1, srcOpnd2);
     appendInsts(irManager.newInstEx(mn, 1, dst, srcOpnd1, srcOpnd2));
@@ -1887,7 +1891,8 @@
                                                CG_OpndHandle * elemBase,
                                                CG_OpndHandle * index) 
 {
-    PtrType * ptrType=((Opnd*)elemBase)->getType()->asPtrType();
+    Type* type = ((Opnd*)elemBase)->getType();
+    PtrType * ptrType=type->asPtrType();
     Type * elemType = ptrType->getPointedToType();
 
     uint32 elemSize=getByteSize(irManager.getTypeSize(elemType));
@@ -2858,10 +2863,10 @@
         break;
     }
     case CompilationInterface::Helper_NewObj_UsingVtable:
+    case CompilationInterface::Helper_NewVector_UsingVtable:
     {
-        assert(numArgs == 2);
         dstOpnd = irManager.newOpnd(retType);
-        CallInst * callInst=irManager.newRuntimeHelperCallInst(CompilationInterface::Helper_NewObj_UsingVtable, 2, (Opnd**)args, dstOpnd);
+        CallInst * callInst=irManager.newRuntimeHelperCallInst(callId, numArgs, (Opnd**)args, dstOpnd);
         appendInsts(callInst);
         break;
     }

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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp Wed Dec  6 05:39:48 2006
@@ -646,9 +646,9 @@
                                                           dstType,
                                                           getCGInst(inst->getSrc(0)));
                 } else if (dstType->isObject()){
-                    cgInst = instructionCallback.convUPtrToObject((ObjectType*)dstType, getCGInst(inst->getSrc(0)));
+                    cgInst = instructionCallback.convUPtrToObject(dstType->asObjectType(), getCGInst(inst->getSrc(0)));
                 } else if (dstType->isUnmanagedPtr()) {
-                    cgInst = instructionCallback.convToUPtr((PtrType*)dstType, getCGInst(inst->getSrc(0)));
+                    cgInst = instructionCallback.convToUPtr(dstType->asPtrType(), getCGInst(inst->getSrc(0)));
                 } else {
                     bool isSigned = Type::isSignedInteger(inst->getType());
                     cgInst = instructionCallback.convToInt(mapToIntConvertOpType(inst),

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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp Wed Dec  6 05:39:48 2006
@@ -36,6 +36,12 @@
     const char* newObj_className;
     const char* newObj_methodName;
     const char* newObj_signature;
+
+    bool  newArray_doInlining;
+    int   newArray_hotnessPercentToInline;
+    const char* newArray_className;
+    const char* newArray_methodName;
+    const char* newArray_signature;
 };
 
 class HelperInlinerAction: public Action {
@@ -57,7 +63,7 @@
     //new obj inlining params;
     flags.newObj_doInlining = getBoolArg("newObj", false);
 
-    flags.newObj_signature = "(II)Ljava/lang/Object;";
+    flags.newObj_signature = "(II)Lorg/vmmagic/unboxed/Address;";
     if (flags.newObj_doInlining) {
         flags.newObj_className = getStringArg("newObj_className", NULL);
         flags.newObj_methodName = getStringArg("newObj_methodName", NULL);
@@ -73,6 +79,26 @@
         flags.newObj_methodName = NULL;
     }
 
+
+    //new array inlining params;
+    flags.newArray_doInlining = getBoolArg("newArray", false);
+
+    flags.newArray_signature = "(III)Lorg/vmmagic/unboxed/Address;";
+    if (flags.newArray_doInlining) {
+        flags.newArray_className = getStringArg("newArray_className", NULL);
+        flags.newArray_methodName = getStringArg("newArray_methodName", NULL);
+        flags.newArray_hotnessPercentToInline = getIntArg("newArray_hotnessPercent", 0);
+        if (flags.newArray_className == NULL || flags.newArray_methodName == NULL) {
+            //TODO:? crash("Invalid newArray fast path helper name: %s::%s\n", flags.newArray_className, flags.newArray_methodName);
+            flags.newArray_doInlining = false;
+        }
+    }
+
+    if (!flags.newArray_doInlining){
+        flags.newArray_className = NULL;
+        flags.newArray_methodName = NULL;
+    }
+
 }
 
 
@@ -100,7 +126,16 @@
 public:
     NewObjHelperInliner(HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst) 
         : HelperInliner(session, tmpMM, cc, inst){}
-        virtual void doInline();
+    
+    virtual void doInline();
+};
+
+
+class NewArrayHelperInliner : public HelperInliner {
+public:
+    NewArrayHelperInliner(HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst) 
+        : HelperInliner(session, tmpMM, cc, inst){}
+    virtual void doInline();
 };
 
 
@@ -129,6 +164,11 @@
                             helperInliners.push_back(new (tmpMM) NewObjHelperInliner(this, tmpMM, cc, inst));
                         }
                         break;
+                    case Op_NewArray:
+                        if (flags.newArray_doInlining && nodePercent >= flags.newArray_hotnessPercentToInline) {
+                            helperInliners.push_back(new (tmpMM) NewArrayHelperInliner(this, tmpMM, cc, inst));
+                        }
+                        break;
                     default: break;
                 }
             }
@@ -173,29 +213,67 @@
 
 }
 
-void HelperInliner::inlineVMHelper(MethodCallInst* call) {
-    CompilationInterface* ci = cc->getVMCompilationInterface();
-    IRManager* irm = cc->getHIRManager();
+typedef StlVector<MethodCallInst*> InlineVector;
 
-    //now inline the call
-    CompilationContext inlineCC(cc->getCompilationLevelMemoryManager(), ci, cc->getCurrentJITContext());
-    inlineCC.setPipeline(cc->getPipeline());
+#define PRAGMA_INLINE "org/vmmagic/pragma/InlinePragma"
 
-    Inliner inliner(action, localMM, *irm, false);
-    InlineNode* regionToInline = inliner.createInlineNode(inlineCC, call);
+void HelperInliner::inlineVMHelper(MethodCallInst* origCall) {
+    InlineVector  methodsToInline(localMM);
+    methodsToInline.push_back(origCall);
+    while (!methodsToInline.empty()) {
+        MethodCallInst* call = *methodsToInline.rbegin();
+        methodsToInline.pop_back();
+        if (Log::isEnabled()) {
+            Log::out()<<"Inlining VMHelper:";call->print(Log::out());Log::out()<<std::endl;
+        }
 
-    inliner.connectRegion(regionToInline);
+        CompilationInterface* ci = cc->getVMCompilationInterface();
+        IRManager* irm = cc->getHIRManager();
 
-    // Optimize inlined region before splicing
-    inlineCC.stageId = cc->stageId;
-    Inliner::runInlinerPipeline(inlineCC, flags.inlinerPipelineName);
-    cc->stageId = inlineCC.stageId;
+        //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;
+
+        //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;
+            for (Inst* inst = (Inst*)node->getFirstInst(); inst!=NULL; inst = inst->getNextInst()) {
+                if (inst->isMethodCall()) {
+                    MethodCallInst* methodCall = inst->asMethodCallInst();
+                    MethodDesc* md = methodCall->getMethodDesc();
+                    uint32 nThrows = md->getNumThrows();
+                    for (uint32 i=0; i<nThrows;i++) {
+                        NamedType* type = md->getThrowType(i);
+                        const char* name = type->getName();
+                        if (!strcmp(name, PRAGMA_INLINE)) {
+                            methodsToInline.push_back(methodCall);
+                            if (Log::isEnabled()) {
+                                Log::out()<<"Found InlinePragma, adding to the queue:";methodCall->print(Log::out());Log::out()<<std::endl;
+                            }
+                        }
+                    }
+                }
+            }
+        }
 
-    inliner.inlineRegion(regionToInline, false);
+        //inline the region
+        inliner.inlineRegion(regionToInline, false);
+    }
 }
 
 void NewObjHelperInliner::doInline() {
-#ifdef _EM64T_
+#if defined  (_EM64T_) || defined (_IPF_)
     return;
 #else
     if (Log::isEnabled())  {
@@ -208,9 +286,9 @@
     if (!method) {
         return;
     }
-    
-    TypeInst *typeInst = (TypeInst*)inst;
-    Type * type = typeInst->getTypeInfo();
+
+    Opnd* dstOpnd= inst->getDst();
+    Type * type = dstOpnd->getType();
     assert(type->isObject());
     ObjectType* objType = type->asObjectType();
 
@@ -231,17 +309,92 @@
 
     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());
+    Opnd* callResOpnd = opndManager.createSsaTmpOpnd(typeManager.getUnmanagedPtrType(typeManager.getInt8Type()));
     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();
+    MethodCallInst* call = instFactory.makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
+    call->insertBefore(inst);
+    inst->unlink();
+    assert(call == call->getNode()->getLastInst());
+
+    //convert address type to managed object type
+    Edge* fallEdge= call->getNode()->getUnconditionalEdge();
+    assert(fallEdge && fallEdge->getTargetNode()->isBlockNode());
+    Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
+    Node* fallNode = fallEdge->getTargetNode();
+    if (fallNode->getInDegree()>1) {
+        fallNode = irm->getFlowGraph().spliceBlockOnEdge(fallEdge, instFactory.makeLabel());
+    }
+    fallNode->prependInst(instFactory.makeConv(mod, type->tag, dstOpnd, callResOpnd));
+    
+    //inline the method
+    inlineVMHelper(call);
+#endif
+}
+
+
+void NewArrayHelperInliner::doInline() {
+#if defined  (_EM64T_) || defined (_IPF_)
+    return;
+#else
+    if (Log::isEnabled())  {
+        Log::out() << "Processing inst:"; inst->print(Log::out()); Log::out()<<std::endl;
+    }
+    assert(inst->getOpcode() == Op_NewArray);
+
+    //find the method
+    MethodDesc* method = ensureClassIsResolvedAndInitialized(flags.newArray_className, flags.newArray_methodName, flags.newArray_signature);
+    if (!method) {
+        return;
+    }
+
+
+    //the method signature is (int objSize, int allocationHandle)
+    Opnd* dstOpnd = inst->getDst();
+    ArrayType* arrayType = dstOpnd->getType()->asArrayType();
+    int allocationHandle = (int)arrayType->getAllocationHandle();
+    Type* elemType = arrayType->getElementType();
+    int elemSize = 4; //TODO: EM64T references!
+    if (elemType->isDouble() || elemType->isInt8()) {
+        elemSize = 8;
+    } else if (elemType->isInt2() || elemType->isChar()) {
+        elemSize = 2;
+    } else  if (elemType->isInt1()) {
+        elemSize = 1;
+    }
+
+    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* numElements = inst->getSrc(0);
+    Opnd* elemSizeOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
+    Opnd* allocationHandleOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
+    instFactory.makeLdConst(elemSizeOpnd, elemSize)->insertBefore(inst);
+    instFactory.makeLdConst(allocationHandleOpnd, allocationHandle)->insertBefore(inst);
+    Opnd* args[3] = {numElements, elemSizeOpnd, allocationHandleOpnd};
+    Opnd* callResOpnd = opndManager.createSsaTmpOpnd(typeManager.getUnmanagedPtrType(typeManager.getInt8Type()));
+    MethodCallInst* call = instFactory.makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 3, args, method)->asMethodCallInst();
     call->insertBefore(inst);
     inst->unlink();
     assert(call == call->getNode()->getLastInst());
 
+    //convert address type to managed array type
+    Edge* fallEdge= call->getNode()->getUnconditionalEdge();
+    assert(fallEdge && fallEdge->getTargetNode()->isBlockNode());
+    Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
+    Node* fallNode = fallEdge->getTargetNode();
+    if (fallNode->getInDegree()>1) {
+        fallNode = irm->getFlowGraph().spliceBlockOnEdge(fallEdge, instFactory.makeLabel());
+    }
+    fallNode->prependInst(instFactory.makeConv(mod, arrayType->tag, dstOpnd, callResOpnd));
+    
     //inline the method
     inlineVMHelper(call);
 #endif

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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Wed Dec  6 05:39:48 2006
@@ -57,10 +57,12 @@
 }
 
 Type* convertMagicType2HIR(TypeManager& tm, Type* type) {
-    if (!type->isObject() || !type->isNamedType()) {
+    if (!type->isObject() || !type->isNamedType() || type->isSystemObject()) {
         return type;
     }
+
     assert(isMagicClass(type));
+
     const char* name = type->getName();    
     if (!strcmp(name, "org/vmmagic/unboxed/Address") 
         || !strcmp(name, "org/vmmagic/unboxed/ObjectReference")) 
@@ -3941,6 +3943,13 @@
     if (!strcmp(mname,"newResolvedUsingAllocHandleAndSize")) {
         assert(numArgs == 2);
         Opnd* res = irBuilder.genVMHelperCall(CompilationInterface::Helper_NewObj_UsingVtable, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return;
+    }
+
+    if (!strcmp(mname,"newVectorUsingAllocHandle")) {
+        assert(numArgs == 3);
+        Opnd* res = irBuilder.genVMHelperCall(CompilationInterface::Helper_NewVector_UsingVtable, resType, numArgs, srcOpnds);
         pushOpnd(res);
         return;
     }

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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h Wed Dec  6 05:39:48 2006
@@ -158,6 +158,8 @@
     virtual bool        isAddressFinal()    = 0;
     virtual void*       getIndirectAddress()= 0;
     virtual uint32      getNumHandlers()    = 0;
+    virtual uint32      getNumThrows()    = 0;
+    virtual NamedType*  getThrowType(uint32 i) = 0;
     
     // Exception handler and signature parsing API
     virtual unsigned    parseJavaHandlers(ExceptionCallback&) = 0;

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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp Wed Dec  6 05:39:48 2006
@@ -1040,4 +1040,13 @@
 
 
 
+
+NamedType* DrlVMMethodDesc::getThrowType(uint32 i) {
+    assert(i<=method_number_throws(drlMethod));
+    Class_Handle ch = method_get_throws(drlMethod, i);
+    assert(ch);
+    NamedType* res = compilationInterface->getTypeManager().getObjectType(ch);
+    return res;
+}
+
 } //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=483073&r1=483072&r2=483073
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.h Wed Dec  6 05:39:48 2006
@@ -274,6 +274,9 @@
     uint32       getByteCodeSize() {return (uint32) method_get_byte_code_size(drlMethod);}
     uint16       getMaxStack()     {return (uint16) method_get_max_stack(drlMethod);}
     uint32       getNumHandlers()  {return method_get_num_handlers(drlMethod);}
+    uint32       getNumThrows() {return method_number_throws(drlMethod);}
+    NamedType*   getThrowType(uint32 i);
+
     //
     // accessors for method info, code and data
     //

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=483073&r1=483072&r2=483073
==============================================================================
--- 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 Dec  6 05:39:48 2006
@@ -30,7 +30,9 @@
 
     public static Address getTlsBaseAddress() {fail(); return null;}
 
-    public static Object newResolvedUsingAllocHandleAndSize(int objSize, int allocationHandle) {fail(); return null;}
+    public static Address newResolvedUsingAllocHandleAndSize(int objSize, int allocationHandle) {fail(); return null;}
+    
+    public static Address newVectorUsingAllocHandle(int arrayLen, int elemSize, int allocationHandle) {fail(); return null;}