harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexei Fedotov" <alexei.fedo...@gmail.com>
Subject Re: svn commit: r545753 - in /harmony/enhanced/drlvm/trunk: build/custom/msvc_2003/jitrino/ build/custom/msvc_2005/jitrino/ vm/jitrino/src/translator/ vm/jitrino/src/translator/java/
Date Sat, 09 Jun 2007 17:59:01 GMT
Hello Alexey,

I've run
$ ( cd build && ./build.bat reg.test )

and got a lot of assertions of the following form
    [junit] Assertion failed: 0, file
C:\Users\af\ws_harmony\94\trunk\working_vm\vm\ji
trino\src\translator\java\JavaLabelPrepass.cpp, line 693
    [junit] Assertion failed: depth == 0, file
C:\Users\af\ws_harmony\94\trunk\working
_vm\vm\jitrino\src\main\PMF.cpp, line 708

I noticed that you'd touched the former file today. Could it be
related to your fix?

Thanks!

On 6/9/07, varlax@apache.org <varlax@apache.org> wrote:
> Author: varlax
> Date: Sat Jun  9 07:34:44 2007
> New Revision: 545753
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=545753
> Log:
> Fixed OPT compiler, HARMONY-3797 [drlvm][jit] bad handling of fall-through-reachable exception handlers
>
> Removed:
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/ExceptionInfo.cpp
> Modified:
>    harmony/enhanced/drlvm/trunk/build/custom/msvc_2003/jitrino/jitrino.vcproj
>    harmony/enhanced/drlvm/trunk/build/custom/msvc_2005/jitrino/jitrino.vcproj
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/ExceptionInfo.h
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.h
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaFlowGraphBuilder.cpp
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp
>    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h
>
> Modified: harmony/enhanced/drlvm/trunk/build/custom/msvc_2003/jitrino/jitrino.vcproj
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/custom/msvc_2003/jitrino/jitrino.vcproj?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/build/custom/msvc_2003/jitrino/jitrino.vcproj (original)
> +++ harmony/enhanced/drlvm/trunk/build/custom/msvc_2003/jitrino/jitrino.vcproj Sat Jun  9 07:34:44 2007
> @@ -997,9 +997,6 @@
>                                RelativePath="..\..\..\..\vm\jitrino\src\translator\ByteCodeParser.h">
>                        </File>
>                        <File
> -                               RelativePath="..\..\..\..\vm\jitrino\src\translator\ExceptionInfo.cpp">
> -                       </File>
> -                       <File
>                                RelativePath="..\..\..\..\vm\jitrino\src\translator\ExceptionInfo.h">
>                        </File>
>                        <File
>
> Modified: harmony/enhanced/drlvm/trunk/build/custom/msvc_2005/jitrino/jitrino.vcproj
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/custom/msvc_2005/jitrino/jitrino.vcproj?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/build/custom/msvc_2005/jitrino/jitrino.vcproj (original)
> +++ harmony/enhanced/drlvm/trunk/build/custom/msvc_2005/jitrino/jitrino.vcproj Sat Jun  9 07:34:44 2007
> @@ -1524,10 +1524,6 @@
>                                >
>                        </File>
>                        <File
> -                               RelativePath="..\..\..\..\vm\jitrino\src\translator\ExceptionInfo.cpp"
> -                               >
> -                       </File>
> -                       <File
>                                RelativePath="..\..\..\..\vm\jitrino\src\translator\ExceptionInfo.h"
>                                >
>                        </File>
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/ExceptionInfo.h
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/ExceptionInfo.h?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/ExceptionInfo.h (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/ExceptionInfo.h Sat Jun  9 07:34:44 2007
> @@ -15,18 +15,14 @@
>  *  limitations under the License.
>  */
>
> -/**
> - * @author Intel, George A. Timoshenko
> - * @version $Revision: 1.10.24.4 $
> - *
> - */
> -
>  #ifndef _EXCEPTIONINFO_H_
>  #define _EXCEPTIONINFO_H_
>
>  namespace Jitrino {
>
>  class LabelInst;
> +class CatchBlock;
> +class Type;
>
>  class ExceptionInfo {
>  public:
> @@ -61,31 +57,14 @@
>     LabelInst* label;
>  };
>
> -class Handler : public ExceptionInfo {
> -public:
> -    Handler(uint32 id,
> -            uint32 beginOffset,
> -            uint32 endOffset,
> -            ExceptionInfo* _tryBlock)
> -    : ExceptionInfo(id,beginOffset,endOffset), tryBlock(_tryBlock) {}
> -    virtual ~Handler() {}
> -
> -    uint32 getTryRegionId()            {return tryBlock->getId();}
> -    ExceptionInfo* getTryBlock()    {return tryBlock;}
> -private:
> -    ExceptionInfo* tryBlock;
> -};
> -
> -class CatchBlock;
> -class Type;
> -
> -class CatchHandler : public Handler {
> +class CatchHandler : public ExceptionInfo {
>  public:
>     CatchHandler(uint32 id,
>                  uint32 beginOffset,
>                  uint32 endOffset,
> -                 CatchBlock* tryBlock,
> -                 Type* excType);
> +                 Type* excType)
> +                 : ExceptionInfo(id, beginOffset, endOffset),
> +                 exceptionType(excType), nextHandler(NULL), order(0) {}
>     virtual ~CatchHandler() {}
>
>     Type*          getExceptionType()              {return exceptionType;}
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp Sat Jun  9 07:34:44 2007
> @@ -123,8 +123,6 @@
>
>     flags.ignoreSync       = getBoolArg("ignoreSync",false);
>     flags.syncAsEnterFence = getBoolArg("syncAsEnterFence",false);
> -    flags.newCatchHandling = getBoolArg("newCatchHandling",true);
> -
>
>     flags.genMinMaxAbs = getBoolArg("genMinMaxAbs", false);
>     flags.genFMinMaxAbs = getBoolArg("genFMinMaxAbs", false);
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h Sat Jun  9 07:34:44 2007
> @@ -56,7 +56,6 @@
>     bool onlyBalancedSync   : 1;    // treat all method synchronization as balanced
>     bool ignoreSync         : 1;    // do not generate monitor enter/exit instructions
>     bool syncAsEnterFence   : 1;    // implement monitor enter as enter fence and
> -    bool newCatchHandling   : 1;    // use fix for catch handler ordering problem
>     bool genMinMaxAbs       : 1;    // gen min/max/abs opcodes instead of using select
>     bool genFMinMaxAbs      : 1;    // gen min/max/abs opcodes for floats
>     bool optArrayInit       : 1;    // skip array initializers from optimizations
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.cpp Sat Jun  9 07:34:44 2007
> @@ -691,7 +691,6 @@
>         nextOffset = currentOffset + len;
>         return true;
>     }
> -    linearPassDone = true;
>     // get next label by popping label stack
>     while (!labelStack->isEmpty()) {
>         nextOffset = (uint32) (labelStack->pop() - byteCodes);
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.h
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.h?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.h (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeParser.h Sat Jun  9 07:34:44 2007
> @@ -47,10 +47,9 @@
>
>  class JavaByteCodeParserCallback : public ByteCodeParserCallback {
>  public:
> -    JavaByteCodeParserCallback() {
> +    JavaByteCodeParserCallback() : isLinearPass(true)  {
>         currentOffset = 0;
>         nextOffset = 0;
> -        isLinearPass = true;
>         linearPassDone = false;
>         visited = NULL;
>         bytecodevisited = NULL;
> @@ -58,10 +57,11 @@
>         labelStack = NULL;
>         noNeedToParse = false;
>     }
> -    JavaByteCodeParserCallback(MemoryManager& memManager,uint32 byteCodeLength) {
> +    JavaByteCodeParserCallback(MemoryManager& memManager,uint32 byteCodeLength)
> +        : isLinearPass(false)
> +    {
>         currentOffset = 0;
>         nextOffset = 0;
> -        isLinearPass = false;
>         linearPassDone = false;
>         visited = new (memManager) BitSet(memManager,byteCodeLength);
>         bytecodevisited = new (memManager) BitSet(memManager,byteCodeLength);
> @@ -74,7 +74,7 @@
>  protected:
>     // the current byte codes offset
>     uint32           currentOffset;
> -    bool             isLinearPass;
> +    const bool       isLinearPass;
>     bool             linearPassDone;
>     BitSet*          visited;
>     BitSet*          bytecodevisited;
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Sat Jun  9 07:34:44 2007
> @@ -430,7 +430,7 @@
>     }
>
>     // start a new basic block
> -    Log::out() << "TRANSLATOR BASICBLOCK " << (int32)offset << " " << ::std::endl;
> +    if (Log::isEnabled()) Log::out() << "TRANSLATOR BASICBLOCK " << (int32)offset << " " << ::std::endl;
>
>     // finish the previous basic block, if any work was required
>     if (!lastInstructionWasABranch) {
> @@ -443,13 +443,12 @@
>     stateInfo->flags = state->flags;
>     stateInfo->stackDepth = state->stackDepth;
>     stateInfo->exceptionInfo = state->exceptionInfo;
> -    for(int i=0; i<state->stackDepth; ++i)
> +    for(unsigned i=0; i<state->stackDepth; ++i)
>         stateInfo->stack[i] = state->stack[i];
>     assert(stateInfo != NULL);
>     Type* handlerExceptionType = NULL;
>     uint32 lblId = getNextLabelId();
>     LabelInst* labelInst = getLabel(lblId);
> -    ::std::vector<LabelInst*> oldLabels;
>
>     ::std::vector<LabelInst*> catchLabels;
>
> @@ -459,10 +458,10 @@
>          exceptionInfo = exceptionInfo->getNextExceptionInfoAtOffset()) {
>         if (exceptionInfo->isCatchBlock()) {
>             CatchBlock* catchBlock = (CatchBlock*)exceptionInfo;
> -            Log::out() << "TRY REGION " << (int)exceptionInfo->getBeginOffset()
> -                << " " << (int)exceptionInfo->getEndOffset() << ::std::endl;
>             CatchHandler *first = ((CatchBlock*)exceptionInfo)->getHandlers();
>             if (Log::isEnabled()) {
> +                Log::out() << "TRY REGION " << (int)exceptionInfo->getBeginOffset()
> +                    << " " << (int)exceptionInfo->getEndOffset() << ::std::endl;
>                 for (; first != NULL; first = first->getNextHandler()) {
>                     Log::out() << " handler " << (int)first->getBeginOffset() << ::std::endl;
>                 }
> @@ -482,32 +481,16 @@
>             // catch handler block
>             isCatchHandler = true;
>             CatchHandler* handler = (CatchHandler*)exceptionInfo;
> -            Log::out() << "CATCH REGION " << (int)exceptionInfo->getBeginOffset()
> +            if (Log::isEnabled()) Log::out() << "CATCH REGION " << (int)exceptionInfo->getBeginOffset()
>                 << " " << (int)exceptionInfo->getEndOffset() << ::std::endl;
> -            if (translationFlags.newCatchHandling) {
> -                handlerExceptionType = (handlerExceptionType == NULL) ?
> -                    handler->getExceptionType() :
> -                    typeManager.getCommonObjectType((ObjectType*) handlerExceptionType, (ObjectType*) handler->getExceptionType());
> -            } else {
> -                handlerExceptionType = handler->getExceptionType();
> -            }
> +            handlerExceptionType = (handlerExceptionType == NULL) ?
> +                handler->getExceptionType() :
> +                typeManager.getCommonObjectType((ObjectType*) handlerExceptionType, (ObjectType*) handler->getExceptionType());
>             LabelInst *oldLabel = labelInst;
> -            oldLabels.push_back(oldLabel);
> -
> -            if (translationFlags.newCatchHandling) {
> -                labelInst = (LabelInst*)
> -                    irBuilder.getInstFactory()->makeCatchLabel(
> -                                             handler->getExceptionOrder(),
> -                                             handler->getExceptionType());
> -                catchLabels.push_back(labelInst);
> -            } else {
> -                labelInst = (LabelInst*)
> -                    irBuilder.getInstFactory()->makeCatchLabel(
> -                                             labelInst->getLabelId(),
> -                                             handler->getExceptionOrder(),
> -                                             handlerExceptionType);
> -                setLabel(lblId,labelInst);
> -            }
> +            labelInst = irBuilder.getInstFactory()->makeCatchLabel(
> +                                            handler->getExceptionOrder(),
> +                                            handler->getExceptionType());
> +            catchLabels.push_back(labelInst);
>             labelInst->setState(oldLabel->getState());
>             exceptionInfo->setLabelInst(labelInst);
>             if(Log::isEnabled()) {
> @@ -517,7 +500,7 @@
>         } else {jitrino_assert(0);}    // only catch blocks should occur in Java
>     }
>     // generate the label instruction
> -    if(translationFlags.newCatchHandling && !catchLabels.empty()) {
> +    if(!catchLabels.empty()) {
>         for(::std::vector<LabelInst*>::iterator iter = catchLabels.begin(); iter != catchLabels.end(); ++iter) {
>             LabelInst* catchLabel = *iter;
>             irBuilder.genLabel(catchLabel);
> @@ -538,20 +521,25 @@
>         }
>         cfgBuilder.genBlock(labelInst);
>     }
> -    //
> -    // Load var operands where current basic block begins
> -    //
> -    for (uint32 k=numVars; k < (uint32)stateInfo->stackDepth; k++) {
> -        if(Log::isEnabled()) {
> -            Log::out() << "STACK ";stateInfo->stack[k].type->print(Log::out()); Log::out() << ::std::endl;
> -        }
>
> -        genLdVar(k,prepass.getJavaType(stateInfo->stack[k].type));
> -    }
>     if (isCatchHandler) {
>         // for catch handler blocks, generate the catch instruction
> -        pushOpnd(irBuilder.genCatch(handlerExceptionType));
> -    } else  if (stateInfo->isSubroutineEntry()) {
> +        assert(stateInfo->isCatchLabel());
> +        assert(1 == stateInfo->stackDepth - numVars);
> +        assert(stateInfo->stack[numVars].type == handlerExceptionType);
> +        pushOpnd(irBuilder.genCatch(stateInfo->stack[numVars].type));
> +    } else {
> +        //
> +        // Load var operands where current basic block begins
> +        //
> +        for (uint32 k=numVars; k < (uint32)stateInfo->stackDepth; k++) {
> +            if(Log::isEnabled()) {
> +                Log::out() << "STACK ";StateInfo::print(stateInfo->stack[k], Log::out());Log::out() << ::std::endl;
> +            }
> +            genLdVar(k,prepass.getJavaType(stateInfo->stack[k].type));
> +        }
> +    }
> +    if (stateInfo->isSubroutineEntry()) {
>         pushOpnd(irBuilder.genSaveRet());
>     }
>  }
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaFlowGraphBuilder.cpp
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaFlowGraphBuilder.cpp?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaFlowGraphBuilder.cpp (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaFlowGraphBuilder.cpp Sat Jun  9 07:34:44 2007
> @@ -65,15 +65,10 @@
>     //
>     NodeList::const_iterator niter = std::find(fallThruNodes.begin(), fallThruNodes.end(), block);
>     assert(niter != fallThruNodes.end());
> -    TranslatorFlags* translatorFlags = irBuilder.getTranslatorFlags();
>     for(++niter; niter != fallThruNodes.end(); ++niter) {
>         Node* node = *niter;
> -        if (translatorFlags->newCatchHandling) {
> -            if (node->isBlockNode() && !((LabelInst*)node->getFirstInst())->isCatchLabel()) {
> -                break;
> -            }
> -        } else if (node->isBlockNode()) {
> -                break;
> +        if (node->isBlockNode() && !((LabelInst*)node->getFirstInst())->isCatchLabel()) {
> +            break;
>         }
>     }
>     assert(niter != fallThruNodes.end());
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp Sat Jun  9 07:34:44 2007
> @@ -14,11 +14,6 @@
>  *  See the License for the specific language governing permissions and
>  *  limitations under the License.
>  */
> -
> -/**
> - * @author Intel, George A. Timoshenko
> - * @version $Revision: 1.40.12.2.4.4 $
> - */
>
>  #include <stdio.h>
>  #include <iostream>
> @@ -32,8 +27,8 @@
>
>  namespace Jitrino {
>
> -VariableIncarnation::VariableIncarnation(uint32 offset, uint32 block, Type* t)
> -: definingOffset(offset), definingBlock(block), declaredType(t), opnd(NULL)
> +VariableIncarnation::VariableIncarnation(uint32 offset, Type* t)
> +: definingOffset(offset), declaredType(t), opnd(NULL)
>  {
>     _prev = _next = NULL;
>  }
> @@ -41,12 +36,6 @@
>  void VariableIncarnation::setMultipleDefs()
>  {
>     definingOffset = -1;
> -    definingBlock = -1;
> -}
> -
> -void VariableIncarnation::ldBlock(int32 blockNumber)
> -{
> -    if (definingBlock!=blockNumber) definingBlock = -1;
>  }
>
>  Type* VariableIncarnation::getDeclaredType()
> @@ -147,7 +136,7 @@
>         out << " (" << tmp << ",DO=" << tmp->definingOffset << ") <-i->";
>         tmp = (VariableIncarnation*)tmp->_next;
>     } while (tmp);
> -    out << ::std::endl;
> +    //out << ::std::endl;
>  }
>
>
> @@ -159,7 +148,7 @@
>         out << " (" << cur_var_inc << ",DO=" << cur_var_inc->definingOffset << ",LO=" << linkOffset << ") <->";
>         tmp = (SlotVar*)tmp->_next;
>     } while (tmp);
> -    out << ::std::endl;
> +    //out << ::std::endl;
>  }
>
>
> @@ -246,34 +235,49 @@
>     if (definingOffset==-1) createVarOpnd(irBuilder);
>  }
>
> -void  StateInfo::addExceptionInfo(ExceptionInfo *info)
> +StateInfo::SlotInfo& StateInfo::top() {
> +    assert(stack && stackDepth != 0);
> +    return stack[stackDepth - 1];
> +}
> +
> +StateInfo::SlotInfo& StateInfo::push(Type *type) {
> +    StateInfo::SlotInfo& slot = stack[stackDepth++];
> +    slot.type = type;
> +    slot.slotFlags = 0;
> +    slot.vars = NULL;
> +    slot.jsrLabelOffset = 0;
> +    return slot;
> +}
> +
> +void  StateInfo::addCatchHandler(CatchHandler *info)
>  {
> -    if ( !info->isCatchBlock() ) {
> +    setCatchLabel();
> +    info->setNextExceptionInfoAtOffset(exceptionInfo);
> +    exceptionInfo = info;
> +}
> +
> +void  StateInfo::addExceptionInfo(CatchBlock *info) {
> +    ExceptionInfo *exc;
> +    ExceptionInfo *prev = NULL;
> +    for (exc = exceptionInfo; exc != NULL; exc = exc->getNextExceptionInfoAtOffset()) {
> +        if (exc->isCatchBlock() &&
> +            ((CatchBlock *)exc)->getExcTableIndex() > ((CatchBlock *)info)->getExcTableIndex()) {
> +            break;
> +        }
> +        prev = exc;
> +    }
> +    if (prev == NULL) {
>         info->setNextExceptionInfoAtOffset(exceptionInfo);
>         exceptionInfo = info;
> -    }else{
> -        ExceptionInfo *exc;
> -        ExceptionInfo *prev = NULL;
> -        for (exc = exceptionInfo; exc != NULL; exc = exc->getNextExceptionInfoAtOffset()) {
> -            if (exc->isCatchBlock() &&
> -                ((CatchBlock *)exc)->getExcTableIndex() > ((CatchBlock *)info)->getExcTableIndex()) {
> -                break;
> -            }
> -            prev = exc;
> -        }
> -        if (prev == NULL) {
> -            info->setNextExceptionInfoAtOffset(exceptionInfo);
> -            exceptionInfo = info;
> -        } else {
> -            info->setNextExceptionInfoAtOffset(prev->getNextExceptionInfoAtOffset());
> -            prev->setNextExceptionInfoAtOffset(info);
> -        }
> +    } else {
> +        info->setNextExceptionInfoAtOffset(prev->getNextExceptionInfoAtOffset());
> +        prev->setNextExceptionInfoAtOffset(info);
>     }
>  }
>
>  void StateInfo::cleanFinallyInfo(uint32 offset)
>  {
> -    for (int32 k=0; k < stackDepth; k++) {
> +    for (unsigned k=0; k < stackDepth; k++) {
>         if (stack[k].jsrLabelOffset == offset) {
>             stack[k].jsrLabelOffset = 0;
>             stack[k].type = 0;
> @@ -299,7 +303,7 @@
>             enclosingMethod->getHandlerInfo(i,&beginOffset,&endOffset,
>                 &handlerOffset,&handlerClassIndex);
>             if (!catchBlock(beginOffset,endOffset-beginOffset,
> -                handlerOffset,0,handlerClassIndex))
> +                handlerOffset,handlerClassIndex))
>             {
>                 // handlerClass failed to be resolved. LinkingException throwing helper
>                 // will be generated instead of method's body
> @@ -311,22 +315,37 @@
>
>     void addHandlerForCatchBlock(CatchBlock* block,
>                                       uint32 handlerOffset,
> -                                      uint32 handlerLength,
>                                       Type*  exceptionType) {
>         jitrino_assert( exceptionType);
>         assert(!exceptionType->isUnresolvedType());//must be resolved by verifier
> -        Log::out() << "Catch Exception Type = " << exceptionType->getName() << ::std::endl;
> +        if (Log::isEnabled()) Log::out() << "Catch Exception Type = " << exceptionType->getName() << ::std::endl;
>
> +        // FIXME can we operate with just sole handler per offset, just merging exceptionTypes?
> +        // need to check about handler for finally.
>         CatchHandler* handler = new (memManager)
>             CatchHandler(nextRegionId++,
>                          handlerOffset,
> -                         handlerOffset+handlerLength,
> -                         block,
> +                         handlerOffset,
>                          exceptionType);
>         block->addHandler(handler);
> -        StateInfo *catchInfo = prepass.stateTable->createStateInfo(handlerOffset);
> -        catchInfo->setCatchLabel();
> -        catchInfo->addExceptionInfo(handler);
> +        StateInfo *hi = prepass.stateTable->createStateInfo(handlerOffset, true);
> +        hi->addCatchHandler(handler);
> +        StateInfo::SlotInfo* slot;
> +        if (hi->stackDepth != prepass.getNumVars()) {
> +            slot = &hi->top();
> +            if (slot->type != exceptionType) {
> +                slot->type = prepass.typeManager.getCommonType(exceptionType, slot->type);
> +                StateInfo::clearExactType(slot);
> +            }
> +        } else {
> +            slot = &hi->push(exceptionType);
> +            StateInfo::setNonNull(slot);
> +            StateInfo::setExactType(slot);
> +        }
> +        assert(prepass.getNumVars() + 1 == (unsigned)hi->stackDepth);
> +        slot->vars = new (memManager) SlotVar(
> +            prepass.getOrCreateVarInc(handlerOffset, hi->stackDepth - 1, slot->type));
> +
>     }
>
>     CatchBlock* splitBlockWithOffset(CatchBlock* block, uint32 offset)
> @@ -346,16 +365,9 @@
>
>         for (CatchHandler* handler = block->getHandlers();
>                            handler != NULL;
> -                           handler = handler->getNextHandler() ) {
> -            CatchHandler* newHandler =
> -                new (memManager) CatchHandler(nextRegionId++,
> -                                              handler->getBeginOffset(),
> -                                              handler->getEndOffset(),
> -                                              newBlock,
> -                                              handler->getExceptionType());
> -            newBlock->addHandler(newHandler);
> -            assert(prepass.stateTable->getStateInfo(handler->getBeginOffset()));
> -            prepass.stateTable->getStateInfo(handler->getBeginOffset())->addExceptionInfo(newHandler);
> +                           handler = handler->getNextHandler() )
> +        {
> +            addHandlerForCatchBlock(newBlock, handler->getBeginOffset(), handler->getExceptionType());
>         }
>         return newBlock;
>     }
> @@ -363,17 +375,16 @@
>     bool catchBlock(uint32 tryOffset,
>                             uint32 tryLength,
>                             uint32 handlerOffset,
> -                            uint32 handlerLength,
>                             uint32 exceptionTypeToken)  {
>
> -        Log::out() << "CatchBlock @ " << (int)tryOffset << "," << (int)tryOffset+(int)tryLength
> -             << " handler @ " << (int)handlerOffset << "," << (int)handlerOffset+(int)handlerLength
> +        if (Log::isEnabled()) Log::out() << "CatchBlock @ " << (int)tryOffset << ","
> +            << (int)tryOffset+(int)tryLength
> +             << " handler @ " << (int)handlerOffset << ","
>              << " exception type " << (int)exceptionTypeToken << ","
>              << " numCatch " << numCatch << ::std::endl;
>
>         uint32 endOffset = tryOffset + tryLength;
>         prepass.setLabel(handlerOffset);
> -        prepass.setLabel(handlerOffset+handlerLength);
>         prepass.setLabel(tryOffset);
>         prepass.setLabel(endOffset);
>
> @@ -392,16 +403,17 @@
>                 //distinct exception types if there are several unresolved exceptions in a single try block
>                 //usually verifier loads all exception types caught for in method
>                 //but verifier is turned off for bootstrap classes
> -                Log::out()<<"WARNING: resolving type from inside of compilation session!!"<<std::endl;
> +                if (Log::isEnabled()) Log::out()<<"WARNING: resolving type from inside of compilation session!!"<<std::endl;
>                 exceptionType = compilationInterface.resolveNamedType(enclosingMethod->getParentHandle(),exceptionTypeToken);
>             }
>         } else {
> +            //FIXME should use j.l.Throwable for correct type propagation ??
>             exceptionType = prepass.typeManager.getSystemObjectType();
>         }
>
>         if (prevCatch != NULL && prevCatch->equals(tryOffset, endOffset) == true) {
>             catchBlock = prevCatch;
> -            addHandlerForCatchBlock(catchBlock, handlerOffset, handlerLength, exceptionType);
> +            addHandlerForCatchBlock(catchBlock, handlerOffset, exceptionType);
>         } else {
>             prepass.stateTable->createStateInfo(tryOffset);
>             //
> @@ -419,7 +431,7 @@
>                 if ( block->offsetSplits(tryOffset) || block->offsetSplits(endOffset) ) {
>                     if ( !unnested_try_regions_found ) {
>                         unnested_try_regions_found = true;
> -                        Log::out() << "unnested try-regions encountered" << std::endl;
> +                        if (Log::isEnabled()) Log::out() << "unnested try-regions encountered" << std::endl;
>                     }
>                 }
>                 assert(tryOffset < endOffset);
> @@ -442,7 +454,7 @@
>                 new (memManager) CatchBlock(nextRegionId++, tryOffset, endOffset, numCatch++);
>             prepass.stateTable->getStateInfo(tryOffset)->addExceptionInfo(catchBlock);
>             prepass.exceptionTable.push_back(catchBlock);
> -            addHandlerForCatchBlock(catchBlock, handlerOffset, handlerLength, exceptionType);
> +            addHandlerForCatchBlock(catchBlock, handlerOffset, exceptionType);
>         }
>         return 1; // all exceptionTypes are OK
>     }
> @@ -482,11 +494,11 @@
>     doubleType= typeManager.getDoubleType();
>
>     numLabels = 0;
> -    numVars = methodDesc.getNumVars();
>     labels = new (memManager) BitSet(memManager,numByteCodes);
>     subroutines = new (memManager) BitSet(memManager,numByteCodes);
> -    int numStack = md.getMaxStack()+1;
> -    stateInfo.stack  = new (memManager) struct StateInfo::SlotInfo[numVars+numStack];
> +    numVars = methodDesc.getNumVars();
> +    int numStack = methodDesc.getMaxStack()+1;
> +    stateInfo.stack  = new (memManager) StateInfo::SlotInfo[numVars+numStack];
>     stateInfo.stackDepth = numVars;
>     for (uint32 k=0; k < numVars+numStack; k++) {
>         struct StateInfo::SlotInfo *slot = &stateInfo.stack[k];
> @@ -498,7 +510,7 @@
>     blockNumber  = 0;
>     labelOffsets = NULL;
>     // exceptions
> -    stateTable = new (memManager)  StateTable(memManager,typeManager,*this,20,numVars);
> +    stateTable = new (memManager)  StateTable(memManager,typeManager,*this,numStack,numVars);
>
>     // 1st count number of catch and finally blocks
>     // parse and create exception info
> @@ -515,8 +527,6 @@
>     }
>     hasJsrLabels = false;
>     isFallThruLabel = true;
> -    numVars = methodDesc.getNumVars();
> -    methodDesc.getMaxStack();
>     uint32 numArgs = methodDesc.getNumParams();
>     for (uint32 i=0, j=0; i<numArgs; i++,j++) {
>         Type *type;
> @@ -544,7 +554,7 @@
>             }
>             slot->type = typeManager.toInternalType(type);
>         }
> -        slot->vars  = new (memManager) SlotVar(getOrCreateVarInc(0, j, slot->type, NULL));
> +        slot->vars  = new (memManager) SlotVar(getOrCreateVarInc(0, j, slot->type));
>         JavaVarType javaType = getJavaType(type);
>         if (javaType == L || javaType == D) j++;
>     }
> @@ -552,11 +562,11 @@
>  }
>
>  void JavaLabelPrepass::offset(uint32 offset) {
> -    Log::out() << std::endl << "PREPASS OFFSET " << (int32)offset << ", blockNo=" << blockNumber << std::endl;
> +    if (Log::isEnabled()) Log::out() << std::endl << "PREPASS OFFSET " << (int32)offset << ", blockNo=" << blockNumber << std::endl;
>     bytecodevisited->setBit(offset,true);
>     if (offset==0)
>         stateTable->restoreStateInfo(&stateInfo, offset);
> -    if (labels->getBit(offset) == true/* && !visited->getBit(offset)*/) {
> +    if (labels->getBit(offset) == true) {
>         if (linearPassDone)
>             stateTable->restoreStateInfo(&stateInfo, offset);
>         setStackVars();
> @@ -565,32 +575,13 @@
>             propagateStateInfo(offset,isFallThruLabel);
>             isFallThruLabel = true;
>         }
> -        Log::out() << "BASICBLOCK " << (int32)offset << " " << blockNumber << std::endl;
> +        if (Log::isEnabled()) Log::out() << "BASICBLOCK " << (int32)offset << " #" << blockNumber << std::endl;
>         ++blockNumber;
>         visited->setBit(offset,true);
>         stateTable->restoreStateInfo(&stateInfo,offset);
> -        if (stateInfo.isCatchLabel()) {
> -            Type *handlerExceptionType = NULL;
> -            for (ExceptionInfo* exceptionInfo = stateInfo.exceptionInfo;
> -                 exceptionInfo != NULL;
> -                 exceptionInfo = exceptionInfo->getNextExceptionInfoAtOffset()) {
> -                if (exceptionInfo->isCatchHandler()) {
> -                    // catch handler block
> -                    CatchHandler* handler = (CatchHandler*)exceptionInfo;
> -                    handlerExceptionType = handler->getExceptionType();
> -                    break;
> -                }
> -            }
> -            if(Log::isEnabled()) {
> -                Log::out() << "CATCH " << (int32) offset << " ";
> -                handlerExceptionType->print(Log::out());
> -                Log::out() << ::std::endl;
> -            }
> -            pushType(handlerExceptionType);
> -        }
> -        else if (stateInfo.isSubroutineEntry()) {
> -            pushType(typeManager.getSystemObjectType());
> -            stateInfo.stack[stateInfo.stackDepth-1].jsrLabelOffset = offset;
> +        if (stateInfo.isSubroutineEntry()) {
> +            stateInfo.push(typeManager.getSystemObjectType());
> +            stateInfo.top().jsrLabelOffset = offset;
>         }
>     }
>  }
> @@ -600,7 +591,7 @@
>  void JavaLabelPrepass::setLabel(uint32 offset) {
>     if (labels->getBit(offset)) // this label is already seen
>         return;
> -    Log::out() << "SET LABEL " << (int) offset << " " << (int) numLabels << ::std::endl;
> +    if (Log::isEnabled()) Log::out() << "SET LABEL " << (int) offset << " #" << (int) numLabels << ::std::endl;
>     labels->setBit(offset,true);
>     numLabels++;
>  }
> @@ -652,14 +643,14 @@
>     return (*iter).second;
>  }
>
> -VariableIncarnation* JavaLabelPrepass::getOrCreateVarInc(uint32 offset, uint32 index, Type* type, VariableIncarnation* prev)
> +VariableIncarnation* JavaLabelPrepass::getOrCreateVarInc(uint32 offset, uint32 index, Type* type)
>  {
>     int numStack = methodDesc.getMaxStack()+1;
>     uint32 key = offset*(numVars+numStack)+index;
>     StlHashMap<uint32,VariableIncarnation*>::iterator iter = localVars.find(key);
>     VariableIncarnation* var;
>     if (iter==localVars.end()) {
> -        var = new(memManager) VariableIncarnation(offset, blockNumber, type);
> +        var = new(memManager) VariableIncarnation(offset, type);
>         localVars[key] = var;
>     } else {
>         var = (*iter).second;
> @@ -680,49 +671,39 @@
>  // stack operations
>  //
>
> -struct StateInfo::SlotInfo   JavaLabelPrepass::topType() {
> +StateInfo::SlotInfo&   JavaLabelPrepass::topType() {
>     return stateInfo.stack[stateInfo.stackDepth-1];
>  }
>
> -struct StateInfo::SlotInfo JavaLabelPrepass::popType() {
> -    struct StateInfo::SlotInfo top = stateInfo.stack[--stateInfo.stackDepth];
> -    assert (stateInfo.stackDepth >= (int)numVars);
> +StateInfo::SlotInfo& JavaLabelPrepass::popType() {
> +    StateInfo::SlotInfo& top = stateInfo.stack[--stateInfo.stackDepth];
> +    assert (stateInfo.stackDepth >= numVars);
>     return top;
>  }
>
>  void    JavaLabelPrepass::popAndCheck(Type *type) {
> -    struct StateInfo::SlotInfo top = popType();
> +    StateInfo::SlotInfo& top = popType();
>     if( !(top.type == type) )
>         assert(0);
>  }
>
>  void    JavaLabelPrepass::popAndCheck(JavaVarType type) {
> -    struct StateInfo::SlotInfo top = popType();
> +    StateInfo::SlotInfo& top = popType();
>     if(!(top.type && getJavaType(top.type) == type))
>         assert(0);
>  }
>
>  void    JavaLabelPrepass::pushType(Type *type) {
> -    struct StateInfo::SlotInfo* slot = &stateInfo.stack[stateInfo.stackDepth++];
> -    slot->type = type;
> -    slot->slotFlags = 0;
> -    slot->vars = NULL;
> -    slot->jsrLabelOffset = 0;
> +    stateInfo.push(type);
>  }
>
>
>  void    JavaLabelPrepass::pushType(Type *type, uint32 varNumber) {
> -    struct StateInfo::SlotInfo* slot = &stateInfo.stack[stateInfo.stackDepth++];
> -    slot->type           = type;
> -    slot->slotFlags      = 0;
> -    slot->varNumber      = varNumber;
> -    slot->vars            = NULL;
> -    slot->jsrLabelOffset  = 0;
> -    StateInfo::setVarNumber(slot);
> +    stateInfo.push(type).setVarNumber(varNumber);
>  }
>
>
> -void    JavaLabelPrepass::pushType(struct StateInfo::SlotInfo slot) {
> +void    JavaLabelPrepass::pushType(StateInfo::SlotInfo& slot) {
>     stateInfo.stack[stateInfo.stackDepth++] = slot;
>     stateInfo.stack[stateInfo.stackDepth-1].jsrLabelOffset = 0;
>  }
> @@ -733,29 +714,19 @@
>         Log::out() << "SET STACK VARS:" << ::std::endl;
>     }
>
> -    for (int i=numVars; i < stateInfo.stackDepth; i++) {
> +    for (unsigned i=numVars; i < stateInfo.stackDepth; i++) {
>         struct StateInfo::SlotInfo* slot = &stateInfo.stack[i];
>
>         if(Log::isEnabled()) {
>             Log::out() << "SLOT " << i << ":" << ::std::endl;
> -            Log::out() << "       type = ";
> -            if (slot->type)
> -                slot->type->print(Log::out());
> -            else
> -                Log::out() << "NULL";
> -            Log::out() << ::std::endl;
> -            Log::out() << "       vars = ";
> -            if (slot->vars)
> -                slot->vars->getVarIncarnation()->print(Log::out());
> -            else
> -                Log::out() << "NULL";
> +            StateInfo::print(*slot, Log::out());
>             Log::out() << ::std::endl;
>         }
>
>         Type* type = slot->type;
>         assert(type);
>         SlotVar* sv = slot->vars;
> -        VariableIncarnation* var = getOrCreateVarInc(currentOffset, i, type, NULL);
> +        VariableIncarnation* var = getOrCreateVarInc(currentOffset, i, type);
>
>         // Do not merge stack vars of incompatible types
>         if (sv && (sv->getVarIncarnation()->getDeclaredType() == var->getDeclaredType())) {
> @@ -767,17 +738,7 @@
>
>         if(Log::isEnabled()) {
>             Log::out() << "AFTER" << ::std::endl;
> -            Log::out() << "       type = ";
> -            if (slot->type)
> -                slot->type->print(Log::out());
> -            else
> -                Log::out() << "NULL";
> -            Log::out() << ::std::endl;
> -            Log::out() << "       vars = ";
> -            if (slot->vars)
> -                slot->vars->getVarIncarnation()->print(Log::out());
> -            else
> -                Log::out() << "NULL";
> +            StateInfo::print(*slot, Log::out());
>             Log::out() << ::std::endl;
>         }
>     }
> @@ -1549,7 +1510,7 @@
>  void JavaLabelPrepass::pop()                               { popType(); }
>
>  void JavaLabelPrepass::pop2() {
> -    struct StateInfo::SlotInfo type = popType();
> +    StateInfo::SlotInfo& type = popType();
>     if (isCategory2(type))
>         return;
>     popType();
> @@ -1560,23 +1521,23 @@
>  }
>
>  void JavaLabelPrepass::dup_x1() {
> -    struct StateInfo::SlotInfo opnd1 = popType();
> -    struct StateInfo::SlotInfo opnd2 = popType();
> +    StateInfo::SlotInfo& opnd1 = popType();
> +    StateInfo::SlotInfo& opnd2 = popType();
>     pushType(opnd1);
>     pushType(opnd2);
>     pushType(opnd1);
>  }
>
>  void JavaLabelPrepass::dup_x2() {
> -    struct StateInfo::SlotInfo opnd1 = popType();
> -    struct StateInfo::SlotInfo opnd2 = popType();
> +    StateInfo::SlotInfo& opnd1 = popType();
> +    StateInfo::SlotInfo& opnd2 = popType();
>     if (isCategory2(opnd2)) {
>         pushType(opnd1);
>         pushType(opnd2);
>         pushType(opnd1);
>         return;
>     }
> -    struct StateInfo::SlotInfo opnd3 = popType();
> +    StateInfo::SlotInfo& opnd3 = popType();
>     pushType(opnd1);
>     pushType(opnd3);
>     pushType(opnd2);
> @@ -1584,13 +1545,13 @@
>  }
>
>  void JavaLabelPrepass::dup2() {
> -    struct StateInfo::SlotInfo opnd1 = popType();
> +    StateInfo::SlotInfo& opnd1 = popType();
>     if (isCategory2(opnd1)) {
>         pushType(opnd1);
>         pushType(opnd1);
>         return;
>     }
> -    struct StateInfo::SlotInfo opnd2 = popType();
> +    StateInfo::SlotInfo& opnd2 = popType();
>     pushType(opnd2);
>     pushType(opnd1);
>     pushType(opnd2);
> @@ -1598,8 +1559,8 @@
>  }
>
>  void JavaLabelPrepass::dup2_x1() {
> -    struct StateInfo::SlotInfo opnd1 = popType();
> -    struct StateInfo::SlotInfo opnd2 = popType();
> +    StateInfo::SlotInfo& opnd1 = popType();
> +    StateInfo::SlotInfo& opnd2 = popType();
>     if (isCategory2(opnd1)) {
>         // opnd1 is a category 2 instruction
>         pushType(opnd1);
> @@ -1607,7 +1568,7 @@
>         pushType(opnd1);
>     } else {
>         // opnd1 is a category 1 instruction
> -        struct StateInfo::SlotInfo opnd3 = popType();
> +        StateInfo::SlotInfo& opnd3 = popType();
>         pushType(opnd2);
>         pushType(opnd1);
>         pushType(opnd3);
> @@ -1618,8 +1579,8 @@
>
>
>  void JavaLabelPrepass::dup2_x2() {
> -    struct StateInfo::SlotInfo opnd1 = popType();
> -    struct StateInfo::SlotInfo opnd2 = popType();
> +    StateInfo::SlotInfo& opnd1 = popType();
> +    StateInfo::SlotInfo& opnd2 = popType();
>     if (isCategory2(opnd1)) {
>         // opnd1 is category 2
>         if (isCategory2(opnd2)) {
> @@ -1628,7 +1589,7 @@
>             pushType(opnd1);
>         } else {
>             // opnd2 is category 1
> -            struct StateInfo::SlotInfo opnd3 = popType();
> +            StateInfo::SlotInfo& opnd3 = popType();
>             assert(isCategory2(opnd3) == false);
>             pushType(opnd1);
>             pushType(opnd3);
> @@ -1638,7 +1599,7 @@
>     } else {
>         assert(isCategory2(opnd2) == false);
>         // both opnd1 & opnd2 are category 1
> -        struct StateInfo::SlotInfo opnd3 = popType();
> +        StateInfo::SlotInfo& opnd3 = popType();
>         if (isCategory2(opnd3)) {
>             pushType(opnd2);
>             pushType(opnd1);
> @@ -1647,7 +1608,7 @@
>             pushType(opnd1);
>         } else {
>             // opnd1, opnd2, opnd3 all are category 1
> -            struct StateInfo::SlotInfo opnd4 = popType();
> +            StateInfo::SlotInfo& opnd4 = popType();
>             assert(isCategory2(opnd4) == false);
>             pushType(opnd2);
>             pushType(opnd1);
> @@ -1660,8 +1621,8 @@
>  }
>
>  void JavaLabelPrepass::swap() {
> -    struct StateInfo::SlotInfo opnd1 = popType();
> -    struct StateInfo::SlotInfo opnd2 = popType();
> +    StateInfo::SlotInfo& opnd1 = popType();
> +    StateInfo::SlotInfo& opnd2 = popType();
>     pushType(opnd1);
>     pushType(opnd2);
>  }
> @@ -1679,16 +1640,16 @@
>     popAndCheck(type);
>     stateInfo.stack[index].type     = type;
>     stateInfo.stack[index].slotFlags= 0;
> -    stateInfo.stack[index].vars = new (memManager) SlotVar(getOrCreateVarInc(offset, index, type, NULL/*prevVar*/));
> +    stateInfo.stack[index].vars = new (memManager) SlotVar(getOrCreateVarInc(offset, index, type));
>     propagateLocalVarToHandlers(index);
>  }
>
>  void JavaLabelPrepass::genTypeStore(uint32 index, uint32 offset) {
> -    struct StateInfo::SlotInfo slot = popType();
> +    StateInfo::SlotInfo& slot = popType();
>     Type *type = slot.type;
>     stateInfo.stack[index].type     = type;
>     stateInfo.stack[index].slotFlags= slot.slotFlags;
> -    VariableIncarnation* offset_varinc = getOrCreateVarInc(offset, index, type, NULL/*prevVar*/);
> +    VariableIncarnation* offset_varinc = getOrCreateVarInc(offset, index, type);
>     offset_varinc->setDeclaredType(typeManager.getCommonType(type, offset_varinc->getDeclaredType()));
>     stateInfo.stack[index].vars = new (memManager) SlotVar(offset_varinc);
>     if(Log::isEnabled()) {
> @@ -1708,7 +1669,6 @@
>     stateInfo.stack[stateInfo.stackDepth-1].jsrLabelOffset = stateInfo.stack[index].jsrLabelOffset;
>     SlotVar* vars = stateInfo.stack[index].vars;
>     if (vars) {
> -        vars->getVarIncarnation()->ldBlock(blockNumber);
>         vars->mergeVarIncarnations(&typeManager);
>     }
>  }
> @@ -1717,7 +1677,6 @@
>     Type *type = stateInfo.stack[index].type;
>     SlotVar* vars = stateInfo.stack[index].vars;
>     if (vars) {
> -        vars->getVarIncarnation()->ldBlock(blockNumber);
>         vars->mergeVarIncarnations(&typeManager);
>         type = vars->getVarIncarnation()->getDeclaredType();
>     }
> @@ -1750,15 +1709,9 @@
>  }
>
>  void JavaLabelPrepass::genTypeArrayStore() {
> -#ifndef NDEBUG
> -    Type *type =
> -#endif
> -        popType().type;
> +    UNUSED Type *type = popType().type;
>     popAndCheck(int32Type);
> -#ifndef NDEBUG
> -    type =
> -#endif
> -        popType().type;
> +    type = popType().type;
>     assert(type->isArrayType() || type->isNullObject() || type->isUnresolvedObject());
>  }
>
> @@ -1804,7 +1757,7 @@
>     to.vars = from.vars ? new (memManager) SlotVar(from.vars, memManager) : NULL;
>  }
>
> -void  StateTable::setStateInfo(StateInfo *inState, uint32 offset, bool isFallThru) {
> +void  StateTable::setStateInfo(StateInfo *inState, uint32 offset, bool isFallThru, bool varsOnly) {
>     if(Log::isEnabled()) {
>         Log::out() << "SETSTATE offset=" <<(int)offset << " depth=" << inState->stackDepth << ::std::endl;
>         printState(inState);
> @@ -1820,6 +1773,7 @@
>         state->clearFallThroughLabel();
>     assert(getStateInfo(offset) != NULL);
>
> +    setStackInfo(inState, offset, true, !varsOnly);
>     if (!state->isVisited() ) {
>         state->setVisited();
>
> @@ -1828,7 +1782,7 @@
>
>             CatchBlock* except = *it;
>             if ( except->hasOffset(offset) ) {
> -                Log::out() << "try-region begin=" << (int)except->getBeginOffset()
> +                if (Log::isEnabled()) Log::out() << "try-region begin=" << (int)except->getBeginOffset()
>                                      << " end=" << (int)except->getEndOffset() << ::std::endl;
>                 ExceptionInfo *prev = state->exceptionInfo;
>                 bool found  = false;
> @@ -1858,51 +1812,43 @@
>             }
>         }
>     }
> -    int stackDepth = inState->stackDepth;
> +}
> +
> +void  StateTable::setStackInfo(StateInfo *inState, uint32 offset, bool includeVars, bool includeStack)
> +{
> +    if (Log::isEnabled()) Log::out() << "SETSTACK " << includeVars << ", " << includeStack << ::std::endl;
> +    unsigned stackDepth = inState->stackDepth;
>     if (stackDepth > 0) {
> +        StateInfo *state = hashtable[offset];
> +        assert(state);
> +        unsigned from = includeVars ? 0 : numVars;
> +        unsigned to = includeStack ? stackDepth : numVars;
>         if (maxDepth < stackDepth) maxDepth = stackDepth;
> -        Log::out() << "MAXDEPTH " << maxDepth << ::std::endl;
> -        struct StateInfo::SlotInfo *stack = state->stack;
> +        if (Log::isEnabled()) Log::out() << "MAXDEPTH " << maxDepth << ::std::endl;
> +        StateInfo::SlotInfo *stack = state->stack;
>         if (stack == NULL) {
> +            if (Log::isEnabled()) Log::out() << "NEWSTACK" << ::std::endl;
>             stack = new (memManager) StateInfo::SlotInfo[stackDepth+1];
>             state->stack = stack;
> -            for (int i=0; i < stackDepth; i++) {
> +            for (unsigned i = from; i < to; i++) {
>                 copySlotInfo(stack[i], inState->stack[i]);
>             }
> -            state->stackDepth = stackDepth;
> +            state->stackDepth = to;
>         } else { // needs to merge the states
> -            assert(state->stackDepth == stackDepth);
> +            assert(!includeStack || state->stackDepth == stackDepth);
>             if(Log::isEnabled()) {
>                 Log::out() << " before\n";
>                 printState(state);
>             }
> -            for (int i=0; i < stackDepth; i++) {
> +            for (unsigned i = from; i < to; i++) {
>                 struct StateInfo::SlotInfo *inSlot = &inState->stack[i];
>                 struct StateInfo::SlotInfo *slot   = &stack[i];
>                 if(Log::isEnabled()) {
>                     Log::out() << " i = " << i << ::std::endl;
> -                    Log::out() << "inSlot->type: ";
> -                    if (inSlot->type) {
> -                        inSlot->type->print(Log::out());
> -                    } else {
> -                        Log::out() << "null";
> -                    }
> -                    Log::out() << ::std::endl;
> -                    Log::out() << "slot->type: ";
> -                    if (slot->type) {
> -                        slot->type->print(Log::out());
> -                    } else {
> -                        Log::out() << "null";
> -                    }
> -                    Log::out() << ::std::endl;
> -                    if (inSlot->vars) {
> -                        Log::out() << "inSlot->vars: "; inSlot->vars->print(Log::out());
> -                    }
> -                    if (slot->vars) {
> -                        Log::out() << "slot->vars: "; slot->vars->print(Log::out());
> -                    }
> +                    Log::out() << "inSlot: ";StateInfo::print(*inSlot, Log::out());Log::out() << ::std::endl;
> +                    Log::out() << "slot:   ";StateInfo::print(*slot, Log::out());Log::out() << ::std::endl;
>                 }
> -                mergeSlots(inSlot, slot, offset, i < numVars);
> +                mergeSlots(inSlot, slot, offset, i < (unsigned)numVars);
>             }
>         }
>         if(Log::isEnabled()) {
> @@ -1913,6 +1859,14 @@
>  }
>
>  void StateTable::mergeSlots(StateInfo::SlotInfo* inSlot, StateInfo::SlotInfo* slot, uint32 offset, bool isVar) {
> +
> +    if (!getStateInfo(offset)->isVisited()) {
> +        assert(NULL == slot->type);
> +        assert(NULL == slot->vars);
> +        copySlotInfo(*slot, *inSlot);
> +        return;
> +    }
> +
>     slot->jsrLabelOffset = inSlot->jsrLabelOffset;
>     slot->slotFlags = slot->slotFlags & inSlot->slotFlags;
>
> @@ -1973,28 +1927,26 @@
>         Log::out() << "SETSTATE FROM FINALLY offset=" <<(int)offset << " depth=" << inState->stackDepth << ::std::endl;
>         printState(inState);
>     }
> -    StateInfo *state = hashtable[offset];
> -    assert(getStateInfo(offset) != NULL);
> -    int stackDepth = inState->stackDepth;
> +    StateInfo *state = getStateInfo(offset);
> +    assert(state);
> +    unsigned stackDepth = inState->stackDepth;
>     if (stackDepth > 0) {
>         if (maxDepth < stackDepth) maxDepth = stackDepth;
> -        Log::out() << "MAXDEPTH " << maxDepth << ::std::endl;
> +        if (Log::isEnabled()) Log::out() << "MAXDEPTH " << maxDepth << ::std::endl;
>         struct StateInfo::SlotInfo *stack = state->stack;
> -        if (stack == NULL) {
> -            // stack must be propagated from JSR to jsrNext earlier
> -            assert(0);
> -        }
> +        // stack must be propagated from JSR to jsrNext earlier
> +        assert(stack);
>         assert(state->stackDepth == stackDepth);
>         if(Log::isEnabled()) {
>             Log::out() << " before\n";
>             printState(state);
>         }
> -        for (int i=0; i < stackDepth; i++) {
> +        for (unsigned i=0; i < stackDepth; i++) {
>             struct StateInfo::SlotInfo *inSlot = &inState->stack[i];
>             struct StateInfo::SlotInfo *slot   = &stack[i];
>             Type *intype = inSlot->type;
>             Type *type  = slot->type;
> -            Log::out() << "STACK " << i << ": "<< type << ::std::endl;
> +            if (Log::isEnabled()) Log::out() << "STACK " << i << ": "<< type << ::std::endl;
>             if (!type && intype) {  // don't merge, just rewrite!
>                 slot->type      = intype;
>                 // Consider copying not pointers but SlotVat structures.
> @@ -2047,7 +1999,8 @@
>
>                         uint32 handler_offset = handler->getBeginOffset();
>                         struct StateInfo::SlotInfo *slot = &stateTable->getStateInfo(handler_offset)->stack[varIndex];
> -                        Log::out() << "HANDLER SLOT " << varIndex << " merged to offset " << handler_offset << ::std::endl;
> +                        if (Log::isEnabled()) Log::out() << "HANDLER SLOT " << varIndex
> +                            << " merged to offset " << handler_offset << ::std::endl;
>                         stateTable->mergeSlots(inSlot, slot, handler_offset, true);
>                     }
>             }
>
> Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h
> URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h?view=diff&rev=545753&r1=545752&r2=545753
> ==============================================================================
> --- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h (original)
> +++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.h Sat Jun  9 07:34:44 2007
> @@ -15,12 +15,6 @@
>  *  limitations under the License.
>  */
>
> -/**
> - * @author Intel, George A. Timoshenko
> - * @version $Revision: 1.24.12.1.4.4 $
> - *
> - */
> -
>  #ifndef _JAVALABELPREPASS_H_
>  #define _JAVALABELPREPASS_H_
>
> @@ -40,9 +34,8 @@
>
>  class VariableIncarnation : private Dlink {
>  public:
> -    VariableIncarnation(uint32 offset, uint32 block, Type*);
> +    VariableIncarnation(uint32 offset, Type*);
>     void setMultipleDefs();
> -    void ldBlock(int32 blockNumber);
>     Type* getDeclaredType();
>     void setDeclaredType(Type*);
>
> @@ -69,7 +62,6 @@
>  private:
>     friend class SlotVar;
>     int32   definingOffset;  // offset where the def was found, -1 if multiple defs
> -    int32   definingBlock;   // block  where the def was found, -1 if spans basic block
>     Type*   declaredType;
>     Opnd*   opnd;
>  };
> @@ -116,12 +108,10 @@
>     bool           isFallThroughLabel()     { return (flags & 4) != 0;     }
>     bool           isVisited()              { return (flags & 8) != 0;     }
>
> -    //
> -    // addExceptionInfo() adds both catch-blocks and handlers.
>     //     Catch-blocks should be listed in the same order as the
>     //     corresponding exception table entries were listed in byte-code. (according to VM spec)
> -    //
> -    void  addExceptionInfo(ExceptionInfo *info);
> +    void  addExceptionInfo(CatchBlock* info);
> +    void  addCatchHandler(CatchHandler* info);
>
>     struct SlotInfo {
>         Type *type;
> @@ -130,8 +120,15 @@
>         SlotVar *vars;
>         uint32 jsrLabelOffset;
>         SlotInfo() : type(NULL), varNumber(0), slotFlags(0), vars(NULL), jsrLabelOffset(0){}
> +        void setVarNumber(uint32 n) { varNumber = n;slotFlags |= VarNumberIsSet; }
>     };
>
> +    // Push type to modelled operand stack
> +    SlotInfo& push(Type *type);
> +
> +    // Obtain top slot of modelled operand stack
> +    SlotInfo& top();
> +
>     // remove all slots containing returnAddress for RET instruction with jsrNexOffset == offset
>     void cleanFinallyInfo(uint32 offset);
>
> @@ -144,47 +141,38 @@
>         StackOpndAlive = 0x10,  // the following to get rid of phi nodes in the translator
>         StackOpndSaved = 0x20   // the following to get rid of phi nodes in the translator
>     };
> -    static bool isNonNull(uint32 flags)           { return (flags & IsNonNull)            != 0; }
> -    static bool isExactType(uint32 flags)         { return (flags & IsExactType)          != 0; }
> -    static uint32 setNonNull(uint32 flags,bool val) {
> -        return (val ? (flags | IsNonNull) : (flags & ~IsNonNull));
> -    }
> -    static uint32 setExactType(uint32 flags,bool val){
> -        return (val ? (flags | IsExactType) : (flags & ~IsExactType));
> -    }
> -    static bool isStackOpndAlive(uint32 flags) {return (flags & StackOpndAlive) != 0;}
> -    static bool isStackOpndSaved(uint32 flags) {return (flags & StackOpndSaved) != 0;}
> -    static uint32 setStackOpndAlive(uint32 flags,bool val) {
> -        return (val ? (flags | StackOpndAlive) : (flags & ~StackOpndAlive));
> -    }
> -
> -    static uint32 setStackOpndSaved(uint32 flags,bool val) {
> -        return (val ? (flags | StackOpndSaved) : (flags & ~StackOpndSaved));
> -    }
>
>     static bool isVarNumberSet(struct SlotInfo s) { return (s.slotFlags & VarNumberIsSet) != 0; }
>     static bool isNonNull(struct SlotInfo s)      { return (s.slotFlags & IsNonNull)      != 0; }
>     static bool isExactType(struct SlotInfo s)    { return (s.slotFlags & IsExactType)    != 0; }
>     static bool changeState(struct SlotInfo s)    { return (s.slotFlags & ChangeState)    != 0; }
> -    static void setVarNumber(struct SlotInfo *s)   { s->slotFlags |= VarNumberIsSet; }
>     static void setNonNull(struct SlotInfo *s)     { s->slotFlags |= IsNonNull;      }
>     static void setExactType(struct SlotInfo *s)   { s->slotFlags |= IsExactType;    }
> +    static void clearExactType(struct SlotInfo *s) { s->slotFlags &= ~IsExactType;   }
>     static void setChangeState(struct SlotInfo *s) { s->slotFlags |= ChangeState;    }
> -    static void print(struct SlotInfo s, ::std::ostream& os) {
> +    static void print(SlotInfo& s, ::std::ostream& os) {
> +        Log::out() << "\ttype: ";
>         if (s.type == NULL)
> -            os << "null";
> +            os << "NULL";
>         else
>             s.type->print(os);
> -        if (isVarNumberSet(s)) os << (int)s.varNumber<< ",";
> +        if (isVarNumberSet(s)) os << " ->[" <<(int)s.varNumber<< "],";
>         if (isNonNull(s))      os << ",nn";
>         if (isExactType(s))    os << ",ex";
>         if (changeState(s))    os << ",cs";
> +        //Log::out() << ::std::endl;
> +        Log::out() << "\tvar: ";
> +        if (s.vars) {
> +            s.vars->print(Log::out());
> +        } else {
> +            Log::out() << "NULL";
> +        }
>     }
>     // add flags as needed
>     friend class JavaLabelPrepass;
>     friend class JavaByteCodeTranslator;
> -    int        flags;
> -    int        stackDepth;
> +    unsigned        flags;
> +    unsigned        stackDepth;
>     struct SlotInfo*  stack;
>     ExceptionInfo *exceptionInfo;
>  };
> @@ -244,20 +232,20 @@
>
>     // Variable information
>     VariableIncarnation* getVarInc(uint32 offset, uint32 index);
> -    VariableIncarnation* getOrCreateVarInc(uint32 offset, uint32 index, Type* type, VariableIncarnation* prev);
> +    VariableIncarnation* getOrCreateVarInc(uint32 offset, uint32 index, Type* type);
>     void                 createMultipleDefVarOpnds(IRBuilder*);
>
>     //
>     // operand stack manipulation (to keep track of state only !)
>     //
> -    struct StateInfo::SlotInfo topType();
> -    struct StateInfo::SlotInfo popType();
> +    StateInfo::SlotInfo& topType();
> +    StateInfo::SlotInfo& popType();
>     void                    popAndCheck(Type *type);
>     void                    popAndCheck(JavaVarType type);
> -    void                    pushType(struct StateInfo::SlotInfo slot);
> +    void                    pushType(StateInfo::SlotInfo& slot);
>     void                    pushType(Type *type, uint32 varNumber);
>     void                    pushType(Type *type);
> -    bool isCategory2(struct StateInfo::SlotInfo slot) { return slot.type == int64Type || slot.type == doubleType; }
> +    bool isCategory2(StateInfo::SlotInfo& slot) { return slot.type == int64Type || slot.type == doubleType; }
>
>     //
>     bool        allExceptionTypesResolved() {return problemTypeToken == MAX_UINT32;}
> @@ -549,9 +537,9 @@
>     virtual ~StateTable() {
>     }
>
> -    StateTable(MemoryManager& mm,TypeManager& tm, JavaLabelPrepass& jlp, uint32 size, uint32 numvars) :
> +    StateTable(MemoryManager& mm,TypeManager& tm, JavaLabelPrepass& jlp, uint32 numstack, uint32 numvars) :
>                memManager(mm), typeManager(tm), prepass(jlp),
> -               hashtable(mm), maxDepth(numvars), numVars(numvars)
> +               hashtable(mm), maxDepth(numvars + numstack), numVars(numvars)
>                {
>                     assert(sizeof(POINTER_SIZE_INT)>=sizeof(uint32));
>                     assert(sizeof(uint32*)>=sizeof(uint32));
> @@ -559,23 +547,28 @@
>     StateInfo *getStateInfo(uint32 offset) {
>         return hashtable[offset];
>     }
> -    StateInfo *createStateInfo(uint32 offset) {
> -        StateInfo *state = hashtable[offset]; //lookup((uint32*)(POINTER_SIZE_INT)offset);
> +    StateInfo *createStateInfo(uint32 offset, bool createStack = false) {
> +        StateInfo *state = hashtable[offset];
>         if (state == NULL) {
>             state = new (memManager) StateInfo();
>             hashtable[offset] = state;
>         }
> +        if (createStack && state->stack == NULL) {
> +            state->stack = new (memManager) StateInfo::SlotInfo[maxDepth];
> +            state->stackDepth = numVars;
> +        }
>         if(Log::isEnabled()) {
>             Log::out() << "CREATESTATE " <<(int)offset << " depth " << state->stackDepth << ::std::endl;
> -            printState(state);
> +            //printState(state);
>         }
>         return state;
>     }
>
>     void copySlotInfo(StateInfo::SlotInfo& to, StateInfo::SlotInfo& from);
> -    void  mergeSlots(StateInfo::SlotInfo* inSlot, StateInfo::SlotInfo* slot, uint32 offset, bool isVar);
> -    void  setStateInfo(StateInfo *inState, uint32 offset, bool isFallThru);
> -    void  setStateInfoFromFinally(StateInfo *inState, uint32 offset);
> +    void mergeSlots(StateInfo::SlotInfo* inSlot, StateInfo::SlotInfo* slot, uint32 offset, bool isVar);
> +    void setStackInfo(StateInfo *inState, uint32 offset, bool includeVars, bool includeStack);
> +    void setStateInfo(StateInfo *inState, uint32 offset, bool isFallThru, bool varsOnly = false);
> +    void setStateInfoFromFinally(StateInfo *inState, uint32 offset);
>
>     void restoreStateInfo(StateInfo *stateInfo, uint32 offset) {
>         if(Log::isEnabled()) {
> @@ -586,7 +579,7 @@
>         assert(state != NULL && (state->stack || state->stackDepth==0));
>         stateInfo->flags      = state->flags;
>         stateInfo->stackDepth = state->stackDepth;
> -        for (int i=0; i < stateInfo->stackDepth; i++)
> +        for (unsigned i=0; i < stateInfo->stackDepth; i++)
>             stateInfo->stack[i] = state->stack[i];
>         stateInfo->exceptionInfo = state->exceptionInfo;
>         for (ExceptionInfo *except = stateInfo->exceptionInfo; except != NULL;
> @@ -597,12 +590,9 @@
>                 for (CatchHandler *handler = block->getHandlers(); handler != NULL;
>                      handler = handler->getNextHandler()) {
>                     int cstart = handler->getBeginOffset();
> -                    Log::out() << "SETCATCHINFO "<<(int)cstart<<" "<<(int)prepass.getNumVars()<< ::std::endl;
> +                    if (Log::isEnabled()) Log::out() << "SETCATCHINFO "<<(int)cstart<<" "<<(int)numVars<< ::std::endl;
>                     prepass.pushCatchLabel(cstart);
> -                    int stackDepth = stateInfo->stackDepth;
> -                    stateInfo->stackDepth = prepass.getNumVars();
> -                    setStateInfo(stateInfo,cstart,false);
> -                    stateInfo->stackDepth = stackDepth;
> +                    setStateInfo(stateInfo,cstart,false,true);
>                 }
>             }
>         }
> @@ -612,17 +602,10 @@
>     void printState(StateInfo *state) {
>         if (state == NULL) return;
>         struct StateInfo::SlotInfo *stack = state->stack;
> -        for (int i=0; i < state->stackDepth; i++) {
> +        for (unsigned i=0; i < state->stackDepth; i++) {
>             Log::out() << "STACK " << i << ":";
>             StateInfo::print(stack[i],Log::out());
>             Log::out() << ::std::endl;
> -            Log::out() << "        var: ";
> -            if (stack[i].vars) {
> -                stack[i].vars->print(Log::out());
> -            } else {
> -                Log::out() << "null";
> -            }
> -            Log::out() << ::std::endl;
>         }
>     }
>  protected:
> @@ -638,8 +621,8 @@
>     TypeManager& typeManager;
>     JavaLabelPrepass& prepass;
>     StlHashMap<uint32, StateInfo*> hashtable;
> -    int maxDepth;
> -    int numVars;
> +    unsigned maxDepth;
> +    unsigned numVars;
>  };
>
>  #endif // _JAVALABELPREPASS_H_
>
>
>


-- 
With best regards,
Alexei,
ESSD, Intel

Mime
View raw message