annotate agent/src/share/classes/sun/jvm/hotspot/memory/FreeChunk.java @ 17467:55fb97c4c58d hs25-b65

8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013 Summary: Copyright year updated for files modified during 2013 Reviewed-by: twisti, iveresov
author mikael
date Tue, 24 Dec 2013 11:48:39 -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: 948
diff changeset
2 * Copyright (c) 2003, 2009, 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: 948
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
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: 948
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.memory;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.*;
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
31 import sun.jvm.hotspot.oops.*;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 public class FreeChunk extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
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 private static synchronized void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 Type type = db.lookupType("FreeChunk");
a61af66fc99e Initial load
duke
parents:
diff changeset
44 nextField = type.getAddressField("_next");
a61af66fc99e Initial load
duke
parents:
diff changeset
45 prevField = type.getAddressField("_prev");
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
46 sizeField = type.getAddressField("_size");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Fields
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static AddressField nextField;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static AddressField prevField;
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
52 private static AddressField sizeField;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
55 public FreeChunk next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 return (FreeChunk) VMObjectFactory.newObject(FreeChunk.class, nextField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public FreeChunk prev() {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 Address prev = prevField.getValue(addr).andWithMask(~0x3);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 return (FreeChunk) VMObjectFactory.newObject(FreeChunk.class, prev);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public long size() {
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
65 if (VM.getVM().isCompressedOopsEnabled()) {
904
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
66 Mark mark = new Mark(addr.addOffsetTo(sizeField.getOffset()));
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
67 return mark.getSize();
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
68 } else {
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
69 Address size = sizeField.getValue(addr);
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
70 Debugger dbg = VM.getVM().getDebugger();
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
71 return dbg.getAddressValue(size);
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
72 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public FreeChunk(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
79 public static boolean indicatesFreeChunk(Address cur) {
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
80 FreeChunk f = new FreeChunk(cur);
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
81 return f.isFree();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public boolean isFree() {
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
85 if (VM.getVM().isCompressedOopsEnabled()) {
904
ef671fb22f73 6868051: (SA) FreeChunk support for compressed oops is broken
never
parents: 196
diff changeset
86 Mark mark = new Mark(addr.addOffsetTo(sizeField.getOffset()));
187
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
87 return mark.isCmsFreeChunk();
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
88 } else {
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
89 Address prev = prevField.getValue(addr);
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
90 Debugger dbg = VM.getVM().getDebugger();
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
91 long word = dbg.getAddressValue(prev);
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
92 return (word & 0x1L) == 0x1L;
790e66e5fbac 6687581: Make CMS work with compressed oops
coleenp
parents: 0
diff changeset
93 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }