• Andy McFadden's avatar
    Use local references for native method args. · 0083d37b
    Andy McFadden authored
    This changes the JNI method call mechanism to register all reference
    arguments as local refs, as well as the "this" argument (for virtual
    calls) and the class object (for static calls).
    
    Before now we skipped this part, because we're handing raw object
    pointers around, and we know that all of the arguments can be found by
    the GC on the interpreted stack.  In fact, there's no need to add the
    arguments for GC-correctness; rather, we need to do this to rewrite the
    pointers we hand to native code.
    
    This change impacts JNI method call performance, especially for functions
    with a large number of reference arguments.  To improve things a little,
    there are now four "call bridge" functions:
    
      (1) general handler
      (2) synchronized method handler (grabs lock, calls #1)
      (3) virtual method, no reference args
      (4) static method, no reference args
    
    While booting the system, the virtual/static no-ref handlers are used
    for about 70% of calls.  Since these don't have to scan the method
    signature to look for reference arguments, they're a bit faster.
    
    At this point we're still passing raw pointers around, so nothing should
    really change.
    0083d37b
Native.c 24 KB