On 8/28/06, Fan Bin <[EMAIL PROTECTED]> wrote:
Thank you very much for your answer and your bearing my awful english:). and 
thanks to Egor and Mikhail. Yes, my question is about the safe point in JITed 
code. Your answer are really helps.

I want to suspend a thread from another thead, not for the reason of GC, but 
for some other reasons. From your answer, I know that it is JIT who insert the 
polling code. So I think what should I do is modifying the JIT, insert the 
polling code at the point I want the suspendee to stop. I'll look for bbp in 
the source to see some details first. I'll ask if I meet some questions.


If I get it right, you can also try doing this without JIT polling
code modification. The TM module in DRLVM has a "safepoint callback"
mechanism which allows to call a user-defined code at a closest
safepoint. See hythread_set_safepoint_callback() defined in
vm/include/open/hythread_ext.h.

In other words, if you need to stop another thread at a particular
point and execute some code, you can try doing a sequence like this:
   hythread_suspend_other(t)
   hythread_set_safepoint_callback(t, your_callback_func)
   hythread_resume(t)

For example, this scheme is used for implementing j.l.Thread.stop()
method in DRLVM, you can also look at the jthread_exception_stop()
impl code in vm/thread/src/thread_java_basic.c.

The default action at the safepoint is just "do nothing" and wait for
the resume event (typically it will come from the GC after enumeration
is done).

Thanks,
Andrey.



I still have a question to Wedlon: What do you mean that "As far as I know the DRLVM 
JIT you are looking at does not quite do this yet". Does it mean that the drlvm 
JIT(Jitrino.JET and OPT) I'm looking at can't insert the polling code, or just JET can't 
do this?

Many thanks,
fanbin

----- Original Message -----
From: "Weldon Washburn" <[EMAIL PROTECTED]>
To: <harmony-dev@incubator.apache.org>
Sent: Monday, August 28, 2006 12:38 PM
Subject: Re: [drlvm] how does drlvm insert the safe point into a method


> Hi Fan,
>
> I think you are asking about safe instruction pointer addresses in
> JITed code where the JIT is able to enumerate all live references.  If
> this is the case, it turns out there are lots of subtle interactions
> between all the pieces of the system.  In otherwords, I can't do
> justice to the topic in an email.  But I will point you in the right
> direction.
>
> The JIT can insert  polling code at points where it knows it can find
> all live references on a thread's stack.  When the GC wants a thread
> to suspend and report its live references, it can set a flag in the
> thread-local context.  When the JITed code sees the flag set, it will
> suspend the thread and report the live references. As far as I know
> the DRLVM JIT you are looking at does not quite do this yet.
>
> An incomplete but useful for bringup approach is to let the targetted
> thread continue executing until it tries to allocate an object.
> Assuming there is no space available, the thread is vectored into the
> garbage collector itself.  By design, object allocation sites are
> places where the JIT can enumerate all live references on the stack.
>
> There are other schemes, such as suspending and resuming the targetted
> thread until the JIT reports it can enumerate.  I won't bore you with
> the details here.  Let me know if this helps.
>
>
> On 8/27/06, Fan Bin <[EMAIL PROTECTED]> wrote:
>> Hi, I have a question about jit compiler in drlvm. I want to suspend the 
thread manually on a particular point. I know that the thread can only be suspended 
at safe point. I guess the safe point is inserted by jit compiler when it compile the 
method, but I can't prove it from the source code. So my question is whether it's 
true that it is the jit compiler which insert the safe point. If it is true, how does 
it do this?
>> Thank you for your help.
>>
>
>
> --
> Weldon Washburn
> Intel Middleware Products Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


--
Andrey Chernyshev
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to