jengebr opened a new pull request, #842:
URL: https://github.com/apache/tomcat/pull/842
Enables optimized, non-standard behavior for the most common JSP tags, when
configured to do so.
**Unit tests pending**
**Off by default.**
When activated, the code generation to call `c:set` and/or `c:remove` is
drastically reduced (samples follow). When not activated or when the specific
case is not supported, code generation falls back to the existing standard
behavior. Value comes from:
1. Reduced Object allocation and eventual GC
2. Fewer method calls (setters, start and end tag, recycle tag)
3. Elimination of try/finally
4. No branching by the caller
5. Smaller .java and .class files
So far this supports only basic cases, but they are approximately 25% of of
the tags in my application.
1. `c:set` with `var` and `value`, optional `scope`, no body
7. `c:remove` with `var`, optional `scope`, no body
The nonstandard generated code looks like this:
```
private void _jspx_meth_c_005fset_005f125(javax.servlet.jsp.PageContext
_jspx_page_context)
throws java.lang.Throwable {
_jspx_page_context.setAttribute("groupName", new
org.apache.jasper.el.JspValueExpression("/WEB-INF/views/jsp/features/buybox/offerDisplayGroupLayout.jsp(235,12)
'${tabContents.keySet().toArray()[0]}'",_jsp_getExpressionFactory().createValueExpression(_jspx_page_context.getELContext(),"${tabContents.keySet().toArray()[0]}",java.lang.Object.class)).getValue(_jspx_page_context.getELContext()),
javax.servlet.jsp.PageContext.PAGE_SCOPE);
}
```
The standard generated code looks like this:
```
private boolean
_jspx_meth_c_005fset_005f39(javax.servlet.jsp.tagext.JspTag
_jspx_th_c_005fwhen_005f11, javax.servlet.jsp.PageContext _jspx_page_context)
throws java.lang.Throwable {
javax.servlet.jsp.PageContext pageContext = _jspx_page_context;
javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut();
// c:set
org.apache.taglibs.standard.tag.rt.core.SetTag _jspx_th_c_005fset_005f39
= new org.apache.taglibs.standard.tag.rt.core.SetTag();
_jsp_getInstanceManager().newInstance(_jspx_th_c_005fset_005f39);
try {
_jspx_th_c_005fset_005f39.setPageContext(_jspx_page_context);
_jspx_th_c_005fset_005f39.setParent((javax.servlet.jsp.tagext.Tag)
_jspx_th_c_005fwhen_005f11);
//
/WEB-INF/views/jsp/features/buybox/offerDisplayGroupLayout.jsp(230,12) name =
var type = java.lang.String reqTime = false required = false fragment = false
deferredValue = false expectedTypeName = null deferredMethod = false
methodSignature = null
_jspx_th_c_005fset_005f39.setVar("groupName");
//
/WEB-INF/views/jsp/features/buybox/offerDisplayGroupLayout.jsp(230,12) name =
value type = javax.el.ValueExpression reqTime = true required = false fragment
= false deferredValue = true expectedTypeName = java.lang.Object deferredMethod
= false methodSignature = null
_jspx_th_c_005fset_005f39.setValue(new
org.apache.jasper.el.JspValueExpression("/WEB-INF/views/jsp/features/buybox/offerDisplayGroupLayout.jsp(230,12)
'${tabContents.keySet().toArray()[0]}'",_jsp_getExpressionFactory().createValueExpression(_jspx_page_context.getELContext(),"${tabContents.keySet().toArray()[0]}",java.lang.Object.class)).getValue(_jspx_page_context.getELContext()));
int _jspx_eval_c_005fset_005f39 =
_jspx_th_c_005fset_005f39.doStartTag();
if (_jspx_th_c_005fset_005f39.doEndTag() ==
javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
return true;
}
} finally {
org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005fset_005f39,
_jsp_getInstanceManager(), false);
}
return false;
}
```
Caller code is also modified to eliminate the boolean check:
```
if (_jspx_meth_c_005fset_005f39(_jspx_th_c_005fwhen_005f11,
_jspx_page_context))
return true;
```
```
_jspx_meth_c_005fset_005f125(_jspx_page_context);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]