link.cc (_Jv_Linker::resolve_pool_entry): Don't pass vtable_index to resolve_method.
authorBryce McKinlay <mckinlay@redhat.com>
Sat, 29 Apr 2006 01:35:50 +0000 (01:35 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Sat, 29 Apr 2006 01:35:50 +0000 (02:35 +0100)
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.

From-SVN: r113370

libjava/ChangeLog
libjava/include/execution.h
libjava/include/java-interp.h
libjava/interpret.cc
libjava/link.cc

index ae7766eb0a0255ab71c222c7d7084e578493e08f..ce5d6a4e8d7744d80882524b6e7961ebd7507ab8 100644 (file)
@@ -1,3 +1,19 @@
+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.   
+
 2006-04-28  Andreas Tobler  <a.tobler@schweiz.ch>
 
        * configure.ac: Add an additional checks for dladdr and dlopen on dld.
index fe141e91ec97a3937ab1c18dc7b20a1e29ffc1d6..f0c309c85cca27a36fdd6e8d7e4c9001976f9658 100644 (file)
@@ -26,7 +26,7 @@ struct _Jv_ExecutionEngine
   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 @@ struct _Jv_CompiledEngine : public _Jv_ExecutionEngine
   }
 
   static _Jv_ResolvedMethod *do_resolve_method (_Jv_Method *, jclass,
-                                               jboolean, jint)
+                                               jboolean)
   {
     return NULL;
   }
@@ -118,7 +118,7 @@ class _Jv_InterpreterEngine : public _Jv_ExecutionEngine
   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 ()
   {
index 440a956303f5c935d31f1c192bf422ea901a909f..eb7c99d14db3a573b6a29a48c253e571943558c5 100644 (file)
@@ -243,7 +243,6 @@ _Jv_GetFirstMethod (_Jv_InterpClass *klass)
 struct _Jv_ResolvedMethod
 {
   jint            stack_item_count;    
-  jint            vtable_index;        
   jclass          klass;
   _Jv_Method*     method;
 
index 0e6fbc847cfc0e34140ce867f5ca1710fe5ad9ae..9a2059dadfc4c869e6d4f43182420b6364974c8b 100644 (file)
@@ -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;
 
index e107316d047afb9c4abd0b69eaeaaa8f2dc54b6a..c65b0c97ff19aa9e331090b0361358695926a8a4 100644 (file)
@@ -496,16 +496,11 @@ _Jv_Linker::resolve_pool_entry (jclass klass, int index, bool lazy)
            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;