Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Shen, Siran
wacc
Commits
79d7953b
Commit
79d7953b
authored
Mar 18, 2021
by
Tom Zhao
Browse files
xz1919: WIP resolving rsp and rbp segfault
parent
9b834d88
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/backend/intel/IntelInstructionGenerator.java
View file @
79d7953b
...
...
@@ -659,13 +659,15 @@ public class IntelInstructionGenerator extends InstructionGenerator<IntelInstruc
public
Void
visitScopeNode
(
ScopeNode
node
)
{
List
<
StatNode
>
list
=
node
.
getBody
();
instructions
.
add
(
new
Mov
(
rsp
,
rbp
));
/* 1 leave space for variables in stack */
int
stackSize
=
node
.
getScope
().
getParentSymbolTable
()
==
null
?
0
:
node
.
getScope
().
getParentSymbolTable
().
getSize
();
int
temp
=
stackSize
;
while
(
temp
>
0
)
{
int
realStackSize
=
temp
/
1024
>=
1
?
1024
:
temp
;
instructions
.
add
(
new
Sub
(
realStackSize
,
IntelInstructionSize
.
Q
,
r
b
p
));
instructions
.
add
(
new
Sub
(
realStackSize
,
IntelInstructionSize
.
Q
,
r
s
p
));
temp
=
temp
-
realStackSize
;
}
...
...
@@ -682,7 +684,7 @@ public class IntelInstructionGenerator extends InstructionGenerator<IntelInstruc
/* decrease function stack size, as from this point stack is freed by the scope, not by return */
funcStackSize
-=
stackSize
;
instructions
.
add
(
new
Mov
(
rbp
,
rsp
));
/* 3 restore stack */
temp
=
stackSize
;
while
(
temp
>
0
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment