db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject Re: Any ideas for debugging a byte code generation problem
Date Sun, 20 Mar 2005 09:58:37 GMT
Kathey Marsden wrote:

>    1) As I mentioned I am actually working  on an older release of
>Cloudscape so don't have the changes ported to Derby that I talk about
>in the notes so can't post them here right now, but wanted to get as
>much community input as possible as some sort of solution will need to
>come to Derby.
Let me put this code here too which would go in BCMethod. It iis for the
automatic detection of zero arg method overflows which took care of the
constructor problem.  It would be really nice if we could find a
solution like this for all methods. instead of the having the checks in
the language layer.   The problem is it doesn't work if the stackDepth
is not 0 and even though it could be tweaked for stack depth 1 that does
not appear to be the case for fillResultSet.

There are checks in callMethod and endstatement like this.
if (stackDepth == 0)

// check to see if the method is getting close to the
    // limt and if required overflow to a another method.
    // Currently only called if the stackDepth is zero.
    private void overflowMethodCheck()
        if (handlingOverflow)
        // don't sub method in the middle of a conditional
        if (condition != null)
        int currentCodeSize = myCode.getRelativePC();
        if (currentCodeSize < 55000)
        // only handle no-arg methods at the moment.
        if (parameters != null)
            if (parameters.length != 0)
        int modifiers = myEntry.getModifier();
        // too lazy to handle static methods.
        if ((modifiers & Modifier.STATIC) != 0)
        // System.out.println("NEED TO SPLIT " + myName + "  " +
        String subMethodName = myName + "_sub" +
        BCMethod subMethod = (BCMethod)
                myReturnType, subMethodName);
        subMethod.thrownExceptions = this.thrownExceptions;
        // stop any recursion
        handlingOverflow = true;
        // in this method make a call to the sub method we will
        // be transferring control to.
        this.callMethod(VMOpcode.INVOKEVIRTUAL, (String) null,
subMethodName, myReturnType, 0);
        // and return its value, works just as well for a void method!
        handlingOverflow = false;
        // now the tricky bit, make this object take over the
        // code etc. from the sub method. This is done so
        // that any code that has a reference to this MethodBuilder
        // will continue to work. They will be writing code into the
        // new sub method.
        this.myEntry = subMethod.myEntry;
        this.myCode = subMethod.myCode;
        this.currentVarNum = subMethod.currentVarNum;
        this.statementNum = subMethod.statementNum;
        // copy stack info
        this.stackTypes = subMethod.stackTypes;
        this.stackTypeOffset = subMethod.stackTypeOffset;
        this.maxStack = subMethod.maxStack;
        this.stackDepth = subMethod.stackDepth;

View raw message