diff --git a/hoax/compile-ops.rkt b/hoax/compile-ops.rkt index 90bba9b..7163b5f 100644 --- a/hoax/compile-ops.rkt +++ b/hoax/compile-ops.rkt @@ -65,16 +65,13 @@ (Add rbx 8))] ['unbox (seq (assert-box rax) - (Xor rax type-box) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-box))))] ['car (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 8)))] + (Mov rax (Offset rax (- 8 type-cons))))] ['cdr (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-cons))))] ['empty? (seq (Cmp rax (value->bits '())) if-equal)] ['cons? (type-pred ptr-mask type-cons)] @@ -85,10 +82,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-vector rax) - (Xor rax type-vect) - (Cmp rax 0) + (Cmp rax type-vect) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-vect))) (Sal rax int-shift) (Jmp done) (Label zero) @@ -98,10 +94,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-string rax) - (Xor rax type-str) - (Cmp rax 0) + (Cmp rax type-str) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-str))) (Sal rax int-shift) (Jmp done) (Label zero) diff --git a/hustle/compile-ops.rkt b/hustle/compile-ops.rkt index da59401..c804998 100644 --- a/hustle/compile-ops.rkt +++ b/hustle/compile-ops.rkt @@ -63,16 +63,13 @@ (Add rbx 8))] ['unbox (seq (assert-box rax) - (Xor rax type-box) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-box))))] ['car (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 8)))] + (Mov rax (Offset rax (- 8 type-cons))))] ['cdr (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-cons))))] ['empty? (seq (Cmp rax (value->bits '())) if-equal)] ['cons? (type-pred ptr-mask type-cons)] diff --git a/iniquity/compile-ops.rkt b/iniquity/compile-ops.rkt index 90bba9b..7163b5f 100644 --- a/iniquity/compile-ops.rkt +++ b/iniquity/compile-ops.rkt @@ -65,16 +65,13 @@ (Add rbx 8))] ['unbox (seq (assert-box rax) - (Xor rax type-box) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-box))))] ['car (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 8)))] + (Mov rax (Offset rax (- 8 type-cons))))] ['cdr (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-cons))))] ['empty? (seq (Cmp rax (value->bits '())) if-equal)] ['cons? (type-pred ptr-mask type-cons)] @@ -85,10 +82,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-vector rax) - (Xor rax type-vect) - (Cmp rax 0) + (Cmp rax type-vect) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-vect))) (Sal rax int-shift) (Jmp done) (Label zero) @@ -98,10 +94,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-string rax) - (Xor rax type-str) - (Cmp rax 0) + (Cmp rax type-str) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-str))) (Sal rax int-shift) (Jmp done) (Label zero) diff --git a/jig/compile-ops.rkt b/jig/compile-ops.rkt index 90bba9b..7163b5f 100644 --- a/jig/compile-ops.rkt +++ b/jig/compile-ops.rkt @@ -65,16 +65,13 @@ (Add rbx 8))] ['unbox (seq (assert-box rax) - (Xor rax type-box) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-box))))] ['car (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 8)))] + (Mov rax (Offset rax (- 8 type-cons))))] ['cdr (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-cons))))] ['empty? (seq (Cmp rax (value->bits '())) if-equal)] ['cons? (type-pred ptr-mask type-cons)] @@ -85,10 +82,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-vector rax) - (Xor rax type-vect) - (Cmp rax 0) + (Cmp rax type-vect) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-vect))) (Sal rax int-shift) (Jmp done) (Label zero) @@ -98,10 +94,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-string rax) - (Xor rax type-str) - (Cmp rax 0) + (Cmp rax type-str) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-str))) (Sal rax int-shift) (Jmp done) (Label zero) diff --git a/knock/compile-ops.rkt b/knock/compile-ops.rkt index 90bba9b..7163b5f 100644 --- a/knock/compile-ops.rkt +++ b/knock/compile-ops.rkt @@ -65,16 +65,13 @@ (Add rbx 8))] ['unbox (seq (assert-box rax) - (Xor rax type-box) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-box))))] ['car (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 8)))] + (Mov rax (Offset rax (- 8 type-cons))))] ['cdr (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-cons))))] ['empty? (seq (Cmp rax (value->bits '())) if-equal)] ['cons? (type-pred ptr-mask type-cons)] @@ -85,10 +82,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-vector rax) - (Xor rax type-vect) - (Cmp rax 0) + (Cmp rax type-vect) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-vect))) (Sal rax int-shift) (Jmp done) (Label zero) @@ -98,10 +94,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-string rax) - (Xor rax type-str) - (Cmp rax 0) + (Cmp rax type-str) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-str))) (Sal rax int-shift) (Jmp done) (Label zero) diff --git a/knock/compile.rkt b/knock/compile.rkt index 3767728..9edcbbf 100644 --- a/knock/compile.rkt +++ b/knock/compile.rkt @@ -3,7 +3,8 @@ compile-e compile-es compile-define - compile-match) + compile-match + compile-match-clause) (require "ast.rkt") (require "compile-ops.rkt") @@ -269,8 +270,7 @@ (Add rsp (* 8 (length cm))) ; haven't pushed anything yet (Jmp next) (Label ok) - (Xor rax type-box) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-box))) i1) cm1))])] [(Cons p1 p2) diff --git a/loot/compile-ops.rkt b/loot/compile-ops.rkt index 00388e0..76340c0 100644 --- a/loot/compile-ops.rkt +++ b/loot/compile-ops.rkt @@ -65,16 +65,13 @@ (Add rbx 8))] ['unbox (seq (assert-box rax) - (Xor rax type-box) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-box))))] ['car (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 8)))] + (Mov rax (Offset rax (- 8 type-cons))))] ['cdr (seq (assert-cons rax) - (Xor rax type-cons) - (Mov rax (Offset rax 0)))] + (Mov rax (Offset rax (- type-cons))))] ['empty? (seq (Cmp rax (value->bits '())) if-equal)] ['cons? (type-pred ptr-mask type-cons)] @@ -85,10 +82,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-vector rax) - (Xor rax type-vect) - (Cmp rax 0) + (Cmp rax type-vect) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-vect))) (Sal rax int-shift) (Jmp done) (Label zero) @@ -98,10 +94,9 @@ (let ((zero (gensym)) (done (gensym))) (seq (assert-string rax) - (Xor rax type-str) - (Cmp rax 0) + (Cmp rax type-str) (Je zero) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-str))) (Sal rax int-shift) (Jmp done) (Label zero) diff --git a/loot/compile.rkt b/loot/compile.rkt index 4fc95d0..a8a1a82 100644 --- a/loot/compile.rkt +++ b/loot/compile.rkt @@ -4,6 +4,7 @@ compile-es compile-define compile-match + compile-match-clause compile-lambda-define copy-env-to-stack free-vars-to-heap) @@ -85,7 +86,6 @@ (let ((env (append (reverse fvs) (reverse xs) (list #f)))) (seq (Label (symbol->label f)) (Mov rax (Offset rsp (* 8 (length xs)))) - (Xor rax type-proc) (copy-env-to-stack fvs 8) (compile-e e env #t) (Add rsp (* 8 (length env))) ; pop env @@ -97,7 +97,7 @@ (match fvs ['() (seq)] [(cons _ fvs) - (seq (Mov r9 (Offset rax off)) + (seq (Mov r9 (Offset rax (- off type-proc))) (Push r9) (copy-env-to-stack fvs (+ 8 off)))])) @@ -218,8 +218,7 @@ (Add rsp (* 8 (length c))) (Mov rax (Offset rsp (* 8 (length es)))) (assert-proc rax) - (Xor rax type-proc) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-proc))) (Jmp rax))) ;; Integer Integer -> Asm @@ -242,8 +241,7 @@ (compile-es (cons e es) (cons #f c)) (Mov rax (Offset rsp i)) (assert-proc rax) - (Xor rax type-proc) - (Mov rax (Offset rax 0)) ; fetch the code label + (Mov rax (Offset rax (- type-proc))) ; fetch the code label (Jmp rax) (Label r)))) @@ -386,8 +384,7 @@ (Add rsp (* 8 (length cm))) ; haven't pushed anything yet (Jmp next) (Label ok) - (Xor rax type-box) - (Mov rax (Offset rax 0)) + (Mov rax (Offset rax (- type-box))) i1) cm1))])] [(Cons p1 p2)