Fri, 29 Apr 2016 00:06:10 +0800
Added MIPS 64-bit port.
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2002, 2011, 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@1 | 25 | /* |
aoqi@1 | 26 | * This file has been modified by Loongson Technology in 2015. These |
aoqi@1 | 27 | * modifications are Copyright (c) 2015 Loongson Technology, and are made |
aoqi@1 | 28 | * available on the same license terms set forth above. |
aoqi@1 | 29 | */ |
aoqi@1 | 30 | |
aoqi@0 | 31 | #ifndef SHARE_VM_RUNTIME_REGISTERMAP_HPP |
aoqi@0 | 32 | #define SHARE_VM_RUNTIME_REGISTERMAP_HPP |
aoqi@0 | 33 | |
aoqi@0 | 34 | #include "code/vmreg.hpp" |
aoqi@0 | 35 | #include "utilities/globalDefinitions.hpp" |
aoqi@0 | 36 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 37 | # include "register_x86.hpp" |
aoqi@0 | 38 | #endif |
aoqi@0 | 39 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 40 | # include "register_sparc.hpp" |
aoqi@0 | 41 | #endif |
aoqi@0 | 42 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 43 | # include "register_zero.hpp" |
aoqi@0 | 44 | #endif |
aoqi@0 | 45 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 46 | # include "register_arm.hpp" |
aoqi@0 | 47 | #endif |
aoqi@0 | 48 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 49 | # include "register_ppc.hpp" |
aoqi@0 | 50 | #endif |
aoqi@1 | 51 | #ifdef TARGET_ARCH_mips |
aoqi@1 | 52 | # include "register_mips.hpp" |
aoqi@1 | 53 | #endif |
aoqi@0 | 54 | |
aoqi@0 | 55 | class JavaThread; |
aoqi@0 | 56 | |
aoqi@0 | 57 | // |
aoqi@0 | 58 | // RegisterMap |
aoqi@0 | 59 | // |
aoqi@0 | 60 | // A companion structure used for stack traversal. The RegisterMap contains |
aoqi@0 | 61 | // misc. information needed in order to do correct stack traversal of stack |
aoqi@0 | 62 | // frames. Hence, it must always be passed in as an argument to |
aoqi@0 | 63 | // frame::sender(RegisterMap*). |
aoqi@0 | 64 | // |
aoqi@0 | 65 | // In particular, |
aoqi@0 | 66 | // 1) It provides access to the thread for which the stack belongs. The |
aoqi@0 | 67 | // thread object is needed in order to get sender of a deoptimized frame. |
aoqi@0 | 68 | // |
aoqi@0 | 69 | // 2) It is used to pass information from a callee frame to its caller |
aoqi@0 | 70 | // frame about how the frame should be traversed. This is used to let |
aoqi@0 | 71 | // the caller frame take care of calling oops-do of out-going |
aoqi@0 | 72 | // arguments, when the callee frame is not instantiated yet. This |
aoqi@0 | 73 | // happens, e.g., when a compiled frame calls into |
aoqi@0 | 74 | // resolve_virtual_call. (Hence, it is critical that the same |
aoqi@0 | 75 | // RegisterMap object is used for the entire stack walk. Normally, |
aoqi@0 | 76 | // this is hidden by using the StackFrameStream.) This is used when |
aoqi@0 | 77 | // doing follow_oops and oops_do. |
aoqi@0 | 78 | // |
aoqi@0 | 79 | // 3) The RegisterMap keeps track of the values of callee-saved registers |
aoqi@0 | 80 | // from frame to frame (hence, the name). For some stack traversal the |
aoqi@0 | 81 | // values of the callee-saved registers does not matter, e.g., if you |
aoqi@0 | 82 | // only need the static properies such as frame type, pc, and such. |
aoqi@0 | 83 | // Updating of the RegisterMap can be turned off by instantiating the |
aoqi@0 | 84 | // register map as: RegisterMap map(thread, false); |
aoqi@0 | 85 | |
aoqi@0 | 86 | class RegisterMap : public StackObj { |
aoqi@0 | 87 | public: |
aoqi@0 | 88 | typedef julong LocationValidType; |
aoqi@0 | 89 | enum { |
aoqi@0 | 90 | reg_count = ConcreteRegisterImpl::number_of_registers, |
aoqi@0 | 91 | location_valid_type_size = sizeof(LocationValidType)*8, |
aoqi@0 | 92 | location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size |
aoqi@0 | 93 | }; |
aoqi@0 | 94 | private: |
aoqi@0 | 95 | intptr_t* _location[reg_count]; // Location of registers (intptr_t* looks better than address in the debugger) |
aoqi@0 | 96 | LocationValidType _location_valid[location_valid_size]; |
aoqi@0 | 97 | bool _include_argument_oops; // Should include argument_oop marked locations for compiler |
aoqi@0 | 98 | JavaThread* _thread; // Reference to current thread |
aoqi@0 | 99 | bool _update_map; // Tells if the register map need to be |
aoqi@0 | 100 | // updated when traversing the stack |
aoqi@0 | 101 | |
aoqi@0 | 102 | #ifdef ASSERT |
aoqi@0 | 103 | void check_location_valid(); |
aoqi@0 | 104 | #else |
aoqi@0 | 105 | void check_location_valid() {} |
aoqi@0 | 106 | #endif |
aoqi@0 | 107 | |
aoqi@0 | 108 | public: |
aoqi@0 | 109 | debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame |
aoqi@0 | 110 | RegisterMap(JavaThread *thread, bool update_map = true); |
aoqi@0 | 111 | RegisterMap(const RegisterMap* map); |
aoqi@0 | 112 | |
aoqi@0 | 113 | address location(VMReg reg) const { |
aoqi@0 | 114 | int index = reg->value() / location_valid_type_size; |
aoqi@0 | 115 | assert(0 <= reg->value() && reg->value() < reg_count, "range check"); |
aoqi@0 | 116 | assert(0 <= index && index < location_valid_size, "range check"); |
aoqi@0 | 117 | if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) { |
aoqi@0 | 118 | return (address) _location[reg->value()]; |
aoqi@0 | 119 | } else { |
aoqi@0 | 120 | return pd_location(reg); |
aoqi@0 | 121 | } |
aoqi@0 | 122 | } |
aoqi@0 | 123 | |
aoqi@0 | 124 | void set_location(VMReg reg, address loc) { |
aoqi@0 | 125 | int index = reg->value() / location_valid_type_size; |
aoqi@0 | 126 | assert(0 <= reg->value() && reg->value() < reg_count, "range check"); |
aoqi@0 | 127 | assert(0 <= index && index < location_valid_size, "range check"); |
aoqi@0 | 128 | assert(_update_map, "updating map that does not need updating"); |
aoqi@0 | 129 | _location[reg->value()] = (intptr_t*) loc; |
aoqi@0 | 130 | _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size)); |
aoqi@0 | 131 | check_location_valid(); |
aoqi@0 | 132 | } |
aoqi@0 | 133 | |
aoqi@0 | 134 | // Called by an entry frame. |
aoqi@0 | 135 | void clear(); |
aoqi@0 | 136 | |
aoqi@0 | 137 | bool include_argument_oops() const { return _include_argument_oops; } |
aoqi@0 | 138 | void set_include_argument_oops(bool f) { _include_argument_oops = f; } |
aoqi@0 | 139 | |
aoqi@0 | 140 | JavaThread *thread() const { return _thread; } |
aoqi@0 | 141 | bool update_map() const { return _update_map; } |
aoqi@0 | 142 | |
aoqi@0 | 143 | void print_on(outputStream* st) const; |
aoqi@0 | 144 | void print() const; |
aoqi@0 | 145 | |
aoqi@0 | 146 | // the following contains the definition of pd_xxx methods |
aoqi@0 | 147 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 148 | # include "registerMap_x86.hpp" |
aoqi@0 | 149 | #endif |
aoqi@0 | 150 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 151 | # include "registerMap_sparc.hpp" |
aoqi@0 | 152 | #endif |
aoqi@0 | 153 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 154 | # include "registerMap_zero.hpp" |
aoqi@0 | 155 | #endif |
aoqi@0 | 156 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 157 | # include "registerMap_arm.hpp" |
aoqi@0 | 158 | #endif |
aoqi@0 | 159 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 160 | # include "registerMap_ppc.hpp" |
aoqi@0 | 161 | #endif |
aoqi@1 | 162 | #ifdef TARGET_ARCH_mips |
aoqi@1 | 163 | # include "registerMap_mips.hpp" |
aoqi@1 | 164 | #endif |
aoqi@0 | 165 | |
aoqi@0 | 166 | }; |
aoqi@0 | 167 | |
aoqi@0 | 168 | #endif // SHARE_VM_RUNTIME_REGISTERMAP_HPP |