File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ void stack_thunk_add_ref()
73
73
}
74
74
stack_thunk_top = stack_thunk_ptr + _stackSize - 1 ;
75
75
stack_thunk_save = NULL ;
76
+ stack_thunk_yield_save = NULL ;
76
77
stack_thunk_repaint ();
77
78
}
78
79
}
@@ -90,6 +91,7 @@ void stack_thunk_del_ref()
90
91
stack_thunk_ptr = NULL ;
91
92
stack_thunk_top = NULL ;
92
93
stack_thunk_save = NULL ;
94
+ stack_thunk_yield_save = NULL ;
93
95
}
94
96
}
95
97
@@ -175,15 +177,18 @@ asm(
175
177
" movi a2, stack_thunk_yield_save\n\t "
176
178
" s32i.n a1, a2, 0\n\t "
177
179
" movi a2, stack_thunk_save\n\t "
180
+ /* But, only when inside of bssl stack (saved a1 != 0) */
181
+ " l32i.n a3, a2, 0\n\t "
182
+ " beqz a3, stack_thunk_yield_do_yield\n\t "
178
183
" l32i.n a1, a2, 0\n\t "
179
184
/* optimistic_yield(10000) without extra l32r */
185
+ " stack_thunk_yield_do_yield:\n\t "
180
186
" movi a2, 0x10\n\t "
181
187
" addmi a2, a2, 0x2700\n\t "
182
188
" call0 optimistic_yield\n\t "
183
189
/* Swap bearssl <-> cont stacks, again */
184
190
" movi a2, stack_thunk_yield_save\n\t "
185
191
" l32i.n a1, a2, 0\n\t "
186
- " \n "
187
192
/* Restore caller */
188
193
" l32i.n a0, a1, 12\n\t "
189
194
" addi a1, a1, 16\n\t "
Original file line number Diff line number Diff line change 27
27
#ifndef _STACKTHUNK_H
28
28
#define _STACKTHUNK_H
29
29
30
+ #include <stdint.h>
31
+
30
32
#ifdef __cplusplus
31
33
extern "C" {
32
34
#endif
@@ -80,9 +82,11 @@ thunk_"#fcnToThunk":\n\
80
82
call0 stack_thunk_fatal_smashing\n\
81
83
.L1"#fcnToThunk":\n\
82
84
movi a15, stack_thunk_save /* Restore A1(SP) */ \n \
83
- l32i.n a1, a15, 0\n\
84
- l32i.n a15, a1, 8 /* Restore the saved registers */ \n \
85
- l32i.n a0, a1, 12\n\
85
+ l32i.n a1, a15, 0/* Restore A1(SP) */ \n \
86
+ movi a0, 0 /* Purge temporary storage */ \n \
87
+ s32i.n a0, a15, 0\n\
88
+ l32i.n a15, a1, 8/* Restore A15 */ \n \
89
+ l32i.n a0, a1, 12/* Restore A0 */ \n \
86
90
addi a1, a1, 16 /* Free up stack and return to caller */ \n \
87
91
ret\n\
88
92
.size thunk_"#fcnToThunk", . - thunk_"#fcnToThunk"\n");
You can’t perform that action at this time.
0 commit comments