annotate agent/src/share/classes/sun/jvm/hotspot/memory/CMSBitMap.java @ 1533:9d4dd91c4a0a

6745217: jmap assertion failure Summary: SA shows exception with core files > 2GB. These changes fix that by correcting the size of CMSBitmap during its allocation. Reviewed-by: swamyv
author poonam
date Sat, 15 May 2010 18:24:34 -0700
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1533
9d4dd91c4a0a 6745217: jmap assertion failure
poonam
parents: 0
diff changeset
2 * Copyright 2007-2010 Sun Microsystems, Inc. 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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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.memory;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 public class CMSBitMap extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private static AddressField bmStartWordField;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private static CIntegerField bmWordSizeField;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private static CIntegerField shifterField;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //private static AddressField bmField;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private static long virtualSpaceFieldOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public CMSBitMap(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 });
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 Type type = db.lookupType("CMSBitMap");
a61af66fc99e Initial load
duke
parents:
diff changeset
55 bmStartWordField = type.getAddressField("_bmStartWord");
a61af66fc99e Initial load
duke
parents:
diff changeset
56 bmWordSizeField = type.getCIntegerField("_bmWordSize");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 shifterField = type.getCIntegerField("_shifter");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 //bmField = type.getAddressField("_bm");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 virtualSpaceFieldOffset = type.getField("_virtual_space").getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public void printAll() {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 System.out.println("bmStartWord(): "+bmStartWord());
a61af66fc99e Initial load
duke
parents:
diff changeset
63 System.out.println("bmWordSize(): "+bmWordSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
64 System.out.println("shifter(): "+shifter());
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 public Address bmStartWord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 return bmStartWordField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public long bmWordSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return bmWordSizeField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 public long shifter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 return shifterField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 public VirtualSpace virtualSpace() {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return (VirtualSpace) VMObjectFactory.newObject(VirtualSpace.class, addr.addOffsetTo(virtualSpaceFieldOffset));
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 public BitMap bm() {
1533
9d4dd91c4a0a 6745217: jmap assertion failure
poonam
parents: 0
diff changeset
81 BitMap bitMap = new BitMap((int) (bmWordSize() >> shifter() ));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82 VirtualSpace vs = virtualSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 bitMap.set_map(vs.low());
a61af66fc99e Initial load
duke
parents:
diff changeset
84 return bitMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 public Address getNextMarkedWordAddress(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 Address endWord = bmStartWord().addOffsetTo(bmWordSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int nextOffset = bm().getNextOneOffset(heapWordToOffset(addr), heapWordToOffset(endWord) );
a61af66fc99e Initial load
duke
parents:
diff changeset
90 Address nextAddr = offsetToHeapWord(nextOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return nextAddr;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 int heapWordToOffset(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 int temp = (int)addr.minus(bmStartWord()) / (int) VM.getVM().getAddressSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int ret_val = temp >> shifter();
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return ret_val;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 Address offsetToHeapWord(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 int temp = offset << shifter();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 return bmStartWord().addOffsetTo(temp*VM.getVM().getAddressSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 boolean isMarked(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 BitMap bm = bm();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return bm.at(heapWordToOffset(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }