diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-02-18 01:30:24 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-02-18 01:30:24 -0800 |
commit | a5469a3a7ed6900fe7c8cea6a7558e821d262c56 (patch) | |
tree | 11c7a69db9c6d8877e4280cdf672aa9b658aae53 | |
parent | 54b2ed1e4e3aecb342139238b24e8b786e7b2427 (diff) | |
download | mu-a5469a3a7ed6900fe7c8cea6a7558e821d262c56.tar.gz |
6023 - bug: vars with both stack-offset and reg
This was initially disquieting; was I writing enough tests? Then I noticed I had TODOs for some missing checks.
-rwxr-xr-x | apps/mu | bin | 146876 -> 147404 bytes | |||
-rw-r--r-- | apps/mu.subx | 30 |
2 files changed, 20 insertions, 10 deletions
diff --git a/apps/mu b/apps/mu index 0b10cb48..cec5b506 100755 --- a/apps/mu +++ b/apps/mu Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx index d34cf536..229a6235 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -3622,12 +3622,6 @@ parse-mu-var-def: # line: (addr stream byte), vars: (addr stack (handle var)) - (next-mu-token *(ebp+8) %ecx) (parse-var-with-type %ecx *(ebp+8)) # => eax 89/<- %edx 0/r32/eax - # v->stack-offset = *Next-local-stack-offset - 8b/-> *Next-local-stack-offset 0/r32/eax - 89/<- *(edx+0xc) 0/r32/eax # Var-stack-offset - # *Next-local-stack-offset -= size-of(v) - (size-of %edx) # => eax - 29/subtract-from *Next-local-stack-offset 0/r32/eax # v->block-depth = *Curr-block-depth 8b/-> *Curr-block-depth 0/r32/eax 89/<- *(edx+8) 0/r32/eax @@ -3638,6 +3632,9 @@ parse-mu-var-def: # line: (addr stream byte), vars: (addr stack (handle var)) - 3d/compare-eax-and 0/imm32 { 75/jump-if-!= break/disp8 + # v->stack-offset = *Next-local-stack-offset + 8b/-> *Next-local-stack-offset 0/r32/eax + 89/<- *(edx+0xc) 0/r32/eax # Var-stack-offset # TODO: ensure that there's nothing else on this line (new-vardef Heap %edx) # => eax eb/jump $parse-mu-var-def:end/disp8 @@ -3655,6 +3652,11 @@ parse-mu-var-def: # line: (addr stream byte), vars: (addr stack (handle var)) - (add-operation-and-inputs-to-stmt %eax *(ebp+8) *(ebp+0xc)) } $parse-mu-var-def:end: + # *Next-local-stack-offset -= size-of(v) + 50/push-eax + (size-of %edx) # => eax + 29/subtract-from *Next-local-stack-offset 0/r32/eax + 58/pop-to-eax # . reclaim locals 81 0/subop/add %esp 8/imm32 # . restore registers @@ -3687,6 +3689,8 @@ test-parse-mu-var-def: # setup (clear-stream _test-input-stream) (write _test-input-stream "n: int\n") # caller has consumed the 'var' + c7 0/subop/copy *Curr-block-depth 1/imm32 + c7 0/subop/copy *Next-local-stack-offset -4/imm32 # var vars/ecx: (stack (addr var) 4) 81 5/subop/subtract %esp 0x10/imm32 68/push 0x10/imm32/length @@ -3700,12 +3704,14 @@ test-parse-mu-var-def: 8b/-> *(eax+4) 0/r32/eax # Vardef-var (check-strings-equal *eax "n" "F - test-parse-mu-var-def/var-name") # Var-name (check-ints-equal *(eax+0x10) 0 "F - test-parse-mu-var-def/var-register") # Var-register - # TODO: ensure stack-offset is -4 - # TODO: ensure block-depth is 1 + (check-ints-equal *(eax+8) 1 "F - test-parse-mu-reg-var-def/output-block-depth") # Var-block-depth + (check-ints-equal *(eax+0xc) -4 "F - test-parse-mu-reg-var-def/output-stack-offset") # Var-stack-offset # ensure type is int 8b/-> *(eax+4) 0/r32/eax # Var-type (check-ints-equal *eax 1 "F - test-parse-mu-var-def/var-type:0") # Tree-left (check-ints-equal *(eax+4) 0 "F - test-parse-mu-var-def/var-type:0") # Tree-right + # globals + (check-ints-equal *Next-local-stack-offset -8 "F - test-parse-mu-reg-var-def/Next-local-stack-offset") # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp @@ -3719,6 +3725,8 @@ test-parse-mu-reg-var-def: # setup (clear-stream _test-input-stream) (write _test-input-stream "n/eax: int <- copy 0\n") # caller has consumed the 'var' + c7 0/subop/copy *Curr-block-depth 1/imm32 + c7 0/subop/copy *Next-local-stack-offset -4/imm32 # var vars/ecx: (stack (addr var) 4) 81 5/subop/subtract %esp 0x10/imm32 68/push 0x10/imm32/length @@ -3734,12 +3742,14 @@ test-parse-mu-reg-var-def: 8b/-> *eax 0/r32/eax # List-value (check-strings-equal *eax "n" "F - test-parse-mu-reg-var-def/output-name") # Var-name (check-strings-equal *(eax+0x10) "eax" "F - test-parse-mu-reg-var-def/output-register") # Var-register - # TODO: ensure stack-offset is -4 - # TODO: ensure block-depth is 1 + (check-ints-equal *(eax+8) 1 "F - test-parse-mu-reg-var-def/output-block-depth") # Var-block-depth + (check-ints-equal *(eax+0xc) 0 "F - test-parse-mu-reg-var-def/output-stack-offset") # Var-stack-offset # ensure type is int 8b/-> *(eax+4) 0/r32/eax # Var-type (check-ints-equal *eax 1 "F - test-parse-mu-reg-var-def/output-type:0") # Tree-left (check-ints-equal *(eax+4) 0 "F - test-parse-mu-reg-var-def/output-type:0") # Tree-right + # globals + (check-ints-equal *Next-local-stack-offset -8 "F - test-parse-mu-reg-var-def/Next-local-stack-offset") # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp |