Commit 9d51007d authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Remove the old bootstrap, it is broken and incomplete anyway.

parent e1f61725
...@@ -15,36 +15,34 @@ ...@@ -15,36 +15,34 @@
#include "cc_squirreljme_jvm_Assembly.h" #include "cc_squirreljme_jvm_Assembly.h"
#include "squirreljme.h" #include "squirreljme.h"
JNIEXPORT jlong JNICALL longPack(JNIEnv* env, jclass classy, jint al, jint ah)
{
return (((jlong)al) & UINT64_C(0xFFFFFFFF)) |
((((jlong)ah) & UINT64_C(0xFFFFFFFF)) << UINT64_C(32));
}
JNIEXPORT jint JNICALL longUnpackHigh(JNIEnv* env, jclass classy, jlong v)
{
return (jint)(v >> UINT64_C(32));
}
JNIEXPORT jint JNICALL longUnpackLow(JNIEnv* env, jclass classy, jlong v)
{
return (jint)(v);
}
// Method handler for special functions // Method handler for special functions
JNIEXPORT void JNICALL restrictedFunction(JNIEnv* env, jclass classy); JNIEXPORT void JNICALL restrictedFunction(JNIEnv* env, jclass classy);
// Assembly method mappings // Assembly method mappings
static const JNINativeMethod assemblyMethods[] = static const JNINativeMethod assemblyMethods[] =
{ {
{"arrayLength", "(J)I", (void*)restrictedFunction}, {"arrayLength", "(I)I", (void*)restrictedFunction},
{"arrayLength", "(Ljava/lang/Object;)I", (void*)restrictedFunction}, {"arrayLength", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
{"arrayLengthSet", "(JI)V", (void*)restrictedFunction},
{"arrayLengthSet", "(Ljava/lang/Object;I)V", (void*)restrictedFunction},
{"atomicCompareGetAndSet", "(IIJ)I", (void*)restrictedFunction}, {"atomicCompareGetAndSet", "(IIJ)I", (void*)restrictedFunction},
{"atomicDecrementAndGet", "(J)I", (void*)restrictedFunction}, {"atomicDecrementAndGet", "(J)I", (void*)restrictedFunction},
{"atomicIncrement", "(J)V", (void*)restrictedFunction}, {"atomicIncrement", "(J)V", (void*)restrictedFunction},
{"breakpoint", "()V", (void*)restrictedFunction}, {"breakpoint", "()V", (void*)restrictedFunction},
{"classInfoOfBoolean", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfBooleanPointer", "()J", (void*)restrictedFunction},
{"classInfoOfByte", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfBytePointer", "()J", (void*)restrictedFunction},
{"classInfoOfCharacter", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfCharacterPointer", "()J", (void*)restrictedFunction},
{"classInfoOfDouble", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfDoublePointer", "()J", (void*)restrictedFunction},
{"classInfoOfFloat", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfFloatPointer", "()J", (void*)restrictedFunction},
{"classInfoOfInteger", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfIntegerPointer", "()J", (void*)restrictedFunction},
{"classInfoOfLong", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfLongPointer", "()J", (void*)restrictedFunction},
{"classInfoOfShort", "()Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"classInfoOfShortPointer", "()J", (void*)restrictedFunction},
{"doublePack", "(II)D", (void*)restrictedFunction}, {"doublePack", "(II)D", (void*)restrictedFunction},
{"doubleToRawLongBits", "(D)J", (void*)restrictedFunction}, {"doubleToRawLongBits", "(D)J", (void*)restrictedFunction},
{"doubleUnpackHigh", "(D)I", (void*)restrictedFunction}, {"doubleUnpackHigh", "(D)I", (void*)restrictedFunction},
...@@ -52,50 +50,44 @@ static const JNINativeMethod assemblyMethods[] = ...@@ -52,50 +50,44 @@ static const JNINativeMethod assemblyMethods[] =
{"exceptionHandle", "()V", (void*)restrictedFunction}, {"exceptionHandle", "()V", (void*)restrictedFunction},
{"floatToRawIntBits", "(F)I", (void*)restrictedFunction}, {"floatToRawIntBits", "(F)I", (void*)restrictedFunction},
{"intBitsToFloat", "(I)F", (void*)restrictedFunction}, {"intBitsToFloat", "(I)F", (void*)restrictedFunction},
{"invoke", "(JJ)V", (void*)restrictedFunction}, {"invoke", "(II)V", (void*)restrictedFunction},
{"invoke", "(JJI)V", (void*)restrictedFunction}, {"invoke", "(III)V", (void*)restrictedFunction},
{"invoke", "(JJII)V", (void*)restrictedFunction}, {"invoke", "(IIII)V", (void*)restrictedFunction},
{"invoke", "(JJIII)V", (void*)restrictedFunction}, {"invoke", "(IIIII)V", (void*)restrictedFunction},
{"invoke", "(JJIIII)V", (void*)restrictedFunction}, {"invoke", "(IIIIII)V", (void*)restrictedFunction},
{"invoke", "(JJIIIII)V", (void*)restrictedFunction}, {"invoke", "(IIIIIII)V", (void*)restrictedFunction},
{"invoke", "(JJIIIIII)V", (void*)restrictedFunction}, {"invoke", "(IIIIIIII)V", (void*)restrictedFunction},
{"invoke", "(JJIIIIIII)V", (void*)restrictedFunction}, {"invoke", "(IIIIIIIII)V", (void*)restrictedFunction},
{"invoke", "(JJIIIIIIII)V", (void*)restrictedFunction}, {"invoke", "(IIIIIIIIII)V", (void*)restrictedFunction},
{"invokeV", "(JJ)I", (void*)restrictedFunction}, {"invokeV", "(II)I", (void*)restrictedFunction},
{"invokeV", "(JJI)I", (void*)restrictedFunction}, {"invokeV", "(III)I", (void*)restrictedFunction},
{"invokeV", "(JJII)I", (void*)restrictedFunction}, {"invokeV", "(IIII)I", (void*)restrictedFunction},
{"invokeV", "(JJIII)I", (void*)restrictedFunction}, {"invokeV", "(IIIII)I", (void*)restrictedFunction},
{"invokeV", "(JJIIII)I", (void*)restrictedFunction}, {"invokeV", "(IIIIII)I", (void*)restrictedFunction},
{"invokeV", "(JJIIIII)I", (void*)restrictedFunction}, {"invokeV", "(IIIIIII)I", (void*)restrictedFunction},
{"invokeV", "(JJIIIIII)I", (void*)restrictedFunction}, {"invokeV", "(IIIIIIII)I", (void*)restrictedFunction},
{"invokeV", "(JJIIIIIII)I", (void*)restrictedFunction}, {"invokeV", "(IIIIIIIII)I", (void*)restrictedFunction},
{"invokeV", "(JJIIIIIIII)I", (void*)restrictedFunction}, {"invokeV", "(IIIIIIIIII)I", (void*)restrictedFunction},
{"invokeVL", "(JJ)J", (void*)restrictedFunction}, {"invokeVL", "(II)J", (void*)restrictedFunction},
{"invokeVL", "(JJI)J", (void*)restrictedFunction}, {"invokeVL", "(III)J", (void*)restrictedFunction},
{"invokeVL", "(JJII)J", (void*)restrictedFunction}, {"invokeVL", "(IIII)J", (void*)restrictedFunction},
{"invokeVL", "(JJIII)J", (void*)restrictedFunction}, {"invokeVL", "(IIIII)J", (void*)restrictedFunction},
{"invokeVL", "(JJIIII)J", (void*)restrictedFunction}, {"invokeVL", "(IIIIII)J", (void*)restrictedFunction},
{"invokeVL", "(JJIIIII)J", (void*)restrictedFunction}, {"invokeVL", "(IIIIIII)J", (void*)restrictedFunction},
{"invokeVL", "(JJIIIIII)J", (void*)restrictedFunction}, {"invokeVL", "(IIIIIIII)J", (void*)restrictedFunction},
{"invokeVL", "(JJIIIIIII)J", (void*)restrictedFunction}, {"invokeVL", "(IIIIIIIII)J", (void*)restrictedFunction},
{"invokeVL", "(JJIIIIIIII)J", (void*)restrictedFunction}, {"invokeVL", "(IIIIIIIIII)J", (void*)restrictedFunction},
{"longBitsToDouble", "(J)D", (void*)restrictedFunction}, {"longBitsToDouble", "(J)D", (void*)restrictedFunction},
{"longPack", "(II)J", (void*)restrictedFunction}, {"longPack", "(II)J", (void*)longPack},
{"longUnpackHigh", "(J)I", (void*)restrictedFunction}, {"longUnpackHigh", "(J)I", (void*)longUnpackHigh},
{"longUnpackLow", "(J)I", (void*)restrictedFunction}, {"longUnpackLow", "(J)I", (void*)longUnpackLow},
{"memReadByte", "(JI)I", (void*)restrictedFunction}, {"memReadByte", "(JI)I", (void*)restrictedFunction},
{"memReadInt", "(JI)I", (void*)restrictedFunction}, {"memReadInt", "(JI)I", (void*)restrictedFunction},
{"memReadJavaInt", "(JI)I", (void*)restrictedFunction}, {"memReadLong", "(JI)J", (void*)restrictedFunction},
{"memReadJavaLong", "(JI)J", (void*)restrictedFunction},
{"memReadJavaShort", "(JI)I", (void*)restrictedFunction},
{"memReadPointer", "(JI)J", (void*)restrictedFunction},
{"memReadShort", "(JI)I", (void*)restrictedFunction}, {"memReadShort", "(JI)I", (void*)restrictedFunction},
{"memWriteByte", "(JII)V", (void*)restrictedFunction}, {"memWriteByte", "(JII)V", (void*)restrictedFunction},
{"memWriteInt", "(JII)V", (void*)restrictedFunction}, {"memWriteInt", "(JII)V", (void*)restrictedFunction},
{"memWriteJavaInt", "(JII)V", (void*)restrictedFunction}, {"memWriteLong", "(JIJ)V", (void*)restrictedFunction},
{"memWriteJavaLong", "(JIJ)V", (void*)restrictedFunction},
{"memWriteJavaShort", "(JII)V", (void*)restrictedFunction},
{"memWritePointer", "(JIJ)V", (void*)restrictedFunction},
{"memWriteShort", "(JII)V", (void*)restrictedFunction}, {"memWriteShort", "(JII)V", (void*)restrictedFunction},
{"monitorCountDecrementAndGetAtomic", "(J)I", (void*)restrictedFunction}, {"monitorCountDecrementAndGetAtomic", "(J)I", (void*)restrictedFunction},
{"monitorCountDecrementAndGetAtomic", "(Ljava/lang/Object;)I", (void*)restrictedFunction}, {"monitorCountDecrementAndGetAtomic", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
...@@ -121,37 +113,23 @@ static const JNINativeMethod assemblyMethods[] = ...@@ -121,37 +113,23 @@ static const JNINativeMethod assemblyMethods[] =
{"monitorOwnerSetAtomic", "(JLjava/lang/Thread;)V", (void*)restrictedFunction}, {"monitorOwnerSetAtomic", "(JLjava/lang/Thread;)V", (void*)restrictedFunction},
{"monitorOwnerSetAtomic", "(Ljava/lang/Object;J)V", (void*)restrictedFunction}, {"monitorOwnerSetAtomic", "(Ljava/lang/Object;J)V", (void*)restrictedFunction},
{"monitorOwnerSetAtomic", "(Ljava/lang/Object;Ljava/lang/Thread;)V", (void*)restrictedFunction}, {"monitorOwnerSetAtomic", "(Ljava/lang/Object;Ljava/lang/Thread;)V", (void*)restrictedFunction},
{"objectGetClassInfo", "(J)Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction}, {"objectToPointer", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
{"objectGetClassInfo", "(Ljava/lang/Object;)Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction}, {"objectToPointerRefQueue", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
{"objectGetClassInfoPointer", "(J)J", (void*)restrictedFunction}, {"pointerToObject", "(I)Ljava/lang/Object;", (void*)restrictedFunction},
{"objectGetClassInfoPointer", "(Ljava/lang/Object;)J", (void*)restrictedFunction}, {"poolLoad", "(II)I", (void*)restrictedFunction},
{"objectSetClassInfo", "(JJ)V", (void*)restrictedFunction}, {"poolLoad", "(Ljava/lang/Object;I)I", (void*)restrictedFunction},
{"objectSetClassInfo", "(Ljava/lang/Object;J)V", (void*)restrictedFunction}, {"refCount", "(I)V", (void*)restrictedFunction},
{"objectSetClassInfo", "(JLcc/squirreljme/jvm/ClassInfo;)V", (void*)restrictedFunction},
{"objectSetClassInfo", "(Ljava/lang/Object;Lcc/squirreljme/jvm/ClassInfo;)V", (void*)restrictedFunction},
{"objectToPointer", "(Ljava/lang/Object;)J", (void*)restrictedFunction},
{"objectToPointerRefQueue", "(Ljava/lang/Object;)J", (void*)restrictedFunction},
{"pointerToObject", "(J)Ljava/lang/Object;", (void*)restrictedFunction},
{"pointerToClassInfo", "(J)Lcc/squirreljme/jvm/ClassInfo;", (void*)restrictedFunction},
{"poolLoad", "(JI)J", (void*)restrictedFunction},
{"poolLoad", "(Ljava/lang/Object;I)J", (void*)restrictedFunction},
{"poolStore", "(JIJ)V", (void*)restrictedFunction},
{"poolStore", "(Ljava/lang/Object;IJ)V", (void*)restrictedFunction},
{"refCount", "(J)V", (void*)restrictedFunction},
{"refCount", "(Ljava/lang/Object;)V", (void*)restrictedFunction}, {"refCount", "(Ljava/lang/Object;)V", (void*)restrictedFunction},
{"refGetCount", "(J)I", (void*)restrictedFunction}, {"refGetCount", "(I)I", (void*)restrictedFunction},
{"refGetCount", "(Ljava/lang/Object;)I", (void*)restrictedFunction}, {"refGetCount", "(Ljava/lang/Object;)I", (void*)restrictedFunction},
{"refSetCount", "(JI)V", (void*)restrictedFunction}, {"refSetCount", "(II)V", (void*)restrictedFunction},
{"refSetCount", "(Ljava/lang/Object;I)V", (void*)restrictedFunction}, {"refSetCount", "(Ljava/lang/Object;I)V", (void*)restrictedFunction},
{"refUncount", "(J)V", (void*)restrictedFunction}, {"refUncount", "(I)V", (void*)restrictedFunction},
{"refUncount", "(Ljava/lang/Object;)V", (void*)restrictedFunction}, {"refUncount", "(Ljava/lang/Object;)V", (void*)restrictedFunction},
{"returnFrame", "()V", (void*)restrictedFunction}, {"returnFrame", "()V", (void*)restrictedFunction},
{"returnFrame", "(I)V", (void*)restrictedFunction}, {"returnFrame", "(I)V", (void*)restrictedFunction},
{"returnFrame", "(II)V", (void*)restrictedFunction}, {"returnFrame", "(II)V", (void*)restrictedFunction},
{"returnFrameLong", "(J)V", (void*)restrictedFunction}, {"returnFrameLong", "(J)V", (void*)restrictedFunction},
{"sizeOfBaseArray", "()I", (void*)restrictedFunction},
{"sizeOfBaseObject", "()I", (void*)restrictedFunction},
{"sizeOfPointer", "()I", (void*)restrictedFunction},
{"specialGetExceptionRegister", "()Ljava/lang/Object;", (void*)restrictedFunction}, {"specialGetExceptionRegister", "()Ljava/lang/Object;", (void*)restrictedFunction},
{"specialGetExceptionRegisterThrowable", "()Ljava/lang/Throwable;", (void*)restrictedFunction}, {"specialGetExceptionRegisterThrowable", "()Ljava/lang/Throwable;", (void*)restrictedFunction},
{"specialGetExceptionRegisterPointer", "()J", (void*)restrictedFunction}, {"specialGetExceptionRegisterPointer", "()J", (void*)restrictedFunction},
...@@ -159,73 +137,14 @@ static const JNINativeMethod assemblyMethods[] = ...@@ -159,73 +137,14 @@ static const JNINativeMethod assemblyMethods[] =
{"specialGetPoolRegisterPointer", "()J", (void*)restrictedFunction}, {"specialGetPoolRegisterPointer", "()J", (void*)restrictedFunction},
{"specialGetReturnRegister", "()I", (void*)restrictedFunction}, {"specialGetReturnRegister", "()I", (void*)restrictedFunction},
{"specialGetReturnRegisterLong", "()J", (void*)restrictedFunction}, {"specialGetReturnRegisterLong", "()J", (void*)restrictedFunction},
{"specialGetStaticFieldRegister", "()J", (void*)restrictedFunction},
{"specialGetThreadRegister", "()Ljava/lang/Thread;", (void*)restrictedFunction}, {"specialGetThreadRegister", "()Ljava/lang/Thread;", (void*)restrictedFunction},
{"specialGetThreadRegisterPointer", "()J", (void*)restrictedFunction}, {"specialGetThreadRegisterPointer", "()J", (void*)restrictedFunction},
{"specialSetExceptionRegister", "(J)V", (void*)restrictedFunction}, {"specialSetExceptionRegister", "(J)V", (void*)restrictedFunction},
{"specialSetExceptionRegister", "(Ljava/lang/Object;)V", (void*)restrictedFunction}, {"specialSetExceptionRegister", "(Ljava/lang/Object;)V", (void*)restrictedFunction},
{"specialSetPoolRegister", "(J)V", (void*)restrictedFunction}, {"specialSetPoolRegister", "(J)V", (void*)restrictedFunction},
{"specialSetPoolRegister", "(Ljava/lang/Object;)V", (void*)restrictedFunction}, {"specialSetPoolRegister", "(Ljava/lang/Object;)V", (void*)restrictedFunction},
{"specialSetStaticFieldRegister", "(J)V", (void*)restrictedFunction},
{"specialSetThreadRegister", "(J)V", (void*)restrictedFunction}, {"specialSetThreadRegister", "(J)V", (void*)restrictedFunction},
{"specialSetThreadRegister", "(Ljava/lang/Thread;)V", (void*)restrictedFunction}, {"specialSetThreadRegister", "(Ljava/lang/Thread;)V", (void*)restrictedFunction},
// Un-Pure System Calls
{"sysCall", "(S)V", (void*)restrictedFunction},
{"sysCall", "(SI)V", (void*)restrictedFunction},
{"sysCall", "(SII)V", (void*)restrictedFunction},
{"sysCall", "(SIII)V", (void*)restrictedFunction},
{"sysCall", "(SIIII)V", (void*)restrictedFunction},
{"sysCall", "(SIIIII)V", (void*)restrictedFunction},
{"sysCall", "(SIIIIII)V", (void*)restrictedFunction},
{"sysCall", "(SIIIIIII)V", (void*)restrictedFunction},
{"sysCall", "(SIIIIIIII)V", (void*)restrictedFunction},
{"sysCallV", "(S)I", (void*)restrictedFunction},
{"sysCallV", "(SI)I", (void*)restrictedFunction},
{"sysCallV", "(SII)I", (void*)restrictedFunction},
{"sysCallV", "(SIII)I", (void*)restrictedFunction},
{"sysCallV", "(SIIII)I", (void*)restrictedFunction},
{"sysCallV", "(SIIIII)I", (void*)restrictedFunction},
{"sysCallV", "(SIIIIII)I", (void*)restrictedFunction},
{"sysCallV", "(SIIIIIII)I", (void*)restrictedFunction},
{"sysCallV", "(SIIIIIIII)I", (void*)restrictedFunction},
{"sysCallVL", "(S)J", (void*)restrictedFunction},
{"sysCallVL", "(SI)J", (void*)restrictedFunction},
{"sysCallVL", "(SII)J", (void*)restrictedFunction},
{"sysCallVL", "(SIII)J", (void*)restrictedFunction},
{"sysCallVL", "(SIIII)J", (void*)restrictedFunction},
{"sysCallVL", "(SIIIII)J", (void*)restrictedFunction},
{"sysCallVL", "(SIIIIII)J", (void*)restrictedFunction},
{"sysCallVL", "(SIIIIIII)J", (void*)restrictedFunction},
{"sysCallVL", "(SIIIIIIII)J", (void*)restrictedFunction},
// Pure System Calls {"sysCallP", "(S)V", (void*)restrictedFunction},
{"sysCallP", "(SI)V", (void*)restrictedFunction},
{"sysCallP", "(SII)V", (void*)restrictedFunction},
{"sysCallP", "(SIII)V", (void*)restrictedFunction},
{"sysCallP", "(SIIII)V", (void*)restrictedFunction},
{"sysCallP", "(SIIIII)V", (void*)restrictedFunction},
{"sysCallP", "(SIIIIII)V", (void*)restrictedFunction},
{"sysCallP", "(SIIIIIII)V", (void*)restrictedFunction},
{"sysCallP", "(SIIIIIIII)V", (void*)restrictedFunction},
{"sysCallPV", "(S)I", (void*)restrictedFunction},
{"sysCallPV", "(SI)I", (void*)restrictedFunction},
{"sysCallPV", "(SII)I", (void*)restrictedFunction},
{"sysCallPV", "(SIII)I", (void*)restrictedFunction},
{"sysCallPV", "(SIIII)I", (void*)restrictedFunction},
{"sysCallPV", "(SIIIII)I", (void*)restrictedFunction},
{"sysCallPV", "(SIIIIII)I", (void*)restrictedFunction},
{"sysCallPV", "(SIIIIIII)I", (void*)restrictedFunction},
{"sysCallPV", "(SIIIIIIII)I", (void*)restrictedFunction},
{"sysCallPVL", "(S)J", (void*)restrictedFunction},
{"sysCallPVL", "(SI)J", (void*)restrictedFunction},
{"sysCallPVL", "(SII)J", (void*)restrictedFunction},
{"sysCallPVL", "(SIII)J", (void*)restrictedFunction},
{"sysCallPVL", "(SIIII)J", (void*)restrictedFunction},
{"sysCallPVL", "(SIIIII)J", (void*)restrictedFunction},
{"sysCallPVL", "(SIIIIII)J", (void*)restrictedFunction},
{"sysCallPVL", "(SIIIIIII)J", (void*)restrictedFunction},
{"sysCallPVL", "(SIIIIIIII)J", (void*)restrictedFunction}
}; };
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
......
...@@ -12,11 +12,12 @@ package cc.squirreljme.vm.springcoat; ...@@ -12,11 +12,12 @@ package cc.squirreljme.vm.springcoat;
import cc.squirreljme.jvm.mle.RuntimeShelf; import cc.squirreljme.jvm.mle.RuntimeShelf;
import cc.squirreljme.jvm.mle.constants.BuiltInEncodingType; import cc.squirreljme.jvm.mle.constants.BuiltInEncodingType;
import cc.squirreljme.jvm.mle.constants.BuiltInLocaleType; import cc.squirreljme.jvm.mle.constants.BuiltInLocaleType;
import cc.squirreljme.jvm.mle.constants.ByteOrderType;
import cc.squirreljme.jvm.mle.constants.MemoryProfileType;
import cc.squirreljme.jvm.mle.constants.VMDescriptionType; import cc.squirreljme.jvm.mle.constants.VMDescriptionType;
import cc.squirreljme.jvm.mle.constants.VMStatisticType; import cc.squirreljme.jvm.mle.constants.VMStatisticType;
import cc.squirreljme.jvm.mle.constants.VMType; import cc.squirreljme.jvm.mle.constants.VMType;
import cc.squirreljme.runtime.cldc.SquirrelJME; import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.runtime.cldc.lang.LineEndingUtils; import cc.squirreljme.runtime.cldc.lang.LineEndingUtils;
import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError; import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError;
...@@ -28,6 +29,21 @@ import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError; ...@@ -28,6 +29,21 @@ import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError;
public enum MLERuntime public enum MLERuntime
implements MLEFunction implements MLEFunction
{ {
/** {@link RuntimeShelf#byteOrder()}. */
BYTE_ORDER("byteOrder:()I")
{
/**
* {@inheritDoc}
* @since 2021/02/09
*/
@Override
public Object handle(SpringThreadWorker __thread, Object... __args)
{
// SpringCoat is always big endian
return ByteOrderType.BIG_ENDIAN;
}
},
/** {@link RuntimeShelf#currentTimeMillis()}. */ /** {@link RuntimeShelf#currentTimeMillis()}. */
CURRENT_TIME_MILLIS("currentTimeMillis:()J") CURRENT_TIME_MILLIS("currentTimeMillis:()J")
{ {
...@@ -134,6 +150,21 @@ public enum MLERuntime ...@@ -134,6 +150,21 @@ public enum MLERuntime
} }
}, },
/** {@link RuntimeShelf#memoryProfile()}. */
MEMORY_PROFILE("memoryProfile:()I")
{
/**
* {@inheritDoc}
* @since 2021/02/19
*/
@Override
public Object handle(SpringThreadWorker __thread, Object... __args)
{
// No memory concerns
return MemoryProfileType.NORMAL;
}
},
/** {@link RuntimeShelf#nanoTime()}. */ /** {@link RuntimeShelf#nanoTime()}. */
NANO_TIME("nanoTime:()J") NANO_TIME("nanoTime:()J")
{ {
......
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
// Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------
package cc.squirreljme.jvm.boot;
import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.Constants;
import cc.squirreljme.jvm.SystemCallError;
import cc.squirreljme.jvm.SystemCallIndex;
/**
* This contains the static memory allocator.
*
* @since 2019/05/26
*/
@SuppressWarnings("FeatureEnvy")
public final class Allocator
{
/** Chunk is an object. */
public static final byte CHUNK_BIT_IS_OBJECT =
0x01;
/** Constant pool. */
public static final byte CHUNK_BIT_IS_POOL =
0x02;
/** Tag value bits mask. */
public static final int CHUNK_BITS_VALUE_MASK =
0x0F;
/** Shift for the chunk tag. */
public static final byte CHUNK_TAG_SHIFT =
24;
/** Memory free tag (all bits set). */
public static final int CHUNK_TAG_FREE =
0xFF000000;
/** Chunk tag mask. */
public static final int CHUNK_TAG_MASK =
0xFF000000;
/** The chunk size mask. */
public static final int CHUNK_SIZE_MASK =
0x00FFFFFF;
/** Chunk size limit, lower than the cap to allow for chunk area. */
public static final int CHUNK_SIZE_LIMIT =
16777200;
/** Memory chunk size offset. */
public static final byte CHUNK_SIZE_OFFSET =
0;
/** Next chunk address. */
public static final byte CHUNK_NEXT_OFFSET =
4;
/** The length of chunks. */
public static final byte CHUNK_LENGTH =
8;
/** Extra size to add that must be hit before a chunk is split. */
public static final byte SPLIT_REQUIREMENT =
16;
/** The base RAM address. */
private static volatile int _rambase;
/** The locking pointer address. */
private static volatile int _lockptr;
/**
* Not used.
*
* @since 2019/05/26
*/
private Allocator()
{
}
/**
* Allocates the given number of bytes.
*
* @param __tag The tag to use, only the lowest 8-bits are used.
* @param __sz The number of bytes to allocate.
* @return The address of the allocated data or {@code 0} if there is
* not enough memory remaining.
* @since 2019/10/19
*/
public static final int allocate(int __tag, int __sz)
{
// Determine the special locking key to use, never let this be zero!
int key = Allocator.__giveLockKey();
// Try locking the pointer
int lp = Allocator._lockptr;
try
{
// Lock using our special key, which will never be zero!
// Spin-lock so this is executed as fast as possible!
while (0 != Assembly.atomicCompareGetAndSet(0, key, lp))
continue;
// Fall into the allocation without lock
return Allocator.allocateWithoutLock(__tag, __sz);
}
// Clear the lock always
finally
{
// Clear out lock, if not matched then something is wrong!
int old;
if (key != (old = Assembly.atomicCompareGetAndSet(key, 0, lp)))
{
// Another allocation took our lock??
Assembly.breakpoint();
// {@squirreljme.error SV0j Another allocation took the lock
// from us?}
throw new BootstrapMachineError("SV0j");
}
}
}
/**
* Allocates the given number of bytes, no locking is performed at all.
*
* @param __tag The tag to use, only the lowest 8-bits are used.
* @param __sz The number of bytes to allocate.
* @return The address of the allocated data or {@code 0} if there is
* not enough memory remaining.
* @since 2019/05/26
*/
public static final int allocateWithoutLock(int __tag, int __sz)
{
// The number of desired bytes
int want = Allocator.CHUNK_LENGTH + (__sz <= 4 ? 4 : ((__sz + 3) & (~3)));
// Negative size or too big?
if (__sz < 0 || want > Allocator.CHUNK_SIZE_LIMIT)
return 0;
// Go through the memory chunks to locate a free chunk
int seeker = Allocator._rambase;
while (seeker != 0)
{
// Read chunk properties
int csz = Assembly.memReadInt(seeker, Allocator.CHUNK_SIZE_OFFSET),
cnx = Assembly.memReadInt(seeker, Allocator.CHUNK_NEXT_OFFSET);
// Is this a free block? And can we fit in it?
if ((csz & Allocator.CHUNK_TAG_MASK) == Allocator.CHUNK_TAG_FREE &&
want <= (csz & Allocator.CHUNK_SIZE_MASK))
return Allocator.__claim(__tag, want, seeker, csz, cnx);
// Go to the next chunk
seeker = cnx;
}
// Did not find a free chunk
return 0;
}
/**
* Frees the specified memory pointer, making it available for later use.
*
* @param __p The pointer to free.
* @since 2019/10/19
*/
public static final void free(int __p)
{
// Determine the special locking key to use, never let this be zero!
int key = Allocator.__giveLockKey();
// Try locking the pointer
int lp = Allocator._lockptr;
try
{
// Lock using our special key, which will never be zero!
// Spin-lock so this is executed as fast as possible!
while (0 != Assembly.atomicCompareGetAndSet(0, key, lp))
continue;