* [PATCH] ppc: simplify __clone by saving fn/arg to child stack
@ 2016-04-30 21:39 Bobby Bingham
0 siblings, 0 replies; only message in thread
From: Bobby Bingham @ 2016-04-30 21:39 UTC (permalink / raw)
To: musl
Previously, the parent spilled r30-r31 to its stack so that
the fn/arg could be stored in those registers, where they
would be available to the child process.
If instead, we save fn/arg to the child stack, we can avoid
spilling/restoring any registers in the parent.
---
src/thread/powerpc/clone.s | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff --git a/src/thread/powerpc/clone.s b/src/thread/powerpc/clone.s
index a57dbcc..92ebe76 100644
--- a/src/thread/powerpc/clone.s
+++ b/src/thread/powerpc/clone.s
@@ -13,20 +13,15 @@ __clone:
# SYS_clone = 120
# SYS_exit = 1
-# store non-volatile regs r30, r31 on stack in order to put our
-# start func and its arg there
-stwu 30, -16(1)
-stw 31, 4(1)
-
-# save r3 (func) into r30, and r6(arg) into r31
-mr 30, 3
-mr 31, 6
-
# create initial stack frame for new thread
clrrwi 4, 4, 4
li 0, 0
stwu 0, -16(4)
+# save fn and arg to child stack
+stw 3, 4(4)
+stw 6, 8(4)
+
#move c into first arg
mr 3, 5
#mr 4, 4
@@ -47,26 +42,17 @@ neg 3, 3 #negate the result (errno)
# compare sc result with 0
cmpwi cr7, 3, 0
-# if not 0, jump to end
-bne cr7, 2f
+# if not 0, return
+bnelr cr7
#else: we're the child
#call funcptr: move arg (d) into r3
-mr 3, 31
-#move r30 (funcptr) into CTR reg
-mtctr 30
+lwz 3, 8(1)
+#load funcptr (a) into CTR
+lwz 0, 4(1)
+mtctr 0
# call CTR reg
bctrl
# mov SYS_exit into r0 (the exit param is already in r3)
li 0, 1
sc
-
-2:
-
-# restore stack
-lwz 30, 0(1)
-lwz 31, 4(1)
-addi 1, 1, 16
-
-blr
-
--
2.8.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-30 21:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-30 21:39 [PATCH] ppc: simplify __clone by saving fn/arg to child stack Bobby Bingham
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).