annotate agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCRegisterMap.java @ 12226:7944aba7ba41

8015107: NPG: Use consistent naming for metaspace concepts Reviewed-by: coleenp, mgerdin, hseigel
author ehelin
date Mon, 12 Aug 2013 17:37:02 +0200
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.runtime.sparc;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.asm.sparc.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 public class SPARCRegisterMap extends RegisterMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 /** Register window save area (for L and I regs) */
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private Address window;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 /** Previous save area (for O regs, if needed) */
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private Address youngerWindow;
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private static int registerImplNumberOfRegisters;
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Unified register numbering scheme: each 32-bits counts as a register
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // number, so all the V9 registers take 2 slots.
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private static int[] R_L_nums = new int[] {0+040,2+040,4+040,6+040,8+040,10+040,12+040,14+040};
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static int[] R_I_nums = new int[] {0+060,2+060,4+060,6+060,8+060,10+060,12+060,14+060};
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private static int[] R_O_nums = new int[] {0+020,2+020,4+020,6+020,8+020,10+020,12+020,14+020};
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static int[] R_G_nums = new int[] {0+000,2+000,4+000,6+000,8+000,10+000,12+000,14+000};
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static long badMask;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static long R_LIO_mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private static int sizeofJint;
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 });
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 badMask = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 R_LIO_mask = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 sizeofJint = (int) db.lookupType("jint").getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 registerImplNumberOfRegisters = db.lookupIntConstant("RegisterImpl::number_of_registers").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 for (int i = 0; i < 8; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 Assert.that(R_L_nums[i] < locationValidTypeSize, "in first chunk");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 Assert.that(R_I_nums[i] < locationValidTypeSize, "in first chunk");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 Assert.that(R_O_nums[i] < locationValidTypeSize, "in first chunk");
a61af66fc99e Initial load
duke
parents:
diff changeset
74 Assert.that(R_G_nums[i] < locationValidTypeSize, "in first chunk");
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 badMask |= ((long) 1 << R_O_nums[6]); // SP
a61af66fc99e Initial load
duke
parents:
diff changeset
78 badMask |= ((long) 1 << R_O_nums[7]); // cPC
a61af66fc99e Initial load
duke
parents:
diff changeset
79 badMask |= ((long) 1 << R_I_nums[6]); // FP
a61af66fc99e Initial load
duke
parents:
diff changeset
80 badMask |= ((long) 1 << R_I_nums[7]); // rPC
a61af66fc99e Initial load
duke
parents:
diff changeset
81 badMask |= ((long) 1 << R_G_nums[2]); // TLS
a61af66fc99e Initial load
duke
parents:
diff changeset
82 badMask |= ((long) 1 << R_G_nums[7]); // reserved by libthread
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 for (int i = 0; i < 8; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 R_LIO_mask |= ((long) 1 << R_L_nums[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 R_LIO_mask |= ((long) 1 << R_I_nums[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 R_LIO_mask |= ((long) 1 << R_O_nums[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 /** This is the only public constructor, and is only called by
a61af66fc99e Initial load
duke
parents:
diff changeset
92 SolarisSPARCJavaThread */
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public SPARCRegisterMap(JavaThread thread, boolean updateMap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 super(thread, updateMap);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 protected SPARCRegisterMap(RegisterMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 super(map);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public Object clone() {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 SPARCRegisterMap retval = new SPARCRegisterMap(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return retval;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 protected void clearPD() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 if (thread.hasLastJavaFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 Frame fr = thread.getLastFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
109 window = fr.getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 window = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (VM.getVM().isDebugging()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 Frame fr = thread.getCurrentFrameGuess();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (fr != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 window = fr.getSP();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 youngerWindow = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 protected Address getLocationPD(VMReg vmreg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 VM vm = VM.getVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 int regname = vmreg.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 Assert.that(0 <= regname && regname < regCount, "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Only the GPRs get handled this way
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (regname >= (registerImplNumberOfRegisters << 1)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // don't talk about bad registers
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if ((badMask & ((long) 1 << regname)) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Convert to a GPR
a61af66fc99e Initial load
duke
parents:
diff changeset
140 int secondWord = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // 32-bit registers for in, out and local
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (!isEven(regname)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (vm.isLP64()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 secondWord = sizeofJint;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 SPARCRegister reg = new SPARCRegister(regname >> 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if (reg.isOut()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 Assert.that(youngerWindow != null, "Younger window should be available");
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return youngerWindow.addOffsetTo(reg.afterSave().spOffsetInSavedWindow() + secondWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (reg.isLocal() || reg.isIn()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 Assert.that(window != null, "Window should be available");
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return window.addOffsetTo(reg.spOffsetInSavedWindow() + secondWord);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // Only the window'd GPRs get handled this way; not the globals.
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 protected void initializePD() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 window = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 youngerWindow = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // avoid the shift_individual_registers game
a61af66fc99e Initial load
duke
parents:
diff changeset
172 makeIntegerRegsUnsaved();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 protected void initializeFromPD(RegisterMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 SPARCRegisterMap srm = (SPARCRegisterMap) map;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 window = srm.window;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 youngerWindow = srm.youngerWindow;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // avoid the shift_individual_registers game
a61af66fc99e Initial load
duke
parents:
diff changeset
180 makeIntegerRegsUnsaved();
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public void shiftWindow(Address sp, Address youngerSP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 window = sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 youngerWindow = youngerSP;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Throw away locations for %i, %o, and %l registers:
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // But do not throw away %g register locs.
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (locationValid[0] != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 shiftIndividualRegisters();
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 /** When popping out of compiled frames, we make all IRegs disappear. */
a61af66fc99e Initial load
duke
parents:
diff changeset
194 public void makeIntegerRegsUnsaved() {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 locationValid[0] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
200 //
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 private void shiftIndividualRegisters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 if (!getUpdateMap()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 checkLocationValid();
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 long lv = locationValid[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
210 long lv0 = lv;
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 lv &= ~R_LIO_mask; // clear %l, %o, %i regs
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // if we cleared some non-%g locations, we may have to do some shifting
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (lv != lv0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // copy %i0-%i5 to %o0-%o5, if they have special locations
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // This can happen in within stubs which spill argument registers
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // around a dynamic link operation, such as resolve_opt_virtual_call.
a61af66fc99e Initial load
duke
parents:
diff changeset
219 for (int i = 0; i < 8; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 if ((lv0 & ((long) 1 << R_I_nums[i])) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 location[R_O_nums[i]] = location[R_I_nums[i]];
a61af66fc99e Initial load
duke
parents:
diff changeset
222 lv |= ((long) 1 << R_O_nums[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 locationValid[0] = lv;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 checkLocationValid();
a61af66fc99e Initial load
duke
parents:
diff changeset
229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 private boolean isEven(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return (i & 1) == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 private void checkLocationValid() {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 Assert.that((locationValid[0] & badMask) == 0, "cannot have special locations for SP,FP,TLS,etc.");
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }