What is the reason for the additional indirection in Handle?
Paul Hohensee
Paul.Hohensee at Sun.COM
Tue Sep 9 07:13:29 PDT 2008
Yes, you can pass oops from Java -> native, but they're handlized and you
aren't supposed to use one to access a java object except via JNI calls.
The latter check for a safepoint in progress on entry and block if so. If
that didn't happen, then you could end up with a stale oop in a register
someplace. The vm also checks for a safepoint in progress on return from
native (i.e., native -> Java transition) and blocks there if so. If it
didn't,
then Java code, which uses un-handlized oops, could have those oops
changed out from under it. You can also think of JNI calls as native ->
Java -> native transitions, albeit trivial ones for get and putfield. They
do a Java operation, so effectively they transition in and out of Java
state.
Paul
Gary Benson wrote:
> Keith McGuigan wrote:
>
>> Transistions from Java -> native code (VM or library) and back
>> also have checks for safepoints.
>>
>
> Do things safepoint on Java-native? I thought it was only
> native-Java. I thought Java-native didn't safepoint so you
> could pass oops as arguments to runtime calls.
>
> Cheers,
> Gary
>
>
More information about the hotspot-runtime-dev
mailing list