001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.mmtk.policy;
014
015 import org.mmtk.plan.TransitiveClosure;
016 import org.mmtk.utility.heap.FreeListPageResource;
017 import org.mmtk.utility.heap.VMRequest;
018 import org.mmtk.utility.Constants;
019
020 import org.mmtk.vm.VM;
021
022 import org.vmmagic.pragma.*;
023 import org.vmmagic.unboxed.*;
024
025 /**
026 * Each instance of this class corresponds to one raw page space.
027 *
028 * This class provides access to raw memory for managing internal meta
029 * data.
030 */
031 @Uninterruptible public final class RawPageSpace extends Space
032 implements Constants {
033
034 /**
035 * The caller specifies the region of virtual memory to be used for
036 * this space. If this region conflicts with an existing space,
037 * then the constructor will fail.
038 *
039 * @param name The name of this space (used when printing error messages etc)
040 * @param pageBudget The number of pages this space may consume
041 * before consulting the plan
042 * @param vmRequest An object describing the virtual memory requested.
043 */
044 public RawPageSpace(String name, int pageBudget, VMRequest vmRequest) {
045 super(name, false, false, vmRequest);
046 if (vmRequest.isDiscontiguous()) {
047 pr = new FreeListPageResource(pageBudget, this, 0);
048 } else {
049 pr = new FreeListPageResource(pageBudget, this, start, extent);
050 }
051 }
052
053 public void prepare() { }
054 public void release() { }
055
056 /**
057 * Release a group of pages that were allocated together.
058 *
059 * @param first The first page in the group of pages that were
060 * allocated together.
061 */
062 @Inline
063 public void release(Address first) {
064 ((FreeListPageResource) pr).releasePages(first);
065 }
066
067 /**
068 * Trace an object.
069 *
070 * This makes no sense for a raw page space and should never be
071 * called.
072 *
073 * @param object The object to be traced.
074 * @return <code>zero</code>: calling this is an error.
075 */
076 @Inline
077 public ObjectReference traceObject(TransitiveClosure trace, ObjectReference object) {
078 if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false);
079 return ObjectReference.nullReference();
080 }
081
082 public boolean isLive(ObjectReference object) {
083 return true;
084 }
085 }