Path: blob/master/src/hotspot/share/code/location.cpp
40931 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "code/debugInfo.hpp"26#include "code/location.hpp"27#include "runtime/handles.inline.hpp"2829void Location::print_on(outputStream* st) const {30if(type() == invalid) {31// product of Location::invalid_loc() or Location::Location().32switch (where()) {33case on_stack: st->print("empty"); break;34case in_register: st->print("invalid"); break;35}36return;37}38switch (where()) {39case on_stack: st->print("stack[%d]", stack_offset()); break;40case in_register: st->print("reg %s [%d]", reg()->name(), register_number()); break;41default: st->print("Wrong location where %d", where());42}43switch (type()) {44case normal: break;45case oop: st->print(",oop"); break;46case narrowoop: st->print(",narrowoop"); break;47case int_in_long: st->print(",int"); break;48case lng: st->print(",long"); break;49case float_in_dbl: st->print(",float"); break;50case dbl: st->print(",double"); break;51case addr: st->print(",address"); break;52case vector: st->print(",vector"); break;53default: st->print("Wrong location type %d", type());54}55}565758Location::Location(DebugInfoReadStream* stream) {59_value = (juint) stream->read_int();60}616263void Location::write_on(DebugInfoWriteStream* stream) {64stream->write_int(_value);65}666768// Valid argument to Location::new_stk_loc()?69bool Location::legal_offset_in_bytes(int offset_in_bytes) {70if ((offset_in_bytes % BytesPerInt) != 0) return false;71return (juint)(offset_in_bytes / BytesPerInt) < (OFFSET_MASK >> OFFSET_SHIFT);72}737475