This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[RFA] JVMTI GetArgumentsSize
- From: Kyle Galloway <kgallowa at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: Fri, 16 Feb 2007 11:05:40 -0500
- Subject: [RFA] JVMTI GetArgumentsSize
This patch implements the JVMTI GetArgumentsSize function. This
function returns the number of variable slots used by the arguments of a
method. According to the spec, this is the total number of slots, not
the number of arguments, since wide types occupy two slots. To achieve
this, I have added an accessor for args_raw_size in _Jv_MethodBase, then
I divide the raw size by the word size to get the number of slots. This
should always be a whole number since there should always be a whole
number of slots.
Questions/comments/concerns?
Thanks,
Kyle
ChangeLog
2007-02-16 Kyle Galloway <kgallowa@redhat.com>
* jvmti.cc (_Jv_JVMTI_GetArgumentsSize): New function.
* include/java-interp.h (_Jv_MethodBase::get_args_size): New
method.
Index: libjava/include/java-interp.h
===================================================================
--- libjava/include/java-interp.h (revision 122019)
+++ libjava/include/java-interp.h (working copy)
@@ -100,6 +100,11 @@
{
return self;
}
+
+ jint get_args_size ()
+ {
+ return static_cast<jint> (args_raw_size);
+ }
};
// The type of the PC depends on whether we're doing direct threading
Index: libjava/jvmti.cc
===================================================================
--- libjava/jvmti.cc (revision 122013)
+++ libjava/jvmti.cc (working copy)
@@ -839,6 +839,30 @@
}
static jvmtiError JNICALL
+_Jv_JVMTI_GetArgumentsSize (jvmtiEnv *env, jmethodID method, jint *size)
+{
+ REQUIRE_PHASE (env, JVMTI_PHASE_START | JVMTI_PHASE_LIVE);
+ NULL_CHECK (size);
+
+ 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;
+
+ *size = (imeth->get_args_size () / sizeof (_Jv_word));
+
+ return JVMTI_ERROR_NONE;
+}
+
+static jvmtiError JNICALL
_Jv_JVMTI_GetMethodDeclaringClass (MAYBE_UNUSED jvmtiEnv *env,
jmethodID method,
jclass *declaring_class_ptr)
@@ -1764,7 +1788,7 @@
_Jv_JVMTI_GetMethodModifiers, // GetMethodModifers
RESERVED, // reserved67
_Jv_JVMTI_GetMaxLocals, // GetMaxLocals
- UNIMPLEMENTED, // GetArgumentsSize
+ _Jv_JVMTI_GetArgumentsSize, // GetArgumentsSize
_Jv_JVMTI_GetLineNumberTable, // GetLineNumberTable
UNIMPLEMENTED, // GetMethodLocation
_Jv_JVMTI_GetLocalVariableTable, // GetLocalVariableTable