harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfur...@apache.org
Subject svn commit: r650542 - in /harmony/enhanced/drlvm/trunk/vm: include/open/ jitrino/src/codegenerator/ia32/ jitrino/src/codegenerator/ipf/ jitrino/src/codegenerator/ipf/include/ jitrino/src/jet/ jitrino/src/vm/ vmcore/include/ vmcore/src/class_support/ vm...
Date Tue, 22 Apr 2008 15:11:08 GMT
Author: mfursov
Date: Tue Apr 22 08:10:48 2008
New Revision: 650542

URL: http://svn.apache.org/viewvc?rev=650542&view=rev
Log:
Fix for HARMONY-5627 [drlvm] remove extra exception helpers


Modified:
    harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/rt_helper_info.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/rt_helpers.h Tue Apr 22 08:10:48 2008
@@ -127,60 +127,7 @@
  */
 
     VM_RT_THROW_LAZY=201,
-/**
- * @param The parameters are the following:
- *        \arg Method handle
- *        \arg ...
- *        \arg arg 2
- *        \arg arg 1
- *        \arg Class handle
- *
- * @return None.
- *
- * The arguments to the constructor are pushed the same way they would have
- * been pushed to invoke the constructor, except that the (non-existing)
- * this pointer is replaced with the class handle of the exception.
- * The method handle representing the constructor is pushed last.
- *
- * This function never returns.
- */
-
-    VM_RT_IDX_OUT_OF_BOUNDS=202,
  
-/**
- * @param none
- *  
- * @return None.
- *
- * Throw the <code>java/lang/ArrayIndexOutOfBoundsException</code>.
- *
- * This function never returns.
- */
-    VM_RT_NULL_PTR_EXCEPTION=203,
- 
-/**
- * @param none
- *
- * @return None.
- *
- * Throw the <code>java/lang/NullPointerException</code>
- *
- * This function never returns.
- */
-    VM_RT_DIVIDE_BY_ZERO_EXCEPTION=204,
-  
-/**
- * @param none
- *
- * @return None.
- *
- * Throw the <code>java/lang/ArithmeticException</code>.
- *
- * This function never returns.
- */
-
-    VM_RT_ARRAY_STORE_EXCEPTION=205,
-   
 /**
  * @param none
  * 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp Tue Apr 22 08:10:48 2008
@@ -1906,14 +1906,16 @@
                     Node* dispatchNode= dispatchEdge->getTargetNode();
                     if ((dispatchNode!=fg->getUnwindNode()) ||(checkOpnds[opnd] == (POINTER_SIZE_INT)-1
 #ifdef _EM64T_
-                          ||!Type::isCompressedReference(opnd->getType()->tag)
+                            ||!Type::isCompressedReference(opnd->getType()->tag)
 #endif
-                       )){
+                            )){
                         Node* throwBasicBlock = fg->createBlockNode();
-                        Inst* throwInst = newRuntimeHelperCallInst(VM_RT_NULL_PTR_EXCEPTION, 0, NULL, NULL);
+                        ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(NULL_POINTER_EXCEPTION);
                         assert(lastInst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);
-                        throwInst->setBCOffset(lastInst->getBCOffset());
-                        throwBasicBlock->appendInst(throwInst);
+                        throwException(excType, lastInst->getBCOffset(), throwBasicBlock);
+                        //Inst* throwInst = newRuntimeHelperCallInst(VM_RT_NULL_PTR_EXCEPTION, 0, NULL, NULL);
+                        //throwInst->setBCOffset(lastInst->getBCOffset());
+                        //throwBasicBlock->appendInst(throwInst);
                         int64 zero = 0;
                         if( refsCompressed && opnd->getType()->isReference() ) {
                             assert(!Type::isCompressedReference(opnd->getType()->tag));
@@ -1954,6 +1956,61 @@
         lastInst->unlink();
     }
 }
+void IRManager::throwException(ObjectType* excType, uint16 bcOffset, Node* basicBlock){
+
+    assert(excType);
+
+#ifdef _EM64T_
+    bool lazy = false;
+#else
+    bool lazy = true;
+#endif
+    Inst* throwInst = NULL;
+    assert(bcOffset!=ILLEGAL_BC_MAPPING_VALUE);
+
+    if (lazy){
+        Opnd * helperOpnds[] = {
+            // first parameter exception class
+            newImmOpnd(typeManager.getUnmanagedPtrType(typeManager.getIntPtrType()),
+                Opnd::RuntimeInfo::Kind_TypeRuntimeId, excType),
+            // second is constructor method handle, 0 - means default constructor
+            newImmOpnd(typeManager.getUnmanagedPtrType(typeManager.getIntPtrType()), 0) 
+        };
+        throwInst=newRuntimeHelperCallInst(
+            VM_RT_THROW_LAZY, lengthof(helperOpnds), helperOpnds, NULL);
+    } else {
+        Opnd * helperOpnds1[] = {
+            newImmOpnd(typeManager.getInt32Type(), Opnd::RuntimeInfo::Kind_Size, excType),
+            newImmOpnd(typeManager.getUnmanagedPtrType(typeManager.getIntPtrType()),
+                Opnd::RuntimeInfo::Kind_AllocationHandle, excType)
+        };
+        Opnd * retOpnd=newOpnd(excType);
+        CallInst * callInst=newRuntimeHelperCallInst(
+            VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE,
+            lengthof(helperOpnds1), helperOpnds1, retOpnd);
+        
+        callInst->setBCOffset(bcOffset);
+        basicBlock->appendInst(callInst);
+
+        MethodDesc* md = compilationInterface.resolveMethod( excType, 
+                DEFAUlT_COSTRUCTOR_NAME, DEFAUlT_COSTRUCTOR_DESCRIPTOR);
+        
+        Opnd * target = newImmOpnd(typeManager.getIntPtrType(), Opnd::RuntimeInfo::Kind_MethodDirectAddr, md);
+        Opnd * helperOpnds2[] = { (Opnd*)retOpnd };
+        callInst=newCallInst(target, getDefaultManagedCallingConvention(), 
+            lengthof(helperOpnds2), helperOpnds2, NULL);
+        callInst->setBCOffset(bcOffset);
+        basicBlock->appendInst(callInst);
+
+        Opnd * helperOpnds3[] = { (Opnd*)retOpnd };
+        throwInst=newRuntimeHelperCallInst(
+            VM_RT_THROW, 
+            lengthof(helperOpnds3), helperOpnds3, NULL);
+    }
+    throwInst->setBCOffset(bcOffset);
+    basicBlock->appendInst(throwInst);
+}
+
 //_____________________________________________________________________________________________
 void IRManager::translateToNativeForm()
 {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h Tue Apr 22 08:10:48 2008
@@ -375,6 +375,9 @@
     /** expands SystemExceptionCheckPseudoInst */
     void expandSystemExceptions(uint32 reservedForFlags);
 
