about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorILyoan <ilyoan@gmail.com>2013-02-22 15:17:54 +0900
committerBrian Anderson <banderson@mozilla.com>2013-04-10 18:49:50 -0700
commit3d0d144283959bf62368f6965aae14ce95ee286b (patch)
tree19a9f762bc6d0c04922d3a7314c865e1f3a8521f /src
parent4b4f48283bdd71fa106f1e2ce80c6d2a0d2aff36 (diff)
downloadrust-3d0d144283959bf62368f6965aae14ce95ee286b.tar.gz
rust-3d0d144283959bf62368f6965aae14ce95ee286b.zip
rust morestack assembly for arm
Conflicts:
	src/rt/arch/arm/morestack.S
Diffstat (limited to 'src')
-rw-r--r--src/rt/arch/arm/morestack.S55
-rw-r--r--src/rt/arch/arm/record_sp.S47
2 files changed, 60 insertions, 42 deletions
diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S
index 1afce5bd848..3af8e898cdb 100644
--- a/src/rt/arch/arm/morestack.S
+++ b/src/rt/arch/arm/morestack.S
@@ -8,6 +8,59 @@
 .arm
 .align
 
-.globl __morestack
+.global upcall_new_stack
+.global upcall_del_stack
+.global __morestack
 .hidden __morestack
+
+// r4 and r5 are scratch registers for __morestack due to llvm
+// ARMFrameLowering::adjustForSegmentedStacks() implementation.
+    .align 2
+    .type __morestack,%function
 __morestack:
+
+    // Save frame pointer and return address
+    push {fp, lr}
+    
+    mov fp, sp
+
+    // Save argument registers of the original function
+    push {r0, r1, r2, r3, lr}
+
+    mov r0, r4         // The amount of stack needed
+    add r1, fp, #20    // Address of stack arguments
+    mov r2, r5         // Size of stack arguments
+    
+    // Create new stack
+    bl upcall_new_stack@plt
+
+    // Hold new stack pointer
+    mov r5, r0
+
+    // Pop the saved arguments
+    pop {r0, r1, r2, r3, lr}
+
+    // Grab the return pointer
+    add r4, lr, #16    // Skip past the return
+    mov sp, r5         // Swich to the new stack
+    mov lr, pc
+    mov pc, r4         // Call the original function
+
+    // Switch back to rust stack
+    mov sp, fp
+
+    // Save return value
+    push {r0, r1}
+
+    // Remove the new allocated stack
+    bl upcall_del_stack@plt
+
+    // Restore return value
+    pop {r0, r1}
+
+    // Return
+    pop {fp, lr}
+    mov pc, lr
+.endofmorestack:
+    .size   __morestack, .endofmorestack-__morestack
+   
diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S
index abd8fbb6a5b..fe680004a89 100644
--- a/src/rt/arch/arm/record_sp.S
+++ b/src/rt/arch/arm/record_sp.S
@@ -14,53 +14,18 @@
 .globl get_sp
 
 record_sp_limit:
-	mov r3, r0
-	ldr r0, =my_cpu
-	mov r1, #0
-	mov r2, #0
-    stmfd   sp!, {r3, r7}
-    ldr     r7, =345
-    swi     #0
-    ldmfd   sp!, {r3, r7}
-    movs    r0, r0
-	movmi	r0, #0
-
-	ldr r1, =my_array
-	str r3, [r1, r0]
+	mrc p15, #0, r3, c13, c0, #3
+	add r3, r3, #252
+	str r0, [r3]
 	mov pc, lr
 
-
 get_sp_limit:
-    ldr r0, =my_cpu
-	mov r1, #0
-	mov r2, #0
-    stmfd   sp!, {r4, r7}
-    ldr     r7, =345
-    swi     #0
-    ldmfd   sp!, {r4, r7}
-    movs    r0, r0
-	movmi	r0, #0
-	mov r3, r0
-
-	ldr r1, =my_array
-	ldr r0, [r1, r3]
+	mrc p15, #0, r3, c13, c0, #3
+	add r3, r3, #252
+	ldr r0, [r3]
 	mov pc, lr
 
-
 get_sp:
 	mov r0, sp
 	mov pc, lr
 
-.data
-my_cpu:	.long	0
-.global my_array
-my_array:
-	.long	0
-	.long	0
-	.long	0
-	.long	0
-	.long	0
-	.long	0
-	.long	0
-	.long	0
-.end