duke@435: /* stefank@2314: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "code/debugInfo.hpp" stefank@2314: #include "code/location.hpp" duke@435: duke@435: void Location::print_on(outputStream* st) const { kvn@766: if(type() == invalid) { duke@435: // product of Location::invalid_loc() or Location::Location(). duke@435: switch (where()) { duke@435: case on_stack: st->print("empty"); break; duke@435: case in_register: st->print("invalid"); break; duke@435: } duke@435: return; duke@435: } duke@435: switch (where()) { duke@435: case on_stack: st->print("stack[%d]", stack_offset()); break; duke@435: case in_register: st->print("reg %s [%d]", reg()->name(), register_number()); break; duke@435: default: st->print("Wrong location where %d", where()); duke@435: } duke@435: switch (type()) { duke@435: case normal: break; duke@435: case oop: st->print(",oop"); break; kvn@766: case narrowoop: st->print(",narrowoop"); break; duke@435: case int_in_long: st->print(",int"); break; duke@435: case lng: st->print(",long"); break; duke@435: case float_in_dbl: st->print(",float"); break; duke@435: case dbl: st->print(",double"); break; duke@435: case addr: st->print(",address"); break; duke@435: default: st->print("Wrong location type %d", type()); duke@435: } duke@435: } duke@435: duke@435: duke@435: Location::Location(DebugInfoReadStream* stream) { kvn@766: _value = (juint) stream->read_int(); duke@435: } duke@435: duke@435: duke@435: void Location::write_on(DebugInfoWriteStream* stream) { kvn@766: stream->write_int(_value); duke@435: } duke@435: duke@435: duke@435: // Valid argument to Location::new_stk_loc()? duke@435: bool Location::legal_offset_in_bytes(int offset_in_bytes) { duke@435: if ((offset_in_bytes % BytesPerInt) != 0) return false; kvn@766: return (juint)(offset_in_bytes / BytesPerInt) < (OFFSET_MASK >> OFFSET_SHIFT); duke@435: }