annotate agent/src/share/classes/sun/jvm/hotspot/debugger/Page.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, 2003, 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.debugger;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 /** A class representing an arbitrary-sized page which can be linked
a61af66fc99e Initial load
duke
parents:
diff changeset
28 into a list. Used by the PageCache. */
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 public class Page {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 private long baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private byte[] data;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 private Page prev;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private Page next;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private long unmappedPageLength;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 /** The length of the data[] array implicitly defines the size of the
a61af66fc99e Initial load
duke
parents:
diff changeset
38 page. */
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public Page(long baseAddress, byte[] data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 this.baseAddress = baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 this.data = data;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 /** This constructor creates an "unmapped" page of the specified
a61af66fc99e Initial load
duke
parents:
diff changeset
45 length. Fetches from this page will cause -1 to be inserted into
a61af66fc99e Initial load
duke
parents:
diff changeset
46 the destination buffer. */
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public Page(long baseAddress, long unmappedPageLength) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 this.baseAddress = baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 this.unmappedPageLength = unmappedPageLength;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public long getBaseAddress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public long getSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (data != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 return data.length;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return unmappedPageLength;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 /** Indicates whether this page is mapped in the remote process's
a61af66fc99e Initial load
duke
parents:
diff changeset
65 address space */
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public boolean isMapped() {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 return (data != null);
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 Page getPrev() {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return prev;
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 void setPrev(Page prev) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 this.prev = prev;
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 Page getNext() {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return next;
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 void setNext(Page next) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 this.next = next;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 /** Throws IndexOutOfBoundsException if the number of bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
87 requested is greater than the page size, or if the start address
a61af66fc99e Initial load
duke
parents:
diff changeset
88 doesn't fall within the page. There are no guarantees on whether
a61af66fc99e Initial load
duke
parents:
diff changeset
89 any data was actually fetched if an IndexOutOfBoundsException is
a61af66fc99e Initial load
duke
parents:
diff changeset
90 thrown. If this page is unmapped, -1 is returned for all
a61af66fc99e Initial load
duke
parents:
diff changeset
91 addresses on this page. */
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public void getData(long startAddress, long numBytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 int[] destBuf, long destBufOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
94 throws IndexOutOfBoundsException {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 int startOffset = (int) (startAddress - baseAddress);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if ((data == null) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
97 ((startOffset < 0) || ((startOffset + numBytes) > (baseAddress + unmappedPageLength)))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 throw new IndexOutOfBoundsException("startAddress = " + startAddress +
a61af66fc99e Initial load
duke
parents:
diff changeset
99 ", baseAddress = " + baseAddress +
a61af66fc99e Initial load
duke
parents:
diff changeset
100 ", unmappedPageLength = " + unmappedPageLength);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 for (int i = 0; i < (int) numBytes; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (data != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 destBuf[i + (int) destBufOffset] = ((int) (data[i + startOffset]) & 0x000000FF);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 destBuf[i + (int) destBufOffset] = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 /** Throws IndexOutOfBoundsException if the number of bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
112 requested is greater than the page size, or if the start address
a61af66fc99e Initial load
duke
parents:
diff changeset
113 doesn't fall within the page. There are no guarantees on whether
a61af66fc99e Initial load
duke
parents:
diff changeset
114 any data was actually fetched if an IndexOutOfBoundsException is
a61af66fc99e Initial load
duke
parents:
diff changeset
115 thrown. If this page is unmapped, throws a RuntimeException;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 this should be watched for at higher levels. */
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public void getDataAsBytes(long startAddress, long numBytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
118 byte[] destBuf, long destBufOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
119 throws IndexOutOfBoundsException {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 long startOffset = startAddress - baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (data == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 throw new RuntimeException("Bug in PageCache; should not fetch from unmapped pages using getDataAsBytes");
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 System.arraycopy(data, (int) startOffset, destBuf, (int) destBufOffset, (int) numBytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 public boolean getBoolean(long address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 return (getByte(address) != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public byte getByte(long address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 return data[(int) address - (int) baseAddress];
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public short getShort(long address, boolean bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 int start = (int) address - (int) baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return (short)
a61af66fc99e Initial load
duke
parents:
diff changeset
139 (((data[start + 1] & 0xFF)) |
a61af66fc99e Initial load
duke
parents:
diff changeset
140 ((data[start] & 0xFF) << 8));
a61af66fc99e Initial load
duke
parents:
diff changeset
141 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 return (short)
a61af66fc99e Initial load
duke
parents:
diff changeset
143 (((data[start + 1] & 0xFF) << 8) |
a61af66fc99e Initial load
duke
parents:
diff changeset
144 ((data[start] & 0xFF)));
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 public char getChar(long address, boolean bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return (char) getShort(address, bigEndian);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public int getInt(long address, boolean bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 int start = (int) address - (int) baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return
a61af66fc99e Initial load
duke
parents:
diff changeset
156 ((data[start + 3] & 0xFF)) |
a61af66fc99e Initial load
duke
parents:
diff changeset
157 ((data[start + 2] & 0xFF) << 8) |
a61af66fc99e Initial load
duke
parents:
diff changeset
158 ((data[start + 1] & 0xFF) << 16) |
a61af66fc99e Initial load
duke
parents:
diff changeset
159 ((data[start] & 0xFF) << 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return
a61af66fc99e Initial load
duke
parents:
diff changeset
162 ((data[start + 3] & 0xFF) << 24) |
a61af66fc99e Initial load
duke
parents:
diff changeset
163 ((data[start + 2] & 0xFF) << 16) |
a61af66fc99e Initial load
duke
parents:
diff changeset
164 ((data[start + 1] & 0xFF) << 8) |
a61af66fc99e Initial load
duke
parents:
diff changeset
165 ((data[start] & 0xFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 public long getLong(long address, boolean bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 int start = (int) address - (int) baseAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 if (bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return
a61af66fc99e Initial load
duke
parents:
diff changeset
173 ((data[start + 7] & 0xFFL)) |
a61af66fc99e Initial load
duke
parents:
diff changeset
174 ((data[start + 6] & 0xFFL) << 8) |
a61af66fc99e Initial load
duke
parents:
diff changeset
175 ((data[start + 5] & 0xFFL) << 16) |
a61af66fc99e Initial load
duke
parents:
diff changeset
176 ((data[start + 4] & 0xFFL) << 24) |
a61af66fc99e Initial load
duke
parents:
diff changeset
177 ((data[start + 3] & 0xFFL) << 32) |
a61af66fc99e Initial load
duke
parents:
diff changeset
178 ((data[start + 2] & 0xFFL) << 40) |
a61af66fc99e Initial load
duke
parents:
diff changeset
179 ((data[start + 1] & 0xFFL) << 48) |
a61af66fc99e Initial load
duke
parents:
diff changeset
180 ((data[start] & 0xFFL) << 56);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 return
a61af66fc99e Initial load
duke
parents:
diff changeset
183 ((data[start + 7] & 0xFFL) << 56) |
a61af66fc99e Initial load
duke
parents:
diff changeset
184 ((data[start + 6] & 0xFFL) << 48) |
a61af66fc99e Initial load
duke
parents:
diff changeset
185 ((data[start + 5] & 0xFFL) << 40) |
a61af66fc99e Initial load
duke
parents:
diff changeset
186 ((data[start + 4] & 0xFFL) << 32) |
a61af66fc99e Initial load
duke
parents:
diff changeset
187 ((data[start + 3] & 0xFFL) << 24) |
a61af66fc99e Initial load
duke
parents:
diff changeset
188 ((data[start + 2] & 0xFFL) << 16) |
a61af66fc99e Initial load
duke
parents:
diff changeset
189 ((data[start + 1] & 0xFFL) << 8) |
a61af66fc99e Initial load
duke
parents:
diff changeset
190 ((data[start] & 0xFFL));
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 public float getFloat(long address, boolean bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 return Float.intBitsToFloat(getInt(address, bigEndian));
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public double getDouble(long address, boolean bigEndian) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 return Double.longBitsToDouble(getLong(address, bigEndian));
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }