Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/memory/CMSBitMap.java @ 3945:8ed53447f690
Merge
author | iveresov |
---|---|
date | Thu, 15 Sep 2011 12:44:09 -0700 |
parents | c18cbe5936b8 |
children |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1533
diff
changeset
|
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1533
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1533
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:
1533
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.memory; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.runtime.*; | |
31 import sun.jvm.hotspot.types.*; | |
32 import sun.jvm.hotspot.utilities.*; | |
33 | |
34 public class CMSBitMap extends VMObject { | |
35 private static AddressField bmStartWordField; | |
36 private static CIntegerField bmWordSizeField; | |
37 private static CIntegerField shifterField; | |
38 //private static AddressField bmField; | |
39 private static long virtualSpaceFieldOffset; | |
40 | |
41 public CMSBitMap(Address addr) { | |
42 super(addr); | |
43 } | |
44 | |
45 static { | |
46 VM.registerVMInitializedObserver(new Observer() { | |
47 public void update(Observable o, Object data) { | |
48 initialize(VM.getVM().getTypeDataBase()); | |
49 } | |
50 }); | |
51 } | |
52 | |
53 private static synchronized void initialize(TypeDataBase db) { | |
54 Type type = db.lookupType("CMSBitMap"); | |
55 bmStartWordField = type.getAddressField("_bmStartWord"); | |
56 bmWordSizeField = type.getCIntegerField("_bmWordSize"); | |
57 shifterField = type.getCIntegerField("_shifter"); | |
58 //bmField = type.getAddressField("_bm"); | |
59 virtualSpaceFieldOffset = type.getField("_virtual_space").getOffset(); | |
60 } | |
61 public void printAll() { | |
62 System.out.println("bmStartWord(): "+bmStartWord()); | |
63 System.out.println("bmWordSize(): "+bmWordSize()); | |
64 System.out.println("shifter(): "+shifter()); | |
65 } | |
66 | |
67 public Address bmStartWord() { | |
68 return bmStartWordField.getValue(addr); | |
69 } | |
70 public long bmWordSize() { | |
71 return bmWordSizeField.getValue(addr); | |
72 } | |
73 public long shifter() { | |
74 return shifterField.getValue(addr); | |
75 } | |
76 public VirtualSpace virtualSpace() { | |
77 return (VirtualSpace) VMObjectFactory.newObject(VirtualSpace.class, addr.addOffsetTo(virtualSpaceFieldOffset)); | |
78 } | |
79 | |
80 public BitMap bm() { | |
1533 | 81 BitMap bitMap = new BitMap((int) (bmWordSize() >> shifter() )); |
0 | 82 VirtualSpace vs = virtualSpace(); |
83 bitMap.set_map(vs.low()); | |
84 return bitMap; | |
85 } | |
86 | |
87 public Address getNextMarkedWordAddress(Address addr) { | |
88 Address endWord = bmStartWord().addOffsetTo(bmWordSize()); | |
89 int nextOffset = bm().getNextOneOffset(heapWordToOffset(addr), heapWordToOffset(endWord) ); | |
90 Address nextAddr = offsetToHeapWord(nextOffset); | |
91 return nextAddr; | |
92 } | |
93 | |
94 int heapWordToOffset(Address addr) { | |
95 int temp = (int)addr.minus(bmStartWord()) / (int) VM.getVM().getAddressSize(); | |
96 int ret_val = temp >> shifter(); | |
97 return ret_val; | |
98 } | |
99 | |
100 Address offsetToHeapWord(int offset) { | |
101 int temp = offset << shifter(); | |
102 return bmStartWord().addOffsetTo(temp*VM.getVM().getAddressSize()); | |
103 } | |
104 | |
105 boolean isMarked(Address addr) { | |
106 BitMap bm = bm(); | |
107 return bm.at(heapWordToOffset(addr)); | |
108 } | |
109 } |