Commit Graph

6172 Commits

Author SHA1 Message Date
Kartik Agaram 93d8141e1e 6172
Typo in stats: use the same measures as in previous lines.
2020-03-26 00:34:09 -07:00
Kartik Agaram 0ea5f759fc 6171 2020-03-25 11:46:07 -07:00
Kartik Agaram 606c1ab49a 6170 2020-03-25 09:54:53 -07:00
Kartik Agaram 84c426d2ab 6169 2020-03-25 09:46:35 -07:00
Kartik Agaram 8fa7c79685 6168 2020-03-25 09:39:46 -07:00
Kartik Agaram 9470451cb1 6167 2020-03-25 09:21:06 -07:00
Kartik Agaram 7d117e4699 6166 2020-03-25 09:20:33 -07:00
Kartik Agaram 41d5e711f2 6165 2020-03-25 09:16:04 -07:00
Kartik Agaram be19cb8772 6164 2020-03-24 03:49:56 -07:00
Kartik Agaram e25b9e0a4d 6163 2020-03-23 20:56:58 -07:00
Kartik Agaram 783eb31a05 6162 2020-03-23 20:56:49 -07:00
Kartik Agaram 98d45d34de 6161 2020-03-22 12:05:25 -07:00
Kartik Agaram 0ef7f1d2d6 6160 - plan for safe heap access
Based on apps/handle.subx (commit 4894), but we're able to simplify it
further now that we know more about the situation we find ourselves in.
6 instructions, zero pushes or pops.

Before I can start building this, I need to reorganize my use of handles.
They're going to be fat pointers so we can't store them in registers anymore.
2020-03-21 22:43:43 -07:00
Kartik Agaram fa80585024 6159 2020-03-21 17:26:31 -07:00
Kartik Agaram df609237c1 6158 - standardize opcode names
At the lowest level, SubX without syntax sugar uses names without prepositions.
For example, 01 and 03 are both called 'add', irrespective of source and
destination operand. Horizontal space is at a premium, and we rely on the
comments at the end of each line to fully describe what is happening.

Above that, however, we standardize on a slightly different naming convention
across:
  a) SubX with syntax sugar,
  b) Mu, and
  c) the SubX code that the Mu compiler emits.

Conventions, in brief:
  - by default, the source is on the left and destination on the right.
    e.g. add %eax, 1/r32/ecx ("add eax to ecx")
  - prepositions reverse the direction.
    e.g. add-to %eax, 1/r32/ecx ("add ecx to eax")
         subtract-from %eax, 1/r32/ecx ("subtract ecx from eax")
  - by default, comparisons are left to right while 'compare<-' reverses.

Before, I was sometimes swapping args to make the operation more obvious,
but that would complicate the code-generation of the Mu compiler, and it's
nice to be able to read the output of the compiler just like hand-written
code.

One place where SubX differs from Mu: copy opcodes are called '<-' and
'->'. Hopefully that fits with the spirit of Mu rather than the letter
of the 'copy' and 'copy-to' instructions.
2020-03-21 16:51:52 -07:00
Kartik Agaram c6886c1c97 6157 2020-03-21 15:07:59 -07:00
Kartik Agaram 26f4457cd6 6156 2020-03-21 14:20:10 -07:00
Kartik Agaram 30c45021d4 6155 2020-03-20 18:19:13 -07:00
Kartik Agaram e1de7e0661 6154 - include link to the Mu paper 2020-03-16 01:53:09 -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 f559236bdf 6152 - fix regression in factorial.mu
I had to amend commit 6148 three times yesterday as I kept finding bugs
by inspection. And yet I stubbornly thought I didn't need a test.
2020-03-15 16:44:55 -07:00
Kartik Agaram e2a0b44073 6151 2020-03-15 10:54:25 -07:00
Kartik Agaram abb66df2c7 6150 - call-by-reference is working 2020-03-14 16:04:57 -07:00
Kartik Agaram afa4d6bb4c 6149 - pass multi-word objects to functions
This is quite inefficient; don't use it for very large objects.
2020-03-14 15:46:38 -07:00
Kartik Agaram 9655878e1b 6148 2020-03-14 15:31:35 -07:00
Kartik Agaram 999292dfdd 6147 2020-03-14 15:15:46 -07:00
Kartik Agaram 85a964616d 6146 2020-03-14 14:48:05 -07:00
Kartik Agaram 114641e2c8 6145 - 'address' operator
This could be a can of worms, but I think I have a set of checks that will
keep use of addresses type-safe.
2020-03-14 14:46:45 -07:00
Kartik Agaram 6db056110b 6144 2020-03-14 01:25:34 -07:00
Kartik Agaram 9428990bd6 6143 2020-03-14 01:06:27 -07:00
Kartik Agaram b7b24ec242 6142 2020-03-14 01:03:30 -07:00
Kartik Agaram 9f589350cf 6141 2020-03-14 00:58:52 -07:00
Kartik Agaram a598d09082 6140 2020-03-14 00:50:38 -07:00
Kartik Agaram 9aa6e60538 6139 2020-03-12 01:18:29 -07:00
Kartik Agaram 290f2f677a 6138 2020-03-12 01:16:47 -07:00
Kartik Agaram 8f32cb825e 6137 2020-03-12 01:15:41 -07:00
Kartik Agaram 34a37b475c 6136 - ok, we can now call records and arrays done
Maybe not quite. One final issue: length is denominated in bytes, which
is abstraction-busting and all, but dashed inconvenient.

Unfortunately x86 doesn't have a divide instruction that takes an immediate
:( So I'm not sure how to transparently perform the division without needing
some extra register.
2020-03-12 00:51:28 -07:00
Kartik Agaram 89fc6e43d5 6135 2020-03-12 00:46:10 -07:00
Kartik Agaram f6638d006c 6134 2020-03-12 00:45:23 -07:00
Kartik Agaram ff0f216b41 6133 2020-03-12 00:45:17 -07:00
Kartik Agaram b50c0e3279 6132 2020-03-12 00:36:36 -07:00
Kartik Agaram 92ca78429c 6131 - operating on arrays on the stack 2020-03-12 00:17:35 -07:00
Kartik Agaram d5171ad7fe 6130 2020-03-11 21:34:49 -07:00
Kartik Agaram afc0be47a5 6129 2020-03-11 20:56:27 -07:00
Kartik Agaram 0aa7420745 6128 - arrays on the stack 2020-03-11 19:55:45 -07:00
Kartik Agaram e420279ac1 6127 2020-03-11 19:50:49 -07:00
Kartik Agaram 15655a1246 6126 - support 8-byte register names
Using these is quite unsafe. But what isn't, here?
2020-03-11 18:16:56 -07:00
Kartik Agaram 39eb1e4963 6125 2020-03-11 17:34:48 -07:00
Kartik Agaram f2d6bb1cb8 6124 2020-03-11 17:30:06 -07:00
Kartik Agaram 28746b3666 6123 - runtime helper for initializing arrays
I built this in 3 phases:
a) create a helper in the bootstrap VM to render the state of the stack.
b) interactively arrive at the right function (tools/stack_array.subx)
c) pull the final solution into the standard library (093stack_allocate.subx)

As the final layer says, this may not be the fastest approach for most
(or indeed any) Mu programs. Perhaps it's better on balance for the compiler
to just emit n/4 `push` instructions.

(I'm sure this solution can be optimized further.)
2020-03-11 17:21:59 -07:00