/* * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// 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 ist noch experimentell.