From 02b7f9bd89fcae62c118772b1eb907b6c93055f0 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 18 Jul 2020 15:56:32 -0700 Subject: [PATCH] 6658 --- 120allocate.subx | 2 +- vocabulary.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/120allocate.subx b/120allocate.subx index ff52b2e9..4bcbe727 100644 --- a/120allocate.subx +++ b/120allocate.subx @@ -855,7 +855,7 @@ test-copy-array: e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp - # check-ints-equal(ad->curr - expected-payload, 12 + 4 for alloc-id + 4 for length, msg) + # check-ints-equal(ad->curr - expected-payload, 12 + 4 for alloc-id + 4 for size, msg) # . . push args 68/push "F - test-copy-array: updates allocation descriptor"/imm32 68/push 0x14/imm32 diff --git a/vocabulary.md b/vocabulary.md index 426ed590..ce3eab23 100644 --- a/vocabulary.md +++ b/vocabulary.md @@ -5,9 +5,9 @@ - Kernel strings: null-terminated regions of memory. Unsafe and to be avoided, but needed for interacting with the kernel. -- Arrays: length-prefixed regions of memory containing multiple elements of a +- Arrays: size-prefixed regions of memory containing multiple elements of a single type. Contents are preceded by 4 bytes (32 bits) containing the - `length` of the array in bytes. + `size` of the array in bytes. - Slices: a pair of 32-bit addresses denoting a [half-open](https://en.wikipedia.org/wiki/Interval_(mathematics)) \[`start`, `end`) interval to live memory with a consistent lifetime. @@ -19,10 +19,10 @@ - offset 0: write index - offset 4: read index - - offset 8: length of array (in bytes) + - offset 8: size of array (in bytes) - offset 12: start of array data - Invariant: 0 <= `read` <= `write` <= `length` + Invariant: 0 <= `read` <= `write` <= `size` - File descriptors (fd): Low-level 32-bit integers that the kernel uses to track files opened by the program. @@ -51,7 +51,7 @@ But those are big goals. Here are the syscalls I have so far: 1. SubX can handle 'fake' file descriptors in tests. - 1. `write()` accepts buffer and its length in separate arguments, which + 1. `write()` accepts buffer and its size in separate arguments, which requires callers to manage the two separately and so can be error-prone. SubX's wrapper keeps the two together to increase the chances that we never accidentally go out of array bounds. @@ -178,7 +178,7 @@ allocated memory for it.)_ - `new-stream`: allocates space for a stream of `n` elements, each occupying `b` bytes. - Will abort the entire program if `n*b` requires more than 32 bits. -- `clear-stream`: resets everything in the stream to `0` (except its `length`). +- `clear-stream`: resets everything in the stream to `0` (except its `size`). - `rewind-stream`: resets the read index of the stream to `0` without modifying its contents.