+    /** generater code to throw noted type exception, set for code BC offset and include into basic block*/
+    void throwException(ObjectType* excType, uint16 bcOffset, Node* basicBlock);
+
     /** changes all Extended insts to Native form by calling makeInstNative */
     void translateToNativeForm();
 

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?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Tue Apr 22 08:10:48 2008
@@ -1504,29 +1504,79 @@
 
 void InstCodeSelector::throwSystemException(CompilationInterface::SystemExceptionId id) 
 {
+#ifdef _EM64T_
+    bool lazy = false;
+#else
+    bool lazy = true;
+#endif
+    CallInst * callInst = NULL;
+    ObjectType* excType = NULL; 
 
-    CallInst * callInst=NULL;
     switch (id) {
         case CompilationInterface::Exception_NullPointer:
-            callInst=irManager.newRuntimeHelperCallInst(
-                VM_RT_NULL_PTR_EXCEPTION, 0, NULL, NULL);
+            {
+            excType = compilationInterface.findClassUsingBootstrapClassloader(NULL_POINTER_EXCEPTION);
+            //callInst=irManager.newRuntimeHelperCallInst(
+            //    VM_RT_NULL_PTR_EXCEPTION, 0, NULL, NULL);
+            };
             break;
         case CompilationInterface::Exception_ArrayIndexOutOfBounds:
-            callInst=irManager.newRuntimeHelperCallInst(
-                VM_RT_IDX_OUT_OF_BOUNDS, 0, NULL, NULL);
+            excType = compilationInterface.findClassUsingBootstrapClassloader(INDEX_OUT_OF_BOUNDS);
+            //callInst=irManager.newRuntimeHelperCallInst(
+            //    VM_RT_IDX_OUT_OF_BOUNDS, 0, NULL, NULL);
             break;
         case CompilationInterface::Exception_ArrayTypeMismatch:
-            callInst=irManager.newRuntimeHelperCallInst(
-                VM_RT_ARRAY_STORE_EXCEPTION, 0, NULL, NULL);
+            excType = compilationInterface.findClassUsingBootstrapClassloader(ARRAY_STORE_EXCEPTION);
+            //callInst=irManager.newRuntimeHelperCallInst(
+            //    VM_RT_ARRAY_STORE_EXCEPTION, 0, NULL, NULL);
             break;
         case CompilationInterface::Exception_DivideByZero:
-            callInst=irManager.newRuntimeHelperCallInst(
-                VM_RT_DIVIDE_BY_ZERO_EXCEPTION, 0, NULL, NULL);
+            excType = compilationInterface.findClassUsingBootstrapClassloader(DIVIDE_BY_ZERO_EXCEPTION);
+            //callInst=irManager.newRuntimeHelperCallInst(
+            //    VM_RT_DIVIDE_BY_ZERO_EXCEPTION, 0, NULL, NULL);
             break;
         default:
             assert(0);
     }
-    appendInsts(callInst);
+
+    assert(excType);
+
+    if (lazy){
+        Opnd * helperOpnds[] = {
+            // first parameter exception class
+            irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, excType),
+            // second is constructor method handle, 0 - means default constructor
+            irManager.newImmOpnd(getRuntimeIdType(), 0)
+        };
+        callInst=irManager.newRuntimeHelperCallInst(
+            VM_RT_THROW_LAZY, lengthof(helperOpnds), helperOpnds, NULL);
+        appendInsts(callInst);
+    } else {
+        Opnd * helperOpnds1[] = {
+            irManager.newImmOpnd(typeManager.getInt32Type(), Opnd::RuntimeInfo::Kind_Size, excType),
+            irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_AllocationHandle, excType)
+        };
+        Opnd * retOpnd=irManager.newOpnd(excType);
+        callInst=irManager.newRuntimeHelperCallInst(
+            VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE,
+            lengthof(helperOpnds1), helperOpnds1, retOpnd);
+        appendInsts(callInst);
+
+        MethodDesc* md = compilationInterface.resolveMethod( excType, 
+                DEFAUlT_COSTRUCTOR_NAME, DEFAUlT_COSTRUCTOR_DESCRIPTOR);
+        
+        Opnd * target=irManager.newImmOpnd(typeManager.getInt32Type(), Opnd::RuntimeInfo::Kind_MethodDirectAddr, md);
+        Opnd * helperOpnds2[] = { (Opnd*)retOpnd };
+        callInst=irManager.newCallInst(target, irManager.getDefaultManagedCallingConvention(), 
+            lengthof(helperOpnds2), helperOpnds2, NULL);
+        appendInsts(callInst);
+
+        Opnd * helperOpnds3[] = { (Opnd*)retOpnd };
+        callInst=irManager.newRuntimeHelperCallInst(
+            VM_RT_THROW, 
+            lengthof(helperOpnds3), helperOpnds3, NULL);
+        appendInsts(callInst);
+    }
 }
 
 //_______________________________________________________________________________________________________________
@@ -1638,10 +1688,13 @@
         cmpType = CompareOp::I;
 
     Node* throwBasicBlock = irManager.getFlowGraph()->createBlockNode();
-    Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_IDX_OUT_OF_BOUNDS, 0, NULL, NULL);
-    throwInst->setBCOffset(currentHIRInstBCOffset);
-    throwBasicBlock->appendInst(throwInst);
-                
+
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(INDEX_OUT_OF_BOUNDS);
+    irManager.throwException(excType, currentHIRInstBCOffset, throwBasicBlock);
+
+    //Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_IDX_OUT_OF_BOUNDS, 0, NULL, NULL);
+    //throwInst->setBCOffset(currentHIRInstBCOffset);
+    //throwBasicBlock->appendInst(throwInst);
 
     branch(CompareOp::Geu, cmpType, (Opnd*)index, (Opnd*)arrayLen);
     codeSelector.genTrueEdge(currentBasicBlock, throwBasicBlock, 0);
@@ -1672,11 +1725,13 @@
         cmpOp = CompareOp::Gtu;
     }
     Node* throwBasicBlock = irManager.getFlowGraph()->createBlockNode();
