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.<p>
027 *
028 * This class provides access to raw memory for managing internal meta
029 * data.
030 */
031 @Uninterruptible
032 public final class RawPageSpace extends Space 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 vmRequest An object describing the virtual memory requested.
041 */
042 public RawPageSpace(String name, VMRequest vmRequest) {
043 super(name, false, false, true, vmRequest);
044 if (vmRequest.isDiscontiguous()) {
045 pr = new FreeListPageResource(this, 0);
046 } else {
047 pr = new FreeListPageResource(this, start, extent);
048 }
049 }
050
051 public void prepare() { }
052 public void release() { }
053
054 /**
055 * Release a group of pages that were allocated together.
056 *
057 * @param first The first page in the group of pages that were
058 * allocated together.
059 */
060 @Override
061 @Inline
062 public void release(Address first) {
063 ((FreeListPageResource) pr).releasePages(first);
064 }
065
066 /**
067 * Trace an object.<p>
068 *
069 * This makes no sense for a raw page space and should never be
070 * called.
071 *
072 * @param object The object to be traced.
073 * @return <code>zero</code>: calling this is an error.
074 */
075 @Override
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 @Override
083 public boolean isLive(ObjectReference object) {
084 return true;
085 }
086 }