Skip to content

Commit 5e54f6a

Browse files
committed
Fixing up stack pad in Fraud.
1 parent 43d5745 commit 5e54f6a

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

ziggy/src/compile-ops.rkt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#lang crook
22
{:= B C D0 D1 E0 E1 F}
3-
(provide {:> E0} compile-op0 compile-op1 {:> F} compile-op2)
3+
(provide {:> E0} compile-op0 compile-op1 {:> F} compile-op2 {:> F} pad-stack)
44
(require "ast.rkt")
55
{:> D0} (require "types.rkt")
66
(require a86/ast)
@@ -151,3 +151,17 @@
151151
(Jl 'err)
152152
(Cmp rax (value->bits 255))
153153
(Jg 'err)))
154+
155+
{:> F} ;; Asm
156+
{:> F} ;; Dynamically pad the stack to be aligned for a call
157+
{:> F}
158+
(define pad-stack
159+
(seq (Mov r15 rsp)
160+
(And r15 #b1000)
161+
(Sub rsp r15)))
162+
163+
{:> F} ;; Asm
164+
{:> F} ;; Undo the stack alignment after a call
165+
{:> F}
166+
(define unpad-stack
167+
(seq (Add rsp r15)))

ziggy/src/compile.rkt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
(Ret)
2828
{:> E1} ;; Error handler
2929
{:> E1} (Label 'err)
30+
{:> F} pad-stack
3031
{:> E1} (Call 'raise_error)))
3132

3233
{:> F} ;; type CEnv = (Listof [Maybe Id])

0 commit comments

Comments
 (0)