-    Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_IDX_OUT_OF_BOUNDS, 0, NULL, NULL);
-    throwInst->setBCOffset(currentHIRInstBCOffset);
-    throwBasicBlock->appendInst(throwInst);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(INDEX_OUT_OF_BOUNDS);
+    irManager.throwException(excType, currentHIRInstBCOffset, throwBasicBlock);
+    
+    //Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_IDX_OUT_OF_BOUNDS, 0, NULL, NULL);
+    //throwInst->setBCOffset(currentHIRInstBCOffset);
+    //throwBasicBlock->appendInst(throwInst);
     
-
     branch(cmpOp, cmpType, (Opnd*)a, (Opnd*)b);
     codeSelector.genTrueEdge(currentBasicBlock, throwBasicBlock, 0);
     return getTauUnsafe();
@@ -1702,10 +1757,12 @@
                                                       CG_OpndHandle* tauIsArray) 
 {
     Node* throwBasicBlock = irManager.getFlowGraph()->createBlockNode();
-    Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_ARRAY_STORE_EXCEPTION, 0, NULL, NULL);
     assert(currentHIRInstBCOffset!=ILLEGAL_BC_MAPPING_VALUE);
-    throwInst->setBCOffset(currentHIRInstBCOffset);
-    throwBasicBlock->appendInst(throwInst);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(ARRAY_STORE_EXCEPTION);
+    irManager.throwException(excType, currentHIRInstBCOffset, throwBasicBlock);
+    //Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_ARRAY_STORE_EXCEPTION, 0, NULL, NULL);
+    //throwInst->setBCOffset(currentHIRInstBCOffset);
+    //throwBasicBlock->appendInst(throwInst);
 
     Opnd * args[] = { (Opnd*)src, (Opnd*)array };
     Opnd * flag = irManager.newOpnd(typeManager.getInt32Type());
@@ -1726,10 +1783,12 @@
 CG_OpndHandle*  InstCodeSelector::tau_checkZero(CG_OpndHandle* src) 
 {
     Node* throwBasicBlock = irManager.getFlowGraph()->createBlockNode();
-    Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_DIVIDE_BY_ZERO_EXCEPTION, 0, NULL, NULL);
     assert(currentHIRInstBCOffset!=ILLEGAL_BC_MAPPING_VALUE);
-    throwInst->setBCOffset(currentHIRInstBCOffset);
-    throwBasicBlock->appendInst(throwInst);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(DIVIDE_BY_ZERO_EXCEPTION);
+    irManager.throwException(excType, currentHIRInstBCOffset, throwBasicBlock);
+    //Inst* throwInst = irManager.newRuntimeHelperCallInst(VM_RT_DIVIDE_BY_ZERO_EXCEPTION, 0, NULL, NULL);
+    //throwInst->setBCOffset(currentHIRInstBCOffset);
+    //throwBasicBlock->appendInst(throwInst);
     Opnd * srcOpnd = (Opnd*)src;
     Type * type = srcOpnd->getType();
     CompareZeroOp::Types opType = CompareZeroOp::I;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp Tue Apr 22 08:10:48 2008
@@ -1367,26 +1367,63 @@
 
     IPF_LOG << "      throwSystemException" << endl;
     
-    VM_RT_SUPPORT hId = VM_RT_UNKNOWN;
+    //VM_RT_SUPPORT hId = VM_RT_UNKNOWN;
+    ObjectType* excType = NULL; 
     switch (id) {
         case CompilationInterface::Exception_NullPointer: 
-            hId = VM_RT_NULL_PTR_EXCEPTION;      break;
+            excType = compilationInterface.findClassUsingBootstrapClassloader(NULL_POINTER_EXCEPTION);
+            //hId = VM_RT_NULL_PTR_EXCEPTION;
+            break;
         case CompilationInterface::Exception_ArrayIndexOutOfBounds: 
-            hId = VM_RT_IDX_OUT_OF_BOUNDS;  break;
+            excType = compilationInterface.findClassUsingBootstrapClassloader(INDEX_OUT_OF_BOUNDS);
+            //hId = VM_RT_IDX_OUT_OF_BOUNDS;
+            break;
         case CompilationInterface::Exception_ArrayTypeMismatch: 
-            hId = VM_RT_ARRAY_STORE_EXCEPTION;     break;
+            excType = compilationInterface.findClassUsingBootstrapClassloader(ARRAY_STORE_EXCEPTION);
+            //hId = VM_RT_ARRAY_STORE_EXCEPTION;
+            break;
         case CompilationInterface::Exception_DivideByZero: 
-            hId = VM_RT_DIVIDE_BY_ZERO_EXCEPTION; break;
+            excType = compilationInterface.findClassUsingBootstrapClassloader(DIVIDE_BY_ZERO_EXCEPTION);
+            //hId = VM_RT_DIVIDE_BY_ZERO_EXCEPTION;
+            break;
         default: 
             IPF_ERR << "unexpected id " << id << endl;
     }
     
-    uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
-    Opnd    *helperAddress = opndManager->newImm(address);
-
-    directCall(0, NULL, NULL, helperAddress, p0);
+    throwException(excType);
 }
 
+void IpfInstCodeSelector::throwException(ObjectType* excType)
+{
+    assert(excType);
+
+    Opnd *helperOpnds1[] = {
+        opndManager->newImm((int64) excType->getObjectSize()),
+        opndManager->newImm((int64) excType->getAllocationHandle())
+    };
+    
+    VM_RT_SUPPORT hId = VM_RT_NEW_RESOLVED_USING_VTABLE_AND_SIZE;
+    uint64   address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    Opnd*    helperAddress = opndManager->newImm(address);
+    OpndKind opndKind       = toOpndKind(excType->tag);
+    DataKind dataKind       = toDataKind(excType->tag);
+    RegOpnd* retOpnd       = opndManager->newRegOpnd(opndKind, dataKind);
+    
+    directCall(2, helperOpnds1, retOpnd, helperAddress, p0);
+
+    Opnd * helperOpnds2[] = { (Opnd*)retOpnd };
+    MethodDesc* md = compilationInterface.resolveMethod( excType, 
+            DEFAUlT_COSTRUCTOR_NAME, DEFAUlT_COSTRUCTOR_DESCRIPTOR);
+    call(1, (CG_OpndHandle **)helperOpnds2, NULL, md);
+
+    Opnd * helperOpnds3[] = { (Opnd*)retOpnd };
+
+    hId = VM_RT_THROW;
+    address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    helperAddress = opndManager->newImm(address);
+
+    directCall(1, helperOpnds3, NULL, helperAddress, p0);
+}
 //----------------------------------------------------------------------------//
 // Throw linking exception
 
@@ -1446,10 +1483,12 @@
     cmp(CMPLT_CMP_CREL_EQ, truePred, p0, base, zero);
 
     // p2  brl.call  b0 = helperAddress
-    VM_RT_SUPPORT hId = VM_RT_NULL_PTR_EXCEPTION;
-    uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
-    Opnd    *helperAddress = opndManager->newImm(address);
-    directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(NULL_POINTER_EXCEPTION);
+    throwException(excType);
+    //VM_RT_SUPPORT hId = VM_RT_NULL_PTR_EXCEPTION;
+    //uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    //Opnd    *helperAddress = opndManager->newImm(address);
+    //directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
 
     return opndManager->getTau();    // return fake value (we do not use tau)
 }
@@ -1467,10 +1506,12 @@
     cmp(CMPLT_CMP_CREL_GE, truePred, p0, index, arrayLen);
 
     // p2  brl.call  b0 = helperAddress
-    VM_RT_SUPPORT hId = VM_RT_IDX_OUT_OF_BOUNDS;
-    uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
-    Opnd    *helperAddress = opndManager->newImm(address);
-    directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(INDEX_OUT_OF_BOUNDS);
+    throwException(excType);
+    //VM_RT_SUPPORT hId = VM_RT_IDX_OUT_OF_BOUNDS;
+    //uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    //Opnd    *helperAddress = opndManager->newImm(address);
+    //directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
 
     return opndManager->getTau();    // return fake value (we do not use tau);
 }
@@ -1488,10 +1529,12 @@
     cmp(CMPLT_CMP_CREL_GT, truePred, p0, a, b);
 
     // p2  brl.call  b0 = helperAddress
-    VM_RT_SUPPORT hId = VM_RT_IDX_OUT_OF_BOUNDS;
-    uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
-    Opnd    *helperAddress = opndManager->newImm(address);
-    directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(INDEX_OUT_OF_BOUNDS);
+    throwException(excType);
+    //VM_RT_SUPPORT hId = VM_RT_IDX_OUT_OF_BOUNDS;
+    //uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    //Opnd    *helperAddress = opndManager->newImm(address);
+    //directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
 
     return opndManager->getTau();    // return fake value (we do not use tau);
 }
@@ -1509,10 +1552,12 @@
     cmp(CMPLT_CMP_CREL_GEU, truePred, p0, a, b);
 
     // p2  brl.call  b0 = helperAddress
-    VM_RT_SUPPORT hId = VM_RT_IDX_OUT_OF_BOUNDS;
-    uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
-    Opnd    *helperAddress = opndManager->newImm(address);
-    directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(INDEX_OUT_OF_BOUNDS);
+    throwException(excType);
+    //VM_RT_SUPPORT hId = VM_RT_IDX_OUT_OF_BOUNDS;
+    //uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    //Opnd    *helperAddress = opndManager->newImm(address);
+    //directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
 
     return opndManager->getTau();    // return fake value (we do not use tau);
 }
@@ -1549,10 +1594,12 @@
     cmp(CMPLT_CMP_CREL_EQ, truePred, p0, retOpnd, r0);
 
     // p3   brl.call b0, Helper_ElemTypeException
-    hId     = VM_RT_ARRAY_STORE_EXCEPTION;
-    address = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
-    Opnd    *helperAddress2 = opndManager->newImm(address);
-    directCall(0, NULL, NULL, helperAddress2, truePred, CMPLT_WH_DPNT);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(ARRAY_STORE_EXCEPTION);
+    throwException(excType);
+    //hId     = VM_RT_ARRAY_STORE_EXCEPTION;
+    //address = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    //Opnd    *helperAddress2 = opndManager->newImm(address);
+    //directCall(0, NULL, NULL, helperAddress2, truePred, CMPLT_WH_DPNT);
     
     return opndManager->getTau();    // return fake value (we do not use tau);
 }
@@ -1571,10 +1618,12 @@
     cmp(CMPLT_CMP_CREL_EQ, truePred, p0, src, r0);
 
     // p2  brl.call  b0 = helperAddress
-    VM_RT_SUPPORT hId = VM_RT_DIVIDE_BY_ZERO_EXCEPTION;
-    uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
-    Opnd    *helperAddress = opndManager->newImm(address);
-    directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
+    ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(DIVIDE_BY_ZERO_EXCEPTION);
+    throwException(excType);
+    //VM_RT_SUPPORT hId = VM_RT_DIVIDE_BY_ZERO_EXCEPTION;
+    //uint64  address        = (uint64) compilationInterface.getRuntimeHelperAddress(hId);
+    //Opnd    *helperAddress = opndManager->newImm(address);
+    //directCall(0, NULL, NULL, helperAddress, truePred, CMPLT_WH_DPNT);
 
     return opndManager->getTau();    // return fake value (we do not use tau)
 }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h Tue Apr 22 08:10:48 2008
@@ -183,6 +183,7 @@
     //---------------------------------------------------------------------------//
 
     void          throwException(CG_OpndHandle*, bool);
+    void          throwException(ObjectType* excType);// generater code to throw noted type exception
     void          throwSystemException(CompilationInterface::SystemExceptionId);
     void          throwLinkingException(Class_Handle, uint32, uint32);
     CG_OpndHandle *catchException(Type*);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp Tue Apr 22 08:10:48 2008
@@ -35,6 +35,9 @@
 using std::min;
 
 #include <open/vm.h>
+#include <open/vm_ee.h>
+#include <open/vm_class_info.h>
+#include <open/vm_class_loading.h>
 #include <jit_runtime_support.h>
 #include <jit_intf.h>
 #include <jni_types.h>
@@ -51,6 +54,7 @@
 const CallSig ci_helper_o(CCONV_HELPERS, jvoid, jobj);
 const CallSig ci_helper_v(CCONV_HELPERS, jvoid);
 const CallSig ci_helper_oi(CCONV_HELPERS, jobj, jobj, i32);
+const CallSig ci_helper_lazy(CCONV_MANAGED, jvoid, jobj, jobj);
 const CallSig ci_helper_linkerr(CCONV_HELPERS, jvoid, jobj, i32, i32);
 
 void CodeGen::do_mov(const Val& dst_s, const Val& src_s, bool skipTypeCheck)
@@ -138,7 +142,10 @@
     if (obj.is_imm()) {
         STATS_INC(Stats::npesEliminated,1);
         if (obj.pval() == NULL_REF) {
-            gen_call_throw(ci_helper_v, rt_helper_throw_npe, 0);
+            //gen_args(const CallSig& cs, unsigned idx, const Val * parg0 = NULL, 
+            //      const Val * parg1 = NULL, const Val * parg2 = NULL);
+            Class_Handle npeClass = vm_lookup_class_with_bootstrap(NULL_POINTER_EXCEPTION);
+            gen_throw(npeClass, false);
         }
         return;
     }
@@ -232,7 +239,9 @@
         }
         runlock(obj);
         unsigned br_off = br(ne, 0, 0, taken);
-        gen_call_vm_restore(true, ci_helper_v, rt_helper_throw_npe, 0);
+        Class_Handle npeClass = vm_lookup_class_with_bootstrap(NULL_POINTER_EXCEPTION);
+        gen_throw(npeClass, true);
+
         patch(br_off, ip());
     } // if !useHW
     
@@ -269,7 +278,9 @@
     // Unsigned condition here - aka 'len > (unsigned)index' - this also 
     // covers 'index < 0' - in a single comparation.
     unsigned br_off = br(above, 0, 0, taken);
-    gen_call_vm_restore(true, ci_helper_v, rt_helper_throw_out_of_bounds, 0);
+    //gen_call_vm_restore(true, ci_helper_v, rt_helper_throw_out_of_bounds, 0);
+    Class_Handle ioobClass = vm_lookup_class_with_bootstrap(INDEX_OUT_OF_BOUNDS);
+    gen_throw(ioobClass, true);
     patch(br_off, ip());
     if (is_set(DBG_TRACE_CG)) {dbg(";;>~check.bounds\n");}
 }
@@ -288,7 +299,9 @@
         // if it's i32, then nothing to do more - throw exception ...
         if (jt == i32) {
             // IS zero. Why do people want to divide on zero explicitly?..
-            gen_call_throw(ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+            //gen_call_throw(ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+            Class_Handle aeClass = vm_lookup_class_with_bootstrap(DIVIDE_BY_ZERO_EXCEPTION);
+            gen_throw(aeClass, false);
             if (is_set(DBG_TRACE_CG)) {dbg(";;>~check.div_by_zero\n");}
             return;
         }
@@ -298,7 +311,9 @@
             if (shi.is_imm() && shi.ival() == 0) {
                 // ... yes, it's zero too - throw ...
                 // Why do people want to divide on zero explicitly?..
-                gen_call_throw(ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+                //gen_call_throw(ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+                Class_Handle aeClass = vm_lookup_class_with_bootstrap(DIVIDE_BY_ZERO_EXCEPTION);
+                gen_throw(aeClass, false);
                 if (is_set(DBG_TRACE_CG)) {dbg(";;>~check.div_by_zero\n");}
                 return;
             }
@@ -315,7 +330,9 @@
     if (s.is_imm() && jt == i64 && !is_big(i64)) {
         if (s.lval() == 0) {
             // IS zero. Why do people want to divide on zero explicitly?..
-            gen_call_throw(ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+            //gen_call_throw(ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+            Class_Handle aeClass = vm_lookup_class_with_bootstrap(DIVIDE_BY_ZERO_EXCEPTION);
+            gen_throw(aeClass, false);
         }
         if (is_set(DBG_TRACE_CG)) {dbg(";;>~check.div_by_zero\n");}
         return;
@@ -335,7 +352,9 @@
     }
     if (jt == i32 || !is_big(jt)) {
         unsigned br_off = br(nz, 0, 0, taken);
-        gen_call_vm_restore(true, ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+        //gen_call_vm_restore(true, ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+        Class_Handle aeClass = vm_lookup_class_with_bootstrap(DIVIDE_BY_ZERO_EXCEPTION);
+        gen_throw(aeClass, true);
         patch(br_off, ip());
         if (is_set(DBG_TRACE_CG)) {dbg(";;>~check.div_by_zero\n");}
         return;
@@ -363,7 +382,9 @@
         alu(alu_cmp, mem, Opnd(0));
     }
     unsigned br_hi = br(nz, 0, 0, taken);
-    gen_call_vm_restore(true, ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+    //gen_call_vm_restore(true, ci_helper_v, rt_helper_throw_div_by_zero_exc, 0);
+    Class_Handle aeClass = vm_lookup_class_with_bootstrap(DIVIDE_BY_ZERO_EXCEPTION);
+    gen_throw(aeClass, true);
     patch(br_hi, ip());
     if (!s.is_imm()) {
         // [1] --> connect to here
@@ -705,6 +726,70 @@
     // then the memory was not corrupted.
     // So, just nothing to do with callee-save regs
     //
+}
+
+void CodeGen::gen_throw(Class_Handle exnClass, bool restore)
+{
+#ifdef _EM64T_
+    bool lazy = false;
+#else
+    bool lazy = true;
+#endif
+    BBState saveBB;
+
+    //TODO: Workaround for x86-64 stack should be aligned to half of 16
+#ifdef _EM64T_
+    alu(alu_sub, sp, (unsigned)STACK_SLOT_SIZE);
+    alu(alu_and, sp, ~((unsigned)STACK_SLOT_SIZE));
+    alu(alu_add, sp, (unsigned)STACK_SLOT_SIZE);
+#endif
+
+    if (restore){
+        saveBB = *m_bbstate;
+        for (unsigned i=0; i<ar_num; i++) {
+            AR ar = _ar(i);
+            if (rlocks(ar) != 0) {
+                runlock(ar, true);
+            }
+        }
+    }
+
+    if (lazy) {
+        gen_call_throw(ci_helper_lazy, rt_helper_throw_lazy, 0, exnClass, NULL);
+    } else {
+        static const CallSig ci_new(CCONV_HELPERS, jobj, i32, jobj);
+        unsigned size = class_get_object_size(exnClass);
+        unsigned stackFix;
+        Allocation_Handle ah = class_get_allocation_handle(exnClass);
+        gen_call_vm(ci_new, rt_helper_new, 0, size, ah);
+        gen_save_ret(ci_new);
+
+        static const CallSig cs_constructor(CCONV_MANAGED, jvoid, jobj);
+        static Method_Handle constructorMethDesc = 
+            class_lookup_method_recursively(exnClass, DEFAUlT_COSTRUCTOR_NAME, 
+                DEFAUlT_COSTRUCTOR_DESCRIPTOR);
+        static char* constructorMethAddr = 
+            *(char**)method_get_indirect_address(constructorMethDesc);
+        stackFix = gen_stack_to_args(false, cs_constructor, 0);
+        gen_call_vm(cs_constructor, constructorMethAddr, 1);
+        runlock(cs_constructor);
+        if (stackFix != 0) {
+            alu(alu_sub, sp, stackFix);
+        }
+
+        static const CallSig cs_throw(CCONV_HELPERS, jvoid, jobj);
+        stackFix = gen_stack_to_args(true, cs_throw, 0);
+        gen_call_vm(cs_throw, rt_helper_throw, 1);
+        runlock(cs_throw);
+        if (stackFix != 0) {
+            alu(alu_sub, sp, stackFix);
+        }
+    }
+
+    // Restore BBState first, so ref_counts for registers become valid
+    if (restore){
+        *m_bbstate = saveBB;
+    }
 }
 
 }};             // ~namespace Jitrino::Jet

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h Tue Apr 22 08:10:48 2008
@@ -493,6 +493,13 @@
      */
     void gen_dbg_rt(bool save_regs, const char * fmt, ...);
 
+    /**
+     * @brief Generates code to throw specified tipe of exception.
+     *
+     * The generated code which throws exception of soecified type.
+     * Also it can updates GC info and synchronizes both stack and local vars.
+     */
+    void gen_throw(Class_Handle exnClass, bool restore);
     
     /**
      * The opcode may be one of AASTORE, PUTFIELD or PUTSTATIC.

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.cpp Tue Apr 22 08:10:48 2008
@@ -339,7 +339,7 @@
     m_bc = method_get_bytecode(m_method);
     unsigned bc_size = (unsigned)method_get_bytecode_length(m_method);
     unsigned num_locals = method_get_max_locals(m_method);
-    unsigned max_stack = method_get_max_stack(m_method);
+    unsigned max_stack = method_get_max_stack(m_method) + NATIVE_STACK_SIZE_2_THROW_SYN_EXC;
     
     // Input arguments
     ::std::vector<jtype> inargs;
@@ -1497,17 +1497,12 @@
     rt_helper_get_vtable = 
               (char*)vm_helper_get_addr(VM_RT_GET_INTERFACE_VTABLE_VER0);
 
-    rt_helper_throw_npe = 
-                (char*)vm_helper_get_addr(VM_RT_NULL_PTR_EXCEPTION);
-
     rt_helper_throw = 
                 (char*)vm_helper_get_addr(VM_RT_THROW);
-    rt_helper_throw_out_of_bounds = 
-                (char*)vm_helper_get_addr(VM_RT_IDX_OUT_OF_BOUNDS);
+    rt_helper_throw_lazy = 
+                (char*)vm_helper_get_addr(VM_RT_THROW_LAZY);
     rt_helper_throw_linking_exc = 
                 (char*)vm_helper_get_addr(VM_RT_THROW_LINKING_EXCEPTION);
-    rt_helper_throw_div_by_zero_exc = 
-                (char*)vm_helper_get_addr(VM_RT_DIVIDE_BY_ZERO_EXCEPTION);
 
     rt_helper_checkcast = 
                 (char*)vm_helper_get_addr(VM_RT_CHECKCAST);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.h?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/compiler.h Tue Apr 22 08:10:48 2008
@@ -54,6 +54,7 @@
  * IA-64 and Intel-64.
  */
 #define NATIVE_CODE_SIZE_2_BC_SIZE_RATIO        (10)
+#define NATIVE_STACK_SIZE_2_THROW_SYN_EXC       (2)
 
 /**
  * The class represents a JIT compiler for the Java bytecode under DRLVM

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.cpp Tue Apr 22 08:10:48 2008
@@ -32,10 +32,8 @@
 namespace Jet {
 
 char *  StaticConsts::rt_helper_throw = NULL;
-char *  StaticConsts::rt_helper_throw_out_of_bounds = NULL;
-char *  StaticConsts::rt_helper_throw_npe = NULL;
+char *  StaticConsts::rt_helper_throw_lazy = NULL;
 char *  StaticConsts::rt_helper_throw_linking_exc = NULL;
-char *  StaticConsts::rt_helper_throw_div_by_zero_exc = NULL;
 
 char *  StaticConsts::rt_helper_monitor_enter = NULL;
 char *  StaticConsts::rt_helper_monitor_exit = NULL;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.h?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/sconsts.h Tue Apr 22 08:10:48 2008
@@ -48,10 +48,8 @@
 class StaticConsts {
 public:
     static char *       rt_helper_throw;
-    static char *       rt_helper_throw_out_of_bounds;
+    static char *       rt_helper_throw_lazy;
     static char *       rt_helper_throw_linking_exc;
-    static char *       rt_helper_throw_npe;
-    static char *       rt_helper_throw_div_by_zero_exc;
 
     static char *       rt_helper_new;
     static char *       rt_helper_new_array;

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?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/VMInterface.h Tue Apr 22 08:10:48 2008
@@ -25,6 +25,14 @@
 #include "open/em.h"
 #include "open/ee_em_intf.h"
 
+#define NULL_POINTER_EXCEPTION          "java/lang/NullPointerException"
+#define INDEX_OUT_OF_BOUNDS             "java/lang/ArrayIndexOutOfBoundsException"
+#define ARRAY_STORE_EXCEPTION           "java/lang/ArrayStoreException"
+#define DIVIDE_BY_ZERO_EXCEPTION        "java/lang/ArithmeticException"
+#define DEFAUlT_COSTRUCTOR_NAME         "<init>"
+#define DEFAUlT_COSTRUCTOR_DESCRIPTOR   "()V"
+
+
 namespace Jitrino {
 
 // external and forward declarations

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h Tue Apr 22 08:10:48 2008
@@ -79,7 +79,7 @@
 NativeCodePtr exn_get_rth_throw_array_store();
 
 // rth_throw_arithmetic throws an arithmetic exception (lazily)
-NativeCodePtr exn_get_rth_throw_arithmetic();
+//NativeCodePtr exn_get_rth_throw_arithmetic();
 
 // rth_throw_class_cast_exception throws a class cast exception (lazily)
 NativeCodePtr exn_get_rth_throw_class_cast_exception();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp Tue Apr 22 08:10:48 2008
@@ -463,6 +463,7 @@
 ManagedObject* Class::allocate_instance()
 {
     assert(!hythread_is_suspend_enabled());
+    //assert(is_initialized());
     ManagedObject* new_instance =
         (ManagedObject*)vm_alloc_and_report_ti(m_instance_data_size,
             m_allocation_handle, vm_get_gc_thread_local(), this);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp Tue Apr 22 08:10:48 2008
@@ -216,16 +216,16 @@
     ASSERT_RAISE_AREA;
     assert(!hythread_is_suspend_enabled());
 
-    // check verifier constraints
-    tmn_suspend_enable();
-    if(!clss->verify_constraints(VM_Global_State::loader_env)) {
-        assert(exn_raised());
-        tmn_suspend_disable();
-        return;
-    }
-    tmn_suspend_disable();
-    
     if(!clss->is_initialized()) {
+        // check verifier constraints
+        tmn_suspend_enable();
+        if(!clss->verify_constraints(VM_Global_State::loader_env)) {
+            assert(exn_raised());
+            tmn_suspend_disable();
+            return;
+        }
+        tmn_suspend_disable();
+
         clss->initialize();
     }
 } // class_initialize

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Tue Apr 22 08:10:48 2008
@@ -785,7 +785,11 @@
     DIE(("Lazy exceptions are not supported on this platform"));
 #else
     uint8 *args = (uint8 *) (m2n_get_args(m2n_get_last_frame()) + 1);   // +1 to skip constructor
-    args += exn_constr->get_num_arg_slots() * 4 - 4;
+    if (NULL != exn_constr) {
+        args += exn_constr->get_num_arg_slots() * 4 - 4;
+    } else {
+        args += 1*4 /*default constructor*/ - 4;
+    }
     exn_athrow(NULL, *(Class_Handle *) args, exn_constr, args);
 #endif
 }   //rth_throw_lazy
@@ -1085,27 +1089,27 @@
 
 
 // rth_throw_arithmetic throws an arithmetic exception (lazily)
-NativeCodePtr exn_get_rth_throw_arithmetic()
-{
-    static NativeCodePtr addr = NULL;
-    if (addr) {
-        return addr;
-    }
-
-    Global_Env *env = VM_Global_State::loader_env;
-    LilCodeStub *cs = lil_parse_code_stub("entry 0:stdcall::void;"
-        "std_places 1;" "sp0=%0i;" "tailcall %1i;",
-        env->java_lang_ArithmeticException_Class,
-        lil_npc_to_fp(exn_get_rth_throw_lazy_trampoline()));
-    assert(lil_is_valid(cs));
-    addr = LilCodeGenerator::get_platform()->compile(cs);
-
-    DUMP_STUB(addr, "rth_throw_arithmetic", lil_cs_get_code_size(cs));
-
-    lil_free_code_stub(cs);
-
-    return addr;
-}   //exn_get_rth_throw_arithmetic
+//NativeCodePtr exn_get_rth_throw_arithmetic()
+//{
+//    static NativeCodePtr addr = NULL;
+//    if (addr) {
+//        return addr;
+//    }
+//
+//    Global_Env *env = VM_Global_State::loader_env;
+//    LilCodeStub *cs = lil_parse_code_stub("entry 0:stdcall::void;"
+//        "std_places 1;" "sp0=%0i;" "tailcall %1i;",
+//        env->java_lang_ArithmeticException_Class,
+//        lil_npc_to_fp(exn_get_rth_throw_lazy_trampoline()));
+//    assert(lil_is_valid(cs));
+//    addr = LilCodeGenerator::get_platform()->compile(cs);
+//
+//    DUMP_STUB(addr, "rth_throw_arithmetic", lil_cs_get_code_size(cs));
+//
+//    lil_free_code_stub(cs);
+//
+//    return addr;
+//}   //exn_get_rth_throw_arithmetic
 
 
 // Return the type of class cast exception

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Tue Apr 22 08:10:48 2008
@@ -1662,14 +1662,6 @@
         return rth_wrap_exn_throw(dyn_count, "rth_throw", exn_get_rth_throw());
     case VM_RT_THROW_LAZY:
         return rth_wrap_exn_throw(dyn_count, "rth_throw_lazy", exn_get_rth_throw_lazy());
-    case VM_RT_IDX_OUT_OF_BOUNDS:
-        return rth_wrap_exn_throw(dyn_count, "rth_throw_index_out_of_bounds", exn_get_rth_throw_array_index_out_of_bounds());
-    case VM_RT_NULL_PTR_EXCEPTION:
-        return rth_wrap_exn_throw(dyn_count, "rth_throw_null_pointer", exn_get_rth_throw_null_pointer());
-    case VM_RT_DIVIDE_BY_ZERO_EXCEPTION:
-        return rth_wrap_exn_throw(dyn_count, "rth_throw_arithmetic", exn_get_rth_throw_arithmetic());
-    case VM_RT_ARRAY_STORE_EXCEPTION:
-        return rth_wrap_exn_throw(dyn_count, "rth_throw_array_store", exn_get_rth_throw_array_store());
     case VM_RT_THROW_LINKING_EXCEPTION:
         return rth_get_lil_throw_linking_exception(dyn_count);
     // Type tests
@@ -1778,34 +1770,22 @@
     assert(!hythread_is_suspend_enabled());
     assert(struct_Class_to_java_lang_Class(c)); 
 
+    class_initialize(c);
     ManagedObject* obj = c->allocate_instance();
     if(!obj) {
         exn_raise_object(
             VM_Global_State::loader_env->java_lang_OutOfMemoryError);
         return NULL; // whether this return is reached or not is solved via is_unwindable state
     }
-     return obj;
+    return obj;
 } // class_alloc_new_object
 
 ManagedObject *class_alloc_new_object_using_vtable(VTable *vtable)
 {
     ASSERT_RAISE_AREA;
     assert(!hythread_is_suspend_enabled());
-    assert(struct_Class_to_java_lang_Class(vtable->clss)); 
-#ifdef VM_STATS
-    VM_Statistics::get_vm_stats().num_class_alloc_new_object++;
-    vtable->clss->instance_allocated(vtable->allocated_size);
-#endif //VM_STATS
-    // From vm_types.h: this is the same as instance_data_size with the constraint bit cleared.
-    ManagedObject* o = (ManagedObject*) vm_alloc_and_report_ti(
-        vtable->allocated_size, vtable->clss->get_allocation_handle(),
-        vm_get_gc_thread_local(), vtable->clss);
-    if (!o) {
-        exn_raise_object(
-            VM_Global_State::loader_env->java_lang_OutOfMemoryError);
-        return NULL; // reached by interpreter and from JNI
-    }
-    return o;
+    assert(struct_Class_to_java_lang_Class(vtable->clss));
+    return class_alloc_new_object(vtable->clss);
 } //class_alloc_new_object_using_vtable
 
 ManagedObject* class_alloc_new_object_and_run_default_constructor(Class* clss)
@@ -1823,10 +1803,8 @@
     assert(struct_Class_to_java_lang_Class(clss)); 
 
     ObjectHandle obj = oh_allocate_local_handle();
-    obj->object = clss->allocate_instance();
+    obj->object = class_alloc_new_object(clss);
     if(!obj->object) {
-        exn_raise_object(
-            VM_Global_State::loader_env->java_lang_OutOfMemoryError);
         return NULL;
     }
 

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=650542&r1=650541&r2=650542&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 Tue Apr 22 08:10:48 2008
@@ -65,18 +65,6 @@
     {VM_RT_THROW_LAZY,                         "VM_RT_THROW_LAZY",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_DRL,                  8,
             NULL,   NULL,   NULL,   NULL},
-    {VM_RT_IDX_OUT_OF_BOUNDS,                  "VM_RT_IDX_OUT_OF_BOUNDS",
-            INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              0,
-            NULL,   NULL,   NULL,   NULL},
-    {VM_RT_NULL_PTR_EXCEPTION,                 "VM_RT_NULL_PTR_EXCEPTION",
-            INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              0,
-            NULL,   NULL,   NULL,   NULL},
-    {VM_RT_DIVIDE_BY_ZERO_EXCEPTION,           "VM_RT_DIVIDE_BY_ZERO_EXCEPTION",
-            INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              0,
-            NULL,   NULL,   NULL,   NULL},
-    {VM_RT_ARRAY_STORE_EXCEPTION,              "VM_RT_ARRAY_STORE_EXCEPTION",
-            INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              0,
-            NULL,   NULL,   NULL,   NULL},
     {VM_RT_THROW_LINKING_EXCEPTION,            "VM_RT_THROW_LINKING_EXCEPTION",
             INTERRUPTIBLE_ALWAYS,              CALLING_CONVENTION_STDCALL,              0,
             NULL,   NULL,   NULL,   NULL},

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp Tue Apr 22 08:10:48 2008
@@ -1015,14 +1015,6 @@
         if (res) return res;
 
     switch(f) {
-    case VM_RT_NULL_PTR_EXCEPTION:
-        return exn_get_rth_throw_null_pointer();
-    case VM_RT_IDX_OUT_OF_BOUNDS:
-        return exn_get_rth_throw_array_index_out_of_bounds();
-    case VM_RT_ARRAY_STORE_EXCEPTION:
-        return exn_get_rth_throw_array_store();
-    case VM_RT_DIVIDE_BY_ZERO_EXCEPTION:
-        return exn_get_rth_throw_arithmetic();
     case VM_RT_THROW:
     case VM_RT_THROW_SET_STACK_TRACE:
         return exn_get_rth_throw();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp Tue Apr 22 08:10:48 2008
@@ -146,36 +146,6 @@
     return stub;
 } //gen_vm_rt_exception_throw
 
