tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kin-Man Chung <Kin-Man.Ch...@Eng.Sun.COM>
Subject Re: [PATCH] Re: [PROPOSAL] Modification of the code generated by Jasper2
Date Fri, 17 May 2002 00:41:26 GMT
Denis,

First let me mention a couple of improvements over the existing codes
that was generated for flattening out the try/catch block.  See if
you agree with me.

1. I notice the following code pattern that is now generated.

        bitmask.set(1);
        addTagToVector(tags, 1, new Integer(_jspx_eval_eg_foo_0));
        if (_jspx_eval_eg_foo_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUD
E) {
          out = pageContext.pushBody();
          _jspx_th_eg_foo_0.setBodyContent((javax.servlet.jsp.tagext.BodyContent
) out);
          _jspx_th_eg_foo_0.doInitBody();
        }

and from finallies:

    if (bitmask.get(1)) {
      if (((Integer)tags.elementAt(1)).intValue() != javax.servlet.jsp.tagext.Ta
g.EVAL_BODY_INCLUDE)
        out = pageContext.popBody();
    }

I notice that the code "bitmask.set(1);" is there just for popBody, so
if we move it to inside the test that do pushBody, then we don't need
to do the test in the finallies.  See the codes below.

        addTagToVector(tags, 1, new Integer(_jspx_eval_eg_foo_0));
        if (_jspx_eval_eg_foo_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUD
E) {
          bitmask.set(1);
          out = pageContext.pushBody();
          _jspx_th_eg_foo_0.setBodyContent((javax.servlet.jsp.tagext.BodyContent
) out);
          _jspx_th_eg_foo_0.doInitBody();
        }

and in finallies:

    if (bitmask.get(1)) {
        out = pageContext.popBody();
    }

Maybe you don't need to change the argument for addTagToVector afterall!

2. We don't really need to call finallies if there is no exceptions, so
the call to finallies can be placed in a catch block instead of a finally
block.  This would save us time to check for all the bits that have been
cleared, under normal execution.


Now you mentioned the use of an array to hold tag objects, I have
another idea.  Why don't we use a stack to simulate the runtime state?
Each stack entry would have a tag object and a state.  State 0 means
call release() only, and state 1 means call popBody() and then release().
We push an entry onto the stack when we enter a tag body, and pop it
when we exit the body.  We change the state on the stack top when we do
a pushBody.  When an exception is thrown, we just need to pop the entries
from the stack to decide what to do.  For efficiency, we can use an
array to simulate the stack, and its size would be the number of nesting
of the tags.

I think this is quite simple and faster.  What do you think?



--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message