// This code has been converted from the 1.1E java virtual machine // Thanks to the JavaTopics group for using the code
class ChangeItem;
// Callback object for code relocations class RelocatorListener : public StackObj { public: virtualvoid relocated(int bci, int delta, int new_method_size) = 0;
};
class Relocator : public ResourceObj { public:
Relocator(const methodHandle& method, RelocatorListener* listener);
methodHandle insert_space_at(int bci, int space, u_char inst_buffer[], TRAPS);
// Callbacks from ChangeItem's bool handle_code_changes(); bool handle_widen (int bci, int new_ilen, u_char inst_buffer[]); // handles general instructions void push_jump_widen (int bci, int delta, int new_delta); // pushes jumps bool handle_jump_widen (int bci, int delta); // handles jumps bool handle_switch_pad (int bci, int old_pad, bool is_lookup_switch); // handles table and lookup switches
private: unsignedchar* _code_array; int _code_array_length; int _code_length; unsignedchar* _compressed_line_number_table; int _compressed_line_number_table_size;
methodHandle _method;
u_char _overwrite[3]; // stores overwritten bytes for shrunken instructions
// This will return a raw bytecode, which is possibly rewritten.
Bytecodes::Code code_at(int bci) const { return (Bytecodes::Code) code_array()[bci]; } void code_at_put(int bci, Bytecodes::Code code) { code_array()[bci] = (char) code; }
// get and set signed integers in the code_array inlineint int_at(int bci) const { return Bytes::get_Java_u4(&code_array()[bci]); } inlinevoid int_at_put(int bci, int value) { Bytes::put_Java_u4(&code_array()[bci], value); }
// get and set signed shorts in the code_array inlineshort short_at(int bci) const { return (short)Bytes::get_Java_u2(&code_array()[bci]); } inlinevoid short_at_put(int bci, short value) { Bytes::put_Java_u2((address) &code_array()[bci], value); }
// get the address of in the code_array inlinechar* addr_at(int bci) const { return (char*) &code_array()[bci]; }
int instruction_length_at(int bci) { return Bytecodes::length_at(NULL, code_array() + bci); }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.