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 *
71
72 /** Returns a subregion of the space containing all the objects in
73 the space. */
74 public MemRegion usedRegion() {
75 return new MemRegion(bottom(), end());
76 }
77
78 /** Support for iteration over heap -- not sure how this will
79 interact with GC in reflective system, but necessary for the
80 debugging mechanism */
81 public OopHandle bottomAsOopHandle() {
82 return bottomField.getOopHandle(addr);
83 }
84
85 /** Support for iteration over heap -- not sure how this will
86 interact with GC in reflective system, but necessary for the
87 debugging mechanism */
88 public OopHandle nextOopHandle(OopHandle handle, long size) {
89 return handle.addOffsetToAsOopHandle(size);
90 }
91
92 /** returns all MemRegions where live objects are */
93 public abstract List/*<MemRegion>*/ getLiveRegions();
94
95 /** Returned value is in bytes */
96 public long capacity() { return end().minus(bottom()); }
97 /** Returned value is in bytes */
98 public abstract long used();
99 /** Returned value is in bytes */
100 public abstract long free();
101
102 /** Testers */
103 public boolean contains(Address p) {
104 return (bottom().lessThanOrEqual(p) && end().greaterThan(p));
105 }
106
107 public void print() { printOn(System.out); }
108 public void printOn(PrintStream tty) {
109 tty.print(" space capacity = ");
110 tty.print(capacity());
111 tty.print(", ");
112 tty.print((double) used() * 100.0/ capacity());
113 tty.print(" used");
|
1 /*
2 * Copyright (c) 2000, 2019, 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 *
71
72 /** Returns a subregion of the space containing all the objects in
73 the space. */
74 public MemRegion usedRegion() {
75 return new MemRegion(bottom(), end());
76 }
77
78 /** Support for iteration over heap -- not sure how this will
79 interact with GC in reflective system, but necessary for the
80 debugging mechanism */
81 public OopHandle bottomAsOopHandle() {
82 return bottomField.getOopHandle(addr);
83 }
84
85 /** Support for iteration over heap -- not sure how this will
86 interact with GC in reflective system, but necessary for the
87 debugging mechanism */
88 public OopHandle nextOopHandle(OopHandle handle, long size) {
89 return handle.addOffsetToAsOopHandle(size);
90 }
91
92 /** Returned value is in bytes */
93 public long capacity() { return end().minus(bottom()); }
94 /** Returned value is in bytes */
95 public abstract long used();
96 /** Returned value is in bytes */
97 public abstract long free();
98
99 /** Testers */
100 public boolean contains(Address p) {
101 return (bottom().lessThanOrEqual(p) && end().greaterThan(p));
102 }
103
104 public void print() { printOn(System.out); }
105 public void printOn(PrintStream tty) {
106 tty.print(" space capacity = ");
107 tty.print(capacity());
108 tty.print(", ");
109 tty.print((double) used() * 100.0/ capacity());
110 tty.print(" used");
|