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