This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] _Jv_InterpFrame "this" pointer


Hi,
This patch add a method to _Jv_InterpFrame to get the "this" pointer for an interpreted method. When the method is run, the first argument is copied into a new field in _Jv_InterpFrame. I have added a method get_this_ptr that hecks if the method is static (and returns null if it is) and returns the "this" pointer for this frame.


Comments or concerns?

-Kyle

ChangeLog
2007-02-06  Kyle Galloway  <kgallowa@redhat.com>

	* include/java-interp.h (_Jv_InterpFrame): obj_ptr field added
	to hold "this" pointer for frame.
	(_Jv_InterpFrame::get_this_ptr): New method.
	* interpret-run.cc: Copy the "this" pointer into obj_ptr.




Index: libjava/include/java-interp.h
===================================================================
--- libjava/include/java-interp.h	(revision 121649)
+++ libjava/include/java-interp.h	(working copy)
@@ -372,6 +372,9 @@
   _Jv_word *locals;
   char *locals_type;
 
+  // Object pointer for this frame ("this")
+  _Jv_word obj_ptr;
+
   _Jv_InterpFrame (void *meth, java::lang::Thread *thr, jclass proxyCls = NULL)
   : _Jv_Frame (reinterpret_cast<_Jv_MethodBase *> (meth), thr,
 	             frame_interpreter)
@@ -385,6 +388,21 @@
   {
     thread->interp_frame = (gnu::gcj::RawData *) next_interp;
   }
+
+  jobject get_this_ptr ()
+  {
+    jobject obj;
+
+    _Jv_InterpFrame *iframe = reinterpret_cast<_Jv_InterpFrame *> (thread->frame);
+    _Jv_Method *method = iframe->self->get_method ();
+   
+    if ((method->accflags & java::lang::reflect::Modifier::STATIC) == 0)
+      obj = iframe->obj_ptr.o;
+    else
+      obj = NULL;
+
+    return obj;
+  } 
 };
 
 // A native frame in the call stack really just a placeholder
Index: libjava/interpret-run.cc
===================================================================
--- libjava/interpret-run.cc	(revision 121649)
+++ libjava/interpret-run.cc	(working copy)
@@ -349,6 +349,14 @@
   */
   memcpy ((void*) locals, (void*) args, meth->args_raw_size);
 
+#ifdef DEBUG
+  // Get the object pointer for this method, if it is non-static,
+  // otherwise the value stored here will be meaningless.  The accessor
+  // must check for non-static methods, since no check is done here.
+  if (meth->args_raw_size > 0)
+    memcpy ((void *) &(frame_desc.obj_ptr), (void *) (&locals[0]), sizeof (_Jv_word));
+#endif
+
   _Jv_word *pool_data = meth->defining_class->constants.data;
 
   /* These three are temporaries for common code used by several

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]