Commit Graph

8185 Commits

Author SHA1 Message Date
Kartik K. Agaram 24a6f99107 failing tests not printing since show-stack-state 2021-04-25 22:08:00 -07:00
Kartik K. Agaram 6e0f0bdf50 . 2021-04-25 22:00:00 -07:00
Kartik K. Agaram ffe36c4050 . 2021-04-25 21:45:27 -07:00
Kartik K. Agaram 1a18c9e24b . 2021-04-25 21:35:14 -07:00
Kartik K. Agaram a68ecc0184 . 2021-04-25 21:32:15 -07:00
Kartik K. Agaram 3b1f23f5d7 expand stack to 16MB
It's also no longer contiguous with code.
2021-04-25 21:29:42 -07:00
Kartik K. Agaram 6bb70a236c shell: tab inserts two spaces 2021-04-25 21:03:14 -07:00
Kartik K. Agaram cbebd548ca shell: use ctrl-m rather than tab to bounce to trace
We'll save tab for inserting graphemes.
2021-04-25 21:03:05 -07:00
Kartik K. Agaram 1323a6bb3a .
Show all builtins now that we have more space.
2021-04-25 17:57:19 -07:00
Kartik K. Agaram 8e89dd5a78 devote 2/3rds of screen to definitions 2021-04-25 17:55:17 -07:00
Kartik K. Agaram 35a6f3cc99 add some padding to the sandbox 2021-04-25 17:49:39 -07:00
Kartik K. Agaram a761d0e4ef a troubleshooting note 2021-04-25 16:02:30 -07:00
Kartik K. Agaram d56153d004 . 2021-04-25 15:58:03 -07:00
Kartik K. Agaram 22a95bd813 expand memory to 2GB
It requires more than 1GB to fill the screen with a chessboard pattern
using the definition in shell/iterative-definitions.limg.

I also speed up the chessboard program by clearing the screen up front
and then only rendering the white pixels.
2021-04-25 15:56:34 -07:00
Kartik Agaram 8185a605c6 expand heap to Qemu default 2021-04-25 08:08:47 -07:00
Kartik Agaram 9c3e2821c1 .
Get rid of my experiment adding Game of Life to the shell.
2021-04-24 07:18:15 -07:00
Kartik Agaram cb464c9378 bugfix; thanks Max Bernstein 2021-04-24 07:16:34 -07:00
Kartik Agaram b7224ab44e . 2021-04-23 21:49:28 -07:00
Kartik Agaram fa8d337d90 shell: some example definitions 2021-04-23 21:36:48 -07:00
Kartik Agaram 5915104926 . 2021-04-22 20:02:19 -07:00
Kartik K. Agaram 2ff86d9162 better error message on trace overflow 2021-04-22 10:13:19 -07:00
Kartik K. Agaram 8a66b59940 faster emulation
Thanks Maxwell Bernstein for pointing this out 🤦‍♂️
2021-04-22 09:16:48 -07:00
Kartik K. Agaram 7a7191cc3e clean up with the final bugfix 2021-04-22 09:09:23 -07:00
Kartik K. Agaram bd0410c993 snapshot
It took me _way_ too long to realize that I'm not checking for errors within
the loop, and that will cause it to manifest as an infinite loop as inner
evaluations fail to run.

Debugging notes, for posterity:
  printing one row of a chessboard pattern over fake screen (chessboard screen 4 0 0 15) gets stuck in an infinite loop halfway through
    debug pattern during infinite loop: VWEX. It's still in the loop but it's not executing the body
    raw (fill_rect screen 16 0 20 4 15) works fine
    same number of calls to fill_rect work fine
    replacing calls to fill_rect with pixel inside chessboard2 works fine
    at the point of the infinite loop it's repeatedly going through the hline loop
      -- BUT it never executes the check of the loop (< lo hi) with lo=20, hi=20. Something is returning 1, but it's not inside <
    stream optimization is not implicated

  simple test case with a single loop
    (
      (globals . (
        (foo . (fn () (screen i n)
                 (while (< i n)
                   (pixel screen 4 4 i)
                   (pixel screen 5 4 i)
                   (pixel screen 6 4 i)
                   (pixel screen 7 4 i)
                   (set i (+ i 1)))))
      ))
      (sandbox . (foo screen 0 100))
    )

  simpler (if you reset cursor position before every print):
    (
      (globals . (
        (foo . (fn () (screen i n)
                 (while (< i n)
                   (print screen i)
                   (set i (+ i 1)))))
      ))
      (sandbox . (foo screen 0 210))
    )

  I now believe it has nothing to do with the check. The check always works.
  Sometimes no body is evaluated. And so the set has no effect.
