Fri, 29 Apr 2016 00:06:10 +0800
Added MIPS 64-bit port.
1 /*
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 /*
26 * This file has been modified by Loongson Technology in 2015. These
27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
28 * available on the same license terms set forth above.
29 */
31 #ifndef SHARE_VM_RUNTIME_REGISTERMAP_HPP
32 #define SHARE_VM_RUNTIME_REGISTERMAP_HPP
34 #include "code/vmreg.hpp"
35 #include "utilities/globalDefinitions.hpp"
36 #ifdef TARGET_ARCH_x86
37 # include "register_x86.hpp"
38 #endif
39 #ifdef TARGET_ARCH_sparc
40 # include "register_sparc.hpp"
41 #endif
42 #ifdef TARGET_ARCH_zero
43 # include "register_zero.hpp"
44 #endif
45 #ifdef TARGET_ARCH_arm
46 # include "register_arm.hpp"
47 #endif
48 #ifdef TARGET_ARCH_ppc
49 # include "register_ppc.hpp"
50 #endif
51 #ifdef TARGET_ARCH_mips
52 # include "register_mips.hpp"
53 #endif
55 class JavaThread;
57 //
58 // RegisterMap
59 //
60 // A companion structure used for stack traversal. The RegisterMap contains
61 // misc. information needed in order to do correct stack traversal of stack
62 // frames. Hence, it must always be passed in as an argument to
63 // frame::sender(RegisterMap*).
64 //
65 // In particular,
66 // 1) It provides access to the thread for which the stack belongs. The
67 // thread object is needed in order to get sender of a deoptimized frame.
68 //
69 // 2) It is used to pass information from a callee frame to its caller
70 // frame about how the frame should be traversed. This is used to let
71 // the caller frame take care of calling oops-do of out-going
72 // arguments, when the callee frame is not instantiated yet. This
73 // happens, e.g., when a compiled frame calls into
74 // resolve_virtual_call. (Hence, it is critical that the same
75 // RegisterMap object is used for the entire stack walk. Normally,
76 // this is hidden by using the StackFrameStream.) This is used when
77 // doing follow_oops and oops_do.
78 //
79 // 3) The RegisterMap keeps track of the values of callee-saved registers
80 // from frame to frame (hence, the name). For some stack traversal the
81 // values of the callee-saved registers does not matter, e.g., if you
82 // only need the static properies such as frame type, pc, and such.
83 // Updating of the RegisterMap can be turned off by instantiating the
84 // register map as: RegisterMap map(thread, false);
86 class RegisterMap : public StackObj {
87 public:
88 typedef julong LocationValidType;
89 enum {
90 reg_count = ConcreteRegisterImpl::number_of_registers,
91 location_valid_type_size = sizeof(LocationValidType)*8,
92 location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size
93 };
94 private:
95 intptr_t* _location[reg_count]; // Location of registers (intptr_t* looks better than address in the debugger)
96 LocationValidType _location_valid[location_valid_size];
97 bool _include_argument_oops; // Should include argument_oop marked locations for compiler
98 JavaThread* _thread; // Reference to current thread
99 bool _update_map; // Tells if the register map need to be
100 // updated when traversing the stack
102 #ifdef ASSERT
103 void check_location_valid();
104 #else
105 void check_location_valid() {}
106 #endif
108 public:
109 debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame
110 RegisterMap(JavaThread *thread, bool update_map = true);
111 RegisterMap(const RegisterMap* map);
113 address location(VMReg reg) const {
114 int index = reg->value() / location_valid_type_size;
115 assert(0 <= reg->value() && reg->value() < reg_count, "range check");
116 assert(0 <= index && index < location_valid_size, "range check");
117 if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) {
118 return (address) _location[reg->value()];
119 } else {
120 return pd_location(reg);
121 }
122 }
124 void set_location(VMReg reg, address loc) {
125 int index = reg->value() / location_valid_type_size;
126 assert(0 <= reg->value() && reg->value() < reg_count, "range check");
127 assert(0 <= index && index < location_valid_size, "range check");
128 assert(_update_map, "updating map that does not need updating");
129 _location[reg->value()] = (intptr_t*) loc;
130 _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size));
131 check_location_valid();
132 }
134 // Called by an entry frame.
135 void clear();
137 bool include_argument_oops() const { return _include_argument_oops; }
138 void set_include_argument_oops(bool f) { _include_argument_oops = f; }
140 JavaThread *thread() const { return _thread; }
141 bool update_map() const { return _update_map; }
143 void print_on(outputStream* st) const;
144 void print() const;
146 // the following contains the definition of pd_xxx methods
147 #ifdef TARGET_ARCH_x86
148 # include "registerMap_x86.hpp"
149 #endif
150 #ifdef TARGET_ARCH_sparc
151 # include "registerMap_sparc.hpp"
152 #endif
153 #ifdef TARGET_ARCH_zero
154 # include "registerMap_zero.hpp"
155 #endif
156 #ifdef TARGET_ARCH_arm
157 # include "registerMap_arm.hpp"
158 #endif
159 #ifdef TARGET_ARCH_ppc
160 # include "registerMap_ppc.hpp"
161 #endif
162 #ifdef TARGET_ARCH_mips
163 # include "registerMap_mips.hpp"
164 #endif
166 };
168 #endif // SHARE_VM_RUNTIME_REGISTERMAP_HPP