summaryrefslogtreecommitdiff
path: root/libjava/interpret.cc
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2006-04-29 01:35:50 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2006-04-29 01:35:50 +0000
commit763b66b3c80da8970b622023a523b3fb68b4b418 (patch)
tree190c70f4d67cff0f7db66783ec89f4f81229bbdb /libjava/interpret.cc
parentf644e0f4d5b0d7e1c84bbb2e01de75a1145d6d2c (diff)
downloadgcc-763b66b3c80da8970b622023a523b3fb68b4b418.tar.gz
2006-04-28 Bryce McKinlay <mckinlay@redhat.com>
* link.cc (_Jv_Linker::resolve_pool_entry): Don't pass vtable_index to resolve_method. * interpret.cc (insn_invokevirtual): Use method->index, not vtable_index. Check accflag FINAL to determine finals. Only do explicit null check if calling a final method. Use throw_null_pointer_exception. (invokevirtual_resolved): Likewise. (null_pointer_exc): Remove static field. (throw_null_pointer_exception): Always define. Throw a new NullPointerException every time. * include/java-interp.h (_Jv_ResolvedMethod): Remove vtable_index field. * include/execution.h (resolve_method): Remove vtable_index argument. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113370 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/interpret.cc')
-rw-r--r--libjava/interpret.cc57
1 files changed, 20 insertions, 37 deletions
diff --git a/libjava/interpret.cc b/libjava/interpret.cc
index 0e6fbc847cf..9a2059dadfc 100644
--- a/libjava/interpret.cc
+++ b/libjava/interpret.cc
@@ -51,10 +51,8 @@ static void throw_internal_error (const char *msg)
__attribute__ ((__noreturn__));
static void throw_incompatible_class_change_error (jstring msg)
__attribute__ ((__noreturn__));
-#ifndef HANDLE_SEGV
static void throw_null_pointer_exception ()
__attribute__ ((__noreturn__));
-#endif
static void throw_class_format_error (jstring msg)
__attribute__ ((__noreturn__));
@@ -1142,31 +1140,27 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
* the corresponding bit JV_CONSTANT_ResolvedFlag in the tag
* directly. For now, I don't think it is worth it. */
- SAVE_PC();
rmeth = (_Jv_Linker::resolve_pool_entry (meth->defining_class,
index)).rmethod;
sp -= rmeth->stack_item_count;
- // We don't use NULLCHECK here because we can't rely on that
- // working if the method is final. So instead we do an
- // explicit test.
- if (! sp[0].o)
- {
- //printf("invokevirtual pc = %p/%i\n", pc, meth->get_pc_val(pc));
- throw new java::lang::NullPointerException;
- }
- if (rmeth->vtable_index == -1)
+ if (rmeth->method->accflags & Modifier::FINAL)
{
- // final methods do not appear in the vtable,
- // if it does not appear in the superclass.
+ // We can't rely on NULLCHECK working if the method is final.
+ SAVE_PC();
+ if (! sp[0].o)
+ throw_null_pointer_exception ();
+
+ // Final methods might not appear in the vtable.
fun = (void (*)()) rmeth->method->ncode;
}
else
{
+ NULLCHECK (sp[0].o);
jobject rcv = sp[0].o;
_Jv_VTable *table = *(_Jv_VTable**) rcv;
- fun = (void (*)()) table->get_method (rmeth->vtable_index);
+ fun = (void (*)()) table->get_method (rmeth->method->index);
}
#ifdef DIRECT_THREADED
@@ -1183,26 +1177,22 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
{
rmeth = (_Jv_ResolvedMethod *) AVAL ();
sp -= rmeth->stack_item_count;
- // We don't use NULLCHECK here because we can't rely on that
- // working if the method is final. So instead we do an
- // explicit test.
- if (! sp[0].o)
+
+ if (rmeth->method->accflags & Modifier::FINAL)
{
+ // We can't rely on NULLCHECK working if the method is final.
SAVE_PC();
- throw new java::lang::NullPointerException;
- }
+ if (! sp[0].o)
+ throw_null_pointer_exception ();
- if (rmeth->vtable_index == -1)
- {
- // final methods do not appear in the vtable,
- // if it does not appear in the superclass.
+ // Final methods might not appear in the vtable.
fun = (void (*)()) rmeth->method->ncode;
}
else
{
jobject rcv = sp[0].o;
_Jv_VTable *table = *(_Jv_VTable**) rcv;
- fun = (void (*)()) table->get_method (rmeth->vtable_index);
+ fun = (void (*)()) table->get_method (rmeth->method->index);
}
}
goto perform_invoke;
@@ -2882,7 +2872,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
if (! sp[0].o)
{
SAVE_PC();
- throw new java::lang::NullPointerException;
+ throw_null_pointer_exception ();
}
fun = (void (*)()) rmeth->method->ncode;
@@ -2906,7 +2896,7 @@ _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
if (! sp[0].o)
{
SAVE_PC();
- throw new java::lang::NullPointerException;
+ throw_null_pointer_exception ();
}
fun = (void (*)()) rmeth->method->ncode;
}
@@ -3304,17 +3294,11 @@ throw_incompatible_class_change_error (jstring msg)
throw new java::lang::IncompatibleClassChangeError (msg);
}
-#ifndef HANDLE_SEGV
-static java::lang::NullPointerException *null_pointer_exc;
static void
throw_null_pointer_exception ()
{
- if (null_pointer_exc == NULL)
- null_pointer_exc = new java::lang::NullPointerException;
-
- throw null_pointer_exc;
+ throw new java::lang::NullPointerException;
}
-#endif
/* Look up source code line number for given bytecode (or direct threaded
interpreter) PC. */
@@ -3920,7 +3904,7 @@ _Jv_InterpreterEngine::do_allocate_static_fields (jclass klass,
_Jv_ResolvedMethod *
_Jv_InterpreterEngine::do_resolve_method (_Jv_Method *method, jclass klass,
- jboolean staticp, jint vtable_index)
+ jboolean staticp)
{
int arg_count = _Jv_count_arguments (method->signature, staticp);
@@ -3936,7 +3920,6 @@ _Jv_InterpreterEngine::do_resolve_method (_Jv_Method *method, jclass klass,
&result->arg_types[0],
NULL);
- result->vtable_index = vtable_index;
result->method = method;
result->klass = klass;