Re: [pypy-dev] PPC stacklet switching code

2015-10-14 Thread Vaibhav Sood
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  
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


Re: [pypy-dev] PPC stacklet switching code

2015-10-14 Thread Vaibhav Sood
Sure, I have been referring to the ARM file (since it’s the one similar to 
PPC), I will try and take care of including the necessary header/footer and 
stack adjusting code, thanks for mentioning this issue! 

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:38 PM
To: Vaibhav Sood
Cc: pypy-dev@python.org
Subject: Re: [pypy-dev] PPC stacklet switching code

Re-hi,

Note another issue: the slp_switch() function, from gcc's point of view, does 
not call any other function.  This means gcc will not produce the needed 
header/footer code.  Look at switch_arm_gcc.h for the lengths we need to go 
through to make sure to save/restore everything and realign the stack.


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


Re: [pypy-dev] PPC stacklet switching code

2015-10-14 Thread Armin Rigo
Re-hi,

Note another issue: the slp_switch() function, from gcc's point of
view, does not call any other function.  This means gcc will not
produce the needed header/footer code.  Look at switch_arm_gcc.h for
the lengths we need to go through to make sure to save/restore
everything and realign the stack.


A bientôt,

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


Re: [pypy-dev] PPC stacklet switching code

2015-10-14 Thread Armin Rigo
Hi Vaibhav,

On Wed, Oct 14, 2015 at 11:26 AM, Vaibhav Sood
 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.
___
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev