about summary refs log tree commit diff stats
path: root/056trace.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-04-03 12:35:53 -0700
committerKartik Agaram <vc@akkartik.com>2020-04-03 12:35:53 -0700
commitbfcc0f858aa324739ad645e2056d73a47ab66f82 (patch)
tree24a22e364b2c1d535013c604b7a9620a31606e71 /056trace.subx
parentf730f2f2c7934f52091a848b71f9031ea99e2377 (diff)
downloadmu-bfcc0f858aa324739ad645e2056d73a47ab66f82.tar.gz
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.
Diffstat (limited to '056trace.subx')
-rw-r--r--056trace.subx30
1 files changed, 15 insertions, 15 deletions
diff --git a/056trace.subx b/056trace.subx
index f7dd4694..45ab2792 100644
--- a/056trace.subx
+++ b/056trace.subx
@@ -3,7 +3,7 @@
 # A trace stream looks like a regular stream:
 #   write: int  # index at which writes go
 #   read: int  # index that we've read until
-#   data: (array byte)  # prefixed by length as usual
+#   data: (array byte)  # prefixed by size as usual
 # Usually the trace stream will be in a separate segment set aside for the purpose.
 #
 # primitives for operating on traces (arguments in quotes):
@@ -33,7 +33,7 @@ _test-trace-stream:  # (stream byte)
     0/imm32
     # current read index
     0/imm32
-    # length
+    # size
     8/imm32
     # data
     00 00 00 00 00 00 00 00  # 8 bytes
@@ -43,7 +43,7 @@ _test-trace-stream:  # (stream byte)
 # . op          subop               mod             rm32          base        index         scale       r32
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
-# Allocate a new segment for the trace stream, initialize its length, and save its address to Trace-stream.
+# Allocate a new segment for the trace stream, initialize its size, and save its address to Trace-stream.
 # The Trace-stream segment will consist of variable-length lines separated by newlines (0x0a)
 initialize-trace-stream:  # n: int
     # . prologue
@@ -67,10 +67,10 @@ initialize-trace-stream:  # n: int
 #?     # watch point to catch Trace-stream leaks
 #? $watch-1:
     89/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/eax   Trace-stream/disp32               # copy eax to *Trace-stream
-    # Trace-stream->length = n - 12
+    # Trace-stream->size = n - 12
     # . ecx -= 12
     81          5/subop/subtract    3/mod/direct    1/rm32/ecx    .           .             .           .           .               0xc/imm32         # subtract from ecx
-    # . Trace-stream->length = ecx
+    # . Trace-stream->size = ecx
     89/copy                         1/mod/*+disp8   0/rm32/eax    .           .             .           1/r32/ecx   8/disp8         .                 # copy ecx to *(eax+8)
 $initialize-trace-stream:end:
     # . restore registers
@@ -100,12 +100,12 @@ trace:  # line: (addr array byte)
     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .                         6/r32/esi   8/disp8         .                 # copy *(ebp+8) to esi
     # var ecx: int = t->write
     8b/copy                         0/mod/indirect  7/rm32/edi    .           .             .           1/r32/ecx   .               .                 # copy *edi to ecx
-    # var edx: int = t->length
+    # var edx: int = t->size
     8b/copy                         1/mod/*+disp8   7/rm32/edi    .           .             .           2/r32/edx   8/disp8         .                 # copy *(edi+8) to edx
-    # eax = _append-3(&t->data[t->write], &t->data[t->length], line)
+    # eax = _append-3(&t->data[t->write], &t->data[t->size], line)
     # . . push line
     56/push-esi
-    # . . push &t->data[t->length]
+    # . . push &t->data[t->size]
     8d/copy-address                 1/mod/*+disp8   4/rm32/sib    7/base/edi  2/index/edx   .           3/r32/ebx   0xc/disp8       .                 # copy edi+edx+12 to ebx
     53/push-ebx
     # . . push &t->data[t->write]
@@ -122,10 +122,10 @@ trace:  # line: (addr array byte)
     01/add                          0/mod/indirect  7/rm32/edi    .           .             .           0/r32/eax   .               .                 # add eax to *edi
     # refresh ecx = t->write
     8b/copy                         0/mod/indirect  7/rm32/edi    .           .             .           1/r32/ecx   .               .                 # copy *edi to ecx
-    # eax = _append-3(&t->data[t->write], &t->data[t->length], line)
+    # eax = _append-3(&t->data[t->write], &t->data[t->size], line)
     # . . push line
     68/push  Newline/imm32
-    # . . push &t->data[t->length]
+    # . . push &t->data[t->size]
     8d/copy-address                 1/mod/*+disp8   4/rm32/sib    7/base/edi  2/index/edx   .           3/r32/ebx   0xc/disp8       .                 # copy edi+edx+12 to ebx
     53/push-ebx
     # . . push &t->data[t->write]
@@ -868,8 +868,8 @@ _append-3:  # out: (addr byte), outend: (addr byte), s: (addr array byte) -> num
     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
     # . save registers
     51/push-ecx
-    # eax = _append-4(out, outend, &s->data[0], &s->data[s->length])
-    # . . push &s->data[s->length]
+    # eax = _append-4(out, outend, &s->data[0], &s->data[s->size])
+    # . . push &s->data[s->size]
     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .                         0/r32/eax   0x10/disp8      .                 # copy *(ebp+16) to eax
     8b/copy                         0/mod/indirect  0/rm32/eax    .           .             .           1/r32/ecx   .               .                 # copy *eax to ecx
     8d/copy-address                 1/mod/*+disp8   4/rm32/sib    0/base/eax  1/index/ecx   .           1/r32/ecx   4/disp8         .                 # copy eax+ecx+4 to ecx
@@ -965,7 +965,7 @@ _test-stream-line-ABABA:  # (stream byte)
     8/imm32
     # read
     0/imm32
-    # length
+    # size
     8/imm32
     # data
     41 42 41 42 41 0a 00 00  # 8 bytes
@@ -975,7 +975,7 @@ _test-stream-empty:  # (stream byte)
     0/imm32
     # read
     0/imm32
-    # length
+    # size
     8/imm32
     # data
     00 00 00 00 00 00 00 00  # 8 bytes
@@ -985,7 +985,7 @@ _test-stream-filled:  # (stream byte)
     8/imm32
     # read
     0/imm32
-    # length
+    # size
     8/imm32
     # data
     41 41 41 41 0a 41 41 41  # 8 bytes