src/share/vm/runtime/relocator.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 















  25 // This code has been converted from the 1.1E java virtual machine
  26 // Thanks to the JavaTopics group for using the code
  27 
  28 class ChangeItem;
  29 
  30 // Callback object for code relocations
  31 class RelocatorListener : public StackObj {
  32  public:
  33   RelocatorListener() {};
  34   virtual void relocated(int bci, int delta, int new_method_size) = 0;
  35 };
  36 
  37 
  38 class Relocator : public ResourceObj {
  39  public:
  40   Relocator(methodHandle method, RelocatorListener* listener);
  41   methodHandle insert_space_at(int bci, int space, u_char inst_buffer[], TRAPS);
  42 
  43   // Callbacks from ChangeItem's
  44   bool handle_code_changes();


 100 
 101   // basic relocation methods
 102   bool relocate_code         (int bci, int ilen, int delta);
 103   void change_jumps          (int break_bci, int delta);
 104   void change_jump           (int bci, int offset, bool is_short, int break_bci, int delta);
 105   void adjust_exception_table(int bci, int delta);
 106   void adjust_line_no_table  (int bci, int delta);
 107   void adjust_local_var_table(int bci, int delta);
 108   void adjust_stack_map_table(int bci, int delta);
 109   int  get_orig_switch_pad   (int bci, bool is_lookup_switch);
 110   int  rc_instr_len          (int bci);
 111   bool expand_code_array     (int delta);
 112 
 113   // Callback support
 114   RelocatorListener *_listener;
 115   void notify(int bci, int delta, int new_code_length) {
 116     if (_listener != NULL)
 117       _listener->relocated(bci, delta, new_code_length);
 118   }
 119 };


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_RELOCATOR_HPP
  26 #define SHARE_VM_RUNTIME_RELOCATOR_HPP
  27 
  28 #include "interpreter/bytecodes.hpp"
  29 #include "oops/methodOop.hpp"
  30 #ifdef TARGET_ARCH_x86
  31 # include "bytes_x86.hpp"
  32 #endif
  33 #ifdef TARGET_ARCH_sparc
  34 # include "bytes_sparc.hpp"
  35 #endif
  36 #ifdef TARGET_ARCH_zero
  37 # include "bytes_zero.hpp"
  38 #endif
  39 
  40 // This code has been converted from the 1.1E java virtual machine
  41 // Thanks to the JavaTopics group for using the code
  42 
  43 class ChangeItem;
  44 
  45 // Callback object for code relocations
  46 class RelocatorListener : public StackObj {
  47  public:
  48   RelocatorListener() {};
  49   virtual void relocated(int bci, int delta, int new_method_size) = 0;
  50 };
  51 
  52 
  53 class Relocator : public ResourceObj {
  54  public:
  55   Relocator(methodHandle method, RelocatorListener* listener);
  56   methodHandle insert_space_at(int bci, int space, u_char inst_buffer[], TRAPS);
  57 
  58   // Callbacks from ChangeItem's
  59   bool handle_code_changes();


 115 
 116   // basic relocation methods
 117   bool relocate_code         (int bci, int ilen, int delta);
 118   void change_jumps          (int break_bci, int delta);
 119   void change_jump           (int bci, int offset, bool is_short, int break_bci, int delta);
 120   void adjust_exception_table(int bci, int delta);
 121   void adjust_line_no_table  (int bci, int delta);
 122   void adjust_local_var_table(int bci, int delta);
 123   void adjust_stack_map_table(int bci, int delta);
 124   int  get_orig_switch_pad   (int bci, bool is_lookup_switch);
 125   int  rc_instr_len          (int bci);
 126   bool expand_code_array     (int delta);
 127 
 128   // Callback support
 129   RelocatorListener *_listener;
 130   void notify(int bci, int delta, int new_code_length) {
 131     if (_listener != NULL)
 132       _listener->relocated(bci, delta, new_code_length);
 133   }
 134 };
 135 
 136 #endif // SHARE_VM_RUNTIME_RELOCATOR_HPP