public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kyle Galloway <kgallowa@redhat.com>
To: Java Patch List <java-patches@gcc.gnu.org>
Subject: [RFA/JVMTI] Implement GetMaxLocals
Date: Tue, 06 Feb 2007 18:31:00 -0000	[thread overview]
Message-ID: <45C8C982.2020207@redhat.com> (raw)

[-- 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

             reply	other threads:[~2007-02-06 18:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-06 18:31 Kyle Galloway [this message]
2007-02-07 22:54 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45C8C982.2020207@redhat.com \
    --to=kgallowa@redhat.com \
    --cc=java-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).