< prev index next >

src/hotspot/share/runtime/stackValue.cpp

Print this page

  1 /*
  2  * Copyright (c) 1997, 2023, 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  *

276   if (!reg_map->in_cont()) {
277     address value_addr = loc.is_register()
278       // Value was in a callee-save register
279       ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()), fr->sp())
280       // Else value was directly saved on the stack. The frame's original stack pointer,
281       // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
282       : ((address)fr->unextended_sp()) + loc.stack_offset();
283 
284     assert(value_addr == nullptr || reg_map->thread() == nullptr || reg_map->thread()->is_in_usable_stack(value_addr), INTPTR_FORMAT, p2i(value_addr));
285     return value_addr;
286   }
287 
288   address value_addr = loc.is_register()
289     ? reg_map->as_RegisterMap()->stack_chunk()->reg_to_location(*fr, reg_map->as_RegisterMap(), VMRegImpl::as_VMReg(loc.register_number()))
290     : reg_map->as_RegisterMap()->stack_chunk()->usp_offset_to_location(*fr, loc.stack_offset());
291 
292   assert(value_addr == nullptr || Continuation::is_in_usable_stack(value_addr, reg_map->as_RegisterMap()) || (reg_map->thread() != nullptr && reg_map->thread()->is_in_usable_stack(value_addr)), INTPTR_FORMAT, p2i(value_addr));
293   return value_addr;
294 }
295 
296 BasicLock* StackValue::resolve_monitor_lock(const frame* fr, Location location) {
297   assert(location.is_stack(), "for now we only look at the stack");
298   int word_offset = location.stack_offset() / wordSize;
299   // (stack picture)
300   // high: [     ]  word_offset + 1
301   // low   [     ]  word_offset
302   //
303   // sp->  [     ]  0
304   // the word_offset is the distance from the stack pointer to the lowest address
305   // The frame's original stack pointer, before any extension by its callee
306   // (due to Compiler1 linkage on SPARC), must be used.
307   return (BasicLock*) (fr->unextended_sp() + word_offset);
308 }
309 
310 
311 #ifndef PRODUCT
312 
313 void StackValue::print_on(outputStream* st) const {
314   switch(_type) {
315     case T_INT:
316       st->print("%d (int) %f (float) %x (hex)",  *(int *)&_integer_value, *(float *)&_integer_value,  *(int *)&_integer_value);
317       break;
318 
319     case T_OBJECT:
320       if (_handle_value() != nullptr) {
321         _handle_value()->print_value_on(st);
322       } else {
323         st->print("null");
324       }
325       st->print(" <" INTPTR_FORMAT ">", p2i(_handle_value()));
326       break;
327 

  1 /*
  2  * Copyright (c) 1997, 2024, 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  *

276   if (!reg_map->in_cont()) {
277     address value_addr = loc.is_register()
278       // Value was in a callee-save register
279       ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number()), fr->sp())
280       // Else value was directly saved on the stack. The frame's original stack pointer,
281       // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used.
282       : ((address)fr->unextended_sp()) + loc.stack_offset();
283 
284     assert(value_addr == nullptr || reg_map->thread() == nullptr || reg_map->thread()->is_in_usable_stack(value_addr), INTPTR_FORMAT, p2i(value_addr));
285     return value_addr;
286   }
287 
288   address value_addr = loc.is_register()
289     ? reg_map->as_RegisterMap()->stack_chunk()->reg_to_location(*fr, reg_map->as_RegisterMap(), VMRegImpl::as_VMReg(loc.register_number()))
290     : reg_map->as_RegisterMap()->stack_chunk()->usp_offset_to_location(*fr, loc.stack_offset());
291 
292   assert(value_addr == nullptr || Continuation::is_in_usable_stack(value_addr, reg_map->as_RegisterMap()) || (reg_map->thread() != nullptr && reg_map->thread()->is_in_usable_stack(value_addr)), INTPTR_FORMAT, p2i(value_addr));
293   return value_addr;
294 }
295 
296 BasicLock* StackValue::resolve_monitor_lock(const frame& fr, Location location) {
297   assert(location.is_stack(), "for now we only look at the stack");
298   int word_offset = location.stack_offset() / wordSize;
299   // (stack picture)
300   // high: [     ]  word_offset + 1
301   // low   [     ]  word_offset
302   //
303   // sp->  [     ]  0
304   // the word_offset is the distance from the stack pointer to the lowest address
305   // The frame's original stack pointer, before any extension by its callee
306   // (due to Compiler1 linkage on SPARC), must be used.
307   return (BasicLock*) (fr.unextended_sp() + word_offset);
308 }
309 
310 
311 #ifndef PRODUCT
312 
313 void StackValue::print_on(outputStream* st) const {
314   switch(_type) {
315     case T_INT:
316       st->print("%d (int) %f (float) %x (hex)",  *(int *)&_integer_value, *(float *)&_integer_value,  *(int *)&_integer_value);
317       break;
318 
319     case T_OBJECT:
320       if (_handle_value() != nullptr) {
321         _handle_value()->print_value_on(st);
322       } else {
323         st->print("null");
324       }
325       st->print(" <" INTPTR_FORMAT ">", p2i(_handle_value()));
326       break;
327 
< prev index next >