From 667865a95f732eca8fa254d2143a6e9cbce43452 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 29 Feb 2020 22:48:13 -0800 Subject: 6073 --- apps/mu | Bin 163635 -> 163671 bytes apps/mu.subx | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/apps/mu b/apps/mu index e1c87899..6f514b30 100755 Binary files a/apps/mu and b/apps/mu differ diff --git a/apps/mu.subx b/apps/mu.subx index 9b59b6ef..4004aa69 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -5685,17 +5685,7 @@ $emit-subx-stmt-list:check-for-reg-var-def: 0f 85/jump-if-!= break/disp32 $emit-subx-stmt-list:reg-var-def: # TODO: ensure that there's exactly one output - # var output/eax: (handle var) = curr-stmt->outputs->value - 8b/-> *(ecx+0xc) 0/r32/eax - 8b/-> *eax 0/r32/eax - # ensure that output is in a register - 81 7/subop/compare *(eax+0x10) 0/imm32 # Var-register - 0f 84/jump-if-= $emit-subx-stmt-list:abort-reg-var-def-without-register/disp32 - # emit spill - (emit-indent *(ebp+8) *Curr-block-depth) - (write-buffered *(ebp+8) "ff 6/subop/push %") - (write-buffered *(ebp+8) *(eax+0x10)) - (write-buffered *(ebp+8) Newline) + (emit-subx-reg-var-spill *(ebp+8) %ecx) # register variable definition (push *(ebp+0x10) %eax) # emit the instruction as usual @@ -5736,6 +5726,33 @@ $emit-subx-stmt-list:abort-reg-var-def-without-register: cd/syscall 0x80/imm8 # never gets here +emit-subx-reg-var-spill: # out: (addr buffered-file), stmt: (handle stmt) + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # . save registers + 51/push-ecx + # ecx = stmt + 8b/-> *(ebp+0xc) 1/r32/ecx + # var output/eax: (handle var) = curr-stmt->outputs->value + 8b/-> *(ecx+0xc) 0/r32/eax + 8b/-> *eax 0/r32/eax + # ensure that output is in a register + 81 7/subop/compare *(eax+0x10) 0/imm32 # Var-register + 0f 84/jump-if-= $emit-subx-stmt-list:abort-reg-var-def-without-register/disp32 + # emit spill + (emit-indent *(ebp+8) *Curr-block-depth) + (write-buffered *(ebp+8) "ff 6/subop/push %") + (write-buffered *(ebp+8) *(eax+0x10)) + (write-buffered *(ebp+8) Newline) +$emit-subx-reg-var-spill:end: + # . restore registers + 59/pop-to-ecx + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return + emit-subx-cleanup-and-unconditional-nonlocal-branch: # out: (addr buffered-file), stmt: (addr stmt1), vars: (addr stack (handle var)) # . prologue 55/push-ebp -- cgit 1.4.1-2-gfad0