0N/A/*
1472N/A * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
0N/Apackage sun.jvm.hotspot.memory;
0N/A
0N/Aimport java.io.*;
0N/Aimport java.util.*;
0N/A
0N/Aimport sun.jvm.hotspot.debugger.*;
0N/Aimport sun.jvm.hotspot.runtime.*;
0N/Aimport sun.jvm.hotspot.types.*;
0N/A
0N/Apublic class ContiguousSpace extends CompactibleSpace {
0N/A private static AddressField topField;
0N/A
0N/A static {
0N/A VM.registerVMInitializedObserver(new Observer() {
0N/A public void update(Observable o, Object data) {
0N/A initialize(VM.getVM().getTypeDataBase());
0N/A }
0N/A });
0N/A }
0N/A
0N/A private static synchronized void initialize(TypeDataBase db) {
0N/A Type type = db.lookupType("ContiguousSpace");
0N/A
0N/A topField = type.getAddressField("_top");
0N/A }
0N/A
0N/A public ContiguousSpace(Address addr) {
0N/A super(addr);
0N/A }
0N/A
0N/A public Address top() {
0N/A return topField.getValue(addr);
0N/A }
0N/A
0N/A /** In bytes */
0N/A public long capacity() {
0N/A return end().minus(bottom());
0N/A }
0N/A
0N/A /** In bytes */
0N/A public long used() {
0N/A return top().minus(bottom());
0N/A }
0N/A
0N/A /** In bytes */
0N/A public long free() {
0N/A return end().minus(top());
0N/A }
0N/A
0N/A /** In a contiguous space we have a more obvious bound on what parts
0N/A contain objects. */
0N/A public MemRegion usedRegion() {
0N/A return new MemRegion(bottom(), top());
0N/A }
0N/A
0N/A /** Returns regions of Space where live objects live */
0N/A public List/*<MemRegion>*/ getLiveRegions() {
0N/A List res = new ArrayList();
0N/A res.add(new MemRegion(bottom(), top()));
0N/A return res;
0N/A }
0N/A
0N/A /** Testers */
0N/A public boolean contains(Address p) {
0N/A return (bottom().lessThanOrEqual(p) && top().greaterThan(p));
0N/A }
0N/A
0N/A public void printOn(PrintStream tty) {
0N/A tty.print(" [" + bottom() + "," +
0N/A top() + "," + end() + ")");
0N/A super.printOn(tty);
0N/A }
0N/A}