Skip to content

Commit 958ac51

Browse files
ILyoanbrson
authored andcommitted
---
yaml --- r: 71917 b: refs/heads/dist-snap c: 3d0d144 h: refs/heads/master i: 71915: 7387c14 v: v3
1 parent 66b9f46 commit 958ac51

File tree

3 files changed

+61
-43
lines changed

3 files changed

+61
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 4b4f48283bdd71fa106f1e2ce80c6d2a0d2aff36
10+
refs/heads/dist-snap: 3d0d144283959bf62368f6965aae14ce95ee286b
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/rt/arch/arm/morestack.S

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,59 @@
88
.arm
99
.align
1010

11-
.globl __morestack
11+
.global upcall_new_stack
12+
.global upcall_del_stack
13+
.global __morestack
1214
.hidden __morestack
15+
16+
// r4 and r5 are scratch registers for __morestack due to llvm
17+
// ARMFrameLowering::adjustForSegmentedStacks() implementation.
18+
.align 2
19+
.type __morestack,%function
1320
__morestack:
21+
22+
// Save frame pointer and return address
23+
push {fp, lr}
24+
25+
mov fp, sp
26+
27+
// Save argument registers of the original function
28+
push {r0, r1, r2, r3, lr}
29+
30+
mov r0, r4 // The amount of stack needed
31+
add r1, fp, #20 // Address of stack arguments
32+
mov r2, r5 // Size of stack arguments
33+
34+
// Create new stack
35+
bl upcall_new_stack@plt
36+
37+
// Hold new stack pointer
38+
mov r5, r0
39+
40+
// Pop the saved arguments
41+
pop {r0, r1, r2, r3, lr}
42+
43+
// Grab the return pointer
44+
add r4, lr, #16 // Skip past the return
45+
mov sp, r5 // Swich to the new stack
46+
mov lr, pc
47+
mov pc, r4 // Call the original function
48+
49+
// Switch back to rust stack
50+
mov sp, fp
51+
52+
// Save return value
53+
push {r0, r1}
54+
55+
// Remove the new allocated stack
56+
bl upcall_del_stack@plt
57+
58+
// Restore return value
59+
pop {r0, r1}
60+
61+
// Return
62+
pop {fp, lr}
63+
mov pc, lr
64+
.endofmorestack:
65+
.size __morestack, .endofmorestack-__morestack
66+

branches/dist-snap/src/rt/arch/arm/record_sp.S

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,18 @@
1414
.globl get_sp
1515

1616
record_sp_limit:
17-
mov r3, r0
18-
ldr r0, =my_cpu
19-
mov r1, #0
20-
mov r2, #0
21-
stmfd sp!, {r3, r7}
22-
ldr r7, =345
23-
swi #0
24-
ldmfd sp!, {r3, r7}
25-
movs r0, r0
26-
movmi r0, #0
27-
28-
ldr r1, =my_array
29-
str r3, [r1, r0]
17+
mrc p15, #0, r3, c13, c0, #3
18+
add r3, r3, #252
19+
str r0, [r3]
3020
mov pc, lr
3121

32-
3322
get_sp_limit:
34-
ldr r0, =my_cpu
35-
mov r1, #0
36-
mov r2, #0
37-
stmfd sp!, {r4, r7}
38-
ldr r7, =345
39-
swi #0
40-
ldmfd sp!, {r4, r7}
41-
movs r0, r0
42-
movmi r0, #0
43-
mov r3, r0
44-
45-
ldr r1, =my_array
46-
ldr r0, [r1, r3]
23+
mrc p15, #0, r3, c13, c0, #3
24+
add r3, r3, #252
25+
ldr r0, [r3]
4726
mov pc, lr
4827

49-
5028
get_sp:
5129
mov r0, sp
5230
mov pc, lr
5331

54-
.data
55-
my_cpu: .long 0
56-
.global my_array
57-
my_array:
58-
.long 0
59-
.long 0
60-
.long 0
61-
.long 0
62-
.long 0
63-
.long 0
64-
.long 0
65-
.long 0
66-
.end

0 commit comments

Comments
 (0)