-
-
-void *get_vm_rt_idx_out_of_bounds_address()
-{
-    static void *addr = 0;
-    if(addr) {
-        return addr;
-    }
-    Class * exc_clss = VM_Global_State::loader_env->java_lang_ArrayIndexOutOfBoundsException_Class;
-
-    addr = gen_vm_rt_exception_throw(exc_clss, "rt_idx_out_of_bounds");
-    return addr;
-} //get_vm_rt_idx_out_of_bounds_address
-
-
-
-void *get_vm_rt_array_store_exception_address()
-{
-    static void *addr = 0;
-    if(addr) {
-        return addr;
-    }
-
-    addr = gen_vm_rt_exception_throw(VM_Global_State::loader_env->java_lang_ArrayStoreException_Class, "rt_array_store_exception");
-
-    return addr;
-} //get_vm_rt_array_store_exception_address
-
-
-
 void *get_vm_rt_null_ptr_exception_address()
 {
     static void *addr = 0;
@@ -188,17 +158,3 @@
 
     return addr;
 } //get_vm_rt_null_ptr_exception_address
-
-
-
-void *get_vm_rt_divide_by_zero_exception_address()
-{
-    static void *addr = 0;
-    if(addr) {
-        return addr;
-    }
-    Class * exc_clss = VM_Global_State::loader_env->java_lang_ArithmeticException_Class;
-
-    addr = gen_vm_rt_exception_throw(exc_clss, "rt_divide_by_zero_exception");
-    return addr;
-} //get_vm_rt_divide_by_zero_exception_address

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp?rev=650542&r1=650541&r2=650542&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp Tue Apr 22 08:10:48 2008
@@ -71,10 +71,7 @@
 void *gen_vm_rt_exception_throw(Class *exc, char *stub_name);
 void gen_vm_rt_athrow_internal_compactor(Merced_Code_Emitter &emitter);
 void *get_vm_rt_athrow_naked_compactor();
-void *get_vm_rt_idx_out_of_bounds_address();
-void *get_vm_rt_array_store_exception_address();
 void *get_vm_rt_null_ptr_exception_address();
-void *get_vm_rt_divide_by_zero_exception_address();
 
 ///////// end exceptions
 
@@ -1817,22 +1814,6 @@
         break;
     case VM_RT_AASTORE_TEST:
         fptr = get_aastore_test_compactor();
-        dereference_fptr = false;
-        break;
-    case VM_RT_IDX_OUT_OF_BOUNDS:
-        fptr = get_vm_rt_idx_out_of_bounds_address();
-        dereference_fptr = false;
-        break;
-    case VM_RT_ARRAY_STORE_EXCEPTION:
-        fptr = get_vm_rt_array_store_exception_address();
-        dereference_fptr = false;
-        break;
-    case VM_RT_NULL_PTR_EXCEPTION:
-        fptr = get_vm_rt_null_ptr_exception_address();
-        dereference_fptr = false;
-        break;
-    case VM_RT_DIVIDE_BY_ZERO_EXCEPTION:
-        fptr = get_vm_rt_divide_by_zero_exception_address();
         dereference_fptr = false;
         break;
     case VM_RT_THROW:



Mime
View raw message