harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfur...@apache.org
Subject svn commit: r598532 - in /harmony/enhanced/drlvm/trunk/vm: gc_cc/javasrc/org/apache/harmony/drlvm/gc_cc/ gc_gen/javasrc/org/apache/harmony/drlvm/gc_gen/ include/open/ jitrino/config/ia32/ jitrino/src/optimizer/ jitrino/src/shared/ jitrino/src/translato...
Date Tue, 27 Nov 2007 07:00:35 GMT
Author: mfursov
Date: Mon Nov 26 23:00:33 2007
New Revision: 598532

URL: http://svn.apache.org/viewvc?rev=598532&view=rev
Log:
Fix for [drlvm][jit][opt] VMMagic package support refactoring for Jitrino.OPT compiler

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/include/open/vm.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.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/optimizer/inliner.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- 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 Mon Nov 26 23:00:33 2007
@@ -38,7 +38,7 @@
 
 
     @Inline
-    public static Address alloc(int objSize, int allocationHandle) {
+    private static Address alloc(int objSize, int allocationHandle) {
         Address tlsAddr = VMHelper.getTlsBaseAddress();
 
         Address tlsFreeFieldAddr = tlsAddr.plus(TLS_CURRENT_OFFSET);
@@ -59,9 +59,19 @@
     }
 
 
-    @Inline   
-    public static Address allocArray(int arrayLen, int elemSize, int allocationHandle) {
+    @Inline
+    public static Address alloc(Address classHandle) {
+        int objSize = VMHelper.getTypeSize(classHandle);
+        int allocationHandle = VMHelper.getAllocationHandle(classHandle);
+        return alloc(objSize, allocationHandle);
+    }
+
+    @Inline 
+    public static Address allocArray(Address elemClassHandle, int arrayLen) {
+        Address arrayClassHandle = VMHelper.getArrayClass(elemClassHandle);
+        int allocationHandle = VMHelper.getAllocationHandle(arrayClassHandle);
         if (arrayLen >= 0) {
+            int elemSize = VMHelper.getArrayElemSize(arrayClassHandle);
             int firstElementOffset = ARRAY_LEN_OFFSET + (elemSize==8?8:GC_ARRAY_MIN_FIRST_ELEM_FROM_LEN_OFFSET);
             int size = firstElementOffset + elemSize*arrayLen;
             size = (((size + (GC_OBJECT_ALIGNMENT - 1)) & (~(GC_OBJECT_ALIGNMENT - 1))));

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- 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 Mon Nov 26 23:00:33 2007
@@ -34,7 +34,8 @@
     public static final int TLS_GC_OFFSET = TLSGCOffset();
 
     @Inline
-    public static Address alloc(int objSize, int allocationHandle) {
+    private static Address alloc(int objSize, int allocationHandle ) {
+
         Address TLS_BASE = VMHelper.getTlsBaseAddress();
 
         Address allocator_addr = TLS_BASE.plus(TLS_GC_OFFSET);
@@ -54,12 +55,23 @@
         return VMHelper.newResolvedUsingAllocHandleAndSize(objSize, allocationHandle);    
     }
 
+    @Inline
+    public static Address alloc(Address classHandle) {
+        int objSize = VMHelper.getTypeSize(classHandle);
+        int allocationHandle = VMHelper.getAllocationHandle(classHandle);
+        return alloc(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!
+    private static final int GC_OBJECT_ALIGNMENT = 4;
 
     @Inline
-    public static Address allocArray(int arrayLen, int elemSize, int allocationHandle) {
+    public static Address allocArray(Address elemClassHandle, int arrayLen) {
+        Address arrayClassHandle = VMHelper.getArrayClass(elemClassHandle);
+        int allocationHandle = VMHelper.getAllocationHandle(arrayClassHandle);
         if (arrayLen >= 0) {
+            int elemSize = VMHelper.getArrayElemSize(arrayClassHandle);
             int firstElementOffset = ARRAY_LEN_OFFSET + (elemSize==8?8:4);
             int size = firstElementOffset + elemSize*arrayLen;
             size = (((size + (GC_OBJECT_ALIGNMENT - 1)) & (~(GC_OBJECT_ALIGNMENT - 1))));

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/vm.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/vm.h Mon Nov 26 23:00:33 2007
@@ -325,6 +325,13 @@
  */
  VMEXPORT unsigned class_get_unboxed_data_offset(Class_Handle ch);
 
+
+ /**
+ * @return The size of array element for the given array class
+ */
+ VMEXPORT unsigned class_get_array_element_size(Class_Handle ch);
+
+
 /**
  * @return The class of the array element of the given class.
  *

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf Mon Nov 26 23:00:33 2007
@@ -103,22 +103,22 @@
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE=on
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE_hotnessPercent=1
 
--XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE=on
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE=off
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_NEW_VECTOR_USING_VTABLE_hotnessPercent=1
 
--XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL=on
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL=off
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_ENTER_NON_NULL_hotnessPercent=1
 
--XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL=on
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL=off
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_MONITOR_EXIT_NON_NULL_hotnessPercent=1
 
--XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=on
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0=off
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_GET_INTERFACE_VTABLE_VER0_hotnessPercent=1
 
--XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_CHECKCAST=on
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_CHECKCAST=off
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_CHECKCAST_hotnessPercent=1
 
--XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF=on
+-XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF=off
 -XX:jit.SD2_OPT.arg.optimizer.inline_helpers.VM_RT_INSTANCEOF_hotnessPercent=1
 
 -XX:jit.SD2_OPT.arg.codegen.dce1.early=yes

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp Mon Nov 26 23:00:33 2007
@@ -403,16 +403,18 @@
 
 JitHelperCallOp::Id _BlockCodeSelector::convertJitHelperId(JitHelperCallId callId) {
     switch(callId) {
-    case InitializeArray:           return JitHelperCallOp::InitializeArray;
-    case SaveThisState:             return JitHelperCallOp::SaveThisState;
-    case ReadThisState:             return JitHelperCallOp::ReadThisState;
-    case LockedCompareAndExchange:  return JitHelperCallOp::LockedCompareAndExchange;
-    case AddValueProfileValue:      return JitHelperCallOp::AddValueProfileValue;
-    case FillArrayWithConst:        return JitHelperCallOp::FillArrayWithConst;
-    case StringCompareTo:           return JitHelperCallOp::StringCompareTo;
-    case StringRegionMatches:       return JitHelperCallOp::StringRegionMatches;
+        case InitializeArray:           return JitHelperCallOp::InitializeArray;
+        case SaveThisState:             return JitHelperCallOp::SaveThisState;
+        case ReadThisState:             return JitHelperCallOp::ReadThisState;
+        case LockedCompareAndExchange:  return JitHelperCallOp::LockedCompareAndExchange;
+        case AddValueProfileValue:      return JitHelperCallOp::AddValueProfileValue;
+        case FillArrayWithConst:        return JitHelperCallOp::FillArrayWithConst;
+        case StringCompareTo:           return JitHelperCallOp::StringCompareTo;
+        case StringRegionMatches:       return JitHelperCallOp::StringRegionMatches;
+        default: break;
     }
-    assert(0);
+    crash("\n JIT helper in not supported in LIR : %d\n", callId);
+
     return JitHelperCallOp::InitializeArray; // to keep compiler quiet
 }
     

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp Mon Nov 26 23:00:33 2007
@@ -480,6 +480,22 @@
         os << "StringCompareTo"; break;
     case StringRegionMatches:
         os << "StringRegionMatches"; break;
+    case ClassIsArray:
+        os << "ClassIsArray"; break;
+    case ClassGetAllocationHandle:
+        os << "ClassGetAllocationHandle"; break;
+    case ClassGetTypeSize:
+        os << "ClassGetTypeSize"; break;
+    case ClassGetArrayElemSize:
+        os << "ClassGetArrayElemSize"; break;
+    case ClassIsInterface:
+        os << "ClassIsInterface"; break;
+    case ClassIsFinal:
+        os << "ClassIsFinal"; break;
+    case ClassGetArrayClass:
+        os << "ClassGetArrayClass"; break;
+    case ClassGetFastCheckDepth:
+        os << "ClassGetFastCheckDepth"; break;
     default:
         assert(0); break;
         }
@@ -836,6 +852,13 @@
     case Type::Double:
         newInst = makeConstInst(table.duplicate(opndManager, inst->getDst()),
                                 inst->getValue().d);
+        break;
+    case Type::UnmanagedPtr:
+        {
+            ConstInst::ConstValue v;
+            v.i8 = inst->getValue().i8;
+            newInst = makeConstInst(table.duplicate(opndManager, inst->getDst()), v);
+        }
         break;
     case Type::NullObject:
         newInst = makeConstInst(table.duplicate(opndManager, inst->getDst()));

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h Mon Nov 26 23:00:33 2007
@@ -277,7 +277,16 @@
     LockedCompareAndExchange,
     AddValueProfileValue,
     StringCompareTo,
-    StringRegionMatches
+    StringRegionMatches,
+    ClassIsArray,
+    ClassGetAllocationHandle,
+    ClassGetTypeSize,
+    ClassGetArrayElemSize,
+    ClassIsInterface,
+    ClassIsFinal,
+    ClassGetArrayClass,
+    ClassIsFinalizable,
+    ClassGetFastCheckDepth
 };
 
 enum Opcode {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.cpp Mon Nov 26 23:00:33 2007
@@ -415,6 +415,15 @@
                         case AddValueProfileValue:
                         case StringCompareTo:
                         case StringRegionMatches:
+                        case ClassIsArray:
+                        case ClassGetAllocationHandle:
+                        case ClassGetTypeSize:
+                        case ClassGetArrayElemSize:
+                        case ClassIsInterface:
+                        case ClassIsFinal:
+                        case ClassGetArrayClass:
+                        case ClassIsFinalizable:
+                        case ClassGetFastCheckDepth:
                             break;
                         default:
                             assert(0);

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp Mon Nov 26 23:00:33 2007
@@ -25,6 +25,7 @@
 #include "LoopTree.h"
 #include "Dominator.h"
 #include "StlPriorityQueue.h"
+#include "VMMagic.h"
 
 namespace Jitrino {
 
@@ -38,9 +39,10 @@
 
 struct HelperInlinerFlags {
     HelperInlinerFlags(MemoryManager& mm) 
-        : inlinerPipelineName(NULL), opcodeToHelperMapping(mm), helperConfigs(mm){}
+        : inlinerPipelineName(NULL), pragmaInlineType(NULL), opcodeToHelperMapping(mm), helperConfigs(mm){}
 
     const char* inlinerPipelineName;
+    Type* pragmaInlineType;
 
     StlMap<Opcode, VM_RT_SUPPORT> opcodeToHelperMapping;
     StlMap<VM_RT_SUPPORT, HelperConfig*> helperConfigs;
@@ -86,9 +88,10 @@
 
 class HelperInliner {
 public:
-    HelperInliner(HelperInlinerSession* _sessionAction, MemoryManager& tmpMM, CompilationContext* _cc, Inst* _inst, uint32 _hotness, MethodDesc* _helperMethod, VM_RT_SUPPORT _helperId)  
+    HelperInliner(HelperInlinerSession* _sessionAction, MemoryManager& tmpMM, CompilationContext* _cc, Inst* _inst, 
+        uint32 _hotness, MethodDesc* _helperMethod, VM_RT_SUPPORT _helperId)  
         : flags(((HelperInlinerAction*)_sessionAction->getAction())->getFlags()), localMM(tmpMM), 
-        cc(_cc), inst(_inst), session(_sessionAction), method(_helperMethod), helperId(_helperId)
+        cc(_cc), inst(_inst), session(_sessionAction), method(_helperMethod),  helperId(_helperId)
     {
         hotness=_hotness;
         irm = cc->getHIRManager();
@@ -118,21 +121,12 @@
     MethodDesc*  method;
     VM_RT_SUPPORT helperId;
 
-    //these fields used by almost every subclass -> cache them
+    //cache these values for convenience of use
     IRManager* irm;
     InstFactory* instFactory;
     OpndManager* opndManager;
     TypeManager* typeManager;
     ControlFlowGraph* cfg;
-private: 
-    void inline_NewObj();
-    void inline_NewArray();
-    void inline_TauLdIntfcVTableAddr();
-    void inline_TauCheckCast();
-    void inline_TauInstanceOf();
-    void inline_TauStRef();
-    void inline_TauMonitorEnter();
-    void inline_TauMonitorExit();
 };
 
 class HelperInlinerCompare {
@@ -146,10 +140,14 @@
     HelperInlinerAction* action = (HelperInlinerAction*)getAction();
     HelperInlinerFlags& flags = action->getFlags();
 
-    if (cc->getVMCompilationInterface()->resolveClassUsingBootstrapClassloader(PRAGMA_INLINE) == NULL) {
-        Log::out()<<"Helpers inline pass failed! class not found: "<<PRAGMA_INLINE<<std::endl;
-        return;
+    if (flags.pragmaInlineType== NULL) {
+        flags.pragmaInlineType= cc->getVMCompilationInterface()->resolveClassUsingBootstrapClassloader(PRAGMA_INLINE_TYPE_NAME);
+        if (flags.pragmaInlineType == NULL) {
+            Log::out()<<"Helpers inline pass failed! class not found: "<<PRAGMA_INLINE_TYPE_NAME<<std::endl;
+            return;
+        }
     }
+
     //finding all helper calls
     ControlFlowGraph& fg = irm.getFlowGraph();
     double entryExecCount = fg.hasEdgeProfile() ? fg.getEntryNode()->getExecCount(): 1;
@@ -202,21 +200,75 @@
 }
 
 void HelperInliner::run()  {
+#ifdef _EM64T_
+    assert(VMInterface::areReferencesCompressed());
+#endif
+
     if (Log::isEnabled())  {
         Log::out() << "Processing inst:"; inst->print(Log::out()); Log::out()<<std::endl; 
     }
     assert(method);
-    switch(inst->getOpcode()) {
-        case Op_NewObj:                 inline_NewObj(); break;
-        case Op_NewArray:               inline_NewArray(); break;
-        case Op_TauLdIntfcVTableAddr:   inline_TauLdIntfcVTableAddr(); break;
-        case Op_TauCheckCast:           inline_TauCheckCast(); break;
-        case Op_TauInstanceOf:          inline_TauInstanceOf(); break;
-        case Op_TauStRef:               inline_TauStRef(); break;
-        case Op_TauMonitorEnter:        inline_TauMonitorEnter(); break;
-        case Op_TauMonitorExit:         inline_TauMonitorExit(); break;
-        default: assert(0);
+
+    //Convert all inst params info helper params
+    uint32 numHelperArgs = method->getNumParams();
+    uint32 numInstArgs = inst->getNumSrcOperands();
+    Opnd** helperArgs =new (irm->getMemoryManager()) Opnd*[numHelperArgs];
+#ifdef _DEBUG
+    std::fill(helperArgs, helperArgs + numHelperArgs, (Opnd*)NULL);
+#endif
+    uint32 currentHelperArg = 0;
+    if (inst->isType()) {
+        Type* type = inst->asTypeInst()->getTypeInfo();
+        assert(type->isNamedType());
+        Opnd* typeOpnd = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type()));
+        Inst* ldconst = instFactory->makeLdConst(typeOpnd, (POINTER_SIZE_SINT)type->asNamedType()->getVMTypeHandle());
+        ldconst->insertBefore(inst);
+        helperArgs[currentHelperArg] = typeOpnd;
+        currentHelperArg++;
+    }
+    for (uint32 i = 0; i < numInstArgs; i++) {
+        Opnd* instArg = inst->getSrc(i);
+        if (instArg->getType()->tag == Type::Tau) { //TODO: what to do with taus?
+            continue;
+        }
+        assert(currentHelperArg < numHelperArgs);
+        helperArgs[currentHelperArg] = instArg;
+    }
+    assert(helperArgs[numHelperArgs-1]!=NULL);
+
+
+    //Prepare res opnd
+    Opnd* instResOpnd = inst->getDst();
+    Type* helperRetType = method->getReturnType();
+    Type* instResType = instResOpnd->getType();
+    bool needResConv = instResType && instResType->isObject() && helperRetType->isObject() && VMMagicUtils::isVMMagicClass(helperRetType->asObjectType()->getName());
+    Opnd* helperResOpnd = !needResConv ? instResOpnd : opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type()));
+    
+    //Make a call inst
+    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
+    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
+    MethodCallInst* call = instFactory->makeDirectCall(helperResOpnd, tauSafeOpnd, tauSafeOpnd, numHelperArgs, helperArgs, method)->asMethodCallInst();
+    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
+    call->setBCOffset(inst->getBCOffset());
+    call->insertBefore(inst);
+    inst->unlink();
+
+    finalizeCall(call); //make call last inst in a block
+
+    if (needResConv) {
+        //convert address type to managed object type
+        Edge* fallEdge= call->getNode()->getUnconditionalEdge();
+        assert(fallEdge && fallEdge->getTargetNode()->isBlockNode());
+        Node* fallNode = fallEdge->getTargetNode();
+        if (fallNode->getInDegree()>1) {
+            fallNode = irm->getFlowGraph().spliceBlockOnEdge(fallEdge, instFactory->makeLabel());
+        }
+        Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
+        fallNode->prependInst(instFactory->makeConvUnmanaged(mod, Type::Object, instResOpnd, helperResOpnd));
     }
+
+    //Inline the call
+    inlineVMHelper(call);
 }
 
 MethodDesc* HelperInliner::findHelperMethod(CompilationInterface* ci, VM_RT_SUPPORT helperId) 
@@ -265,382 +317,4 @@
         cfg->addEdge(node, dispatchNode);
     }
 }
-
-
-
-void HelperInliner::inline_NewObj() {
-#if defined (_IPF_)
-    return;
-#else
-    assert(inst->getOpcode() == Op_NewObj);
-
-    Opnd* dstOpnd= inst->getDst();
-    Type * type = dstOpnd->getType();
-    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
-
-
-#ifdef _EM64T_
-    assert(VMInterface::areReferencesCompressed());
-#endif
-    //the method signature is (int objSize, int allocationHandle)
-    int allocationHandle= (int)(POINTER_SIZE_INT)objType->getAllocationHandle();
-    int objSize=objType->getObjectSize();
-
-    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
-    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
-    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(callResOpnd, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-    call->insertBefore(inst);
-    inst->unlink();
-
-    assert(call == call->getNode()->getLastInst());
-
-    //todo: use finalizeCall here!
-
-    //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->makeConvUnmanaged(mod, type->tag, dstOpnd, callResOpnd));
-
-    inlineVMHelper(call);
-#endif
-}
-
-void HelperInliner::inline_NewArray() {
-#if defined (_IPF_)
-    return;
-#else
-    assert(inst->getOpcode() == Op_NewArray);
-
-    //the method signature is (int objSize, int allocationHandle)
-    Opnd* dstOpnd = inst->getDst();
-    ArrayType* arrayType = dstOpnd->getType()->asArrayType();
-#ifdef _EM64T_
-    assert(VMInterface::areReferencesCompressed());
-#endif
-    int allocationHandle = (int)(POINTER_SIZE_INT)arrayType->getAllocationHandle();
-    Type* elemType = arrayType->getElementType();
-    int elemSize = 0; //TODO: check if references are compressed!
-    if (elemType->isBoolean() || elemType->isInt1()) {
-        elemSize = 1;
-    } else if (elemType->isInt2() || elemType->isChar()) {
-        elemSize = 2;
-    } else if (elemType->isInt4() || elemType->isSingle()) {
-        elemSize = 4;
-    } else if (elemType->isInt8() || elemType->isDouble()) {
-        elemSize = 8;
-    } else {
-        elemSize = 4;
-    }
-
-    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();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-    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->makeConvUnmanaged(mod, arrayType->tag, dstOpnd, callResOpnd));
-    
-    inlineVMHelper(call);
-#endif
-}
-
-
-void HelperInliner::inline_TauMonitorEnter() {
-#if defined (_IPF_)
-    return;
-#else
-    assert(inst->getOpcode() == Op_TauMonitorEnter);
-
-    Opnd* objOpnd = inst->getSrc(0);
-    assert(objOpnd->getType()->isObject());
-    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
-    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
-    Opnd* args[1] = {objOpnd};
-    MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 1, args, method)->asMethodCallInst();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-    call->insertBefore(inst);
-    inst->unlink();
-    
-    
-    //if call is not last inst -> make it last inst
-    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();
-        //this is fake dispatch edge -> monenter must never throw exceptions
-        Node* dispatchNode = cfg->getUnwindNode(); 
-        assert(dispatchNode != NULL); //method with monitors must have unwind, so no additional checks is done
-        cfg->addEdge(node, dispatchNode);
-    }
-    
-    inlineVMHelper(call);
-#endif
-}
-
-void HelperInliner::inline_TauMonitorExit() {
-#if defined (_IPF_)
-    return;
-#else
-    assert(inst->getOpcode() == Op_TauMonitorExit);
-
-    Opnd* objOpnd = inst->getSrc(0);
-    assert(objOpnd->getType()->isObject());
-    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
-    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
-    Opnd* args[1] = {objOpnd};
-    MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 1, args, method)->asMethodCallInst();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-    call->insertBefore(inst);
-    inst->unlink();
-
-    assert(call == call->getNode()->getLastInst());
-    assert(call->getNode()->getExceptionEdge()!=NULL);
-
-    inlineVMHelper(call);
-#endif
-}
-
-void HelperInliner::inline_TauStRef() {
-#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();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-    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
-}
-
-void HelperInliner::inline_TauLdIntfcVTableAddr() {
-#if defined  (_EM64T_) || defined (_IPF_)
-    return;
-#else
-    assert(inst->getOpcode() == Op_TauLdIntfcVTableAddr);
-
-    Opnd* baseOpnd = inst->getSrc(0);
-    assert(baseOpnd->getType()->isObject());
-    
-    Type* type = inst->asTypeInst()->getTypeInfo();
-    Opnd* typeOpnd  = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type()));
-    Opnd* typeValOpnd = opndManager->createSsaTmpOpnd(typeManager->getUIntPtrType());
-    void* typeId = type->asNamedType()->getRuntimeIdentifier();
-    instFactory->makeLdConst(typeValOpnd, (int)typeId)->insertBefore(inst); //TODO: fix this for EM64T
-    Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
-    instFactory->makeConv(mod, Type::UnmanagedPtr, typeOpnd, typeValOpnd)->insertBefore(inst);
-    
-    Opnd* resOpnd = inst->getDst();
-    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
-    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
-    Opnd* args[2] = {baseOpnd, typeOpnd};
-    MethodCallInst* call = instFactory->makeDirectCall(resOpnd, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-    call->insertBefore(inst);
-    inst->unlink();
-
-    finalizeCall(call);
-    
-    inlineVMHelper(call);
-#endif
-}
-
-
-
-void HelperInliner::inline_TauCheckCast() {
-#if defined  (_EM64T_) || defined (_IPF_)
-    return;
-#else
-    //TODO: this is 99% clone of instanceof but result of the slow call's result is handled differently. 
-    //to merge these 2 helpers into the one we need to change IA32CG codegen tau_checkcast handling:
-    //call VM helper for static_cast opcode but not for tau!
-
-    assert(inst->getOpcode() == Op_TauCheckCast);
-
-    Opnd* objOpnd = inst->getSrc(0);
-    assert(objOpnd->getType()->isObject());
-    Type* type = inst->asTypeInst()->getTypeInfo();
-    assert(type->isObject());
-    ObjectType* castType = type->asObjectType();
-
-    void* typeId = castType->getRuntimeIdentifier();
-    bool isArrayType = castType->isArrayType();
-    bool isInterfaceType = castType->isInterface();
-    bool isFastInstanceOf = castType->getFastInstanceOfFlag();
-    bool isFinalTypeCast = castType->isFinalClass();
-    int  fastCheckDepth = isFastInstanceOf ? castType->getClassDepth() : 0;
-    
-    Opnd* typeValOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type()); 
-    instFactory->makeLdConst(typeValOpnd, (int)typeId)->insertBefore(inst);//TODO: em64t & ipf!
-
-    Opnd* typeOpnd = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type())); 
-    Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
-    instFactory->makeConv(mod, Type::UnmanagedPtr, typeOpnd, typeValOpnd)->insertBefore(inst);
-
-    Opnd* isArrayOpnd = opndManager->createSsaTmpOpnd(typeManager->getBooleanType());
-    instFactory->makeLdConst(isArrayOpnd, isArrayType)->insertBefore(inst);
-
-    Opnd* isInterfaceOpnd = opndManager->createSsaTmpOpnd(typeManager->getBooleanType());
-    instFactory->makeLdConst(isInterfaceOpnd, isInterfaceType)->insertBefore(inst);
-
-    Opnd* isFinalOpnd = opndManager->createSsaTmpOpnd(typeManager->getBooleanType());
-    instFactory->makeLdConst(isFinalOpnd, isFinalTypeCast)->insertBefore(inst);
-
-    Opnd* fastCheckDepthOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type());
-    instFactory->makeLdConst(fastCheckDepthOpnd, fastCheckDepth)->insertBefore(inst);
-
-    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
-    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
-
-    Opnd* args[6] = {objOpnd, typeOpnd, isArrayOpnd, isInterfaceOpnd, isFinalOpnd, fastCheckDepthOpnd};
-    MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 6, args, method)->asMethodCallInst();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-    
-    call->insertBefore(inst);
-
-    // after the call the cast is safe
-    Opnd* tauSafeOpnd2 = opndManager->createSsaTmpOpnd(typeManager->getTauType());
-    instFactory->makeTauSafe(tauSafeOpnd2)->insertBefore(inst);
-    instFactory->makeCopy(inst->getDst(), tauSafeOpnd2)->insertBefore(inst);
-
-    inst->unlink();
-
-    finalizeCall(call);
-
-    inlineVMHelper(call);
-#endif
-}
-
-
-void HelperInliner::inline_TauInstanceOf() {
-#if defined  (_EM64T_) || defined (_IPF_)
-    return;
-#else
-    assert(inst->getOpcode() == Op_TauInstanceOf);
-
-    Opnd* objOpnd = inst->getSrc(0);
-    assert(objOpnd->getType()->isObject());
-    Type* type = inst->asTypeInst()->getTypeInfo();
-    assert(type->isObject());
-    ObjectType* castType = type->asObjectType();
-
-    void* typeId = castType->getRuntimeIdentifier();
-    bool isArrayType = castType->isArrayType();
-    bool isInterfaceType = castType->isInterface();
-    bool isFastInstanceOf = castType->getFastInstanceOfFlag();
-    bool isFinalTypeCast = castType->isFinalClass();
-    int  fastCheckDepth = isFastInstanceOf ? castType->getClassDepth() : 0;
-
-    Opnd* typeValOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type()); 
-    instFactory->makeLdConst(typeValOpnd, (int)typeId)->insertBefore(inst);//TODO: em64t & ipf!
-
-    Opnd* typeOpnd = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type())); 
-    Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
-    instFactory->makeConv(mod, Type::UnmanagedPtr, typeOpnd, typeValOpnd)->insertBefore(inst);
-
-    Opnd* isArrayOpnd = opndManager->createSsaTmpOpnd(typeManager->getBooleanType());
-    instFactory->makeLdConst(isArrayOpnd, isArrayType)->insertBefore(inst);
-
-    Opnd* isInterfaceOpnd = opndManager->createSsaTmpOpnd(typeManager->getBooleanType());
-    instFactory->makeLdConst(isInterfaceOpnd, isInterfaceType)->insertBefore(inst);
-
-    Opnd* isFinalOpnd = opndManager->createSsaTmpOpnd(typeManager->getBooleanType());
-    instFactory->makeLdConst(isFinalOpnd, isFinalTypeCast)->insertBefore(inst);
-
-    Opnd* fastCheckDepthOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type());
-    instFactory->makeLdConst(fastCheckDepthOpnd, fastCheckDepth)->insertBefore(inst);
-
-    Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
-    instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
-
-    Opnd* args[6] = {objOpnd, typeOpnd, isArrayOpnd, isInterfaceOpnd, isFinalOpnd, fastCheckDepthOpnd};
-    MethodCallInst* call = instFactory->makeDirectCall(inst->getDst(), tauSafeOpnd, tauSafeOpnd, 6, args, method)->asMethodCallInst();
-    assert(inst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-    call->setBCOffset(inst->getBCOffset());
-
-    call->insertBefore(inst);
-    inst->unlink();
-
-    finalizeCall(call);
-
-    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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.cpp Mon Nov 26 23:00:33 2007
@@ -35,6 +35,7 @@
 #include "StaticProfiler.h"
 #include "optimizer.h"
 #include "deadcodeeliminator.h"
+#include "VMMagic.h"
 
 namespace Jitrino {
 
@@ -154,7 +155,7 @@
 
     _usesOptimisticBalancedSync = argSource->getBoolArg("sync_optimistic", false) ? argSource->getBoolArg("sync_optcatch", true) : false;
     
-    inlinePragma = irm.getCompilationInterface().resolveClassUsingBootstrapClassloader(PRAGMA_INLINE);
+    inlinePragma = irm.getCompilationInterface().resolveClassUsingBootstrapClassloader(PRAGMA_INLINE_TYPE_NAME);
 }
 
 int32 
@@ -865,8 +866,12 @@
         callNode->appendInst(_instFactory.makePseudoThrow());
         isPseudoThrowInserted = true;
     } else {
-        // Inlined graph has exception path so just remove original edge.
-        parentCFG.removeEdge(callNode->getExceptionEdge());
+        // Inlined graph has exception path -> remove original edge.
+        Edge* exceptionEdge = callNode->getExceptionEdge(); 
+        //exception edge can be NULL because the call inserted instead of the HIR inst is artificial
+        if (exceptionEdge) {
+            parentCFG.removeEdge(exceptionEdge);
+        }
     }
     callInst->unlink();
 }

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/inliner.h Mon Nov 26 23:00:33 2007
@@ -28,8 +28,6 @@
 #include "Tree.h"
 #include "irmanager.h"
 
-#define PRAGMA_INLINE "org/vmmagic/pragma/Inline"
-
 namespace Jitrino {
 
 class MemoryManager;

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp Mon Nov 26 23:00:33 2007
@@ -668,6 +668,15 @@
             case AddValueProfileValue:
             case StringCompareTo:
             case StringRegionMatches:
+            case ClassIsArray:
+            case ClassGetAllocationHandle:
+            case ClassGetTypeSize:
+            case ClassGetArrayElemSize:
+            case ClassIsInterface:
+            case ClassIsFinal:
+            case ClassGetArrayClass:
+            case ClassIsFinalizable:
+            case ClassGetFastCheckDepth:
                 break;
             default:
                 assert(0);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp Mon Nov 26 23:00:33 2007
@@ -4466,4 +4466,86 @@
     insertInst(inst);
 }
 
+
+static Class_Handle getClassHandle(Opnd* opnd) {
+    //class handle can be: unmanaged ptr (from magics) or pointer_size_int const (int32 or int64) if loaded as a const
+    //assert(opnd->getType()->isUnmanagedPtr() || opnd->getType()->isInt4() || opnd->getType()->isInt8());
+    assert(opnd->getType()->isUnmanagedPtr());
+    Inst* inst = opnd->getInst();
+    Class_Handle ch = NULL;
+    if (inst->asConstInst() != NULL) {
+        ch = (Class_Handle)(POINTER_SIZE_INT)inst->asConstInst()->getValue().i8;
+    }
+    return ch;
+}
+
+Inst* Simplifier::simplifyJitHelperCall(JitHelperCallInst* inst) {
+    Inst* res = inst;
+    Class_Handle ch = NULL;
+    TypeManager& tm = irManager.getTypeManager();
+    switch(inst->getJitHelperId()) {
+        case ClassIsArray:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                res = genLdConstant((int32)class_is_array(ch));
+            }
+            break;
+        case ClassGetAllocationHandle:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                ConstInst::ConstValue v;
+                v.i8 = (POINTER_SIZE_SINT)class_get_allocation_handle(ch);
+                res = genLdConstant(tm.getUnmanagedPtrType(tm.getInt8Type()), v);
+            }
+            break;
+        case ClassGetTypeSize:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                res = genLdConstant((int32)class_get_boxed_data_size(ch));
+            }
+            break;
+        case ClassGetArrayElemSize:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                res = genLdConstant((int32)class_get_array_element_size(ch));
+            }
+            break;
+        case ClassIsInterface:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                res = genLdConstant((int32)class_property_is_interface2(ch));
+            }
+            break;
+        case ClassIsFinal:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                res = genLdConstant((int32)class_property_is_final(ch));
+            }
+            break;
+        case ClassGetArrayClass:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                ConstInst::ConstValue v;
+                v.i8 = (POINTER_SIZE_SINT)class_get_array_of_class(ch);
+                res = genLdConstant(tm.getUnmanagedPtrType(tm.getInt8Type()), v);
+            }
+            break;
+        case ClassIsFinalizable:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                res = genLdConstant((int32)class_is_finalizable(ch));
+            }
+            break;
+        case ClassGetFastCheckDepth:
+            ch = getClassHandle(inst->getSrc(0));
+            if (ch) {
+                assert(class_get_fast_instanceof_flag(ch));
+                res = genLdConstant((int32)class_get_depth(ch));
+            }
+            break;
+        default: break;
+    }
+    return res;
+}
+
 } //namespace Jitrino 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h Mon Nov 26 23:00:33 2007
@@ -105,6 +105,9 @@
                                          Opnd* tauTypesChecked,
                                          uint32 numArgs,
                                          Opnd** args);
+
+    Inst* simplifyJitHelperCall(JitHelperCallInst* inst);
+
     // loads
     Opnd* simplifyLdRef(Modifier mod, Type *dstType, 
                         uint32 token,
@@ -167,7 +170,7 @@
 
     // tau operations
     Opnd* simplifyTauAnd(MultiSrcInst *tauAndInst);
-
+    
     Opnd* propagateCopy(Opnd*);
 
     static bool isNonNullObject(Opnd*);
@@ -490,7 +493,7 @@
 
     Inst* caseIntrinsicCall(IntrinsicCallInst* inst) {return caseDefault(inst);}
 
-    Inst* caseJitHelperCall(JitHelperCallInst* inst) {return caseDefault(inst);}
+    Inst* caseJitHelperCall(JitHelperCallInst* inst) {return simplifyJitHelperCall(inst->asJitHelperCallInst());}
 
     Inst* caseVMHelperCall(VMHelperCallInst* inst) {return caseDefault(inst);}
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp Mon Nov 26 23:00:33 2007
@@ -26,13 +26,12 @@
 namespace Jitrino {
 
 bool VMMagicUtils::isVMMagicClass(const char* kname) {
-    static const char magicPackage[] = "org/vmmagic/unboxed/";
-    static const unsigned magicPackageLen = sizeof(magicPackage)-1;
+    static const unsigned magicPackageLen = sizeof(VMMAGIC_UNBOXED_PACKAGE_NAME)-1;
     bool res = false;
     if (*kname=='L') {
-        res = !strncmp(kname+1, magicPackage, magicPackageLen);
+        res = !strncmp(kname+1, VMMAGIC_UNBOXED_PACKAGE_NAME, magicPackageLen);
     } else {
-        res = !strncmp(kname, magicPackage, magicPackageLen);
+        res = !strncmp(kname, VMMAGIC_UNBOXED_PACKAGE_NAME, magicPackageLen);
     }
     return res;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h Mon Nov 26 23:00:33 2007
@@ -24,6 +24,12 @@
 #define _VMMAGIC_JITRINO_H_
 namespace Jitrino {
 
+#define VMHELPER_PACKAGE_NAME           "org/apache/harmony/drlvm/"
+#define VMMAGIC_UNBOXED_PACKAGE_NAME    "org/vmmagic/unboxed/"
+
+#define VMHELPER_TYPE_NAME              "org/apache/harmony/drlvm/VMHelper"
+#define PRAGMA_INLINE_TYPE_NAME         "org/vmmagic/pragma/Inline"
+
 class VMMagicUtils {
 public:
     // checks of class nams is vmmagic class

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- 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 26 23:00:33 2007
@@ -92,9 +92,7 @@
 #ifdef _IPF_
     return false;//natives are not tested on IPF.
 #else
-    static const char vmhelperPackage[] = "org/apache/harmony/drlvm/VMHelper";
-    
-    bool res =  !strcmp(name, vmhelperPackage);
+    bool res =  !strcmp(name, VMHELPER_TYPE_NAME);
     return res;
 #endif
 }
@@ -1536,10 +1534,13 @@
     Opnd** srcOpnds = popArgs(numArgs);
     Type* returnType = methodDesc->getReturnType();
 
-    if (VMMagicUtils::isVMMagicClass(methodDesc->getParentType()->getName())) {
-        genVMMagic(methodDesc->getName(), numArgs, srcOpnds, returnType);
+    const char* className = methodDesc->getParentType()->getName();
+    if (VMMagicUtils::isVMMagicClass(className)) {
+        UNUSED bool res = genVMMagic(methodDesc->getName(), numArgs, srcOpnds, returnType);
+        assert(res);
         return;
     }
+
     // callvirt can throw a null pointer exception
     Opnd *tauNullChecked = irBuilder.genTauCheckNull(srcOpnds[0]);
     Opnd* thisOpnd = srcOpnds[0];
@@ -2321,7 +2322,7 @@
         return;
     } else if (isVMHelperClass(kname) && !methodDesc->isNative()) {
         UNUSED bool res = genVMHelper(mname, numArgs, srcOpnds, returnType);
-        assert(res);
+            assert(res);
         return;
     }
     Opnd *tauNullChecked = irBuilder.genTauSafe(); // always safe, is a static method call
@@ -3534,10 +3535,11 @@
     return false;
 }
 
-
 bool JavaByteCodeTranslator::genVMHelper(const char* mname, uint32 numArgs, Opnd **srcOpnds, Type *returnType) {
     Type* resType = VMMagicUtils::isVMMagicClass(returnType->getName()) ? convertVMMagicType2HIR(typeManager, returnType) : returnType;
 
+//VMHelper methods
+
     if (!strcmp(mname,"getTlsBaseAddress")) {
         assert(numArgs == 0);
         Opnd* res = irBuilder.genVMHelperCall(VM_RT_GC_GET_TLS_BASE, resType, numArgs, srcOpnds);
@@ -3594,6 +3596,72 @@
     if (!strcmp(mname,"instanceOf")) {
         assert(numArgs == 2);
         Opnd* res = irBuilder.genVMHelperCall(VM_RT_INSTANCEOF, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+
+    //no VMHelpers exist for these magics -> use internal JIT helpers
+
+    if (!strcmp(mname,"isArray")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassIsArray, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"getAllocationHandle")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassGetAllocationHandle, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"getTypeSize")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassGetTypeSize, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"getArrayElemSize")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassGetArrayElemSize, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"isInterface")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassIsInterface, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"isFinal")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassIsFinal, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"getArrayClass")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassGetArrayClass, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"isFinalizable")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassIsFinalizable, resType, numArgs, srcOpnds);
+        pushOpnd(res);
+        return true;
+    }
+
+    if (!strcmp(mname,"getFastTypeCheckDepth")) {
+        assert(numArgs == 1 && srcOpnds[0]->getType()->isUnmanagedPtr());
+        Opnd* res = irBuilder.genJitHelperCall(ClassGetFastCheckDepth, resType, numArgs, srcOpnds);
         pushOpnd(res);
         return true;
     }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp Mon Nov 26 23:00:33 2007
@@ -12,6 +12,7 @@
     class_get_alignment_unboxed;
     class_get_allocation_handle;
     class_get_array_element_class;
+    class_get_array_element_size;
     class_get_array_of_class;
     class_get_array_of_unboxed;
     class_get_boxed_data_size;

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- 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 26 23:00:33 2007
@@ -678,6 +678,12 @@
 
 
 
+unsigned class_get_array_element_size(Class_Handle ch) 
+{
+    assert(ch);
+    return ch->get_array_element_size();
+}
+
 Class_Handle class_get_array_element_class(Class_Handle cl)
 {
     assert(cl);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp Mon Nov 26 23:00:33 2007
@@ -44,10 +44,10 @@
 static JIT_RT_Function_Entry _jit_rt_function_entries_base[] = {
     {VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE, "VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              2,
-            NULL,   NULL,   "(II)Lorg/vmmagic/unboxed/Address;",   NULL},
+            NULL,   NULL,   "(Lorg/vmmagic/unboxed/Address;)Lorg/vmmagic/unboxed/Address;",   NULL},
     {VM_RT_NEW_VECTOR_USING_VTABLE,            "VM_RT_NEW_VECTOR_USING_VTABLE",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              2,
-            NULL,   NULL,   "(III)Lorg/vmmagic/unboxed/Address;",   NULL},
+            NULL,   NULL,   "(Lorg/vmmagic/unboxed/Address;I)Lorg/vmmagic/unboxed/Address;",   NULL},
     {VM_RT_MULTIANEWARRAY_RESOLVED,            "VM_RT_MULTIANEWARRAY_RESOLVED",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_CDECL,                8,
             NULL,   NULL,   NULL,   NULL},
@@ -113,12 +113,12 @@
     {VM_RT_CHECKCAST,                          "VM_RT_CHECKCAST",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              2,
             "org/apache/harmony/drlvm/VMHelperFastPath",   "checkCast",
-            "(Ljava/lang/Object;Lorg/vmmagic/unboxed/Address;ZZZI)Ljava/lang/Object;",   NULL},
+            "(Lorg/vmmagic/unboxed/Address;Ljava/lang/Object;)Ljava/lang/Object;",   NULL},
 
     {VM_RT_INSTANCEOF,                         "VM_RT_INSTANCEOF",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              2,
             "org/apache/harmony/drlvm/VMHelperFastPath",   "instanceOf",
-            "(Ljava/lang/Object;Lorg/vmmagic/unboxed/Address;ZZZI)Z",   NULL},
+            "(Lorg/vmmagic/unboxed/Address;Ljava/lang/Object;)Z",   NULL},
 
     {VM_RT_AASTORE,                            "VM_RT_AASTORE",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              3,
@@ -131,7 +131,7 @@
     {VM_RT_GET_INTERFACE_VTABLE_VER0,          "VM_RT_GET_INTERFACE_VTABLE_VER0",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              2,
             "org/apache/harmony/drlvm/VMHelperFastPath",   "getInterfaceVTable3",
-            "(Ljava/lang/Object;Lorg/vmmagic/unboxed/Address;)Lorg/vmmagic/unboxed/Address;",   NULL},
+            "(Lorg/vmmagic/unboxed/Address;Ljava/lang/Object;)Lorg/vmmagic/unboxed/Address;",   NULL},
 
     {VM_RT_INITIALIZE_CLASS,                   "VM_RT_INITIALIZE_CLASS",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              1,

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?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- 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 Mon Nov 26 23:00:33 2007
@@ -31,11 +31,25 @@
 */
 public class VMHelper {
 
-    private VMHelper() {}
-    
+ 
 
+    //public constants
 
-    public static Address getTlsBaseAddress() {fail(); return null;}
+    public static final int POINTER_TYPE_SIZE          = getPointerTypeSize();
+
+    public static final boolean COMPRESSED_REFS_MODE   = isCompressedRefsMode();
+
+    public static final boolean COMPRESSED_VTABLE_MODE = isCompressedVTableMode();
+
+    public static final long COMPRESSED_VTABLE_BASE_OFFSET    = getCompressedModeVTableBaseOffset();
+
+    public static final long COMPRESSED_REFS_OBJ_BASE_OFFSET  = getCompressedModeObjectBaseOffset();
+
+
+
+
+
+    //Slow path versions of helpers
 
     //TODO: allocation handle is int only on 32bit OS or (64bit OS && compressed mode)
     public static Address newResolvedUsingAllocHandleAndSize(int objSize, int allocationHandle) {fail(); return null;}
@@ -55,14 +69,38 @@
  
     public static boolean instanceOf(Object obj, Address castTypePtr) {fail(); return false;}
 
+
+
+    //utility magics supported by JIT
+
+    public static Address getTlsBaseAddress() {fail(); return null;}
+
+    public static boolean isArray(Address classHandle) {VMHelper.fail(); return false;}
+
+    public static boolean isInterface(Address classHandle) {VMHelper.fail(); return false;}
+
+    public static boolean isFinal(Address classHandle) {VMHelper.fail(); return false;}
+
+    public static Address getArrayClass(Address elemClassHandle)  {VMHelper.fail(); return null;}
+
+    public static int getAllocationHandle(Address classHandle) {VMHelper.fail(); return 0;}
+
+    public static int getTypeSize(Address classHandle) {VMHelper.fail(); return 0;}
+
+    public static int getArrayElemSize(Address arrayClassHandle) {VMHelper.fail(); return 0;}
+
+    public static int getFastTypeCheckDepth(Address classHandle) {VMHelper.fail(); return 0;}
+
+
+
     protected static void fail() {throw new RuntimeException("Not supported!");}
 
 
-    public static final int POINTER_TYPE_SIZE          = getPointerTypeSize();
-    public static final boolean COMPRESSED_REFS_MODE   = isCompressedRefsMode();
-    public static final boolean COMPRESSED_VTABLE_MODE = isCompressedVTableMode();
-    public static final long COMPRESSED_VTABLE_BASE_OFFSET    = getCompressedModeVTableBaseOffset();
-    public static final long COMPRESSED_REFS_OBJ_BASE_OFFSET  = getCompressedModeObjectBaseOffset();
+
+
+    // private area
+
+    private VMHelper() {}
 
     /** @return pointer-type size. 4 or 8 */
     private static native int getPointerTypeSize();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.java?rev=598532&r1=598531&r2=598532&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelperFastPath.java Mon Nov 26 23:00:33 2007
@@ -55,7 +55,7 @@
 //TODO: refactor code to use getVtableIntfTableOffset method (+ avoid extra comparisons while refactoring)
 
     @Inline
-    public static Address getInterfaceVTable3(Object obj, Address intfType)  {
+    public static Address getInterfaceVTable3(Address intfType, Object obj)  {
         Address vtableAddr = getVTableAddress(obj);
 
         Address inf0Type = vtableAddr.loadAddress(Offset.fromIntZeroExtend(CLASS_INF_TYPE_0_OFFSET));
@@ -77,7 +77,7 @@
     }
 
     @Inline
-    public static Address getInterfaceVTable2(Object obj, Address intfType)  {
+    public static Address getInterfaceVTable2(Address intfType, Object obj)  {
         Address vtableAddr = getVTableAddress(obj);
 
         Address inf0Type = vtableAddr.loadAddress(Offset.fromIntZeroExtend(CLASS_INF_TYPE_0_OFFSET));
@@ -95,7 +95,7 @@
     }
 
     @Inline
-    public static Address getInterfaceVTable1(Object obj, Address intfType)  {
+    public static Address getInterfaceVTable1(Address intfType, Object obj)  {
         Address vtableAddr = getVTableAddress(obj);
 
         Address inf0Type = vtableAddr.loadAddress(Offset.fromIntZeroExtend(CLASS_INF_TYPE_0_OFFSET));
@@ -108,11 +108,11 @@
     }
 
     @Inline
-    public static boolean instanceOf(Object obj, Address castType, boolean isArray, boolean isInterface, boolean isFinalTypeCast, int fastCheckDepth) {
+    public static boolean instanceOf(Address castType, Object obj) {
         if (obj == null) {
             return false;
         }
-        if (isInterface) {
+        if (VMHelper.isInterface(castType)) {
             Address vtableAddr = getVTableAddress(obj);
 
             Address inf0Type = vtableAddr.loadAddress(Offset.fromIntZeroExtend(CLASS_INF_TYPE_0_OFFSET));
@@ -124,19 +124,22 @@
             if (inf1Type.EQ(castType)) {
                 return true;
             }
-        } else if (!isArray && fastCheckDepth!=0) {
-            return fastClassInstanceOf(obj, castType, isFinalTypeCast, fastCheckDepth);
+        } else if (!VMHelper.isArray(castType)) {
+            int fastCheckDepth=VMHelper.getFastTypeCheckDepth(castType);
+            if (fastCheckDepth!=0)  {
+                return fastClassInstanceOf(obj, castType, fastCheckDepth);
+            }
         } 
         return VMHelper.instanceOf(obj, castType);
         
     }
 
     @Inline
-    public static Object checkCast(Object obj, Address castType, boolean isArray, boolean isInterface, boolean isFinalTypeCast, int fastCheckDepth) {
+    public static Object checkCast(Address castType, Object obj) {
         if (obj == null) {
             return obj;
         }
-        if (isInterface) {
+        if (VMHelper.isInterface(castType)) {
             Address vtableAddr = getVTableAddress(obj);
 
             Address inf0Type = vtableAddr.loadAddress(Offset.fromIntZeroExtend(CLASS_INF_TYPE_0_OFFSET));
@@ -148,21 +151,24 @@
             if (inf1Type.EQ(castType)) {
                 return obj;
             }
-        } else if (!isArray && fastCheckDepth!=0 && fastClassInstanceOf(obj, castType, isFinalTypeCast, fastCheckDepth)) {
-            return obj;
+        } else if (!VMHelper.isArray(castType)) {
+            int fastCheckDepth=VMHelper.getFastTypeCheckDepth(castType);
+            if (fastCheckDepth!=0 && fastClassInstanceOf(obj, castType, fastCheckDepth)) {
+                return obj;
+            }
         } 
         return VMHelper.checkCast(obj, castType);
     }
 
     @Inline
-    public static boolean fastClassInstanceOf(Object obj, Address castType, boolean isFinalTypeCast, int fastCheckDepth) {
+    public static boolean fastClassInstanceOf(Object obj, Address castType, int fastCheckDepth) {
         Address objVtableAddr = getVTableAddress(obj);
         Address objClassType  = objVtableAddr.loadAddress(Offset.fromIntZeroExtend(VTABLE_CLASS_OFFSET));
 
         if (objClassType.EQ(castType)) {
             return true;
         }
-        if (isFinalTypeCast) {
+        if (VMHelper.isFinal(castType)) {
             return false;
         }
        



Mime
View raw message