mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
Merge branch 'master' of dice:git/vm
Conflicts: src/cdecl.S
This commit is contained in:
commit
e32a335079
@ -198,7 +198,7 @@ Java_java_io_FileInputStream_read__I(JNIEnv* e, jclass, jint fd)
|
|||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return data;
|
return data & 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,3 +69,13 @@ Java_java_lang_System_doMapLibraryName(JNIEnv* e, jclass, jstring name)
|
|||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT jint JNICALL
|
||||||
|
Java_java_lang_Double_fillBufferWithDouble(JNIEnv *e, jclass, jdouble val,
|
||||||
|
jbyteArray buffer, jint bufferSize) {
|
||||||
|
jboolean isCopy;
|
||||||
|
jbyte* buf = e->GetByteArrayElements(buffer, &isCopy);
|
||||||
|
jint count = snprintf(reinterpret_cast<char*>(buf), bufferSize, "%g", val);
|
||||||
|
e->ReleaseByteArrayElements(buffer, buf, 0);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
@ -35,7 +35,9 @@ public final class Double extends Number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String toString(double v) {
|
public static String toString(double v) {
|
||||||
return "Double.toString: todo";
|
byte[] buffer = new byte[20];
|
||||||
|
int numChars = fillBufferWithDouble(v, buffer, 20);
|
||||||
|
return new String(buffer, 0, numChars, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
@ -67,6 +69,9 @@ public final class Double extends Number {
|
|||||||
throw new NumberFormatException(s);
|
throw new NumberFormatException(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static native int fillBufferWithDouble(double value, byte[] buffer,
|
||||||
|
int charCount);
|
||||||
|
|
||||||
public static native long doubleToRawLongBits(double value);
|
public static native long doubleToRawLongBits(double value);
|
||||||
|
|
||||||
public static native double longBitsToDouble(long bits);
|
public static native double longBitsToDouble(long bits);
|
||||||
|
@ -26,7 +26,7 @@ public final class Float extends Number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String toString(float v) {
|
public static String toString(float v) {
|
||||||
return "Float.toString: todo";
|
return Double.toString(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte byteValue() {
|
public byte byteValue() {
|
||||||
|
@ -81,6 +81,15 @@ public class StringBuilder {
|
|||||||
return append(String.valueOf(v));
|
return append(String.valueOf(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StringBuilder append(float v) {
|
||||||
|
return append(String.valueOf(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBuilder append(double v) {
|
||||||
|
return append(String.valueOf(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public char charAt(int i) {
|
public char charAt(int i) {
|
||||||
if (i < 0 || i >= length) {
|
if (i < 0 || i >= length) {
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
|
@ -683,8 +683,9 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExceptionHandler*
|
ExceptionHandler*
|
||||||
findExceptionHandler(Thread* t, object method)
|
findExceptionHandler(Thread* t, int frame)
|
||||||
{
|
{
|
||||||
|
object method = frameMethod(t, frame);
|
||||||
object eht = codeExceptionHandlerTable(t, methodCode(t, method));
|
object eht = codeExceptionHandlerTable(t, methodCode(t, method));
|
||||||
|
|
||||||
if (eht) {
|
if (eht) {
|
||||||
@ -697,16 +698,16 @@ findExceptionHandler(Thread* t, object method)
|
|||||||
object catchType = 0;
|
object catchType = 0;
|
||||||
if (exceptionHandlerCatchType(eh)) {
|
if (exceptionHandlerCatchType(eh)) {
|
||||||
object e = t->exception;
|
object e = t->exception;
|
||||||
exception = 0;
|
t->exception = 0;
|
||||||
PROTECT(t, e);
|
PROTECT(t, e);
|
||||||
|
|
||||||
PROTECT(t, eht);
|
PROTECT(t, eht);
|
||||||
catchType = resolveClass
|
catchType = resolveClass
|
||||||
(t, codePool(t, code), exceptionHandlerCatchType(eh) - 1);
|
(t, codePool(t, t->code), exceptionHandlerCatchType(eh) - 1);
|
||||||
|
|
||||||
if (catchType) {
|
if (catchType) {
|
||||||
eh = exceptionHandlerTableBody(t, eht, i);
|
eh = exceptionHandlerTableBody(t, eht, i);
|
||||||
exception = e;
|
t->exception = e;
|
||||||
} else {
|
} else {
|
||||||
// can't find what we're supposed to catch - move on.
|
// can't find what we're supposed to catch - move on.
|
||||||
continue;
|
continue;
|
||||||
@ -756,7 +757,7 @@ interpret(Thread* t)
|
|||||||
&byteArrayBody
|
&byteArrayBody
|
||||||
(t, methodName(t, frameMethod(t, frame)), 0));
|
(t, methodName(t, frameMethod(t, frame)), 0));
|
||||||
|
|
||||||
int line = lineNumber(t, frameMethod(t, frame), ip);
|
int line = t->m->processor->lineNumber(t, frameMethod(t, frame), ip);
|
||||||
switch (line) {
|
switch (line) {
|
||||||
case NativeLine:
|
case NativeLine:
|
||||||
fprintf(stderr, "(native)\n");
|
fprintf(stderr, "(native)\n");
|
||||||
@ -1297,14 +1298,30 @@ interpret(Thread* t)
|
|||||||
float b = popFloat(t);
|
float b = popFloat(t);
|
||||||
float a = popFloat(t);
|
float a = popFloat(t);
|
||||||
|
|
||||||
pushInt(t, (a > b ? 1 : 0));
|
if (a < b) {
|
||||||
|
pushInt(t, static_cast<unsigned>(-1));
|
||||||
|
} else if (a > b) {
|
||||||
|
pushInt(t, 1);
|
||||||
|
} else if (a == b) {
|
||||||
|
pushInt(t, 0);
|
||||||
|
} else {
|
||||||
|
pushInt(t, 1);
|
||||||
|
}
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case fcmpl: {
|
case fcmpl: {
|
||||||
float b = popFloat(t);
|
float b = popFloat(t);
|
||||||
float a = popFloat(t);
|
float a = popFloat(t);
|
||||||
|
|
||||||
pushInt(t, (a < b ? 1 : 0));
|
if (a < b) {
|
||||||
|
pushInt(t, static_cast<unsigned>(-1));
|
||||||
|
} else if (a > b) {
|
||||||
|
pushInt(t, 1);
|
||||||
|
} else if (a == b) {
|
||||||
|
pushInt(t, 0);
|
||||||
|
} else {
|
||||||
|
pushInt(t, static_cast<unsigned>(-1));
|
||||||
|
}
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case fconst_0: {
|
case fconst_0: {
|
||||||
@ -2606,7 +2623,7 @@ interpret(Thread* t)
|
|||||||
|
|
||||||
pokeInt(t, t->frame + FrameIpOffset, t->ip);
|
pokeInt(t, t->frame + FrameIpOffset, t->ip);
|
||||||
for (; frame >= base; popFrame(t)) {
|
for (; frame >= base; popFrame(t)) {
|
||||||
ExceptionHandler* eh = findExceptionHandler(t, frameMethod(t, frame));
|
ExceptionHandler* eh = findExceptionHandler(t, frame);
|
||||||
if (eh) {
|
if (eh) {
|
||||||
sp = frame + FrameFootprint;
|
sp = frame + FrameFootprint;
|
||||||
ip = exceptionHandlerIp(eh);
|
ip = exceptionHandlerIp(eh);
|
||||||
@ -2670,6 +2687,14 @@ pushArguments(Thread* t, object this_, const char* spec, bool indirectObjects,
|
|||||||
pushLong(t, va_arg(a, uint64_t));
|
pushLong(t, va_arg(a, uint64_t));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'F': {
|
||||||
|
++ s;
|
||||||
|
float f = va_arg(a, double);
|
||||||
|
uint32_t i;
|
||||||
|
memcpy(&i, &f, 4);
|
||||||
|
pushInt(t, i);
|
||||||
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
++ s;
|
++ s;
|
||||||
pushInt(t, va_arg(a, uint32_t));
|
pushInt(t, va_arg(a, uint32_t));
|
||||||
@ -2847,13 +2872,13 @@ class MyProcessor: public Processor {
|
|||||||
return new (s->allocate(sizeof(Thread))) Thread(m, javaThread, parent);
|
return new (s->allocate(sizeof(Thread))) Thread(m, javaThread, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Compiled*
|
virtual void*
|
||||||
methodStub(vm::Thread*)
|
methodStub(vm::Thread*)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Compiled*
|
virtual void*
|
||||||
nativeInvoker(vm::Thread*)
|
nativeInvoker(vm::Thread*)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -2980,8 +3005,10 @@ class MyProcessor: public Processor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual int
|
virtual int
|
||||||
lineNumber(Thread* t, object method, unsigned ip)
|
lineNumber(vm::Thread* vmt, object method, unsigned ip)
|
||||||
{
|
{
|
||||||
|
Thread* t = static_cast<Thread*>(vmt);
|
||||||
|
|
||||||
if (methodFlags(t, method) & ACC_NATIVE) {
|
if (methodFlags(t, method) & ACC_NATIVE) {
|
||||||
return NativeLine;
|
return NativeLine;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user