1 /*
2 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 //
26 // The ObjectHeap is an abstraction over all generations in the VM
27 // It gives access to all present objects and classes.
28 //
29
30 package sun.jvm.hotspot.oops;
31
32 import java.util.*;
33
34 import sun.jvm.hotspot.debugger.*;
35 import sun.jvm.hotspot.gc.cms.*;
36 import sun.jvm.hotspot.gc.shared.*;
37 import sun.jvm.hotspot.gc.epsilon.*;
38 import sun.jvm.hotspot.gc.g1.*;
39 import sun.jvm.hotspot.gc.parallel.*;
40 import sun.jvm.hotspot.memory.*;
41 import sun.jvm.hotspot.runtime.*;
42 import sun.jvm.hotspot.types.*;
43 import sun.jvm.hotspot.utilities.*;
44
45 public class ObjectHeap {
46
47 private static final boolean DEBUG;
48
49 static {
50 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
51 }
52
53 private Address boolArrayKlassHandle;
54 private Address byteArrayKlassHandle;
55 private Address charArrayKlassHandle;
56 private Address intArrayKlassHandle;
57 private Address shortArrayKlassHandle;
58 private Address longArrayKlassHandle;
59 private Address singleArrayKlassHandle;
426 for (int i = 0; i < genHeap.nGens(); i++) {
427 Generation gen = genHeap.getGen(i);
428 gen.spaceIterate(lrc, true);
429 }
430 } else if (heap instanceof ParallelScavengeHeap) {
431 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
432 PSYoungGen youngGen = psh.youngGen();
433 // Add eden space
434 addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
435 // Add from-space but not to-space
436 addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
437 PSOldGen oldGen = psh.oldGen();
438 addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
439 } else if (heap instanceof G1CollectedHeap) {
440 G1CollectedHeap g1h = (G1CollectedHeap) heap;
441 g1h.heapRegionIterate(lrc);
442 } else if (heap instanceof EpsilonHeap) {
443 EpsilonHeap eh = (EpsilonHeap) heap;
444 liveRegions.add(eh.space().top());
445 liveRegions.add(eh.space().bottom());
446 } else {
447 if (Assert.ASSERTS_ENABLED) {
448 Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName());
449 }
450 }
451
452 // If UseTLAB is enabled, snip out regions associated with TLABs'
453 // dead regions. Note that TLABs can be present in any generation.
454
455 // FIXME: consider adding fewer boundaries to live region list.
456 // Theoretically only need to stop at TLAB's top and resume at its
457 // end.
458
459 if (VM.getVM().getUseTLAB()) {
460 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
461 ThreadLocalAllocBuffer tlab = thread.tlab();
462 if (tlab.start() != null) {
463 if ((tlab.top() == null) || (tlab.end() == null)) {
464 System.err.print("Warning: skipping invalid TLAB for thread ");
465 thread.printThreadIDOn(System.err);
|
1 /*
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 //
26 // The ObjectHeap is an abstraction over all generations in the VM
27 // It gives access to all present objects and classes.
28 //
29
30 package sun.jvm.hotspot.oops;
31
32 import java.util.*;
33
34 import sun.jvm.hotspot.debugger.*;
35 import sun.jvm.hotspot.gc.cms.*;
36 import sun.jvm.hotspot.gc.shared.*;
37 import sun.jvm.hotspot.gc.epsilon.*;
38 import sun.jvm.hotspot.gc.g1.*;
39 import sun.jvm.hotspot.gc.parallel.*;
40 import sun.jvm.hotspot.gc.z.*;
41 import sun.jvm.hotspot.memory.*;
42 import sun.jvm.hotspot.runtime.*;
43 import sun.jvm.hotspot.types.*;
44 import sun.jvm.hotspot.utilities.*;
45
46 public class ObjectHeap {
47
48 private static final boolean DEBUG;
49
50 static {
51 DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
52 }
53
54 private Address boolArrayKlassHandle;
55 private Address byteArrayKlassHandle;
56 private Address charArrayKlassHandle;
57 private Address intArrayKlassHandle;
58 private Address shortArrayKlassHandle;
59 private Address longArrayKlassHandle;
60 private Address singleArrayKlassHandle;
427 for (int i = 0; i < genHeap.nGens(); i++) {
428 Generation gen = genHeap.getGen(i);
429 gen.spaceIterate(lrc, true);
430 }
431 } else if (heap instanceof ParallelScavengeHeap) {
432 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
433 PSYoungGen youngGen = psh.youngGen();
434 // Add eden space
435 addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
436 // Add from-space but not to-space
437 addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
438 PSOldGen oldGen = psh.oldGen();
439 addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
440 } else if (heap instanceof G1CollectedHeap) {
441 G1CollectedHeap g1h = (G1CollectedHeap) heap;
442 g1h.heapRegionIterate(lrc);
443 } else if (heap instanceof EpsilonHeap) {
444 EpsilonHeap eh = (EpsilonHeap) heap;
445 liveRegions.add(eh.space().top());
446 liveRegions.add(eh.space().bottom());
447 } else if (heap instanceof ZCollectedHeap) {
448 ZCollectedHeap zh = (ZCollectedHeap) heap;
449 zh.heap().pageTable().pageTableIterate(p -> {
450 if (p.refcount() > 0 ) {
451 liveRegions.add(ZGlobals.ZAddressSpaceStart.addOffsetTo(p.start()));
452 liveRegions.add(ZGlobals.ZAddressSpaceStart.addOffsetTo(p.top()));
453 }
454 });
455 } else {
456 if (Assert.ASSERTS_ENABLED) {
457 Assert.that(false, "Unexpected CollectedHeap type: " + heap.getClass().getName());
458 }
459 }
460
461 // If UseTLAB is enabled, snip out regions associated with TLABs'
462 // dead regions. Note that TLABs can be present in any generation.
463
464 // FIXME: consider adding fewer boundaries to live region list.
465 // Theoretically only need to stop at TLAB's top and resume at its
466 // end.
467
468 if (VM.getVM().getUseTLAB()) {
469 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
470 ThreadLocalAllocBuffer tlab = thread.tlab();
471 if (tlab.start() != null) {
472 if ((tlab.top() == null) || (tlab.end() == null)) {
473 System.err.print("Warning: skipping invalid TLAB for thread ");
474 thread.printThreadIDOn(System.err);
|