No subject

Jagannathan, Suresh
Tue, 21 Aug 2001 10:43:11 -0400

Based on a quick reading of the code and talking to Cristian, the Java <-> C
worked as follows:

  -- Multiple Java threads shared the same C stack.  There is a global lock
to the C
     stack that must be acquired by a Java thread before it can make a C
call.  If Java
     thread T calls C which then calls another Java procedure, which is then
     no other Java thread can execute until the call-back and return from C
     Stated another way, Java threads that are in the midst of C calls
effectively run with
     preemption turned off.

  -- Before a Java thread makes a C call, its stub records the current C
stack top as
     part of the information kept on the frame.
     When an exception is raised, the frame containing the handler resets
the C stack

     The Java runtime can traverse the stack to find the exception handler
because the
     return address is at the top of the frame, and the code pointer for the
exception handler
     is kept in the code stream at a known offset from the return address.

  --  Generated stubs for C procedures register GC-able values with the
garbage collector,
      and pass these values through an indirection table.  This means that
even if the object
      is copied in the heap during a GC, C can still access it.  As long
there is an active C
      procedure running, objects supplied to it won't be GC'ed.  

Hope this helps,