< prev index next >

src/hotspot/share/runtime/registerMap.hpp

Print this page




   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_RUNTIME_REGISTERMAP_HPP
  26 #define SHARE_RUNTIME_REGISTERMAP_HPP
  27 
  28 #include "code/vmreg.hpp"

  29 #include "utilities/globalDefinitions.hpp"
  30 #include "utilities/macros.hpp"
  31 
  32 class JavaThread;
  33 
  34 //
  35 // RegisterMap
  36 //
  37 // A companion structure used for stack traversal. The RegisterMap contains
  38 // misc. information needed in order to do correct stack traversal of stack
  39 // frames.  Hence, it must always be passed in as an argument to
  40 // frame::sender(RegisterMap*).
  41 //
  42 // In particular,
  43 //   1) It provides access to the thread for which the stack belongs.  The
  44 //      thread object is needed in order to get sender of a deoptimized frame.
  45 //
  46 //   2) It is used to pass information from a callee frame to its caller
  47 //      frame about how the frame should be traversed.  This is used to let
  48 //      the caller frame take care of calling oops-do of out-going


  56 //   3) The RegisterMap keeps track of the values of callee-saved registers
  57 //      from frame to frame (hence, the name).  For some stack traversal the
  58 //      values of the callee-saved registers does not matter, e.g., if you
  59 //      only need the static properties such as frame type, pc, and such.
  60 //      Updating of the RegisterMap can be turned off by instantiating the
  61 //      register map as: RegisterMap map(thread, false);
  62 
  63 class RegisterMap : public StackObj {
  64  public:
  65     typedef julong LocationValidType;
  66   enum {
  67     reg_count = ConcreteRegisterImpl::number_of_registers,
  68     location_valid_type_size = sizeof(LocationValidType)*8,
  69     location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size
  70   };
  71  private:
  72   intptr_t*    _location[reg_count];    // Location of registers (intptr_t* looks better than address in the debugger)
  73   LocationValidType _location_valid[location_valid_size];
  74   bool        _include_argument_oops;   // Should include argument_oop marked locations for compiler
  75   JavaThread* _thread;                  // Reference to current thread




  76   bool        _update_map;              // Tells if the register map need to be
  77                                         // updated when traversing the stack




  78 
  79 #ifdef ASSERT
  80   void check_location_valid();
  81 #else
  82   void check_location_valid() {}
  83 #endif
  84 
  85  public:
  86   debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame
  87   RegisterMap(JavaThread *thread, bool update_map = true);
  88   RegisterMap(const RegisterMap* map);
  89 
  90   address location(VMReg reg) const {
  91     int index = reg->value() / location_valid_type_size;
  92     assert(0 <= reg->value() && reg->value() < reg_count, "range check");
  93     assert(0 <= index && index < location_valid_size, "range check");
  94     if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) {
  95       return (address) _location[reg->value()];
  96     } else {
  97       return pd_location(reg);
  98     }
  99   }
 100 










 101   void set_location(VMReg reg, address loc) {
 102     int index = reg->value() / location_valid_type_size;
 103     assert(0 <= reg->value() && reg->value() < reg_count, "range check");
 104     assert(0 <= index && index < location_valid_size, "range check");
 105     assert(_update_map, "updating map that does not need updating");
 106     _location[reg->value()] = (intptr_t*) loc;
 107     _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size));
 108     check_location_valid();
 109   }
 110 
 111   // Called by an entry frame.
 112   void clear();
 113 
 114   bool include_argument_oops() const      { return _include_argument_oops; }
 115   void set_include_argument_oops(bool f)  { _include_argument_oops = f; }
 116 
 117   JavaThread *thread() const { return _thread; }
 118   bool update_map()    const { return _update_map; }













 119 
 120   void print_on(outputStream* st) const;
 121   void print() const;







 122 
 123   // the following contains the definition of pd_xxx methods
 124 #include CPU_HEADER(registerMap)
 125 
 126 };
 127 
 128 #endif // SHARE_RUNTIME_REGISTERMAP_HPP


   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_RUNTIME_REGISTERMAP_HPP
  26 #define SHARE_RUNTIME_REGISTERMAP_HPP
  27 
  28 #include "code/vmreg.hpp"
  29 #include "runtime/handles.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 class JavaThread;
  34 
  35 //
  36 // RegisterMap
  37 //
  38 // A companion structure used for stack traversal. The RegisterMap contains
  39 // misc. information needed in order to do correct stack traversal of stack
  40 // frames.  Hence, it must always be passed in as an argument to
  41 // frame::sender(RegisterMap*).
  42 //
  43 // In particular,
  44 //   1) It provides access to the thread for which the stack belongs.  The
  45 //      thread object is needed in order to get sender of a deoptimized frame.
  46 //
  47 //   2) It is used to pass information from a callee frame to its caller
  48 //      frame about how the frame should be traversed.  This is used to let
  49 //      the caller frame take care of calling oops-do of out-going


  57 //   3) The RegisterMap keeps track of the values of callee-saved registers
  58 //      from frame to frame (hence, the name).  For some stack traversal the
  59 //      values of the callee-saved registers does not matter, e.g., if you
  60 //      only need the static properties such as frame type, pc, and such.
  61 //      Updating of the RegisterMap can be turned off by instantiating the
  62 //      register map as: RegisterMap map(thread, false);
  63 
  64 class RegisterMap : public StackObj {
  65  public:
  66     typedef julong LocationValidType;
  67   enum {
  68     reg_count = ConcreteRegisterImpl::number_of_registers,
  69     location_valid_type_size = sizeof(LocationValidType)*8,
  70     location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size
  71   };
  72  private:
  73   intptr_t*    _location[reg_count];    // Location of registers (intptr_t* looks better than address in the debugger)
  74   LocationValidType _location_valid[location_valid_size];
  75   bool        _include_argument_oops;   // Should include argument_oop marked locations for compiler
  76   JavaThread* _thread;                  // Reference to current thread
  77   Handle      _cont;                    // The current continuation, if any
  78   bool        _on_hstack;               // Whether we're on the h-stack
  79   intptr_t**  _last_vstack_fp;          // The location of the continuation entry frame's fp when walking h-stacks
  80 
  81   bool        _update_map;              // Tells if the register map need to be
  82                                         // updated when traversing the stack
  83   bool        _validate_oops;           // whether to perform valid oop checks in asserts -- used only in the map use for continuation freeze/thaw
  84   bool        _walk_cont;               // whether to walk frames on a continuation stack
  85 
  86   DEBUG_ONLY(bool  _skip_missing;)     
  87 
  88 #ifdef ASSERT
  89   void check_location_valid();
  90 #else
  91   void check_location_valid() {}
  92 #endif
  93 
  94  public:
  95   DEBUG_ONLY(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame
  96   RegisterMap(JavaThread *thread, bool update_map = true, bool walk_cont = false, bool validate_oops = true);
  97   RegisterMap(const RegisterMap* map);
  98 
  99   address location(VMReg reg) const {
 100     int index = reg->value() / location_valid_type_size;
 101     assert(0 <= reg->value() && reg->value() < reg_count, "range check");
 102     assert(0 <= index && index < location_valid_size, "range check");
 103     if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) {
 104       return (address) _location[reg->value()];
 105     } else {
 106       return pd_location(reg);
 107     }
 108   }
 109 
 110   address trusted_location(VMReg reg) const {
 111     return (address) _location[reg->value()];
 112   }
 113 
 114   void verify(RegisterMap& other) {
 115     for (int i = 0; i < reg_count; ++i) {
 116       assert(_location[i] == other._location[i], "");
 117     }
 118   }
 119 
 120   void set_location(VMReg reg, address loc) {
 121     int index = reg->value() / location_valid_type_size;
 122     assert(0 <= reg->value() && reg->value() < reg_count, "range check");
 123     assert(0 <= index && index < location_valid_size, "range check");
 124     assert(!_validate_oops || _update_map, "updating map that does not need updating");
 125     _location[reg->value()] = (intptr_t*) loc;
 126     _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size));
 127     check_location_valid();
 128   }
 129 
 130   // Called by an entry frame.
 131   void clear();
 132 
 133   bool include_argument_oops() const      { return _include_argument_oops; }
 134   void set_include_argument_oops(bool f)  { _include_argument_oops = f; }
 135 
 136   JavaThread *thread() const { return _thread; }
 137   bool update_map()    const { return _update_map; }
 138   bool validate_oops() const { return _validate_oops; }
 139   bool walk_cont()     const { return _walk_cont; }
 140 
 141   bool in_cont()       const { return _on_hstack; } // Whether we are currently on the hstack
 142   oop  cont()          const { return _cont(); }
 143   void set_cont(oop cont);
 144   void set_cont(Handle cont);
 145   void set_in_cont(bool on_hstack);
 146   intptr_t** last_vstack_fp()            { return _last_vstack_fp; }
 147   void set_last_vstack_fp(intptr_t** fp) { _last_vstack_fp = fp; }
 148 
 149   const RegisterMap* as_RegisterMap() const { return this; }
 150   RegisterMap* as_RegisterMap() { return this; }
 151 
 152   void print_on(outputStream* st) const;
 153   void print() const;
 154 
 155 #ifdef ASSERT
 156   void set_skip_missing(bool value) { _skip_missing = value; }
 157   bool should_skip_missing() const  { return _skip_missing; }
 158 
 159   VMReg find_register_spilled_here(void* p);
 160 #endif
 161 
 162   // the following contains the definition of pd_xxx methods
 163 #include CPU_HEADER(registerMap)
 164 
 165 };
 166 
 167 #endif // SHARE_RUNTIME_REGISTERMAP_HPP
< prev index next >