Commit Graph

51 Commits

Author SHA1 Message Date
Kartik Agaram bfcc0f858a 6182 - start of support for safe handles
So far it's unclear how to do this in a series of small commits. Still
nibbling around the edges. In this commit we standardize some terminology:

The length of an array or stream is denominated in the high-level elements.
The _size_ is denominated in bytes.

The thing we encode into the type is always the size, not the length.

There's still an open question of what to do about the Mu `length` operator.
I'd like to modify it to provide the length. Currently it provides the
size. If I can't fix that I'll rename it.
2020-04-03 12:35:53 -07:00
Kartik Agaram f730f2f2c7 6181 2020-04-03 01:05:01 -07:00
Kartik Agaram c48ce3c8bf 6153 - switch 'main' to use Mu strings
At the SubX level we have to put up with null-terminated kernel strings
for commandline args. But so far we haven't done much with them. Rather
than try to support them we'll just convert them transparently to standard
length-prefixed strings.

In the process I realized that it's not quite right to treat the combination
of argc and argv as an array of kernel strings. Argc counts the number
of elements, whereas the length of an array is usually denominated in bytes.
2020-03-15 21:03:12 -07:00
Kartik Agaram 3cf0315859 6094 - new 'compute-offset' instruction
If indexing into a type with power-of-2-sized elements we can access them
in one instruction:

  x/reg1: (addr int) <- index A/reg2: (addr array int), idx/reg3: int

This translates to a single instruction because x86 instructions support
an addressing mode with left-shifts.

For non-powers-of-2, however, we need a multiply. To keep things type-safe,
it is performed like this:

  x/reg1: (offset T) <- compute-offset A: (addr array T), idx: int
  y/reg2: (addr T) <- index A, x

An offset is just an int that is guaranteed to be a multiple of size-of(T).
Offsets can only be used in index instructions, and the types will eventually
be required to line up.

In the process, I have to expand Input-size because mu.subx is growing
big.
2020-03-07 17:40:45 -08:00
Kartik Agaram b5fbf20556 6085
Support parsing ints from strings rather than slices.
2020-03-06 13:44:54 -08:00
Kartik Agaram c1737cbaae 6083 2020-03-06 12:08:42 -08:00
Kartik Agaram af326d9e39 6070 2020-02-29 05:53:13 -08:00
Kartik Agaram 17c46e0b8c 6064
Fix CI.
2020-02-27 21:28:02 -08:00
Kartik Agaram 2c966386d1 6000 - clean up after no-local branches 2020-02-09 20:39:19 -08:00
Kartik Agaram 6c059c7ef3 5999
Fix CI. apps/survey was running out of space in the trace segment when
translating apps/mu.subx
2020-02-09 18:38:55 -08:00
Kartik Agaram d20fbf71c3 5948 - branching to named blocks 2020-01-29 17:34:07 -08:00
Kartik Agaram cfdd5b8bf3 5933
Expand some buffer sizes to continue building mu.subx natively.
2020-01-27 02:35:35 -08:00
Kartik Agaram 622f1be099 5898 - strengthen slice-empty? check
Anytime we create a slice, the first check tends to be whether it's empty.
If we handle ill-formed slices here where start > end, that provides a
measure of safety.

In the Mu translator (mu.subx) we often check for a trailing ':' or ','
and decrement slice->end to ignore it. But that could conceivably yield
ill-formed slices if the slice started out empty. Now we make sure we never
operate on such ill-formed slices.
2020-01-19 17:37:11 -08:00
Kartik Agaram 51858e5d46 5887 - reorganize library
Layers 0-89 are used in self-hosting SubX.
Layers 90-99 are not needed for self-hosting SubX, and therefore could
use transitional levels of syntax sugar.
Layers 100 and up use all SubX syntax sugar.
2020-01-14 01:52:54 -08:00
Kartik Agaram a9baaac00b 5847 - literal inputs 2019-12-31 21:58:52 -08:00
Kartik Agaram 2a2a5b1e43 5804
Try to make the comments consistent with the type system we'll eventually
have.
2019-12-08 23:31:05 -08:00
Kartik Agaram a93cd189c9 5803 2019-12-07 20:50:23 -08:00
Kartik Agaram 58467e6cbc 5792
Fix a bug in one test: it checks eax when the component under test returns
nothing. It's been just accidentally passing all these months.
2019-12-05 23:29:24 -08:00
Kartik Agaram 931b17daa0 5782 - fix a widespread bug with Heap-size 2019-11-30 11:14:49 -08:00
Kartik Agaram 8d5437838b 5778 2019-11-29 01:27:39 -08:00
Kartik Agaram 3a7da4e735 5769 - support uppercase hex in SubX 2019-11-28 00:37:26 -08:00
Kartik Agaram 70187b1c01 5765
A couple more primitives now working. In the process I ran into an issue
with some buffer filling up when running ntranslate. Isolating it to survey.subx
was straightforward, but --trace ran out of RAM, and --trace --dump ran
out of (7GB of) disk. In the end what helped was just repeatedly inserting
exits at different points, and I realized there was a magic number that
hadn't been turned into a named constant.
2019-11-26 22:11:23 -08:00
Kartik Agaram 442fdabe30 5752
Support binary operations with reg/mem and reg operands.

Everything is passing. However, the self-hosting translator now generates
some discrepancies compared to the C++ translator :(
2019-11-18 01:15:29 -08:00
Kartik Agaram f0b7e327c5 5714
Replace calculations of constants with labels.
2019-10-25 06:10:36 -07:00
Kartik Agaram 5ef9597631 5687
Move stack operations to a layer of their own.

It was some short-term pain to take out the syntax sugar from it, but we
need access to this layer from braces, which can't depend on sugar since
it's part of sugar. Just simpler to keep one clear line and not have to
build sometimes with some sugar but not others.
2019-09-23 09:21:40 -07:00
Kartik Agaram a19dddcabe 5676 2019-09-19 23:29:28 -07:00
Kartik Agaram fd91f7f61b 5675 - move helpers from subx-common into layers
This undoes 5672 in favor of a new plan:

Layers 000 - 099 are for running without syntax sugar. We use them for
building syntax-sugar passes.

Layers 100 and up are for running with all syntax sugar.

The layers are arranged in approximate order so more phases rely on earlier
layers than later ones.

I plan to not use intermediate syntax sugar (just sigils without calls,
or sigils and calls without braces) anywhere except in the specific passes
implementing them.
2019-09-19 23:25:49 -07:00
Kartik Agaram 8a73e0d19a 5673 - standardize a few knobs 2019-09-19 16:32:10 -07:00
Kartik Agaram dfbe155087 5672 - move hex out of apps 2019-09-19 15:59:22 -07:00
Kartik Agaram 68666b07b8 5669 2019-09-19 15:19:07 -07:00
Kartik Agaram a9d473e224 5668 - start reorg to permit syntax sugar in layers
Right now we always build the library before any apps.
Apps are where our syntax sugar translators (sigils, calls, braces) live.
So we can't use sugar in the standard library.

New idea: move all code for SubX phases into the top-level.
Perhaps we should also just build a single file rather than pipeline stages.
But for now we'll build each phase by building up to some specific layer.

This will simplify test_apps and move lots of one-off logic to a more standard
form in test_layers.

I'm also going to reorg existing layers so that we introduce each phase
at a point where it mostly only gets the helpers it needs.

This commit itself is just cleaning up some common strings. Using explicit
names for them streamlines binaries a bit.
2019-09-19 15:12:50 -07:00
Kartik Agaram ecfbbfb5b5 5647 - experimental support for swapping OS 2019-09-11 19:53:23 -07:00
Kartik Agaram e836615a60 5630 2019-09-06 16:17:51 -07:00
Kartik Agaram 77c96940d5 5623 2019-09-04 21:29:42 -07:00
Kartik Agaram 719dec729c 5616 2019-09-04 17:30:40 -07:00
Kartik Agaram 968380517a 5608 - write int to stream 2019-09-02 15:15:11 -07:00
Kartik Agaram 282681c729 5600 2019-08-31 23:42:45 -07:00
Kartik Agaram 333525360b 5592 - switch register names to lowercase 2019-08-26 11:59:21 -07:00
Kartik Agaram 22fb844ba4 5591 2019-08-26 11:54:29 -07:00
Kartik Agaram d8c2f71ce9 5586 - bugfix: no desugar inside string literals 2019-08-25 22:03:23 -07:00
Kartik Agaram 33de6b8031 build out all variants for skipping whitespace
skip {whitespace, non-whitespace} x {from stream, from slice}
2019-08-24 08:18:09 -07:00
Kartik Agaram 306812cc30 done implementing all variants of 'get' 2019-08-13 22:13:14 -07:00
Kartik Agaram 328a8e11f6 done with get-or-stop 2019-08-13 17:15:08 -07:00
Kartik Agaram 0059698b0b half-done testing get-or-stop
Probably not needed for desugar; I'm just working through what we may
replace the calls to 'get-slice' with if and when we decide to start
focusing error messages and so writing tests for them.
2019-08-13 12:40:25 -07:00
Kartik Agaram 63b8b18ef7 standardize test input/output/error streams 2019-08-13 12:27:15 -07:00
Kartik Agaram 64e8faba37 . 2019-08-13 12:19:49 -07:00
Kartik Agaram 64d51af46f . 2019-08-13 09:55:28 -07:00
Kartik Agaram d826a2d659 new variant: maybe-get-slice 2019-08-13 00:06:18 -07:00
Kartik Agaram 2b48729fd2 new variant: maybe-get returns null on failure 2019-08-12 23:39:53 -07:00
Kartik Agaram 15a84e2449 better error message when get aborts 2019-08-12 23:18:31 -07:00