mirror of
https://github.com/corda/corda.git
synced 2025-01-15 09:20:22 +00:00
lots of build fixes
This commit is contained in:
parent
45f5417827
commit
2176c32cee
@ -1,13 +1,23 @@
|
|||||||
#ifndef OPCODES_H
|
#ifndef CONSTANTS_H
|
||||||
#define OPCODES_H
|
#define CONSTANTS_H
|
||||||
|
|
||||||
enum OpCode {
|
enum OpCode {
|
||||||
aaload,
|
aaload,
|
||||||
aastore,
|
aastore,
|
||||||
aconst,
|
aconst_null,
|
||||||
|
aload,
|
||||||
|
aload_0,
|
||||||
|
aload_1,
|
||||||
|
aload_2,
|
||||||
|
aload_3,
|
||||||
anewarray,
|
anewarray,
|
||||||
areturn,
|
areturn,
|
||||||
arraylength,
|
arraylength,
|
||||||
|
astore,
|
||||||
|
astore_0,
|
||||||
|
astore_1,
|
||||||
|
astore_2,
|
||||||
|
astore_3,
|
||||||
athrow,
|
athrow,
|
||||||
baload,
|
baload,
|
||||||
bastore,
|
bastore,
|
||||||
@ -34,7 +44,11 @@ enum OpCode {
|
|||||||
dstore,
|
dstore,
|
||||||
dsub,
|
dsub,
|
||||||
dup,
|
dup,
|
||||||
|
dup_x1,
|
||||||
|
dup_x2,
|
||||||
dup2,
|
dup2,
|
||||||
|
dup2_x1,
|
||||||
|
dup2_x2,
|
||||||
f2d,
|
f2d,
|
||||||
f2i,
|
f2i,
|
||||||
f2l,
|
f2l,
|
||||||
@ -55,6 +69,7 @@ enum OpCode {
|
|||||||
getfield,
|
getfield,
|
||||||
getstatic,
|
getstatic,
|
||||||
goto_,
|
goto_,
|
||||||
|
goto_w,
|
||||||
i2b,
|
i2b,
|
||||||
i2c,
|
i2c,
|
||||||
i2d,
|
i2d,
|
||||||
@ -65,9 +80,22 @@ enum OpCode {
|
|||||||
iaload,
|
iaload,
|
||||||
iand,
|
iand,
|
||||||
iastore,
|
iastore,
|
||||||
iconst,
|
iconst_0,
|
||||||
|
iconst_1,
|
||||||
|
iconst_2,
|
||||||
|
iconst_3,
|
||||||
|
iconst_4,
|
||||||
|
iconst_5,
|
||||||
idiv,
|
idiv,
|
||||||
if_,
|
if_,
|
||||||
|
if_acmpeq,
|
||||||
|
if_acmpne,
|
||||||
|
if_icmpeq,
|
||||||
|
if_icmpne,
|
||||||
|
if_icmpgt,
|
||||||
|
if_icmpge,
|
||||||
|
if_icmplt,
|
||||||
|
if_icmple,
|
||||||
ifeq,
|
ifeq,
|
||||||
ifge,
|
ifge,
|
||||||
ifgt,
|
ifgt,
|
||||||
@ -78,6 +106,10 @@ enum OpCode {
|
|||||||
ifnull,
|
ifnull,
|
||||||
iinc,
|
iinc,
|
||||||
iload,
|
iload,
|
||||||
|
iload_0,
|
||||||
|
iload_1,
|
||||||
|
iload_2,
|
||||||
|
iload_3,
|
||||||
impdep1,
|
impdep1,
|
||||||
impdep2,
|
impdep2,
|
||||||
imul,
|
imul,
|
||||||
@ -93,10 +125,15 @@ enum OpCode {
|
|||||||
ishl,
|
ishl,
|
||||||
ishr,
|
ishr,
|
||||||
istore,
|
istore,
|
||||||
|
istore_0,
|
||||||
|
istore_1,
|
||||||
|
istore_2,
|
||||||
|
istore_3,
|
||||||
isub,
|
isub,
|
||||||
iushr,
|
iushr,
|
||||||
ixor,
|
ixor,
|
||||||
jsr,
|
jsr,
|
||||||
|
jsr_w,
|
||||||
l2d,
|
l2d,
|
||||||
l2f,
|
l2f,
|
||||||
l2i,
|
l2i,
|
||||||
@ -105,11 +142,17 @@ enum OpCode {
|
|||||||
land,
|
land,
|
||||||
lastore,
|
lastore,
|
||||||
lcmp,
|
lcmp,
|
||||||
lconst,
|
lconst_0,
|
||||||
|
lconst_1,
|
||||||
ldc,
|
ldc,
|
||||||
ldc2,
|
ldc_w,
|
||||||
|
ldc2_w,
|
||||||
ldiv,
|
ldiv,
|
||||||
lload,
|
lload,
|
||||||
|
lload_0,
|
||||||
|
lload_1,
|
||||||
|
lload_2,
|
||||||
|
lload_3,
|
||||||
lmul,
|
lmul,
|
||||||
lneg,
|
lneg,
|
||||||
lookupswitch,
|
lookupswitch,
|
||||||
@ -119,6 +162,10 @@ enum OpCode {
|
|||||||
lshl,
|
lshl,
|
||||||
lshr,
|
lshr,
|
||||||
lstore,
|
lstore,
|
||||||
|
lstore_0,
|
||||||
|
lstore_1,
|
||||||
|
lstore_2,
|
||||||
|
lstore_3,
|
||||||
lsub,
|
lsub,
|
||||||
lushr,
|
lushr,
|
||||||
lxor,
|
lxor,
|
||||||
@ -142,4 +189,15 @@ enum OpCode {
|
|||||||
wide
|
wide
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif//OPCODES_H
|
enum TypeCode {
|
||||||
|
T_BOOLEAN = 4,
|
||||||
|
T_CHAR = 5,
|
||||||
|
T_FLOAT = 6,
|
||||||
|
T_DOUBLE = 7,
|
||||||
|
T_BYTE = 8,
|
||||||
|
T_SHORT = 9,
|
||||||
|
T_INT = 10,
|
||||||
|
T_LONG = 11
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif//CONSTANTS_H
|
@ -340,6 +340,10 @@ addMember(Object* o, Object* member)
|
|||||||
{
|
{
|
||||||
switch (o->type) {
|
switch (o->type) {
|
||||||
case Object::Type: case Object::Pod:
|
case Object::Type: case Object::Pod:
|
||||||
|
if (member->type == Object::Array) {
|
||||||
|
static_cast<Type*>(o)->members.append
|
||||||
|
(Scalar::make(o, 0, "uint32_t", "length", sizeof(uint32_t)));
|
||||||
|
}
|
||||||
static_cast<Type*>(o)->members.append(member);
|
static_cast<Type*>(o)->members.append(member);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -9,25 +9,17 @@
|
|||||||
(object methodTable)
|
(object methodTable)
|
||||||
(object staticTable))
|
(object staticTable))
|
||||||
|
|
||||||
(pod field
|
(type field
|
||||||
(uint16_t flags)
|
(uint16_t flags)
|
||||||
(object name)
|
(object name)
|
||||||
(object class))
|
(object class))
|
||||||
|
|
||||||
(type fieldTable
|
(type method
|
||||||
(object index)
|
|
||||||
(array field body))
|
|
||||||
|
|
||||||
(pod method
|
|
||||||
(uint16_t flags)
|
(uint16_t flags)
|
||||||
(object name)
|
(object name)
|
||||||
(object spec)
|
(object spec)
|
||||||
(object code))
|
(object code))
|
||||||
|
|
||||||
(type methodTable
|
|
||||||
(object index)
|
|
||||||
(array method body))
|
|
||||||
|
|
||||||
(pod exceptionHandler
|
(pod exceptionHandler
|
||||||
(uint16_t start)
|
(uint16_t start)
|
||||||
(uint16_t end)
|
(uint16_t end)
|
||||||
@ -62,19 +54,22 @@
|
|||||||
(array char value))
|
(array char value))
|
||||||
|
|
||||||
(type byte
|
(type byte
|
||||||
(uint8_t value))
|
(int8_t value))
|
||||||
|
|
||||||
(type boolean
|
(type boolean
|
||||||
(extends byte))
|
(extends byte))
|
||||||
|
|
||||||
(type short
|
(type short
|
||||||
|
(int16_t value))
|
||||||
|
|
||||||
|
(type char
|
||||||
(uint16_t value))
|
(uint16_t value))
|
||||||
|
|
||||||
(type int
|
(type int
|
||||||
(uint32_t value))
|
(int32_t value))
|
||||||
|
|
||||||
(type long
|
(type long
|
||||||
(uint64_t value))
|
(int64_t value))
|
||||||
|
|
||||||
(type float
|
(type float
|
||||||
(uint32_t value))
|
(uint32_t value))
|
||||||
@ -90,22 +85,22 @@
|
|||||||
(array object body))
|
(array object body))
|
||||||
|
|
||||||
(type byteArray
|
(type byteArray
|
||||||
(array uint8_t body))
|
(array int8_t body))
|
||||||
|
|
||||||
(type booleanArray
|
(type booleanArray
|
||||||
(extends byteArray))
|
(extends byteArray))
|
||||||
|
|
||||||
(type shortArray
|
(type shortArray
|
||||||
(array uint16_t body))
|
(array int16_t body))
|
||||||
|
|
||||||
(type charArray
|
(type charArray
|
||||||
(array uint16_t body))
|
(array uint16_t body))
|
||||||
|
|
||||||
(type intArray
|
(type intArray
|
||||||
(array uint32_t body))
|
(array int32_t body))
|
||||||
|
|
||||||
(type longArray
|
(type longArray
|
||||||
(array uint64_t body))
|
(array int64_t body))
|
||||||
|
|
||||||
(type floatArray
|
(type floatArray
|
||||||
(array uint32_t body))
|
(array uint32_t body))
|
||||||
|
271
src/vm.cpp
271
src/vm.cpp
@ -7,7 +7,7 @@ namespace {
|
|||||||
typedef void* object;
|
typedef void* object;
|
||||||
typedef unsigned Type;
|
typedef unsigned Type;
|
||||||
|
|
||||||
#include "opcodes.h"
|
#include "constants.h"
|
||||||
|
|
||||||
enum ObjectType {
|
enum ObjectType {
|
||||||
NullType,
|
NullType,
|
||||||
@ -304,10 +304,10 @@ run(Thread* t)
|
|||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
if (i >= 0 and i < objectArrayLength(t, array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < objectArrayLength(t, array)) {
|
||||||
push(t, objectArrayBody(t, array)[i]);
|
push(t, objectArrayBody(t, array)[i]);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
objectArrayLength(t, array));
|
objectArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
@ -325,10 +325,10 @@ run(Thread* t)
|
|||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
if (i >= 0 and i < objectArrayLength(t, array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < objectArrayLength(t, array)) {
|
||||||
set(t, objectArrayBody(array)[i], value);
|
set(t, objectArrayBody(t, array)[i], value);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
objectArrayLength(t, array));
|
objectArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
@ -346,31 +346,31 @@ run(Thread* t)
|
|||||||
case aload:
|
case aload:
|
||||||
case iload:
|
case iload:
|
||||||
case lload: {
|
case lload: {
|
||||||
push(t, frameBody(t, t->frame)[codeBody(t, t->code)[ip++]]);
|
push(t, frameLocals(t, t->frame)[codeBody(t, t->code)[ip++]]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case aload_0:
|
case aload_0:
|
||||||
case iload_0:
|
case iload_0:
|
||||||
case lload_0: {
|
case lload_0: {
|
||||||
push(t, frameBody(t, t->frame)[0]);
|
push(t, frameLocals(t, t->frame)[0]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case aload_1:
|
case aload_1:
|
||||||
case iload_1:
|
case iload_1:
|
||||||
case lload_1: {
|
case lload_1: {
|
||||||
push(t, frameBody(t, t->frame)[1]);
|
push(t, frameLocals(t, t->frame)[1]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case aload_2:
|
case aload_2:
|
||||||
case iload_2:
|
case iload_2:
|
||||||
case lload_2: {
|
case lload_2: {
|
||||||
push(t, frameBody(t, t->frame)[2]);
|
push(t, frameLocals(t, t->frame)[2]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case aload_3:
|
case aload_3:
|
||||||
case iload_3:
|
case iload_3:
|
||||||
case lload_3: {
|
case lload_3: {
|
||||||
push(t, frameBody(t, t->frame)[3]);
|
push(t, frameLocals(t, t->frame)[3]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case anewarray: {
|
case anewarray: {
|
||||||
@ -382,15 +382,15 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object class_ = resolveClass(t, codePool(t->code), index);
|
object class_ = resolveClass(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
object array = makeObjectArray(t, class_, c);
|
object array = makeObjectArray(t, class_, c);
|
||||||
t->vm->sys->zero(objectArrayBody(array), c * 4);
|
t->vm->sys->zero(objectArrayBody(t, array), c * 4);
|
||||||
|
|
||||||
push(t, array);
|
push(t, array);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d", c);
|
object message = makeJString(t, "%d", c);
|
||||||
t->exception = makeNegativeArrayStoreException(t, message);
|
t->exception = makeNegativeArrayStoreException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -399,10 +399,10 @@ run(Thread* t)
|
|||||||
case areturn:
|
case areturn:
|
||||||
case ireturn:
|
case ireturn:
|
||||||
case lreturn: {
|
case lreturn: {
|
||||||
t->frame = frameNext(t->frame);
|
t->frame = frameNext(t, t->frame);
|
||||||
if (t->frame) {
|
if (t->frame) {
|
||||||
t->code = methodCode(frameMethod(t->frame));
|
t->code = methodCode(t, frameMethod(t, t->frame));
|
||||||
ip = frameIp(t->frame);
|
ip = frameIp(t, t->frame);
|
||||||
goto loop;
|
goto loop;
|
||||||
} else {
|
} else {
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
@ -414,7 +414,13 @@ run(Thread* t)
|
|||||||
case arraylength: {
|
case arraylength: {
|
||||||
object array = pop(t);
|
object array = pop(t);
|
||||||
if (array) {
|
if (array) {
|
||||||
push(t, makeInt(t, arrayLength(array)));
|
if (typeOf(array) == ObjectArrayType) {
|
||||||
|
push(t, makeInt(t, objectArrayLength(t, array)));
|
||||||
|
} else {
|
||||||
|
// for all other array types, the length follow the class pointer.
|
||||||
|
push(t, makeInt(t, reinterpret_cast<uint32_t&>
|
||||||
|
(static_cast<uintptr_t*>(array)[1])));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
t->exception = makeNullPointerException(t, 0);
|
t->exception = makeNullPointerException(t, 0);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
@ -425,35 +431,35 @@ run(Thread* t)
|
|||||||
case istore:
|
case istore:
|
||||||
case lstore: {
|
case lstore: {
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
set(t, frameBody(t, t->frame)[codeBody(t, t->code)[ip++]], value);
|
set(t, frameLocals(t, t->frame)[codeBody(t, t->code)[ip++]], value);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case astore_0:
|
case astore_0:
|
||||||
case istore_0:
|
case istore_0:
|
||||||
case lstore_0: {
|
case lstore_0: {
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
set(t, frameBody(t, t->frame)[0], value);
|
set(t, frameLocals(t, t->frame)[0], value);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case astore_1:
|
case astore_1:
|
||||||
case istore_1:
|
case istore_1:
|
||||||
case lstore_1: {
|
case lstore_1: {
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
set(t, frameBody(t, t->frame)[1], value);
|
set(t, frameLocals(t, t->frame)[1], value);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case astore_2:
|
case astore_2:
|
||||||
case istore_2:
|
case istore_2:
|
||||||
case lstore_2: {
|
case lstore_2: {
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
set(t, frameBody(t, t->frame)[2], value);
|
set(t, frameLocals(t, t->frame)[2], value);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case astore_3:
|
case astore_3:
|
||||||
case istore_3:
|
case istore_3:
|
||||||
case lstore_3: {
|
case lstore_3: {
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
set(t, frameBody(t, t->frame)[3], value);
|
set(t, frameLocals(t, t->frame)[3], value);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case athrow: {
|
case athrow: {
|
||||||
@ -470,11 +476,11 @@ run(Thread* t)
|
|||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
if (i >= 0 and i < byteArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < byteArrayLength(t, array)) {
|
||||||
push(t, makeByte(t, byteArrayBody(array)[i]));
|
push(t, makeByte(t, byteArrayBody(t, array)[i]));
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
byteArrayLength(array));
|
byteArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -491,11 +497,11 @@ run(Thread* t)
|
|||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
if (i >= 0 and i < byteArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < byteArrayLength(t, array)) {
|
||||||
byteArrayBody(array)[i] = intValue(t, value);
|
byteArrayBody(t, array)[i] = intValue(t, value);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
byteArrayLength(array));
|
byteArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -515,11 +521,11 @@ run(Thread* t)
|
|||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
if (i >= 0 and i < charArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < charArrayLength(t, array)) {
|
||||||
push(t, makeInt(t, charArrayBody(array)[i]));
|
push(t, makeInt(t, charArrayBody(t, array)[i]));
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
charArrayLength(array));
|
charArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -536,11 +542,11 @@ run(Thread* t)
|
|||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
if (i >= 0 and i < charArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < charArrayLength(t, array)) {
|
||||||
charArrayBody(array)[i] = intValue(t, value);
|
charArrayBody(t, array)[i] = intValue(t, value);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
charArrayLength(array));
|
charArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -557,7 +563,7 @@ run(Thread* t)
|
|||||||
if (t->stack[t->sp - 1]) {
|
if (t->stack[t->sp - 1]) {
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object class_ = resolveClass(t, codePool(t->code), index);
|
object class_ = resolveClass(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
if (not instanceOf(t, class_, t->stack[t->sp - 1])) {
|
if (not instanceOf(t, class_, t->stack[t->sp - 1])) {
|
||||||
@ -664,7 +670,7 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object field = resolveField(t, codePool(t->code), index);
|
object field = resolveField(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
push(t, getField(instance, field));
|
push(t, getField(instance, field));
|
||||||
@ -679,11 +685,11 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object field = resolveField(t, codePool(t->code), index);
|
object field = resolveField(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
if (not classInitialized(fieldClass(field))) {
|
if (not classInitialized(fieldClass(t, field))) {
|
||||||
t->code = classInitializer(fieldClass(field));
|
t->code = classInitializer(fieldClass(t, field));
|
||||||
ip -= 3;
|
ip -= 3;
|
||||||
parameterCount = 0;
|
parameterCount = 0;
|
||||||
goto invoke;
|
goto invoke;
|
||||||
@ -746,11 +752,11 @@ run(Thread* t)
|
|||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
if (i >= 0 and i < intArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < intArrayLength(t, array)) {
|
||||||
push(t, makeInt(t, intArrayBody(array)[i]));
|
push(t, makeInt(t, intArrayBody(t, array)[i]));
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
intArrayLength(array));
|
intArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -774,11 +780,11 @@ run(Thread* t)
|
|||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
if (i >= 0 and i < intArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < intArrayLength(t, array)) {
|
||||||
intArrayBody(array)[i] = intValue(t, value);
|
intArrayBody(t, array)[i] = intValue(t, value);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
intArrayLength(array));
|
intArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -789,27 +795,27 @@ run(Thread* t)
|
|||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case iconst_0: {
|
case iconst_0: {
|
||||||
push(t, makeInt(0));
|
push(t, makeInt(t, 0));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case iconst_1: {
|
case iconst_1: {
|
||||||
push(t, makeInt(1));
|
push(t, makeInt(t, 1));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case iconst_2: {
|
case iconst_2: {
|
||||||
push(t, makeInt(2));
|
push(t, makeInt(t, 2));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case iconst_3: {
|
case iconst_3: {
|
||||||
push(t, makeInt(3));
|
push(t, makeInt(t, 3));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case iconst_4: {
|
case iconst_4: {
|
||||||
push(t, makeInt(4));
|
push(t, makeInt(t, 4));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case iconst_5: {
|
case iconst_5: {
|
||||||
push(t, makeInt(5));
|
push(t, makeInt(t, 5));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case idiv: {
|
case idiv: {
|
||||||
@ -1007,8 +1013,8 @@ run(Thread* t)
|
|||||||
uint8_t index = codeBody(t, t->code)[ip++];
|
uint8_t index = codeBody(t, t->code)[ip++];
|
||||||
int8_t c = codeBody(t, t->code)[ip++];
|
int8_t c = codeBody(t, t->code)[ip++];
|
||||||
|
|
||||||
int32_t v = intValue(t, frameBody(t, t->frame)[index]);
|
int32_t v = intValue(t, frameLocals(t, t->frame)[index]);
|
||||||
frameBody(t, t->frame)[index] = makeInt(t, v + c);
|
frameLocals(t, t->frame)[index] = makeInt(t, v + c);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case imul: {
|
case imul: {
|
||||||
@ -1031,7 +1037,7 @@ run(Thread* t)
|
|||||||
if (t->stack[t->sp - 1]) {
|
if (t->stack[t->sp - 1]) {
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object class_ = resolveClass(t, codePool(t->code), index);
|
object class_ = resolveClass(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
if (instanceOf(t, class_, t->stack[t->sp - 1])) {
|
if (instanceOf(t, class_, t->stack[t->sp - 1])) {
|
||||||
@ -1051,7 +1057,7 @@ run(Thread* t)
|
|||||||
|
|
||||||
ip += 2;
|
ip += 2;
|
||||||
|
|
||||||
object method = resolveMethod(t, codePool(t->code), index);
|
object method = resolveMethod(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
parameterCount = methodParameterCount(method);
|
parameterCount = methodParameterCount(method);
|
||||||
@ -1072,7 +1078,7 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object method = resolveMethod(t, codePool(t->code), index);
|
object method = resolveMethod(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
parameterCount = methodParameterCount(method);
|
parameterCount = methodParameterCount(method);
|
||||||
@ -1082,7 +1088,7 @@ run(Thread* t)
|
|||||||
(findSpecialMethod(t, method, t->stack[t->sp - parameterCount]));
|
(findSpecialMethod(t, method, t->stack[t->sp - parameterCount]));
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
} else {
|
} else {
|
||||||
t->code = methodCode(method);
|
t->code = methodCode(t, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
goto invoke;
|
goto invoke;
|
||||||
@ -1097,18 +1103,18 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object method = resolveMethod(t, codePool(t->code), index);
|
object method = resolveMethod(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
if (not classInitialized(methodClass(method))) {
|
if (not classInitialized(methodClass(t, method))) {
|
||||||
t->code = classInitializer(methodClass(method));
|
t->code = classInitializer(methodClass(t, method));
|
||||||
ip -= 2;
|
ip -= 2;
|
||||||
parameterCount = 0;
|
parameterCount = 0;
|
||||||
goto invoke;
|
goto invoke;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameterCount = methodParameterCount(method);
|
parameterCount = methodParameterCount(method);
|
||||||
t->code = methodCode(method);
|
t->code = methodCode(t, method);
|
||||||
} goto invoke;
|
} goto invoke;
|
||||||
|
|
||||||
case invokevirtual: {
|
case invokevirtual: {
|
||||||
@ -1116,13 +1122,13 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object method = resolveMethod(t, codePool(t->code), index);
|
object method = resolveMethod(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
parameterCount = methodParameterCount(method);
|
parameterCount = methodParameterCount(method);
|
||||||
if (t->stack[t->sp - parameterCount]) {
|
if (t->stack[t->sp - parameterCount]) {
|
||||||
t->code = methodCode
|
t->code = methodCode
|
||||||
(findVirtualMethod(t, method, t->stack[t->sp - parameterCount]));
|
(t, findVirtualMethod(t, method, t->stack[t->sp - parameterCount]));
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
goto invoke;
|
goto invoke;
|
||||||
@ -1185,7 +1191,7 @@ run(Thread* t)
|
|||||||
uint8_t offset1 = codeBody(t, t->code)[ip++];
|
uint8_t offset1 = codeBody(t, t->code)[ip++];
|
||||||
uint8_t offset2 = codeBody(t, t->code)[ip++];
|
uint8_t offset2 = codeBody(t, t->code)[ip++];
|
||||||
|
|
||||||
push(t, makeInt(ip));
|
push(t, makeInt(t, ip));
|
||||||
ip = (ip - 1) + ((offset1 << 8) | offset2);
|
ip = (ip - 1) + ((offset1 << 8) | offset2);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
@ -1195,7 +1201,7 @@ run(Thread* t)
|
|||||||
uint8_t offset3 = codeBody(t, t->code)[ip++];
|
uint8_t offset3 = codeBody(t, t->code)[ip++];
|
||||||
uint8_t offset4 = codeBody(t, t->code)[ip++];
|
uint8_t offset4 = codeBody(t, t->code)[ip++];
|
||||||
|
|
||||||
push(t, makeInt(ip));
|
push(t, makeInt(t, ip));
|
||||||
ip = (ip - 1)
|
ip = (ip - 1)
|
||||||
+ ((offset1 << 24) | (offset2 << 16) | (offset3 << 8) | offset4);
|
+ ((offset1 << 24) | (offset2 << 16) | (offset3 << 8) | offset4);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
@ -1203,14 +1209,14 @@ run(Thread* t)
|
|||||||
case l2i: {
|
case l2i: {
|
||||||
object v = pop(t);
|
object v = pop(t);
|
||||||
|
|
||||||
push(t, makeInt(t, static_cast<int32_t>(longValue(v))));
|
push(t, makeInt(t, static_cast<int32_t>(longValue(t, v))));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case ladd: {
|
case ladd: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) + longValue(b)));
|
push(t, makeLong(t, longValue(t, a) + longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case laload: {
|
case laload: {
|
||||||
@ -1219,11 +1225,11 @@ run(Thread* t)
|
|||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
if (i >= 0 and i < longArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < longArrayLength(t, array)) {
|
||||||
push(t, makeLong(t, longArrayBody(array)[i]));
|
push(t, makeLong(t, longArrayBody(t, array)[i]));
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
longArrayLength(array));
|
longArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -1237,7 +1243,7 @@ run(Thread* t)
|
|||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) & longValue(b)));
|
push(t, makeLong(t, longValue(t, a) & longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lastore: {
|
case lastore: {
|
||||||
@ -1247,11 +1253,11 @@ run(Thread* t)
|
|||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
if (i >= 0 and i < longArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < longArrayLength(t, array)) {
|
||||||
longArrayBody(array)[i] = longValue(value);
|
longArrayBody(t, array)[i] = longValue(t, value);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
longArrayLength(array));
|
longArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -1265,20 +1271,20 @@ run(Thread* t)
|
|||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeInt(t, longValue(a) > longValue(b) ? 1
|
push(t, makeInt(t, longValue(t, a) > longValue(t, b) ? 1
|
||||||
: longValue(a) == longValue(b) ? 0 : -1));
|
: longValue(t, a) == longValue(t, b) ? 0 : -1));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lconst_0: {
|
case lconst_0: {
|
||||||
push(t, makeLong(0));
|
push(t, makeLong(t, 0));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lconst_1: {
|
case lconst_1: {
|
||||||
push(t, makeLong(1));
|
push(t, makeLong(t, 1));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case ldc: {
|
case ldc: {
|
||||||
push(t, codePool(t->code)[codeBody(t, t->code)[ip++]]);
|
push(t, rawArrayBody(t, codePool(t, t->code))[codeBody(t, t->code)[ip++]]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case ldc_w:
|
case ldc_w:
|
||||||
@ -1286,76 +1292,77 @@ run(Thread* t)
|
|||||||
uint8_t index1 = codeBody(t, t->code)[ip++];
|
uint8_t index1 = codeBody(t, t->code)[ip++];
|
||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
|
|
||||||
push(t, codePool(t->code)[codeBody(t, t->code)[(offset1 << 8) | offset2]]);
|
push(t, rawArrayBody(t, codePool(t, t->code))[(index1 << 8) | index2]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case ldiv: {
|
case ldiv: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) / longValue(b)));
|
push(t, makeLong(t, longValue(t, a) / longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lmul: {
|
case lmul: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) * longValue(b)));
|
push(t, makeLong(t, longValue(t, a) * longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lneg: {
|
case lneg: {
|
||||||
object v = pop(t);
|
object v = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, - longValue(v)));
|
push(t, makeLong(t, - longValue(t, v)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lor: {
|
case lor: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) | longValue(b)));
|
push(t, makeLong(t, longValue(t, a) | longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lrem: {
|
case lrem: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) % longValue(b)));
|
push(t, makeLong(t, longValue(t, a) % longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lshl: {
|
case lshl: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) << longValue(b)));
|
push(t, makeLong(t, longValue(t, a) << longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lshr: {
|
case lshr: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) >> longValue(b)));
|
push(t, makeLong(t, longValue(t, a) >> longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lsub: {
|
case lsub: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) - longValue(b)));
|
push(t, makeLong(t, longValue(t, a) - longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lushr: {
|
case lushr: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, static_cast<uint64_t>(longValue(a)) << longValue(b)));
|
push(t, makeLong(t, static_cast<uint64_t>(longValue(t, a))
|
||||||
|
<< longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case lxor: {
|
case lxor: {
|
||||||
object b = pop(t);
|
object b = pop(t);
|
||||||
object a = pop(t);
|
object a = pop(t);
|
||||||
|
|
||||||
push(t, makeLong(t, longValue(a) ^ longValue(b)));
|
push(t, makeLong(t, longValue(t, a) ^ longValue(t, b)));
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case new_: {
|
case new_: {
|
||||||
@ -1363,7 +1370,7 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object class_ = resolveClass(t, codePool(t->code), index);
|
object class_ = resolveClass(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
if (not classInitialized(class_)) {
|
if (not classInitialized(class_)) {
|
||||||
@ -1441,7 +1448,7 @@ run(Thread* t)
|
|||||||
|
|
||||||
push(t, array);
|
push(t, array);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d", c);
|
object message = makeJString(t, "%d", c);
|
||||||
t->exception = makeNegativeArrayStoreException(t, message);
|
t->exception = makeNegativeArrayStoreException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -1469,7 +1476,7 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object field = resolveField(t, codePool(t->code), index);
|
object field = resolveField(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
@ -1485,11 +1492,11 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t index = (index1 << 8) | index2;
|
uint16_t index = (index1 << 8) | index2;
|
||||||
|
|
||||||
object field = resolveField(t, codePool(t->code), index);
|
object field = resolveField(t, codePool(t, t->code), index);
|
||||||
if (t->exception) goto throw_;
|
if (t->exception) goto throw_;
|
||||||
|
|
||||||
if (not classInitialized(fieldClass(field))) {
|
if (not classInitialized(fieldClass(t, field))) {
|
||||||
t->code = classInitializer(fieldClass(field));
|
t->code = classInitializer(fieldClass(t, field));
|
||||||
ip -= 3;
|
ip -= 3;
|
||||||
parameterCount = 0;
|
parameterCount = 0;
|
||||||
goto invoke;
|
goto invoke;
|
||||||
@ -1500,14 +1507,14 @@ run(Thread* t)
|
|||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case ret: {
|
case ret: {
|
||||||
ip = intValue(t, frameBody(t, t->frame)[codeBody(t, t->code)[ip++]]);
|
ip = intValue(t, frameLocals(t, t->frame)[codeBody(t, t->code)[ip]]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case return_: {
|
case return_: {
|
||||||
t->frame = frameNext(t->frame);
|
t->frame = frameNext(t, t->frame);
|
||||||
if (t->frame) {
|
if (t->frame) {
|
||||||
t->code = methodCode(frameMethod(t->frame));
|
t->code = methodCode(t, frameMethod(t, t->frame));
|
||||||
ip = frameIp(t->frame);
|
ip = frameIp(t, t->frame);
|
||||||
goto loop;
|
goto loop;
|
||||||
} else {
|
} else {
|
||||||
t->code = 0;
|
t->code = 0;
|
||||||
@ -1521,11 +1528,11 @@ run(Thread* t)
|
|||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
if (i >= 0 and i < shortArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < shortArrayLength(t, array)) {
|
||||||
push(t, makeShort(t, shortArrayBody(array)[i]));
|
push(t, makeShort(t, shortArrayBody(t, array)[i]));
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
shortArrayLength(array));
|
shortArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -1542,11 +1549,11 @@ run(Thread* t)
|
|||||||
int32_t i = intValue(t, index);
|
int32_t i = intValue(t, index);
|
||||||
|
|
||||||
if (array) {
|
if (array) {
|
||||||
if (i >= 0 and i < shortArrayLength(array)) {
|
if (i >= 0 and static_cast<uint32_t>(i) < shortArrayLength(t, array)) {
|
||||||
shortArrayBody(array)[i] = intValue(t, value);
|
shortArrayBody(t, array)[i] = intValue(t, value);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d not in [0,%d]", i,
|
object message = makeJString(t, "%d not in [0,%d]", i,
|
||||||
shortArrayLength(array));
|
shortArrayLength(t, array));
|
||||||
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
t->exception = makeArrayIndexOutOfBoundsException(t, message);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
@ -1582,7 +1589,7 @@ run(Thread* t)
|
|||||||
uint8_t index1 = codeBody(t, t->code)[ip++];
|
uint8_t index1 = codeBody(t, t->code)[ip++];
|
||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
|
|
||||||
push(t, frameBody(t, t->frame)[(index1 << 8) | index2]);
|
push(t, frameLocals(t, t->frame)[(index1 << 8) | index2]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case astore:
|
case astore:
|
||||||
@ -1592,7 +1599,7 @@ run(Thread* t)
|
|||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
|
|
||||||
object value = pop(t);
|
object value = pop(t);
|
||||||
set(t, frameBody(t, t->frame)[(index1 << 8) | index2], value);
|
set(t, frameLocals(t, t->frame)[(index1 << 8) | index2], value);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case iinc: {
|
case iinc: {
|
||||||
@ -1604,30 +1611,30 @@ run(Thread* t)
|
|||||||
uint8_t count2 = codeBody(t, t->code)[ip++];
|
uint8_t count2 = codeBody(t, t->code)[ip++];
|
||||||
uint16_t count = (count1 << 8) | count2;
|
uint16_t count = (count1 << 8) | count2;
|
||||||
|
|
||||||
int32_t v = intValue(t, frameBody(t, t->frame)[index]);
|
int32_t v = intValue(t, frameLocals(t, t->frame)[index]);
|
||||||
frameBody(t, t->frame)[index] = makeInt(t, v + count);
|
frameLocals(t, t->frame)[index] = makeInt(t, v + count);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
case ret: {
|
case ret: {
|
||||||
uint8_t index1 = codeBody(t, t->code)[ip++];
|
uint8_t index1 = codeBody(t, t->code)[ip++];
|
||||||
uint8_t index2 = codeBody(t, t->code)[ip++];
|
uint8_t index2 = codeBody(t, t->code)[ip++];
|
||||||
|
|
||||||
ip = intValue(t, frameBody(t, t->frame)[(index1 << 8) | index2]);
|
ip = intValue(t, frameLocals(t, t->frame)[(index1 << 8) | index2]);
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
default: abort(t);
|
default: abort(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
invoke:
|
invoke:
|
||||||
if (codeMaxStack(t->code) + t->sp - parameterCount > Thread::StackSize) {
|
if (codeMaxStack(t, t->code) + t->sp - parameterCount > Thread::StackSize) {
|
||||||
t->exception = makeStackOverflowException(t, 0);
|
t->exception = makeStackOverflowException(t, 0);
|
||||||
goto throw_;
|
goto throw_;
|
||||||
}
|
}
|
||||||
|
|
||||||
frameIp(t->frame) = ip;
|
frameIp(t, t->frame) = ip;
|
||||||
|
|
||||||
t->frame = makeFrame(t, t->code, t->frame);
|
t->frame = makeFrame(t, t->code, t->frame);
|
||||||
memcpy(frameLocals(t->frame),
|
memcpy(frameLocals(t, t->frame),
|
||||||
t->stack + t->sp - parameterCount,
|
t->stack + t->sp - parameterCount,
|
||||||
parameterCount);
|
parameterCount);
|
||||||
t->sp -= parameterCount;
|
t->sp -= parameterCount;
|
||||||
@ -1635,18 +1642,18 @@ run(Thread* t)
|
|||||||
goto loop;
|
goto loop;
|
||||||
|
|
||||||
throw_:
|
throw_:
|
||||||
for (; t->frame; t->frame = frameNext(t->frame)) {
|
for (; t->frame; t->frame = frameNext(t, t->frame)) {
|
||||||
t->code = methodCode(frameMethod(t->frame));
|
t->code = methodCode(t, frameMethod(t, t->frame));
|
||||||
object eht = codeExceptionHandlerTable(t->code);
|
object eht = codeExceptionHandlerTable(t, t->code);
|
||||||
if (eht) {
|
if (eht) {
|
||||||
for (unsigned i = 0; i < exceptionHandleTableLength(eht); ++i) {
|
for (unsigned i = 0; i < exceptionHandleTableLength(t, eht); ++i) {
|
||||||
ExceptionHandler* eh = exceptionHandlerTableBody(eht)[i];
|
ExceptionHandler* eh = exceptionHandlerTableBody(t, eht)[i];
|
||||||
uint16_t catchType = exceptionHandlerCatchType(eh);
|
uint16_t catchType = exceptionHandlerCatchType(eh);
|
||||||
if (catchType == 0 or
|
if (catchType == 0 or
|
||||||
instanceOf(rawArrayBody(codePool(t->code))[catchType],
|
instanceOf(rawArrayBody(t, codePool(t, t->code))[catchType],
|
||||||
t->exception))
|
t->exception))
|
||||||
{
|
{
|
||||||
t->sp = frameStackBase(t->frame);
|
t->sp = frameStackBase(t, t->frame);
|
||||||
ip = exceptionHandlerIp(eh);
|
ip = exceptionHandlerIp(eh);
|
||||||
push(t, t->exception);
|
push(t, t->exception);
|
||||||
t->exception = 0;
|
t->exception = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user