Hi Tomek,

Tomasz Grabiec kirjoitti:
> Dnia 2009-11-16, pon o godzinie 12:19 +0200, Pekka Enberg pisze:
>> Next step is to change gc_safepoint() to look up struct gc_map based on 
>> regs->eip. I was thinking of adding an hash map of GC maps to struct 
>> compilation_unit but we first need to be able to look up the compilation 
>> unit based on EIP. Tomek, don't we do something like that for exceptions 
>> already? Can we reuse that infrastructure? Pointers to relevant code 
>> appreciated :-).
> 
> I think we should utilise the stackwalker to walk through java frames.
> The code could be simmilar to the one of
> native_vmstackwalker_getclasscontext() in runtime/stack-walker.c
> 
> The relevant steps are:
> 1) init_stack_trace_elem_current(&st_elem);
> 
>    I've just sent a patch for this one, cause it was buggy.
>    it initializes (after the patch) st_elem to point to the current
> frame (the direct caller of init_stack_trace_elem_current)
> 
> 2) stack_trace_elem_next_java(&st_elem)
> 
>    walks back to the next java frame in the call chain. The function
> works regardless of what kind of (valid) frame st_elem points to.
> Returns false if there are no more java frames, in which case st_elem
> will point to the last frame.
> 
> 3) For every java frame, st_elem.addr contains the IP address inside
> frame's function (currently it's set to callee's return_address - 1,
> cause we don't know the call insn size). We can use
> jit_lookup_cu(st_elem.addr) to get the compilation unit pointer.
> 
> Note that jit_lookup_cu() returns the nearest cu that preceeds given IP,
> so we can use it only when we are sure that given IP is in some JIT
> method. That's for the speed. We could of course write
> jit_lookup_cu_safe() which could check if IP is within method's code and
> return NULL when it isn't.

Yeah, that sounds good.

I think using jit_lookup_cu() is safe because we're going to need to do 
a second lookup in the gc map hash map which contains accurate EIPs. So 
if the EIP is not a safepoint, the hash map lookup will fail and we 
catch the error.

                        Pekka

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to