annotate agent/src/share/classes/sun/jvm/hotspot/interpreter/OopMapCacheEntry.java @ 2042:0a8e0d4345b3 hs20-b05 jdk7-b124

7010068: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - first pass Summary: Update the copyright to be 2010 on all changed files in OpenJDK Reviewed-by: jcoomes
author trims
date Mon, 03 Jan 2011 15:30:05 -0800
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) 2001, 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.interpreter;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 public class OopMapCacheEntry {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // Iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
32 public boolean isValue(int offset) { return !entryAt(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
33 public boolean isOop (int offset) { return entryAt(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
34 public void iterateOop(OffsetClosure oopClosure) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 int n = numberOfEntries();
a61af66fc99e Initial load
duke
parents:
diff changeset
36 for (int i = 0; i < n; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 if (entryAt(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 oopClosure.offsetDo(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40 }
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
44 public void fill(Method method, int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 this.method = method;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 this.bci = bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (method.isNative()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Native method activations have oops only among the parameters and one
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // extra oop following the parameters (the mirror for static native methods).
a61af66fc99e Initial load
duke
parents:
diff changeset
50 fillForNative();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 OopMapForCacheEntry gen = new OopMapForCacheEntry(method, bci, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 gen.computeMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public void setMask(CellTypeStateList vars,
a61af66fc99e Initial load
duke
parents:
diff changeset
58 CellTypeStateList stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 int stackTop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // compute bit mask size
a61af66fc99e Initial load
duke
parents:
diff changeset
61 int maxLocals = (int) method.getMaxLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 int nEntries = maxLocals + stackTop;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 maskSize = nEntries;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 allocateBitMask();
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 CellTypeStateList curList = vars;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 int listIdx = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 for (int entryIdx = 0; entryIdx < nEntries; entryIdx++, listIdx++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // switch to stack when done with locals
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (entryIdx == maxLocals) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 curList = stack;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 listIdx = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 CellTypeState cell = curList.get(listIdx);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // set oop bit
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if ( cell.isReference()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 mask.atPut(entryIdx, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // verify bit mask
a61af66fc99e Initial load
duke
parents:
diff changeset
84 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 Assert.that(verifyMask(vars, stack, maxLocals, stackTop), "mask could not be verified");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
91 //
a61af66fc99e Initial load
duke
parents:
diff changeset
92 private Method method; // the method for which the mask is valid
a61af66fc99e Initial load
duke
parents:
diff changeset
93 private int bci; // the bci for which the mask is valid
a61af66fc99e Initial load
duke
parents:
diff changeset
94 private int maskSize; // the required mask size in bits
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private BitMap mask; // may be null if mask is empty
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 Method method() { return method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 int bci() { return bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 int numberOfEntries() { return maskSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 boolean entryAt(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 return mask.at(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 void setEmptyMask() { mask = null; }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void allocateBitMask() {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 if (maskSize > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 mask = new BitMap(maskSize);
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 // fills the bit mask for native calls
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void fillForNative() {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 Assert.that(method.isNative(), "method must be native method");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 maskSize = (int) method.getSizeOfParameters();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 allocateBitMask();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // fill mask for parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
119 MaskFillerForNative mf = new MaskFillerForNative(method, mask, maskSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 mf.generate();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 static class VerifyClosure implements OffsetClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 private OopMapCacheEntry entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 private boolean failed;
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 VerifyClosure(OopMapCacheEntry entry) { this.entry = entry; }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 public void offsetDo(int offset) { if (!entry.isOop(offset)) failed = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 boolean failed() { return failed; }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 boolean verifyMask(CellTypeStateList vars, CellTypeStateList stack, int maxLocals, int stackTop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Check mask includes map
a61af66fc99e Initial load
duke
parents:
diff changeset
134 VerifyClosure blk = new VerifyClosure(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 iterateOop(blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (blk.failed()) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Check if map is generated correctly
a61af66fc99e Initial load
duke
parents:
diff changeset
139 for(int i = 0; i < maxLocals; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 boolean v1 = isOop(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 boolean v2 = vars.get(i).isReference();
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 Assert.that(v1 == v2, "locals oop mask generation error");
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 for(int j = 0; j < stackTop; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 boolean v1 = isOop(maxLocals + j);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 boolean v2 = stack.get(j).isReference();
a61af66fc99e Initial load
duke
parents:
diff changeset
150 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 Assert.that(v1 == v2, "stack oop mask generation error");
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }