harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Fursov" <mike.fur...@gmail.com>
Subject Re: [drlvm][magic] New Magic features proposal.
Date Mon, 22 Jan 2007 11:30:52 GMT
Pavel,
I see the direction of your improvement - optimization of JNI calls.
The scenario you proposed is  (correct me if I'm wrong)

1) We have a native JNI call from JAVA
2) JIT replaces the call with another call -> call to stub written in Java
with a help of VMMagic package and passes original native call's method
handle as a parameter to the stub.
3) Stub does the following:
  a) allocates m2n (stack area in JIT terms)
  b) asks JIT to store registers
  c) asks JIT to make call native method without JNI stub
  d) checks if exception had happened in native code and rethrows it.


The M2N:

struct M2nFrame {
    M2nFrame*            prev_m2nf;
    M2nFrame**           p_lm2nf;
    ObjectHandles*       local_object_handles;
    Method_Handle        method;
    frame_type           current_frame_type; // type of the current frame
also shows is the frame unwindable
    Registers*           pop_regs; // This is only for M2nFrames for
suspended managed code (as against ones that call stubs and prepare
jvmtiPopFrame)
    uint32               edi;
    uint32               esi;
    uint32               ebx;
    uint32               ebp;
    uint32               eip;
    Registers*           regs; // This is only for M2nFrames for suspended
managed code (as against ones that call stubs and prepare jvmtiPopFrame)
};


Problems:
P1) GC in native code -> we need to iterate stack. In this case VM restores
registers from M2N frame. So JIT must store registers using the same layout
as VM restores them. This is a new contract between VM and JIT. Do you have
any proposals how to implement this contract and do not pass any knowledge
about VM internals to JIT?

P2) M2N frames are linked into a list. Is it right that helper's code is
responsible to support the list?


P3) What JIT must save to EIP register?


P4) How to protect native call's args if GC happens in native code?



-- 
Mikhail Fursov

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message