Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1HeapRegionTable.java @ 17736:58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
Reviewed-by: tschatzl, pliden
author | brutisso |
---|---|
date | Fri, 14 Mar 2014 10:15:46 +0100 |
parents | 50287b659eb8 |
children | 6701abbc4441 |
rev | line source |
---|---|
12904
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
1 /* |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
4 * |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
8 * |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
13 * accompanied this code). |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
14 * |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
18 * |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
21 * questions. |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
22 * |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
23 */ |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
24 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
25 package sun.jvm.hotspot.gc_implementation.g1; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
26 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
27 import java.util.Iterator; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
28 import java.util.Observable; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
29 import java.util.Observer; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
30 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
31 import sun.jvm.hotspot.debugger.Address; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
32 import sun.jvm.hotspot.runtime.VM; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
33 import sun.jvm.hotspot.runtime.VMObject; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
34 import sun.jvm.hotspot.runtime.VMObjectFactory; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
35 import sun.jvm.hotspot.types.AddressField; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
36 import sun.jvm.hotspot.types.CIntegerField; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
37 import sun.jvm.hotspot.types.Type; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
38 import sun.jvm.hotspot.types.TypeDataBase; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
39 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
40 // Mirror class for G1HeapRegionTable. It's essentially an index -> HeapRegion map. |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
41 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
42 public class G1HeapRegionTable extends VMObject { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
43 // HeapRegion** _base; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
44 static private AddressField baseField; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
45 // uint _length; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
46 static private CIntegerField lengthField; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
47 // HeapRegion** _biased_base |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
48 static private AddressField biasedBaseField; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
49 // size_t _bias |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
50 static private CIntegerField biasField; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
51 // uint _shift_by |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
52 static private CIntegerField shiftByField; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
53 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
54 static { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
55 VM.registerVMInitializedObserver(new Observer() { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
56 public void update(Observable o, Object data) { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
57 initialize(VM.getVM().getTypeDataBase()); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
58 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
59 }); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
60 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
61 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
62 static private synchronized void initialize(TypeDataBase db) { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
63 Type type = db.lookupType("G1HeapRegionTable"); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
64 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
65 baseField = type.getAddressField("_base"); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
66 lengthField = type.getCIntegerField("_length"); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
67 biasedBaseField = type.getAddressField("_biased_base"); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
68 biasField = type.getCIntegerField("_bias"); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
69 shiftByField = type.getCIntegerField("_shift_by"); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
70 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
71 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
72 private HeapRegion at(long index) { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
73 Address arrayAddr = baseField.getValue(addr); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
74 // Offset of &_base[index] |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
75 long offset = index * VM.getVM().getAddressSize(); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
76 Address regionAddr = arrayAddr.getAddressAt(offset); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
77 return (HeapRegion) VMObjectFactory.newObject(HeapRegion.class, |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
78 regionAddr); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
79 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
80 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
81 public long length() { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
82 return lengthField.getValue(addr); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
83 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
84 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
85 public long bias() { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
86 return biasField.getValue(addr); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
87 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
88 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
89 public long shiftBy() { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
90 return shiftByField.getValue(addr); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
91 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
92 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
93 private class HeapRegionIterator implements Iterator<HeapRegion> { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
94 private long index; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
95 private long length; |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
96 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
97 @Override |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
98 public boolean hasNext() { return index < length; } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
99 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
100 @Override |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
101 public HeapRegion next() { return at(index++); } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
102 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
103 @Override |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
104 public void remove() { /* not supported */ } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
105 |
13419
50287b659eb8
8029329: tmtools tests fail with NPE (in the tool) when run with G1 and FlightRecorder
sjohanss
parents:
12904
diff
changeset
|
106 HeapRegionIterator(long committedLength) { |
12904
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
107 index = 0; |
13419
50287b659eb8
8029329: tmtools tests fail with NPE (in the tool) when run with G1 and FlightRecorder
sjohanss
parents:
12904
diff
changeset
|
108 length = committedLength; |
12904
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
109 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
110 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
111 |
13419
50287b659eb8
8029329: tmtools tests fail with NPE (in the tool) when run with G1 and FlightRecorder
sjohanss
parents:
12904
diff
changeset
|
112 public Iterator<HeapRegion> heapRegionIterator(long committedLength) { |
50287b659eb8
8029329: tmtools tests fail with NPE (in the tool) when run with G1 and FlightRecorder
sjohanss
parents:
12904
diff
changeset
|
113 return new HeapRegionIterator(committedLength); |
12904
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
114 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
115 |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
116 public G1HeapRegionTable(Address addr) { |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
117 super(addr); |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
118 } |
9e5fadad7fdf
8025925: jmap fails with "field _length not found in type HeapRegionSeq"
tschatzl
parents:
diff
changeset
|
119 } |