about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-03-08 15:31:33 -0700
committerKartik Agaram <vc@akkartik.com>2020-03-08 15:31:33 -0700
commit8d8a0ba4e5cfbbe1cfcb7f44b00af89e8d1a55c2 (patch)
tree8bfaea732e9bba9f880df59ffd389ea5adc15989
parentd0dbfc83ccb116a179b3c11de644ac9a5a6ca75b (diff)
downloadmu-8d8a0ba4e5cfbbe1cfcb7f44b00af89e8d1a55c2.tar.gz
6100
Fix a bug with a live register being clobbered.
-rw-r--r--apps/mu.subx11
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index 88fd0d21..d8cb1046 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -5618,6 +5618,7 @@ $populate-mu-type:line-loop:
       (slice-equal? %edx "}")
       3d/compare-eax-and 0/imm32
       0f 85/jump-if-!= break/disp32
+$populate-mu-type:parse-element:
       # var v/esi: (handle var) = parse-var-with-type(word-slice, first-line)
       (parse-var-with-type %edx %ecx)  # => eax
 #?       (write-buffered Stderr "populate-mu-type: ")
@@ -5627,28 +5628,34 @@ $populate-mu-type:line-loop:
 #?       (write-buffered Stderr Newline)
 #?       (flush Stderr)
       89/<- %esi 0/r32/eax
+$populate-mu-type:create-typeinfo-fields:
       # var r/eax: (addr {(handle var) (handle var)})
 #?       (write-buffered Stderr "populate-mu-type: typeinfo: ")
 #?       (print-int32-buffered Stderr %edi)
 #?       (write-buffered Stderr Newline)
 #?       (flush Stderr)
       (get-or-insert *(edi+4) *esi 0xc)  # Typeinfo-fields Var-name => eax
+$populate-mu-type:set-input-type:
       # r->first = v
       89/<- *eax 6/r32/esi
-      # if (r->second == 0) create a new var with some placeholder data
       {
+$populate-mu-type:create-output-type:
+        # if (r->second == 0) create a new var with some placeholder data
         81 7/subop/compare *(eax+4) 0/imm32
         75/jump-if-!= break/disp8
         # temporarily spill r to esi
+        56/push-esi
         89/<- %esi 0/r32/eax
         (new-literal Heap %edx)  # => eax
         89/<- *(esi+4) 0/r32/eax
         89/<- %eax 6/r32/esi
+        5e/pop-to-esi
 #?         (write-buffered Stderr "creating new output var ")
 #?         (print-int32-buffered Stderr %eax)
 #?         (write-buffered Stderr Newline)
 #?         (flush Stderr)
       }
+$populate-mu-type:set-output-offset:
       # r->second->offset = curr-offset
       8b/-> *(eax+4) 0/r32/eax
 #?       (write-buffered Stderr "writing offset ")
@@ -5657,7 +5664,7 @@ $populate-mu-type:line-loop:
 #?       (print-int32-buffered Stderr %eax)
 #?       (write-buffered Stderr Newline)
 #?       (flush Stderr)
-      89/<- *(eax+0xc) 3/r32/ebx
+      89/<- *(eax+0xc) 3/r32/ebx  # Var-offset
       # curr-offset += size-of(v)
 #?       (write-buffered Stderr "elem ")
 #?       (write-buffered Stderr *eax)  # Var-name