Re: [Aegisvm-devel] patch to jni.c
Status: Pre-Alpha
Brought to you by:
pwlfong
|
From: Philip F. <pw...@us...> - 2002-08-22 10:11:37
|
Hi Gildas,
I have just finished the implementation of the jni functions for method
calling. I ended up doing things differently than what you suggested
in your patch:
1/ The non-virtual method invocation functions you suggested is
simply a macro-based factoring of the stub code. I filled in
the actual implementation and didn't use macros.
2/ The virtual method invocation functions are actually much more
subtle than your implementation. It involves instance/interface
method dispatching logic. So I ended up doing things my own way.
3/ I really appreciate your factoring of common code in CallMethodA
and CallMethodV. You basically did two things:
a/ You introduced an extra argument obj to reuse the static method
invocation code for instance method invocation. I adopted the
idea in my code.
b/ You make CallMethodV delegate its method invocation task to
CallMethodA. You achieve this by converting the input va_list
into an array of jvalue. This is real nice, with only one
catch. Since you allocate the array from the stack frame of
the caller, if the caller perform multiple jni calls, then
all these intermediate arrays will be accumulated in the
caller's frame without deallocation. One apparent fix would
be to use the arena check-pointing mechanism to deallocate the
intermediate array when the invocation returns. However, the
catch is, in the mean time, JNI may have already allocated
some local references from the caller frame, and simple
rewinding based on check-pointing will corrupt the local
reference registry. The cleanest way to implement this
is to allocate the intermediate arrays in the callee's stack
frame. I am too eager to release soon, and so I'll leave the
code unfactored for now, and will return to this issue later.
If you have a good way of fixing it, please do let me know.
Again, thanks for your contribution. :-)
Philip
--
Philip W. L. Fong pw...@us...
The Aegis VM Project http://aegisvm.sourceforge.net
The Aegis VM Project is an on-going effort to implement a lightweight,
secure JVM. It will eventually feature a modular architecture, Proof
Linking, that supports pluggable verification modules.
|