146 #ifdef ENABLE_VERIFIER
180 #define TYPECHECK_CHECK_TYPE(i,tp,msg) \
182 if (VAR(i)->type != (tp)) { \
183 exceptions_throw_verifyerror(state->m, (msg)); \
188 #define TYPECHECK_INT(i) \
189 TYPECHECK_CHECK_TYPE(i,TYPE_INT,"Expected to find integer value")
190 #define TYPECHECK_LNG(i) \
191 TYPECHECK_CHECK_TYPE(i,TYPE_LNG,"Expected to find long value")
192 #define TYPECHECK_FLT(i) \
193 TYPECHECK_CHECK_TYPE(i,TYPE_FLT,"Expected to find float value")
194 #define TYPECHECK_DBL(i) \
195 TYPECHECK_CHECK_TYPE(i,TYPE_DBL,"Expected to find double value")
196 #define TYPECHECK_ADR(i) \
197 TYPECHECK_CHECK_TYPE(i,TYPE_ADR,"Expected to find object value")
199 #define TYPECHECK_INT_OP(o) TYPECHECK_INT((o).varindex)
200 #define TYPECHECK_LNG_OP(o) TYPECHECK_LNG((o).varindex)
201 #define TYPECHECK_FLT_OP(o) TYPECHECK_FLT((o).varindex)
202 #define TYPECHECK_DBL_OP(o) TYPECHECK_DBL((o).varindex)
203 #define TYPECHECK_ADR_OP(o) TYPECHECK_ADR((o).varindex)
231 OLD_LOG(
"allocating savedindices buffer");
266 OLD_LOG(
"restoring saved invars");
305 #define TYPECHECK_VARIABLESBASED
306 #define EXCEPTION do { return false; } while (0)
307 #define VERIFY_ERROR(msg) TYPECHECK_VERIFYERROR_bool(msg)
311 #undef TYPECHECK_VARIABLESBASED
339 #define TYPECHECK_VARIABLESBASED
340 #define OP1 VAR(state->iptr->sx.s23.s2.args[0])
343 #undef TYPECHECK_VARIABLESBASED
371 #define TYPECHECK_VARIABLESBASED
372 #define OP1 state->iptr->sx.s23.s2.args[0]
375 #undef TYPECHECK_VARIABLESBASED
402 #define TYPECHECK_VARIABLESBASED
403 #define VERIFY_ERROR(msg) TYPECHECK_VERIFYERROR_bool(msg)
406 #undef TYPECHECK_VARIABLESBASED
436 localmap += 5 * (javaindex-1);
437 for (t=0; t<5; ++t) {
438 varindex = *localmap++;
440 OLD_LOG1(
"invalidate local %d", varindex);
446 localmap += 5 * javaindex;
451 for (t=0; t<5; ++t) {
452 varindex = *localmap++;
454 OLD_LOG1(
"invalidate local %d", varindex);
462 for (t=0; t<5; ++t) {
463 varindex = *localmap++;
465 OLD_LOG1(
"invalidate local %d", varindex);
475 #define EXCEPTION do { return false; } while (0)
476 #define VERIFY_ERROR(msg) TYPECHECK_VERIFYERROR_bool(msg)
478 #define CHECK_LOCAL_TYPE(index, t) \
480 if (!typevector_checktype(jd->var, (index), (t))) \
481 VERIFY_ERROR("Local variable type mismatch"); \
484 #define STORE_LOCAL(t, index) \
487 typecheck_invalidate_locals(state, (index), false); \
488 typevector_store(jd->var, (index), (temp_t), NULL); \
491 #define STORE_LOCAL_2_WORD(t, index) \
494 typecheck_invalidate_locals(state, (index), true); \
495 typevector_store(jd->var, (index), (temp_t), NULL); \
498 #define REACH_BLOCK(target) \
500 if (!typestate_reach(state, (target), \
501 state->bptr->outvars, jd->var, \
502 state->bptr->outdepth)) \
506 #define REACH(target) REACH_BLOCK((target).block)
540 OLD_LOGSTR1(
"\n---- BLOCK %04d ------------------------------------------------\n",state->
bptr->
nr);
543 superblockend =
false;
589 #define TYPECHECK_VARIABLESBASED
591 #define METHOD (state->m)
593 #define BPTR (state->bptr)
594 #include <typecheck-variablesbased-gen.inc>
599 #undef TYPECHECK_VARIABLESBASED
611 OLD_LOG(
"reaching exception handlers");
627 OLD_LOG(
"\t\tnext instruction");
639 if (!superblockend) {
640 OLD_LOG(
"reaching following block");
644 #ifdef TYPECHECK_DEBUG
682 #define MAXPARAMS 255
693 #ifdef TYPECHECK_STATISTICS
694 int count_iterations = 0;
698 TYPECHECK_COUNTIF(cdata->method->exceptiontablelength != 0,stat_methods_with_handlers);
699 state.stat_maythrow =
false;
710 OLD_LOGSTR(
"\n==============================================================================\n");
712 OLD_LOGSTR(
"\n==============================================================================\n");
779 OLD_LOG(
"Exception handler stacks set.\n");
805 #ifdef TYPECHECK_STATISTICS
806 OLD_LOG1(
"Typechecker did %4d iterations",count_iterations);
#define OLD_LOG2(str, a, b)
static void typestate_restore_invars(verifier_state *state)
#define TYPECHECK_COUNT(cnt)
exception_entry ** handlers
#define TYPECHECK_MARK(var)
exception_entry * exceptiontable
bool typecheck(jitdata *jd)
void typecheck_init_state(verifier_state *state, basicblock::State minstate)
bool typecheck_init_locals(verifier_state *state, bool newthis)
static bool handle_invocation(verifier_state *state)
static bool handle_multianewarray(verifier_state *state)
#define OLD_LOGSTR1(str, a)
void typevector_print(FILE *file, const varinfo *vec, int size)
#define IS_2_WORD_TYPE(a)
static bool handle_basic_block(verifier_state *state)
#define TYPECHECK_COUNT_FREQ(array, val, limit)
void show_basicblock(jitdata *jd, basicblock *bptr, int stage)
static void typecheck_invalidate_locals(verifier_state *state, s4 index, bool twoword)
#define OLD_LOGIF(cond, str)
void typecheck_reset_state(verifier_state *state)
classref_or_classinfo catchtype
#define TYPECHECK_VERIFYERROR_bool(msg)
void typevector_copy_inplace(varinfo *src, varinfo *dst, int size)
Fieldref, Methodref and InterfaceMethodref.
static bool handle_fieldaccess(verifier_state *state, varinfo *instance, varinfo *value)
static void typestate_save_invars(verifier_state *state)
void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
bool typecheck_copy_types(verifier_state *state, s4 *srcvars, s4 *dstvars, s4 n)
#define TYPECHECK_COUNTIF(cond, cnt)
static void * allocate(size_t size)
void jit_check_basicblock_numbers(jitdata *jd)
bool typestate_reach(verifier_state *state, basicblock *destblock, s4 *srcvars, varinfo *srclocals, s4 n)
#define MCOPY(dest, src, type, num)
classinfo * class_java_lang_Throwable
#define OLD_LOGMETHOD(str, m)
static bool handle_builtin(verifier_state *state)
#define VERIFIER_EXTRA_VARS