| 1 |
/* |
| 2 |
* $Id$ |
| 3 |
* |
| 4 |
* Copyright (C) 2003-2009 JNode.org |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or modify it |
| 7 |
* under the terms of the GNU Lesser General Public License as published |
| 8 |
* by the Free Software Foundation; either version 2.1 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, but |
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 14 |
* License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public License |
| 17 |
* along with this library; If not, write to the Free Software Foundation, Inc., |
| 18 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
package org.jnode.vm.memmgr; |
| 22 |
|
| 23 |
import org.jnode.vm.ObjectVisitor; |
| 24 |
import org.jnode.vm.VmArchitecture; |
| 25 |
import org.jnode.vm.classmgr.ObjectFlags; |
| 26 |
import org.jnode.vm.classmgr.VmMethod; |
| 27 |
import org.jnode.vm.scheduler.Monitor; |
| 28 |
import org.vmmagic.pragma.Uninterruptible; |
| 29 |
import org.vmmagic.unboxed.Address; |
| 30 |
import org.vmmagic.unboxed.Extent; |
| 31 |
import org.vmmagic.unboxed.ObjectReference; |
| 32 |
|
| 33 |
/** |
| 34 |
* @author Ewout Prangsma (epr@users.sourceforge.net) |
| 35 |
*/ |
| 36 |
public abstract class HeapHelper implements Uninterruptible { |
| 37 |
|
| 38 |
/** |
| 39 |
* Mark the given object as finalized. |
| 40 |
* |
| 41 |
* @param src |
| 42 |
*/ |
| 43 |
public abstract void setFinalized(Object src); |
| 44 |
|
| 45 |
/** |
| 46 |
* Change the color of the given object from oldColor to newColor. |
| 47 |
* |
| 48 |
* @param dst |
| 49 |
* @param oldColor |
| 50 |
* @param newColor |
| 51 |
* @return True if the color was changed, false if the current color of the object was not equal to oldColor. |
| 52 |
*/ |
| 53 |
public abstract boolean atomicChangeObjectColor(Object dst, int oldColor, int newColor); |
| 54 |
|
| 55 |
public abstract int incrementAge(Object obj); |
| 56 |
|
| 57 |
public abstract boolean setOld(Object obj); |
| 58 |
|
| 59 |
public abstract int getNbRefs(Object obj); |
| 60 |
|
| 61 |
public abstract int decRef(Object obj); |
| 62 |
|
| 63 |
public abstract void copy(Address src, Address dst, Extent size); |
| 64 |
|
| 65 |
public abstract void clear(Address dst, int size); |
| 66 |
|
| 67 |
public abstract void clear(Address dst, Extent size); |
| 68 |
|
| 69 |
public abstract Address allocateBlock(Extent size); |
| 70 |
|
| 71 |
/** |
| 72 |
* Gets the start address of the boot image |
| 73 |
*/ |
| 74 |
public abstract Address getBootImageStart(); |
| 75 |
|
| 76 |
/** |
| 77 |
* End the end address of the boot image |
| 78 |
*/ |
| 79 |
public abstract Address getBootImageEnd(); |
| 80 |
|
| 81 |
/** |
| 82 |
* Gets the start address of the boot heap |
| 83 |
*/ |
| 84 |
public abstract Address getBootHeapStart(); |
| 85 |
|
| 86 |
/** |
| 87 |
* End the end address of the boot heap |
| 88 |
*/ |
| 89 |
public abstract Address getBootHeapEnd(); |
| 90 |
|
| 91 |
/** |
| 92 |
* Gets the amount of memory available to the memory manager |
| 93 |
*/ |
| 94 |
public abstract Extent getHeapSize(); |
| 95 |
|
| 96 |
public abstract void invokeFinalizer(VmMethod finalizer, Object object); |
| 97 |
|
| 98 |
public abstract void die(String msg); |
| 99 |
|
| 100 |
/** |
| 101 |
* Gets the inflated monitor of an object (if any). |
| 102 |
* |
| 103 |
* @param object |
| 104 |
* @param arch |
| 105 |
* @return The inflated monitor of the given object, or null if the given object has no |
| 106 |
* inflated monitor. |
| 107 |
*/ |
| 108 |
public abstract Monitor getInflatedMonitor(Object object, VmArchitecture arch); |
| 109 |
|
| 110 |
/** |
| 111 |
* Stop and block all threads (on all processors) on a GC safe point. |
| 112 |
* Only the calling thread (the GC thread) will continue. |
| 113 |
*/ |
| 114 |
public abstract void stopThreadsAtSafePoint(); |
| 115 |
|
| 116 |
/** |
| 117 |
* Unblock all threads (on all processors). |
| 118 |
* This method is called after a call a call to {@link #stopThreadsAtSafePoint()}. |
| 119 |
*/ |
| 120 |
public abstract void restartThreads(); |
| 121 |
|
| 122 |
/** |
| 123 |
* Visit all roots of the object tree. |
| 124 |
* |
| 125 |
* @param visitor |
| 126 |
*/ |
| 127 |
public abstract void visitAllRoots(ObjectVisitor visitor, VmHeapManager heapManager); |
| 128 |
|
| 129 |
/** |
| 130 |
* Boot the architecture object. |
| 131 |
* |
| 132 |
* @param emptyMMap If true all page mappings in the AVAILABLE region |
| 133 |
* are removed. |
| 134 |
*/ |
| 135 |
public abstract void bootArchitecture(boolean emptyMMap); |
| 136 |
} |