Explanation on the anatomy of a JNI call and return

Fiterau Paul fiteraup at yahoo.com
Thu Jan 24 10:01:21 PST 2013


Hello guys. Sorry for the intrusion. Looked everywhere for this information, no luck. Browsed the code, very difficult to get an idea from it. 20 hours of search with no result. Also posted on StackOverflow, http://stackoverflow.com/questions/14497754/the-jni-call-its-effect-on-the-two-stacks, got no response. If someone could explain to me the evolution of the native and the java stack during a JNI call invocation, I'd be very appreciative.

What I could find over the internet is this: http://weblogs.java.net/blog/mlam/archive/2006/12/a_tale_of_two_s.html . But this is not Hotspot. Plus, I'm doubtful on whether the information is accurate, since, in a native to native call, you'd get a recurse in executeJava, the interpreter (like shown bellow) and I suspect the interpreter does not have the lightest of stack frames.
	* native stack: executeJava -> mNa -> executeJava -> mNb

	* Java stack:  mNa -> mNb
My question is, what's the anatomy of a java to native, native to native call and native to java in terms of stack frames. The purpose is, for a School project I have involving static analysis, where I should infer a very conservative upper bound for both the Java stack and the native stack. Right now there's a tool inferring the upper bound for the Java stack, but it doesn't take into account that some methods might already be compiled. I can use that measure in my inference.

I'm especially interested in what would be the worst case with regards to stack consumption in a call chain. Let's say A calls B which calls C which calls D.  
Would it be more stack consuming if  B, C and D were all native or it's more consuming if they are interleaved (one native one not). 
From what tests I made, it seems that having all of them native does seem to yield the highest consumption. On the Native stack and on the java stack.

Thanks for any input! And sorry for the not really dev oriented post. 
Paul.


More information about the hotspot-dev mailing list