Thanks Armin! This helps me a lot, I will try this out

Regards,
Vaibhav

-----Original Message-----
From: armin.r...@gmail.com [mailto:armin.r...@gmail.com] On Behalf Of Armin Rigo
Sent: Wednesday, October 14, 2015 7:30 PM
To: Vaibhav Sood
Cc: pypy-dev@python.org
Subject: Re: [pypy-dev] PPC stacklet switching code

Hi Vaibhav,

On Wed, Oct 14, 2015 at 11:26 AM, Vaibhav Sood <vaibhav_s...@persistent.com> 
wrote:
> code to return back to the calling function slp_switch. However in 
> between the calling function’s stack content is overwritten by the 
> g_restore_state code (it memcpy’s the stored heap memory data to the 
> stack) causing the saved LR value to be destroyed and thus returning 
> from the g_restore_state function (using blr) causes a segfault

I would decrement sp around the two calls to the C functions, g_save_state and 
g_restore_state, to give them their own temporary places to write to without 
interference.  This is similar to how the
x86 version gives "rsp" as argument, but then uses CALL, which pushes the 
return address just below rsp, i.e. out of scope of the saving/restoring.  
Example:

...
mr     r3, sp            # the 1st argument is the value of sp without
the extra space
stdu   sp, -64(sp)   # decrement sp again; 64 should be enough
...call g_save_state...
addi   sp, sp, 64     # restore sp
...


A bientôt,

Armin.

DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.

_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to