Bytecode Instrumentation
| 2004 JavaOne
SM
Conference | Session 3042 Copyright Hewlett Packard Co., 2004.
27
static ByteOffset
injection_template(MethodImage *mi,
ByteCode *bytecodes,
ByteOffset max_nbytes,
CrwCpoolIndex method_index)
{
max_stack = mi->max_stack + 2;
nbytes += push_pool_constant_bytecodes(
bytecodes+nbytes, ci->class_num
ber_index);
nbytes += push_short_constant_bytecodes(
bytecodes+nbytes, mi->num
ber);
bytecodes[nbytes++] = (ByteCode)opc_invokestatic;
bytecodes[nbytes++] = (ByteCode)(method_index >> 8);
bytecodes[nbytes++] = (ByteCode)method_index;
bytecodes[nbytes] = 0;
/* Check max stack value */
if ( max_stack > mi->new_max_stack ) {
mi->new_max_stack = max_stack;
}
Generating the bytecodes