compute_stack_effects() is called in add_safepoint_edges(). In debug build, C2 invokes it for almost all bytecodes in Parse::do_one_block().
There are 2 places that we can optimize it.
1. rsize is not used by many bytecodes. we could use a lambda to wrap it up. only evaluate the lambda on demand.
here is the code snippet.
BasicType rtype = T_ILLEGAL;
int rsize = 0;
if (code != Bytecodes::_illegal) {
depth = Bytecodes::depth(code); // checkcast=0, athrow=-1
rtype = Bytecodes::result_type(code); // checkcast=P, athrow=V
if (rtype < T_CONFLICT)
rsize = type2size[rtype];
}
it requires 2 loads and 2 comparisons every time. We will skip the computation if it is not in use and 2 loads and 1 comparison when it's used.
2. we could leverage assertion to skip computation.
if asserts that resize is -depth, we could use it directly
assert(rsize == -depth, "");
inputs = rsize;
There are 2 places that we can optimize it.
1. rsize is not used by many bytecodes. we could use a lambda to wrap it up. only evaluate the lambda on demand.
here is the code snippet.
BasicType rtype = T_ILLEGAL;
int rsize = 0;
if (code != Bytecodes::_illegal) {
depth = Bytecodes::depth(code); // checkcast=0, athrow=-1
rtype = Bytecodes::result_type(code); // checkcast=P, athrow=V
if (rtype < T_CONFLICT)
rsize = type2size[rtype];
}
it requires 2 loads and 2 comparisons every time. We will skip the computation if it is not in use and 2 loads and 1 comparison when it's used.
2. we could leverage assertion to skip computation.
if asserts that resize is -depth, we could use it directly
assert(rsize == -depth, "");
inputs = rsize;