2021-04-22 09:05:11 -07:00
Kartik K. Agaram 4e70cac998 . 2021-04-22 09:03:20 -07:00
Kartik K. Agaram 8bbf7ad455 . 2021-04-22 07:57:10 -07:00
Kartik K. Agaram 6842dddd68 . 2021-04-22 07:56:49 -07:00
Kartik K. Agaram 4afe53d834 shell: non-recursive 'while' 2021-04-21 21:34:55 -07:00
Kartik K. Agaram a5e1a220fd shell: refuse to 'def' duplicate names 2021-04-21 20:54:18 -07:00
Kartik K. Agaram c54b7e9630 shell: separate 'def' from 'set'
'def' creates new bindings (only in globals)
'set' only modifies existing bindings (either in env or globals)
2021-04-21 20:53:38 -07:00
Kartik K. Agaram bfc6fa1876 slightly more responsive animation 2021-04-21 20:12:16 -07:00
Kartik K. Agaram bcd37c381a clear old output when new run is in progress
I'm currently doing this extremely naively/slowly/uglily. Not a bottleneck.
2021-04-21 20:06:46 -07:00
Kartik K. Agaram bc4b6021de . 2021-04-21 19:56:32 -07:00
Kartik K. Agaram 5daa1f06d4 . 2021-04-21 19:45:02 -07:00
Kartik K. Agaram 9a5e94ce1f . 2021-04-21 19:44:06 -07:00
Kartik K. Agaram 25791d9032 opt: don't clear streams of bytes on the stack
All over the Mu code I reflexively initialize all variables just to keep
unsafe SubX easy to debug. However I don't really need to do this for safe
Mu code, since the type- and memory-safety already ensures we can't read
from streams beyond what we've written to them. For now I'll continue mostly
with the same approach, but with one exception for streams of bytes.

Mu programs often emit traces, and in doing so they often use temporary
streams of bytes that can get quite long. I'm hoping avoiding initializing
KBs of data all over the place will measurably speed up the Mu shell.
2021-04-21 19:30:28 -07:00
Kartik Agaram a8fb537a88 . 2021-04-21 08:28:00 -07:00
Kartik K. Agaram d27994a9d7 shell: show screen state during evaluation
All highly experimental. Current constraints:

* No tail recursion elimination
* No heap reuse
* Keep implementation simple

So it's slow, and I don't want to complicate it to speed it up. So I'm
investing in affordances to help deal with the slowness. However, in the
process I've taken the clean abstraction of a trace ("all you need to do
is add to the trace") and bolted on call counts and debug-prints as independent
mechanisms.
2021-04-21 00:25:06 -07:00
Kartik K. Agaram d604e68c2b . 2021-04-21 00:17:22 -07:00
Kartik K. Agaram 7b2d39b8d4 an interface approximating stack traces 2021-04-20 23:27:13 -07:00
Kartik K. Agaram fb34909b4e get bresenham line drawing working with a trace
(brline . (fn () (screen x0 y0 x1 y1 color)
                 ((fn (dx dy sx sy)
                    ((fn (err)
                       (brline1 screen x0 y0 x1 y1 dx dy sx sy err color))
                     (+ dx dy)))
                  (abs (- x1 x0))
                  (- 0 (abs (- y1 y0)))
                  (sgn (- x1 x0))
                  (sgn (- y1 y0)))))
    (brline1 . (fn () (screen x y xmax ymax dx dy sx sy err color)
                 (pixel screen x y color)
                 (if (andf (= x xmax) (= y ymax))
                   ()
                   ((fn (e2)
                      (brline1 screen
                        (if (>= e2 dy)
                          (+ x sx)
                          x)
                        (if (<= e2 dx)
                          (+ y sy)
                          y)
                        xmax
                        ymax
                        dx
                        dy
                        sx
                        sy
                        (+ err
                           (+
                             (if (>= e2 dy)
                               dy
                               0)
                             (if (<= e2 dx)
                               dx
                               0)))
                        color))
                    (* err 2)))))

sandbox: (brline screen 1 1 5 5 12)

There are two ideas stemming from this commit:
  - I need an extremely compact on-screen trace to underlie the trace UX
  - perhaps we should start truncating trace lines
2021-04-20 19:47:57 -07:00
Kartik K. Agaram fb3967876c deemphasize fn arg evaluation slightly 2021-04-19 21:19:56 -07:00
Kartik K. Agaram 34596b6ee9 reimplement pixel graphics
Before: we always drew pixels atop characters, and we only drew pixels
that were explicitly requested.

After: we always draw pixels atop characters, and we only draw pixels that
don't have color 0.

Both semantics should be identical as long as pixels are never drawn atop
characters.
2021-04-19 21:05:57 -07:00
Kartik K. Agaram c22874a97f . 2021-04-19 10:47:30 -07:00
Kartik K. Agaram 1114442c23 . 2021-04-19 10:47:30 -07:00
Kartik K. Agaram 8e38b86ab0 add some checks
Even if they duplicate lower-level ones, we have an opportunity for better
error messages. Any time I see a hard-to-debug error message, I should
be asking myself, "what higher-level primitive should catch and improve
this error?"
2021-04-19 10:47:30 -07:00
Kartik K. Agaram f5ece0451b start cleaning up pixel graphics
Filling pixels isn't a rare corner case. I'm going to switch to a dense
rather than sparse representation for pixels, but callers will have to
explicitly request the additional memory.
2021-04-19 10:47:30 -07:00
Kartik K. Agaram 5c5bca9df5 re-enable tests
Disabled in commit 1354161a3, and then I forgot about them for a while.
2021-04-18 23:26:38 -07:00
Kartik K. Agaram 53b56c67a9 Revert "allow drawing all pixels"
It causes us to run out of memory during tests.
2021-04-18 23:25:26 -07:00
Kartik K. Agaram ad46997f95 . 2021-04-18 23:10:01 -07:00