Always return stack pointer to bottom of frame when method returns
This commit is contained in:
parent
df4fa67122
commit
0c03966509
3 changed files with 9 additions and 0 deletions
|
@ -176,6 +176,9 @@ public class CodegenImpl implements Codegen {
|
|||
// set frame pointer to start of arguments
|
||||
"addi s0,sp,8\n"
|
||||
+ "call " + methodLabel + "\n"
|
||||
// restore stack to frame pointer - 8 (bottom of frame)
|
||||
// this ensures any stack growth inside the method is undone
|
||||
+ "addi sp,s0,-8\n"
|
||||
// restore old frame pointer & stack pointer
|
||||
+ "lw s0,4(sp)\n"
|
||||
+ "lw sp,(sp)\n"
|
||||
|
|
|
@ -176,6 +176,9 @@ public class CodegenImpl implements Codegen {
|
|||
// set frame pointer to start of arguments
|
||||
"addi s0,sp,8\n"
|
||||
+ "call " + methodLabel + "\n"
|
||||
// restore stack to frame pointer - 8 (bottom of frame)
|
||||
// this ensures any stack growth inside the method is undone
|
||||
+ "addi sp,s0,-8\n"
|
||||
// restore old frame pointer & stack pointer
|
||||
+ "lw s0,4(sp)\n"
|
||||
+ "lw sp,(sp)\n"
|
||||
|
|
|
@ -176,6 +176,9 @@ public class CodegenImpl implements Codegen {
|
|||
// set frame pointer to start of arguments
|
||||
"addi s0,sp,8\n"
|
||||
+ "call " + methodLabel + "\n"
|
||||
// restore stack to frame pointer - 8 (bottom of frame)
|
||||
// this ensures any stack growth inside the method is undone
|
||||
+ "addi sp,s0,-8\n"
|
||||
// restore old frame pointer & stack pointer
|
||||
+ "lw s0,4(sp)\n"
|
||||
+ "lw sp,(sp)\n"
|
||||
|
|
Loading…
Reference in a new issue