| 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; |
| 22 |
|
| 23 |
import org.jnode.annotation.Internal; |
| 24 |
import org.jnode.annotation.KernelSpace; |
| 25 |
import org.jnode.annotation.MagicPermission; |
| 26 |
import org.jnode.vm.classmgr.VmClassType; |
| 27 |
import org.jnode.vm.scheduler.VmProcessor; |
| 28 |
import org.vmmagic.unboxed.Address; |
| 29 |
import org.vmmagic.unboxed.Word; |
| 30 |
|
| 31 |
/** |
| 32 |
* Class containing "magic" methods that are interpreted by the VM itself, |
| 33 |
* instead of being executed as normal java methods. The actual method |
| 34 |
* bodies are not used. |
| 35 |
* <p/> |
| 36 |
* Methods is this class can also be called from inside JNode. |
| 37 |
* |
| 38 |
* @author Ewout Prangsma (epr@users.sourceforge.net) |
| 39 |
*/ |
| 40 |
@MagicPermission |
| 41 |
public final class VmMagic { |
| 42 |
|
| 43 |
/** |
| 44 |
* Gets the VmType of the given object. |
| 45 |
* |
| 46 |
* @param object |
| 47 |
* @return the VmType of the given object |
| 48 |
*/ |
| 49 |
public static VmClassType<?> getObjectType(Object object) { |
| 50 |
return null; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Gets the Type Information Block of the given object. |
| 55 |
* |
| 56 |
* @param object |
| 57 |
* @return TIB |
| 58 |
*/ |
| 59 |
public static Object[] getTIB(Object object) { |
| 60 |
return null; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Gets all of the flags of the given object. |
| 65 |
* |
| 66 |
* @param object |
| 67 |
* @return the object flags |
| 68 |
*/ |
| 69 |
public static Word getObjectFlags(Object object) { |
| 70 |
return Word.zero(); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Gets the GC color flags of the given object. |
| 75 |
* |
| 76 |
* @param object |
| 77 |
* @return the GC color flags (as an int) |
| 78 |
*/ |
| 79 |
public static int getObjectColor(Object object) { |
| 80 |
return 0; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Sets all of the flags of the given object. |
| 85 |
* |
| 86 |
* @param object the target object |
| 87 |
* @param flags the new flags value |
| 88 |
*/ |
| 89 |
public static void setObjectFlags(Object object, Word flags) { |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Gets the address of the first array element of the given array. |
| 94 |
* |
| 95 |
* @param array |
| 96 |
* @return the address of the first array element of the given array |
| 97 |
*/ |
| 98 |
public static Address getArrayData(Object array) { |
| 99 |
return null; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Has the given object been finalized. |
| 104 |
* |
| 105 |
* @param src |
| 106 |
* @return if the given object has been finalized |
| 107 |
*/ |
| 108 |
public static boolean isFinalized(Object src) { |
| 109 |
return false; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Gets the current stackframe |
| 114 |
* |
| 115 |
* @return The address of the stackframe of the current thread |
| 116 |
*/ |
| 117 |
@KernelSpace |
| 118 |
@Internal |
| 119 |
public static Address getCurrentFrame() { |
| 120 |
return null; |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* Gets the timestamp of the current processor. |
| 125 |
* |
| 126 |
* @return the timestamp of the current processor |
| 127 |
*/ |
| 128 |
public static long getTimeStamp() { |
| 129 |
return 0; |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Type cast a 32-bit word to a Java float. |
| 134 |
* |
| 135 |
* @param value a 32-bit word |
| 136 |
* @return the same bit pattern as a float |
| 137 |
*/ |
| 138 |
public static float intBitsToFloat(int value) { |
| 139 |
return 0; |
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* Type cast a Java float to a 32-bit word. |
| 144 |
* |
| 145 |
* @param value a float |
| 146 |
* @return the same bit pattern as a 32-bit word |
| 147 |
*/ |
| 148 |
public static int floatToRawIntBits(float value) { |
| 149 |
return 0; |
| 150 |
} |
| 151 |
|
| 152 |
/** |
| 153 |
* Type cast a 64-bit word to a Java double. |
| 154 |
* |
| 155 |
* @param value a 64-bit word |
| 156 |
* @return the same bit pattern as a double |
| 157 |
*/ |
| 158 |
public static double longBitsToDouble(long value) { |
| 159 |
return 0; |
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* Type cast a Java double to a 64-bit word. |
| 164 |
* |
| 165 |
* @param value a double |
| 166 |
* @return the same bit pattern as a 64-bit word |
| 167 |
*/ |
| 168 |
public static long doubleToRawLongBits(double value) { |
| 169 |
return 0; |
| 170 |
} |
| 171 |
|
| 172 |
/** |
| 173 |
* Force a breakpoint |
| 174 |
*/ |
| 175 |
public static void breakPoint() { |
| 176 |
} |
| 177 |
|
| 178 |
/** |
| 179 |
* Gets the processor executing the current thread. |
| 180 |
* |
| 181 |
* @return the processor executing the current thread |
| 182 |
*/ |
| 183 |
@KernelSpace |
| 184 |
public static VmProcessor currentProcessor() { |
| 185 |
return null; |
| 186 |
} |
| 187 |
|
| 188 |
/** |
| 189 |
* Gets the address of a shared static field. |
| 190 |
* |
| 191 |
* @param index |
| 192 |
* @return the address of a shared static field |
| 193 |
*/ |
| 194 |
public static Address getSharedStaticFieldAddress(int index) { |
| 195 |
return null; |
| 196 |
} |
| 197 |
|
| 198 |
/** |
| 199 |
* Gets the address of a isolated static field. |
| 200 |
* |
| 201 |
* @param index |
| 202 |
* @return the address of a isolated static field |
| 203 |
*/ |
| 204 |
public static Address getIsolatedStaticFieldAddress(int index) { |
| 205 |
return null; |
| 206 |
} |
| 207 |
|
| 208 |
/** |
| 209 |
* Are we currently running JNode. |
| 210 |
* |
| 211 |
* @return true when running JNode, false when running any other VM. |
| 212 |
*/ |
| 213 |
public static boolean isRunningJNode() { |
| 214 |
return false; |
| 215 |
} |
| 216 |
|
| 217 |
/** |
| 218 |
* Do not instantiate this class. |
| 219 |
*/ |
| 220 |
private VmMagic() { |
| 221 |
} |
| 222 |
} |