This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch FYI: Interpreter invokevirtual clean-up
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: Java Patches <java-patches at gcc dot gnu dot org>
- Date: Fri, 28 Apr 2006 21:41:49 -0400
- Subject: Patch FYI: Interpreter invokevirtual clean-up
This patch removes an unnecessary field, vtable_index, from
_Jv_ResolvedMethod and cleans up / removes the code referencing it.
I'm checking this in to trunk.
Bryce
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.
Index: link.cc
===================================================================
--- link.cc (revision 113355)
+++ link.cc (working copy)
@@ -496,16 +496,11 @@
throw new java::lang::NoSuchMethodError (sb->toString());
}
- int vtable_index = -1;
- if (pool->tags[index] != JV_CONSTANT_InterfaceMethodref)
- vtable_index = (jshort)the_method->index;
-
pool->data[index].rmethod
= klass->engine->resolve_method(the_method,
found_class,
((the_method->accflags
- & Modifier::STATIC) != 0),
- vtable_index);
+ & Modifier::STATIC) != 0));
pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
}
break;
Index: interpret.cc
===================================================================
--- interpret.cc (revision 113355)
+++ interpret.cc (working copy)
@@ -51,10 +51,8 @@
__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 @@
* 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 @@
{
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 @@
if (! sp[0].o)
{
SAVE_PC();
- throw new java::lang::NullPointerException;
+ throw_null_pointer_exception ();
}
fun = (void (*)()) rmeth->method->ncode;
@@ -2906,7 +2896,7 @@
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 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_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 @@
&result->arg_types[0],
NULL);
- result->vtable_index = vtable_index;
result->method = method;
result->klass = klass;
Index: include/java-interp.h
===================================================================
--- include/java-interp.h (revision 113355)
+++ include/java-interp.h (working copy)
@@ -243,7 +243,6 @@
struct _Jv_ResolvedMethod
{
jint stack_item_count;
- jint vtable_index;
jclass klass;
_Jv_Method* method;
Index: include/execution.h
===================================================================
--- include/execution.h (revision 113358)
+++ include/execution.h (working copy)
@@ -26,7 +26,7 @@
void (*allocate_static_fields) (jclass, int, int);
void (*create_ncode) (jclass);
_Jv_ResolvedMethod *(*resolve_method) (_Jv_Method *, jclass,
- jboolean, jint);
+ jboolean);
void (*post_miranda_hook) (jclass);
};
@@ -50,7 +50,7 @@
}
static _Jv_ResolvedMethod *do_resolve_method (_Jv_Method *, jclass,
- jboolean, jint)
+ jboolean)
{
return NULL;
}
@@ -118,7 +118,7 @@
static void do_allocate_static_fields (jclass, int, int);
static void do_create_ncode (jclass);
static _Jv_ResolvedMethod *do_resolve_method (_Jv_Method *, jclass,
- jboolean, jint);
+ jboolean);
static bool do_need_resolve_string_fields ()
{