public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFA/JVMTI] Implement GetMaxLocals
@ 2007-02-06 18:31 Kyle Galloway
  2007-02-07 22:54 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Kyle Galloway @ 2007-02-06 18:31 UTC (permalink / raw)
  To: Java Patch List

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

Hi,

This patch is 1/2 of my earlier patch to implement GetLocalVariableTable 
and GetMaxLocals.  Originally I had put these together since 
GetMaxLocals was fairly trivial, but since the earlier patch has not yet 
been reviewed, and GetMaxLocals is useful in other cases, I have 
resubmitted just this portion.

Comments?

-Kyle

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

	* jvmti.cc (CHECK_FOR_NATIVE_METHOD): New macro.
	(_Jv_JVMTI_GetMaxLocals): New method.
	* include/java-interp.h
	(_Jv_InterpMethod::get_max_locals): New method.




[-- Attachment #2: getmaxlocals.patch --]
[-- Type: text/x-patch, Size: 2523 bytes --]

Index: libjava/include/java-interp.h
===================================================================
--- libjava/include/java-interp.h	(revision 121649)
+++ libjava/include/java-interp.h	(working copy)
@@ -219,6 +219,11 @@
    */
   void get_line_table (jlong& start, jlong& end, jintArray& line_numbers,
 		       jlongArray& code_indices);
+  
+  int get_max_locals ()
+  {
+    return static_cast<int> (max_locals);
+  }
 
   /* Installs a break instruction at the given code index. Returns
      the pc_t of the breakpoint or NULL if index is invalid. */
Index: libjava/jvmti.cc
===================================================================
--- libjava/jvmti.cc	(revision 121649)
+++ libjava/jvmti.cc	(working copy)
@@ -155,6 +155,18 @@
     }						\
   while (0)
 
+#define CHECK_FOR_NATIVE_METHOD(AjmethodID)	\
+  do					\
+    {					\
+      jboolean is_native;		\
+      jvmtiError jerr = env->IsMethodNative (AjmethodID, &is_native);	\
+      if (jerr != JVMTI_ERROR_NONE)					\
+        return jerr;							\
+      if (is_native)							\
+        return JVMTI_ERROR_NATIVE_METHOD;			        \
+    }									\
+  while (0)
+
 static jvmtiError JNICALL
 _Jv_JVMTI_SuspendThread (MAYBE_UNUSED jvmtiEnv *env, jthread thread)
 {
@@ -730,6 +742,31 @@
 }
 
 static jvmtiError JNICALL
+_Jv_JVMTI_GetMaxLocals (MAYBE_UNUSED jvmtiEnv *env, jmethodID method,
+                        jint *max_locals)
+{
+  REQUIRE_PHASE (env, JVMTI_PHASE_START | JVMTI_PHASE_LIVE);
+  NULL_CHECK (max_locals);
+  
+  CHECK_FOR_NATIVE_METHOD (method);
+  
+  jclass klass;
+  jvmtiError jerr = env->GetMethodDeclaringClass (method, &klass);
+  if (jerr != JVMTI_ERROR_NONE)
+    return jerr;
+
+  _Jv_InterpMethod *imeth = reinterpret_cast<_Jv_InterpMethod *> 
+                              (_Jv_FindInterpreterMethod (klass, method));
+    
+  if (imeth == NULL)
+    return JVMTI_ERROR_INVALID_METHODID;
+  
+  *max_locals = imeth->get_max_locals ();
+  
+  return JVMTI_ERROR_NONE;
+}
+
+static jvmtiError JNICALL
 _Jv_JVMTI_GetMethodDeclaringClass (MAYBE_UNUSED jvmtiEnv *env,
 				   jmethodID method,
 				   jclass *declaring_class_ptr)
@@ -1656,7 +1693,7 @@
   _Jv_JVMTI_GetMethodDeclaringClass,  // GetMethodDeclaringClass
   _Jv_JVMTI_GetMethodModifiers,	// GetMethodModifers
   RESERVED,			// reserved67
-  UNIMPLEMENTED,		// GetMaxLocals
+  _Jv_JVMTI_GetMaxLocals,		// GetMaxLocals
   UNIMPLEMENTED,		// GetArgumentsSize
   _Jv_JVMTI_GetLineNumberTable,	// GetLineNumberTable
   UNIMPLEMENTED,		// GetMethodLocation

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFA/JVMTI] Implement GetMaxLocals
  2007-02-06 18:31 [RFA/JVMTI] Implement GetMaxLocals Kyle Galloway
@ 2007-02-07 22:54 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2007-02-07 22:54 UTC (permalink / raw)
  To: Kyle Galloway; +Cc: Java Patch List

>>>>> "Kyle" == Kyle Galloway <kgallowa@redhat.com> writes:

Kyle> This patch is 1/2 of my earlier patch to implement
Kyle> GetLocalVariableTable and GetMaxLocals.  Originally I had put these
Kyle> together since GetMaxLocals was fairly trivial, but since the earlier
Kyle> patch has not yet been reviewed, and GetMaxLocals is useful in other
Kyle> cases, I have resubmitted just this portion.

Kyle> Comments?

Looks good, please commit.  Sorry for the delay on this.
BTW, Keith, if you are looking at these, I think it would be fine for
you to approve them.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-07 22:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-06 18:31 [RFA/JVMTI] Implement GetMaxLocals Kyle Galloway
2007-02-07 22:54 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).