1 #ifdef USE_PRAGMA_IDENT_SRC 2 #pragma ident "@(#)location.cpp 1.40 07/05/05 17:05:21 JVM" 3 #endif 4 /* 5 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 * 8 * This code is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License version 2 only, as 10 * published by the Free Software Foundation. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23 * CA 95054 USA or visit www.sun.com if you need additional information or 24 * have any questions. 25 * 26 */ 27 28 #include "incls/_precompiled.incl" 29 #include "incls/_location.cpp.incl" 30 31 void Location::print_on(outputStream* st) const { 32 if(type() == invalid) { 33 // product of Location::invalid_loc() or Location::Location(). 34 switch (where()) { 35 case on_stack: st->print("empty"); break; 36 case in_register: st->print("invalid"); break; 37 } 38 return; 39 } 40 switch (where()) { 41 case on_stack: st->print("stack[%d]", stack_offset()); break; 42 case in_register: st->print("reg %s [%d]", reg()->name(), register_number()); break; 43 default: st->print("Wrong location where %d", where()); 44 } 45 switch (type()) { 46 case normal: break; 47 case oop: st->print(",oop"); break; 48 case narrowoop: st->print(",narrowoop"); break; 49 case int_in_long: st->print(",int"); break; 50 case lng: st->print(",long"); break; 51 case float_in_dbl: st->print(",float"); break; 52 case dbl: st->print(",double"); break; 53 case addr: st->print(",address"); break; 54 default: st->print("Wrong location type %d", type()); 55 } 56 } 57 58 59 Location::Location(DebugInfoReadStream* stream) { 60 _value = (juint) stream->read_int(); 61 } 62 63 64 void Location::write_on(DebugInfoWriteStream* stream) { 65 stream->write_int(_value); 66 } 67 68 69 // Valid argument to Location::new_stk_loc()? 70 bool Location::legal_offset_in_bytes(int offset_in_bytes) { 71 if ((offset_in_bytes % BytesPerInt) != 0) return false; 72 return (juint)(offset_in_bytes / BytesPerInt) < (OFFSET_MASK >> OFFSET_SHIFT); 73 } 74