diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-06 00:36:28 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-06 00:36:28 -0700 |
commit | ce094a5d827b82c48eb76b1b4c04cf899219c33b (patch) | |
tree | 5fe3a3ef14e3d7de3b291273378935500393ea80 /apps/tile/environment.mu | |
parent | e41bc160a0dfee0c38ecf20b20ddaf7e6f3da408 (diff) | |
download | mu-ce094a5d827b82c48eb76b1b4c04cf899219c33b.tar.gz |
6968
Snapshot that requires a check in the Mu compiler. Currently I don't spill a register if it could possibly be over-written by a function output within. However, find-in-call-path is a good example of where this constraint is too lenient and results in unsafe code. The variable `curr` gets clobbered during loop update by the variable `match?`. What's the answer? Perhaps we should ban all conditional updates to function outputs? That'd be dashed inconvenient.
Diffstat (limited to 'apps/tile/environment.mu')
-rw-r--r-- | apps/tile/environment.mu | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index deb66a0d..78462817 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -83,8 +83,8 @@ $process:body: { break-if-= copy-object prev-word-ah, cursor-word-ah cursor-to-end prev-word - var cursor-word-index/eax: (addr int) <- get sandbox, cursor-word-index - decrement *cursor-word-index + var cursor-call-path/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path + decrement-final-element cursor-call-path } break $process:body } @@ -107,8 +107,8 @@ $process:body: { break-if-= copy-object next-word-ah, cursor-word-ah cursor-to-start next-word - var cursor-word-index/eax: (addr int) <- get sandbox, cursor-word-index - increment *cursor-word-index + var cursor-call-path/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path + increment-final-element cursor-call-path } break $process:body } @@ -132,8 +132,8 @@ $process:body: { copy-object prev-word-ah, cursor-word-ah cursor-to-end prev-word delete-next prev-word - var cursor-word-index/eax: (addr int) <- get sandbox, cursor-word-index - decrement *cursor-word-index + var cursor-call-path/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path + decrement-final-element cursor-call-path } break $process:body } @@ -144,8 +144,8 @@ $process:body: { append-word cursor-word-ah var next-word-ah/ecx: (addr handle word) <- get cursor-word, next copy-object next-word-ah, cursor-word-ah - var cursor-word-index/eax: (addr int) <- get sandbox, cursor-word-index - increment *cursor-word-index + var cursor-call-path/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path + increment-final-element cursor-call-path break $process:body } compare key, 0xa # enter @@ -172,19 +172,19 @@ fn toggle-cursor-word _sandbox: (addr sandbox) { $toggle-cursor-word:body: { var sandbox/esi: (addr sandbox) <- copy _sandbox var expanded-words/edi: (addr handle call-path) <- get sandbox, expanded-words - var cursor-word-index/ecx: (addr int) <- get sandbox, cursor-word-index - var already-expanded?/eax: boolean <- find-in-call-path expanded-words, *cursor-word-index + var cursor-call-path/ecx: (addr handle call-path-element) <- get sandbox, cursor-call-path + var already-expanded?/eax: boolean <- find-in-call-path expanded-words, cursor-call-path compare already-expanded?, 0 # false { break-if-!= # if not already-expanded, insert - insert-in-call-path expanded-words *cursor-word-index + insert-in-call-path expanded-words cursor-call-path break $toggle-cursor-word:body } { break-if-= # otherwise delete - delete-in-call-path expanded-words *cursor-word-index + delete-in-call-path expanded-words cursor-call-path } } } @@ -247,7 +247,9 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding var first-word-ah/eax: (addr handle word) <- get line, data var curr-word/eax: (addr word) <- lookup *first-word-ah # - var word-index/ebx: int <- copy 0 + var word-index-storage: (handle call-path-element) + var word-index/ebx: (addr handle call-path-element) <- address word-index-storage + allocate word-index # leak # loop-carried dependency var curr-col/ecx: int <- copy left-col # @@ -319,14 +321,17 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding subtract-from top-row, 1 move-cursor screen, top-row, curr-col start-color screen, 8, 7 - print-int32-hex-bits screen, word-index, 4 + { + var word-index-val/eax: int <- final-element-value word-index + print-int32-hex-bits screen, word-index-val, 4 + } reset-formatting screen add-to top-row, 1 # now render main column curr-col <- render-column screen, functions, bindings, line, curr-word, top-row, curr-col, cursor-word, cursor-col-a var next-word-ah/edx: (addr handle word) <- get curr-word, next curr-word <- lookup *next-word-ah - word-index <- increment + increment-final-element word-index loop } right-col <- copy curr-col |