Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+ $Id: codegen.c 7918 2007-05-20 20:42:18Z michi $
*/
#include "native/jni.h"
#include "native/native.h"
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
#include "vm/builtin.h"
#include "vm/exceptions.h"
case ICMD_CHECKCAST: /* ..., objectref ==> ..., objectref */
- /* val.a: (classinfo*) superclass */
-
- /* superclass is an interface:
- *
- * OK if ((sub == NULL) ||
- * (sub->vftbl->interfacetablelength > super->index) &&
- * (sub->vftbl->interfacetable[-super->index] != NULL));
- *
- * superclass is a class:
- *
- * OK if ((sub == NULL) || (0
- * <= (sub->vftbl->baseval - super->vftbl->baseval) <=
- * super->vftbl->diffval));
- */
-
if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
/* object type cast-check */
classinfo *super;
- vftbl_t *supervftbl;
s4 superindex;
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
- super = NULL;
+ super = NULL;
superindex = 0;
- supervftbl = NULL;
}
else {
- super = iptr->sx.s23.s3.c.cls;
+ super = iptr->sx.s23.s3.c.cls;
superindex = super->index;
- supervftbl = super->vftbl;
}
-#if defined(ENABLE_THREADS)
- codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+ if ((super == NULL) || !(super->flags & ACC_INTERFACE))
+ CODEGEN_CRITICAL_SECTION_NEW;
+
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
/* if class is not resolved, check which code to call */
disp);
}
else {
- disp = dseg_add_address(cd, supervftbl);
+ disp = dseg_add_address(cd, super->vftbl);
emit_label_beqz(cd, BRANCH_LABEL_5, s1);
}
M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
M_ALD(REG_ITMP3, REG_PV, disp);
-#if defined(ENABLE_THREADS)
- codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+ CODEGEN_CRITICAL_SECTION_START;
+
M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
/* if (s1 != REG_ITMP1) { */
/* M_ILD(REG_ITMP1, REG_ITMP3, OFFSET(vftbl_t, baseval)); */
M_ISUB(REG_ITMP2, REG_ITMP3, REG_ITMP2);
M_ALD(REG_ITMP3, REG_PV, disp);
M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
-#if defined(ENABLE_THREADS)
- codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+ CODEGEN_CRITICAL_SECTION_END;
+
/* } */
M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3);
emit_classcast_check(cd, iptr, BRANCH_EQ, REG_ITMP3, s1);
case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult */
- /* val.a: (classinfo*) superclass */
-
- /* superclass is an interface:
- *
- * return (sub != NULL) &&
- * (sub->vftbl->interfacetablelength > super->index) &&
- * (sub->vftbl->interfacetable[-super->index] != NULL);
- *
- * superclass is a class:
- *
- * return ((sub != NULL) && (0
- * <= (sub->vftbl->baseval - super->vftbl->baseval) <=
- * super->vftbl->diffvall));
- */
-
{
classinfo *super;
vftbl_t *supervftbl;
supervftbl = super->vftbl;
}
-#if defined(ENABLE_THREADS)
- codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+ if ((super == NULL) || !(super->flags & ACC_INTERFACE))
+ CODEGEN_CRITICAL_SECTION_NEW;
+
s1 = emit_load_s1(jd, iptr, REG_ITMP1);
d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
M_ALD(REG_ITMP2, REG_PV, disp);
-#if defined(ENABLE_THREADS)
- codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+ CODEGEN_CRITICAL_SECTION_START;
+
M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval));
M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval));
-#if defined(ENABLE_THREADS)
- codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+ CODEGEN_CRITICAL_SECTION_END;
+
M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
M_CMPULE(REG_ITMP1, REG_ITMP2, d);
sizeof(stackframeinfo) / SIZEOF_VOID_P +
sizeof(localref_table) / SIZEOF_VOID_P +
1 + /* methodinfo for call trace */
- (md->paramcount > INT_ARG_CNT ? INT_ARG_CNT : md->paramcount) +
+ md->paramcount +
nmd->memuse;
/* create method header */
/* save integer and float argument registers */
- for (i = 0, j = 0; i < md->paramcount && i < INT_ARG_CNT; i++) {
- if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
- M_LST(abi_registers_integer_argument[i], REG_SP, j * 8);
- j++;
- }
- }
+ for (i = 0; i < md->paramcount; i++) {
+ if (!md->params[i].inmemory) {
+ s1 = md->params[i].regoff;
- for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
- if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
- M_DST(abi_registers_float_argument[i], REG_SP, j * 8);
- j++;
+ switch (md->paramtypes[i].type) {
+ case TYPE_INT:
+ case TYPE_LNG:
+ case TYPE_ADR:
+ M_LST(s1, REG_SP, i * 8);
+ break;
+ case TYPE_FLT:
+ case TYPE_DBL:
+ M_DST(s1, REG_SP, i * 8);
+ break;
+ }
}
}
/* restore integer and float argument registers */
- for (i = 0, j = 0; i < md->paramcount && i < INT_ARG_CNT; i++) {
- if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
- M_LLD(abi_registers_integer_argument[i], REG_SP, j * 8);
- j++;
- }
- }
+ for (i = 0; i < md->paramcount; i++) {
+ if (!md->params[i].inmemory) {
+ s1 = md->params[i].regoff;
- for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
- if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
- M_DLD(abi_registers_float_argument[i], REG_SP, j * 8);
- j++;
+ switch (md->paramtypes[i].type) {
+ case TYPE_INT:
+ case TYPE_LNG:
+ case TYPE_ADR:
+ M_LLD(s1, REG_SP, i * 8);
+ break;
+ case TYPE_FLT:
+ case TYPE_DBL:
+ M_DLD(s1, REG_SP, i * 8);
+ break;
+ }
}
}