Joseph Wenninger
Christian Thalinger
- $Id: parse.c 5166 2006-07-21 10:09:33Z twisti $
+ $Id: parse.c 5181 2006-07-26 13:27:54Z twisti $
*/
#include "vm/options.h"
#include "vm/statistics.h"
#include "vm/stringlocal.h"
+#include "vm/suck.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/jit.h"
#include "vm/jit/parse.h"
/* fetch next opcode */
fetch_opcode:
- opcode = code_get_u1(p, m);
+ opcode = SUCK_BE_U1(m->jcode + p);
/* store intermediate instruction count (bit 0 mark block starts) */
/* pushing constants onto the stack ***********************************/
case JAVA_BIPUSH:
- NEW_OP_LOADCONST_I(code_get_s1(p+1,m));
+ NEW_OP_LOADCONST_I(SUCK_BE_S1(m->jcode + p + 1));
break;
case JAVA_SIPUSH:
- NEW_OP_LOADCONST_I(code_get_s2(p+1,m));
+ NEW_OP_LOADCONST_I(SUCK_BE_S2(m->jcode + p + 1));
break;
case JAVA_LDC1:
- i = code_get_u1(p + 1, m);
+ i = SUCK_BE_U1(m->jcode + p + 1);
goto pushconstantitem;
case JAVA_LDC2:
case JAVA_LDC2W:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
pushconstantitem:
case JAVA_ILOAD:
case JAVA_FLOAD:
case JAVA_ALOAD:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
nextp = p + 3;
iswide = false;
}
case JAVA_LLOAD:
case JAVA_DLOAD:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
nextp = p + 3;
iswide = false;
}
case JAVA_ISTORE:
case JAVA_FSTORE:
case JAVA_ASTORE:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
iswide = false;
nextp = p + 3;
}
case JAVA_LSTORE:
case JAVA_DSTORE:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
iswide = false;
nextp = p + 3;
}
{
int v;
- if (!iswide) {
- i = code_get_u1(p + 1,m);
- v = code_get_s1(p + 2,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
+ v = SUCK_BE_S1(m->jcode + p + 2);
}
else {
- i = code_get_u2(p + 1,m);
- v = code_get_s2(p + 3,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
+ v = SUCK_BE_S2(m->jcode + p + 3);
iswide = false;
nextp = p + 5;
}
/* managing arrays ****************************************************/
case JAVA_NEWARRAY:
- switch (code_get_s1(p + 1, m)) {
+ switch (SUCK_BE_S1(m->jcode + p + 1)) {
case 4:
bte = builtintable_get_internal(BUILTIN_newarray_boolean);
break;
break;
#if defined(ENABLE_VERIFIER)
default:
- exceptions_throw_verifyerror(m,
- "Invalid array-type to create");
+ exceptions_throw_verifyerror(m, "Invalid array-type to create");
return false;
#endif
}
break;
case JAVA_ANEWARRAY:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
compr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!compr)
return false;
case JAVA_MULTIANEWARRAY:
jd->isleafmethod = false;
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
{
- s4 v = code_get_u1(p + 3, m);
+ s4 v = SUCK_BE_U1(m->jcode + p + 3);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
case JAVA_IF_ACMPEQ:
case JAVA_IF_ACMPNE:
case JAVA_GOTO:
- i = p + code_get_s2(p + 1,m);
+ i = p + SUCK_BE_S2(m->jcode + p + 1);
CHECK_BYTECODE_INDEX(i);
new_block_insert(i);
blockend = true;
break;
case JAVA_GOTO_W:
- i = p + code_get_s4(p + 1,m);
+ i = p + SUCK_BE_S4(m->jcode + p + 1);
CHECK_BYTECODE_INDEX(i);
new_block_insert(i);
blockend = true;
break;
case JAVA_JSR:
- i = p + code_get_s2(p + 1,m);
+ i = p + SUCK_BE_S2(m->jcode + p + 1);
jsr_tail:
CHECK_BYTECODE_INDEX(i);
new_block_insert(i);
break;
case JAVA_JSR_W:
- i = p + code_get_s4(p + 1,m);
+ i = p + SUCK_BE_S4(m->jcode + p + 1);
goto jsr_tail;
case JAVA_RET:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
nextp = p + 3;
iswide = false;
}
/* default target */
- j = p + code_get_s4(nextp, m);
+ j = p + SUCK_BE_S4(m->jcode + nextp);
iptr->sx.s23.s3.lookupdefault.insindex = j;
nextp += 4;
CHECK_BYTECODE_INDEX(j);
/* number of pairs */
- num = code_get_u4(nextp, m);
+ num = SUCK_BE_U4(m->jcode + nextp);
iptr->sx.s23.s2.lookupcount = num;
nextp += 4;
for (i = 0; i < num; i++) {
/* value */
- j = code_get_s4(nextp, m);
+ j = SUCK_BE_S4(m->jcode + nextp);
lookup->value = j;
nextp += 4;
#endif
/* target */
- j = p + code_get_s4(nextp,m);
+ j = p + SUCK_BE_S4(m->jcode + nextp);
lookup->target.insindex = j;
lookup++;
nextp += 4;
/* default target */
- deftarget = p + code_get_s4(nextp, m);
+ deftarget = p + SUCK_BE_S4(m->jcode + nextp);
nextp += 4;
CHECK_BYTECODE_INDEX(deftarget);
new_block_insert(deftarget);
/* lower bound */
- j = code_get_s4(nextp, m);
+ j = SUCK_BE_S4(m->jcode + nextp);
iptr->sx.s23.s2.tablelow = j;
nextp += 4;
/* upper bound */
- num = code_get_s4(nextp, m);
+ num = SUCK_BE_S4(m->jcode + nextp);
iptr->sx.s23.s3.tablehigh = num;
nextp += 4;
CHECK_END_OF_BYTECODE(nextp + 4 * num);
for (i = 0; i < num; i++) {
- j = p + code_get_s4(nextp,m);
+ j = p + SUCK_BE_S4(m->jcode + nextp);
(table++)->insindex = j;
nextp += 4;
CHECK_BYTECODE_INDEX(j);
constant_FMIref *fr;
unresolved_field *uf;
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
if (!fr)
return false;
/* method invocation **************************************************/
case JAVA_INVOKESTATIC:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
mr = class_getconstant(m->class, i, CONSTANT_Methodref);
if (!mr)
return false;
goto invoke_method;
case JAVA_INVOKEINTERFACE:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
mr = class_getconstant(m->class, i,
CONSTANT_InterfaceMethodref);
case JAVA_INVOKESPECIAL:
case JAVA_INVOKEVIRTUAL:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
mr = class_getconstant(m->class, i, CONSTANT_Methodref);
invoke_nonstatic_method:
/* instructions taking class arguments ********************************/
case JAVA_NEW:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
return false;
break;
case JAVA_CHECKCAST:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
return false;
break;
case JAVA_INSTANCEOF:
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
return false;
/* fetch next opcode */
fetch_opcode:
- opcode = code_get_u1(p, m);
+ opcode = SUCK_BE_U1(m->jcode + p);
m->basicblockindex[p] |= (ipc << 1); /*store intermed cnt*/
/* pushing constants onto the stack p */
case JAVA_BIPUSH:
- LOADCONST_I(code_get_s1(p+1,m));
+ LOADCONST_I(SUCK_BE_S1(m->jcode + p + 1));
break;
case JAVA_SIPUSH:
- LOADCONST_I(code_get_s2(p+1,m));
+ LOADCONST_I(SUCK_BE_S2(m->jcode + p + 1));
break;
case JAVA_LDC1:
- i = code_get_u1(p + 1, m);
+ i = SUCK_BE_U1(m->jcode + p + 1);
goto pushconstantitem;
case JAVA_LDC2:
case JAVA_LDC2W:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
pushconstantitem:
case JAVA_ILOAD:
case JAVA_FLOAD:
case JAVA_ALOAD:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
nextp = p + 3;
iswide = false;
}
case JAVA_LLOAD:
case JAVA_DLOAD:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
nextp = p + 3;
iswide = false;
}
case JAVA_ISTORE:
case JAVA_FSTORE:
case JAVA_ASTORE:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
iswide = false;
nextp = p + 3;
}
case JAVA_LSTORE:
case JAVA_DSTORE:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
iswide = false;
nextp = p + 3;
}
{
int v;
- if (!iswide) {
- i = code_get_u1(p + 1,m);
- v = code_get_s1(p + 2,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
+ v = SUCK_BE_S1(m->jcode + p + 2);
}
else {
- i = code_get_u2(p + 1,m);
- v = code_get_s2(p + 3,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
+ v = SUCK_BE_S2(m->jcode + p + 3);
iswide = false;
nextp = p + 5;
}
/* managing arrays ****************************************************/
case JAVA_NEWARRAY:
- switch (code_get_s1(p + 1, m)) {
+ switch (SUCK_BE_S1(m->jcode + p + 1)) {
case 4:
bte = builtintable_get_internal(BUILTIN_newarray_boolean);
break;
break;
case JAVA_ANEWARRAY:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
compr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!compr)
return false;
case JAVA_MULTIANEWARRAY:
jd->isleafmethod = false;
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
{
- s4 v = code_get_u1(p + 3, m);
+ s4 v = SUCK_BE_U1(m->jcode + p + 3);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
case JAVA_IF_ACMPNE:
case JAVA_GOTO:
case JAVA_JSR:
- i = p + code_get_s2(p + 1,m);
+ i = p + SUCK_BE_S2(m->jcode + p + 1);
CHECK_BYTECODE_INDEX(i);
block_insert(i);
blockend = true;
case JAVA_GOTO_W:
case JAVA_JSR_W:
- i = p + code_get_s4(p + 1,m);
+ i = p + SUCK_BE_S4(m->jcode + p + 1);
CHECK_BYTECODE_INDEX(i);
block_insert(i);
blockend = true;
break;
case JAVA_RET:
- if (!iswide) {
- i = code_get_u1(p + 1,m);
+ if (iswide == false) {
+ i = SUCK_BE_U1(m->jcode + p + 1);
}
else {
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
nextp = p + 3;
iswide = false;
}
/* default target */
- j = p + code_get_s4(nextp, m);
+ j = p + SUCK_BE_S4(m->jcode + nextp);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* number of pairs */
- num = code_get_u4(nextp, m);
+ num = SUCK_BE_U4(m->jcode + nextp);
*tablep = num;
tablep++;
nextp += 4;
for (i = 0; i < num; i++) {
/* value */
- j = code_get_s4(nextp, m);
+ j = SUCK_BE_S4(m->jcode + nextp);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* target */
- j = p + code_get_s4(nextp,m);
+ j = p + SUCK_BE_S4(m->jcode + nextp);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* default target */
- j = p + code_get_s4(nextp, m);
+ j = p + SUCK_BE_S4(m->jcode + nextp);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* lower bound */
- j = code_get_s4(nextp, m);
+ j = SUCK_BE_S4(m->jcode + nextp);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
/* upper bound */
- num = code_get_s4(nextp, m);
+ num = SUCK_BE_S4(m->jcode + nextp);
*tablep = num; /* restore for little endian */
tablep++;
nextp += 4;
CHECK_END_OF_BYTECODE(nextp + 4 * (num + 1));
for (i = 0; i <= num; i++) {
- j = p + code_get_s4(nextp,m);
+ j = p + SUCK_BE_S4(m->jcode + nextp);
*tablep = j; /* restore for little endian */
tablep++;
nextp += 4;
constant_FMIref *fr;
unresolved_field *uf;
- i = code_get_u2(p + 1, m);
- fr = class_getconstant(m->class, i,
- CONSTANT_Fieldref);
+ i = SUCK_BE_U2(m->jcode + p + 1);
+ fr = class_getconstant(m->class, i, CONSTANT_Fieldref);
if (!fr)
return false;
/* method invocation **************************************************/
case JAVA_INVOKESTATIC:
- i = code_get_u2(p + 1, m);
- mr = class_getconstant(m->class, i,
- CONSTANT_Methodref);
+ i = SUCK_BE_U2(m->jcode + p + 1);
+ mr = class_getconstant(m->class, i, CONSTANT_Methodref);
if (!mr)
return false;
goto invoke_method;
case JAVA_INVOKEINTERFACE:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
mr = class_getconstant(m->class, i,
CONSTANT_InterfaceMethodref);
case JAVA_INVOKESPECIAL:
case JAVA_INVOKEVIRTUAL:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
mr = class_getconstant(m->class, i,
CONSTANT_Methodref);
/* miscellaneous object operations ************************************/
case JAVA_NEW:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
return false;
break;
case JAVA_CHECKCAST:
- i = code_get_u2(p + 1, m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
return false;
break;
case JAVA_INSTANCEOF:
- i = code_get_u2(p + 1,m);
+ i = SUCK_BE_U2(m->jcode + p + 1);
cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
if (!cr)
return false;