annotate agent/src/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegister.java @ 1913:3b2dea75431e

6984311: JSR 292 needs optional bootstrap method parameters Summary: Allow CONSTANT_InvokeDynamic nodes to have any number of extra operands. Reviewed-by: twisti
author jrose
date Sat, 30 Oct 2010 13:08:23 -0700
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, 2002, 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.asm.sparc;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import sun.jvm.hotspot.asm.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 public class SPARCRegister extends Register {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private static final int nofRegisters = 32; // total number of registers
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private static final int GLOBAL_BASE = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private static final int OUT_BASE = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private static final int LOCAL_BASE = 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private static final int IN_BASE = 24;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private static final int LOCAL_SP_WORD_OFFSET = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private static final int IN_SP_WORD_OFFSET = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 /** Constructor for an explicitly numbered register */
a61af66fc99e Initial load
duke
parents:
diff changeset
43 public SPARCRegister(int number) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 super(number);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 /** Constructor for an I, G, O, or L register */
a61af66fc99e Initial load
duke
parents:
diff changeset
48 public SPARCRegister(SPARCRegisterType type, int number) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 if (type == SPARCRegisterType.GLOBAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 this.number = number + GLOBAL_BASE;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 } else if (type == SPARCRegisterType.OUT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 this.number = number + OUT_BASE;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 } else if (type == SPARCRegisterType.LOCAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 this.number = number + LOCAL_BASE;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 } else if (type == SPARCRegisterType.IN) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 this.number = number + IN_BASE;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 throw new IllegalArgumentException("Invalid SPARC register type");
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 public int getNumberOfRegisters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 return nofRegisters;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public boolean isIn() {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 return (IN_BASE <= getNumber());
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public boolean isLocal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return (LOCAL_BASE <= getNumber() && getNumber() < IN_BASE);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 public boolean isOut() {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return (OUT_BASE <= getNumber() && getNumber() < LOCAL_BASE);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 public boolean isGlobal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return (GLOBAL_BASE <= getNumber() && getNumber() < OUT_BASE);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public SPARCRegister afterSave() {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 Assert.that(isOut() || isGlobal(), "register not visible after save");
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 return isOut() ? new SPARCRegister(getNumber() + (IN_BASE - OUT_BASE)) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public SPARCRegister afterRestore() {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 Assert.that(isIn() || isGlobal(), "register not visible after save");
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 return isIn() ? new SPARCRegister(getNumber() + (OUT_BASE - IN_BASE)) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 /** NOTE: this returns an offset in BYTES in this system! */
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public long spOffsetInSavedWindow() {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 if (isIn()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 return VM.getVM().getAddressSize() * (getNumber() - IN_BASE + IN_SP_WORD_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 } else if (isLocal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 return VM.getVM().getAddressSize() * (getNumber() - LOCAL_BASE + LOCAL_SP_WORD_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 Assert.that(isIn() || isLocal(), "only ins and locals are saved in my frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 return SPARCRegisters.getRegisterName(number);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 public boolean isFramePointer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return number == 30; // is I6?
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public boolean isStackPointer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return number == 14; // is O6?
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public boolean isFloat() {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public boolean isV9Only() {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }