_Jv_word locals[meth->max_locals];
+#ifdef DEBUG
+ frame_desc.locals = locals;
+ char locals_type[meth->max_locals];
+ memset (locals_type, 'x', meth->max_locals);
+ frame_desc.locals_type = locals_type;
+#endif
+
#define INSN_LABEL(op) &&insn_##op
static const void *const insn_target[] =
#ifdef DIRECT_THREADED
+#ifdef DEBUG
+#undef NEXT_INSN
+#define NEXT_INSN \
+ do \
+ { \
+ if (JVMTI_REQUESTED_EVENT (SingleStep)) \
+ { \
+ JNIEnv *env = _Jv_GetCurrentJNIEnv (); \
+ jmethodID method = meth->self; \
+ jlocation loc = meth->insn_index (pc); \
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_SINGLE_STEP, thread, \
+ env, method, loc); \
+ } \
+ goto *((pc++)->insn); \
+ } \
+ while (0)
+#else
+#undef NEXT_INSN
#define NEXT_INSN goto *((pc++)->insn)
+#endif
+
#define INTVAL() ((pc++)->int_val)
#define AVAL() ((pc++)->datum)
#else
+#ifdef DEBUG
+#define NEXT_INSN \
+ do \
+ { \
+ if (JVMTI_REQUESTED_EVENT (SingleStep)) \
+ { \
+ JNIEnv *env = _Jv_GetCurrentJNIEnv (); \
+ jmethodID method = meth->self; \
+ jlocation loc = meth->insn_index (pc); \
+ _Jv_JVMTI_PostEvent (JVMTI_EVENT_SINGLE_STEP, thread, \
+ env, method, loc); \
+ } \
+ goto *(insn_target[*pc++])
+#else
#define NEXT_INSN goto *(insn_target[*pc++])
+#endif
#define GET1S() get1s (pc++)
#define GET2S() (pc += 2, get2s (pc- 2))
*/
memcpy ((void*) locals, (void*) args, meth->args_raw_size);
+#ifdef DEBUG
+ // Get the object pointer for this method, after checking that it is
+ // non-static.
+ _Jv_Method *method = meth->get_method ();
+
+ if ((method->accflags & java::lang::reflect::Modifier::STATIC) == 0)
+ frame_desc.obj_ptr = locals[0].o;
+#endif
+
_Jv_word *pool_data = meth->defining_class->constants.data;
/* These three are temporaries for common code used by several
}
catch (java::lang::Throwable *ex)
{
-#ifdef DIRECT_THREADED
- void *logical_pc = (void *) ((insn_slot *) pc - 1);
-#else
- int logical_pc = pc - 1 - meth->bytecode ();
+#ifdef DEBUG
+ // This needs to be done before the pc is changed.
+ jlong throw_loc = meth->insn_index (pc);
+#endif
+ // Check if the exception is handled and, if so, set the pc to the start
+ // of the appropriate catch block.
+ if (meth->check_handler (&pc, meth, ex))
+ {
+ sp = stack;
+ sp++->o = ex; // Push exception.
+#ifdef DEBUG
+ if (JVMTI_REQUESTED_EVENT (Exception))
+ {
+ using namespace gnu::gcj::jvmti;
+ jlong throw_meth = reinterpret_cast<jlong> (meth->get_method ());
+ jlong catch_loc = meth->insn_index (pc);
+ ExceptionEvent::postExceptionEvent (thread, throw_meth,
+ throw_loc, ex, throw_meth,
+ catch_loc);
+ }
+#endif
+ NEXT_INSN;
+ }
+#ifdef DEBUG
+ if (JVMTI_REQUESTED_EVENT (Exception))
+ {
+ using namespace gnu::gcj::jvmti;
+ jlong throw_meth = reinterpret_cast<jlong> (meth->get_method ());
+ ExceptionEvent::postExceptionEvent (thread, throw_meth, throw_loc,
+ ex, NULL, NULL);
+ }
#endif
- _Jv_InterpException *exc = meth->exceptions ();
- jclass exc_class = ex->getClass ();
-
- for (int i = 0; i < meth->exc_count; i++)
- {
- if (PCVAL (exc[i].start_pc) <= logical_pc
- && logical_pc < PCVAL (exc[i].end_pc))
- {
-#ifdef DIRECT_THREADED
- jclass handler = (jclass) exc[i].handler_type.p;
-#else
- jclass handler = NULL;
- if (exc[i].handler_type.i != 0)
- handler = (_Jv_Linker::resolve_pool_entry (meth->defining_class,
- exc[i].handler_type.i)).clazz;
-#endif /* DIRECT_THREADED */
-
- if (handler == NULL || handler->isAssignableFrom (exc_class))
- {
-
-#ifdef DIRECT_THREADED
- pc = (insn_slot *) exc[i].handler_pc.p;
-#else
- pc = meth->bytecode () + exc[i].handler_pc.i;
-#endif /* DIRECT_THREADED */
- sp = stack;
- sp++->o = ex; // Push exception.
- NEXT_INSN;
- }
- }
- }
-
// No handler, so re-throw.
throw ex;
}