< prev index next >

src/hotspot/share/runtime/stackValue.hpp

Print this page

  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_RUNTIME_STACKVALUE_HPP
 26 #define SHARE_RUNTIME_STACKVALUE_HPP
 27 

 28 #include "code/location.hpp"

 29 #include "runtime/handles.hpp"
 30 
 31 class BasicLock;
 32 class RegisterMap;
 33 class ScopeValue;
 34 
 35 class StackValue : public ResourceObj {
 36  private:
 37   BasicType _type;
 38   intptr_t  _integer_value; // Blank java stack slot value
 39   Handle    _handle_value;  // Java stack slot value interpreted as a Handle
 40  public:
 41 
 42   StackValue(intptr_t value) {
 43     _type              = T_INT;
 44     _integer_value     = value;
 45   }
 46 
 47   StackValue(Handle value, intptr_t scalar_replaced = 0) {
 48     _type                = T_OBJECT;
 49     _integer_value       = scalar_replaced;
 50     _handle_value        = value;
 51     assert(_integer_value == 0 ||  _handle_value.is_null(), "not null object should not be marked as scalar replaced");
 52   }
 53 

 90   }
 91 
 92   void set_int(intptr_t value) {
 93     assert(type() == T_INT, "type check");
 94     _integer_value = value;
 95   }
 96 
 97   BasicType type() const { return  _type; }
 98 
 99   bool equal(StackValue *value) {
100     if (_type != value->_type) return false;
101     if (_type == T_OBJECT)
102       return (_handle_value == value->_handle_value);
103     else {
104       assert(_type == T_INT, "sanity check");
105       // [phh] compare only low addressed portions of intptr_t slots
106       return (*(int *)&_integer_value == *(int *)&value->_integer_value);
107     }
108   }
109 
110   static StackValue* create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
111   static BasicLock*  resolve_monitor_lock(const frame* fr, Location location);
112 

































113 #ifndef PRODUCT
114  public:
115   // Printing
116   void print_on(outputStream* st) const;
117 #endif




118 };
119 
120 #endif // SHARE_RUNTIME_STACKVALUE_HPP

  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_RUNTIME_STACKVALUE_HPP
 26 #define SHARE_RUNTIME_STACKVALUE_HPP
 27 
 28 #include "code/debugInfo.hpp"
 29 #include "code/location.hpp"
 30 #include "oops/instanceStackChunkKlass.inline.hpp"
 31 #include "runtime/handles.hpp"
 32 
 33 class BasicLock;
 34 class RegisterMap;

 35 
 36 class StackValue : public ResourceObj {
 37  private:
 38   BasicType _type;
 39   intptr_t  _integer_value; // Blank java stack slot value
 40   Handle    _handle_value;  // Java stack slot value interpreted as a Handle
 41  public:
 42 
 43   StackValue(intptr_t value) {
 44     _type              = T_INT;
 45     _integer_value     = value;
 46   }
 47 
 48   StackValue(Handle value, intptr_t scalar_replaced = 0) {
 49     _type                = T_OBJECT;
 50     _integer_value       = scalar_replaced;
 51     _handle_value        = value;
 52     assert(_integer_value == 0 ||  _handle_value.is_null(), "not null object should not be marked as scalar replaced");
 53   }
 54 

 91   }
 92 
 93   void set_int(intptr_t value) {
 94     assert(type() == T_INT, "type check");
 95     _integer_value = value;
 96   }
 97 
 98   BasicType type() const { return  _type; }
 99 
100   bool equal(StackValue *value) {
101     if (_type != value->_type) return false;
102     if (_type == T_OBJECT)
103       return (_handle_value == value->_handle_value);
104     else {
105       assert(_type == T_INT, "sanity check");
106       // [phh] compare only low addressed portions of intptr_t slots
107       return (*(int *)&_integer_value == *(int *)&value->_integer_value);
108     }
109   }
110 

111   static BasicLock*  resolve_monitor_lock(const frame* fr, Location location);
112 
113   template<typename RegisterMapT>
114   static StackValue* create_stack_value(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
115     return create_stack_value(sv, stack_value_address(fr, reg_map, sv), reg_map);
116   }
117 
118   template<typename RegisterMapT>
119   static address stack_value_address(const frame* fr, const RegisterMapT* reg_map, ScopeValue* sv) {
120     if (!sv->is_location())
121       return NULL;
122     Location loc = ((LocationValue *)sv)->location();
123     if (loc.type() == Location::invalid)
124       return NULL;
125     
126     address value_addr;
127     if (!reg_map->in_cont()) {
128       value_addr = loc.is_register()
129           // Value was in a callee-save register
130           ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()), fr->sp())
131           // Else value was directly saved on the stack. The frame's original stack pointer,
132           // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
133           : ((address)fr->unextended_sp()) + loc.stack_offset();
134 
135       assert(value_addr == NULL || reg_map->thread() == NULL || reg_map->thread()->is_in_usable_stack(value_addr), INTPTR_FORMAT, p2i(value_addr));
136     } else {
137       value_addr = loc.is_register()
138           ? reg_map->as_RegisterMap()->stack_chunk()->reg_to_location(*fr, reg_map->as_RegisterMap(), VMRegImpl::as_VMReg(loc.register_number()))
139           : reg_map->as_RegisterMap()->stack_chunk()->usp_offset_to_location(*fr, loc.stack_offset());
140         
141       assert(value_addr == NULL || Continuation::is_in_usable_stack(value_addr, reg_map->as_RegisterMap()) || (reg_map->thread() != NULL && reg_map->thread()->is_in_usable_stack(value_addr)), INTPTR_FORMAT, p2i(value_addr));
142     }
143     return value_addr;
144   }
145 
146 #ifndef PRODUCT
147  public:
148   // Printing
149   void print_on(outputStream* st) const;
150 #endif
151 
152 private:
153   template<typename RegisterMapT>
154   static StackValue* create_stack_value(ScopeValue* sv, address value_addr, const RegisterMapT* reg_map);
155 };
156 
157 #endif // SHARE_RUNTIME_STACKVALUE_HPP
< prev index next >