about summary refs log tree commit diff stats
path: root/081table.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 /081table.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 '081table.subx')
-rw-r--r--081table.subx24
1 files changed, 12 insertions, 12 deletions
diff --git a/081table.subx b/081table.subx
index da3f51ed..ed1e9a92 100644
--- a/081table.subx
+++ b/081table.subx
@@ -127,7 +127,7 @@ test-get:
     # - setup: create a table with a couple of keys
     # var table/ecx: (stream {string, number} 16)  # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
@@ -308,7 +308,7 @@ test-get-slice:
     # - setup: create a table with a couple of keys
     # var table/ecx: (stream {string, number} 16)  # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
@@ -409,7 +409,7 @@ get-or-insert:  # table: (addr stream {string_key, T}), key: string_key, row-siz
     #     if string-equal?(key, *curr)
     #       return curr+4
     #     curr += row-size
-    #   if table->write >= table->length
+    #   if table->write >= table->size
     #     abort
     #   zero-out(max, row-size)
     #   *max = key
@@ -456,7 +456,7 @@ $get-or-insert:mismatch:
 $get-or-insert:not-found:
     # result/eax = 0
     31/xor                          3/mod/direct    0/rm32/eax    .           .             .           0/r32/eax   .               .                 # clear eax
-    # if (table->write >= table->length) abort
+    # if (table->write >= table->size) abort
     8b/copy                         0/mod/indirect  6/rm32/esi    .           .             .           1/r32/ecx   .               .                 # copy *esi to ecx
     3b/compare                      1/mod/*+disp8   6/rm32/esi    .           .             .           1/r32/ecx   8/disp8         .                 # compare ecx with *(esi+8)
     73/jump-if-addr>=  $get-or-insert:abort/disp8
@@ -514,7 +514,7 @@ test-get-or-insert:
     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
     # var table/ecx: (stream {string, number} 16)  # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
@@ -658,7 +658,7 @@ get-or-insert-slice:  # table: (addr stream {string_key, T}), key: (addr slice),
     #     if slice-equal?(key, *curr)
     #       return curr+4
     #     curr += row-size
-    #   if table->write >= table->length
+    #   if table->write >= table->size
     #     abort
     #   zero-out(max, row-size)
     #   *max = slice-to-string(ad, key)
@@ -705,7 +705,7 @@ $get-or-insert-slice:mismatch:
 $get-or-insert-slice:not-found:
     # result/eax = 0
     31/xor                          3/mod/direct    0/rm32/eax    .           .             .           0/r32/eax   .               .                 # clear eax
-    # if (table->write >= table->length) abort
+    # if (table->write >= table->size) abort
     8b/copy                         0/mod/indirect  6/rm32/esi    .           .             .           1/r32/ecx   .               .                 # copy *esi to ecx
     3b/compare                      1/mod/*+disp8   6/rm32/esi    .           .             .           1/r32/ecx   8/disp8         .                 # compare ecx with *(esi+8)
     7d/jump-if->=  $get-or-insert-slice:abort/disp8
@@ -769,7 +769,7 @@ test-get-or-insert-slice:
     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
     # var table/ecx: (stream {string, number} 16)  # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
@@ -1054,7 +1054,7 @@ test-get-or-stop:
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/imm32           # add to esp
     # var table/ecx: (stream {string, number} 16)  # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
@@ -1270,7 +1270,7 @@ test-get-slice-or-stop:
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/imm32           # add to esp
     # var table/ecx: (stream {string, number} 16)  # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
@@ -1446,7 +1446,7 @@ test-maybe-get:
     # - setup: create a table with one row
     # var table/ecx: (stream {string, number} 16)   # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx
@@ -1593,7 +1593,7 @@ test-maybe-get-slice:
     # - setup: create a table with one row
     # var table/ecx: (stream {string, number} 16)   # 2 rows * 8 bytes/row
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # subtract from esp
-    68/push  0x10/imm32/length
+    68/push  0x10/imm32/size
     68/push  0/imm32/read
     68/push  0/imm32/write
     89/copy                         3/mod/direct    1/rm32/ecx    .           .             .           4/r32/esp   .               .                 # copy esp to ecx