diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-03-22 12:11:49 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-05-18 00:44:46 -0700 |
commit | 546a92985f7da2491077d641a2c118b4af7f6913 (patch) | |
tree | 1e6ab75543a3028e78c9454fbb6bd6b6a076e0ee /072slice.subx | |
parent | 1f38b75e31d713fc72a9d29d360fe5ad66ba22fe (diff) | |
download | mu-546a92985f7da2491077d641a2c118b4af7f6913.tar.gz |
start migrating handles to fat pointers
CI will fail from this commit onward. Currently working: $ bootstrap translate init.linux 0[4-7]*.subx 080zero-out.subx -o a.elf && ./a.elf test $ bootstrap run a.elf test $ chmod +x a.elf; ./a.elf test Plan: migrate functions that used to return handles to pass in a new arg of type (addr handle). That's a bit of a weird type. There should be few of these functions. (Open question: do we even want to expose this type in the Mu language?) Functions that just need to read from heap without modifying the handle will receive `(addr T)` or `(handle T)` types as arguments. As I sanitize each new file, I need to update signatures for any new functions and add them to a list. I also need to update calls to any functions on the list.
Diffstat (limited to '072slice.subx')
-rw-r--r-- | 072slice.subx | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/072slice.subx b/072slice.subx index 39820594..cfe519b7 100644 --- a/072slice.subx +++ b/072slice.subx @@ -1041,11 +1041,12 @@ test-write-slice-buffered: c3/return # copy a slice into a new (dynamically allocated) string -slice-to-string: # ad: (addr allocation-descriptor), in: (addr slice) -> out/eax: (addr array byte) +slice-to-string: # ad: (addr allocation-descriptor), in: (addr slice), out: (handle array byte) # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp # . save registers + 50/push-eax 51/push-ecx 52/push-edx 53/push-ebx @@ -1060,14 +1061,20 @@ slice-to-string: # ad: (addr allocation-descriptor), in: (addr slice) -> out/ea 89/copy 3/mod/direct 1/rm32/ecx . . . 3/r32/ebx . . # copy ebx to ecx 29/subtract 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . . # subtract edx from ecx 81 0/subop/add 3/mod/direct 1/rm32/ecx . . . . . 4/imm32 # add to ecx - # var out/eax: (handle array byte) = allocate(ad, size) + # allocate(ad, size, out) # . . push args + ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x10/disp8 . # push *(ebp+16) 51/push-ecx ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 . # push *(ebp+8) # . . call e8/call allocate/disp32 # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp + 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp + # eax = out->payload + 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x10/disp8 . # copy *(ebp+16) to eax + 8b/copy 1/mod/*+disp8 0/rm32/eax . . . 0/r32/eax 4/disp8 . # copy *(eax+4) to eax + # skip payload->allocid + 05/add-to-eax 4/imm32 # if (eax == 0) abort 3d/compare-eax-and 0/imm32 74/jump-if-= $slice-to-string:abort/disp8 @@ -1099,6 +1106,7 @@ $slice-to-string:end: 5b/pop-to-ebx 5a/pop-to-edx 59/pop-to-ecx + 58/pop-to-eax # . epilogue 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . . # copy ebp to esp 5d/pop-to-ebp @@ -1144,15 +1152,24 @@ test-slice-to-string: 51/push-ecx 50/push-eax 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . . # copy esp to ecx - # eax = slice-to-string(heap, slice) + # var h/ebx: (handle array byte) + 68/push 0/imm32 + 68/push 0/imm32 + 89/copy 3/mod/direct 3/rm32/ebx . . . 4/r32/esp . . # copy esp to ebx + # slice-to-string(heap, slice, h) # . . push args + 53/push-ebx 51/push-ecx 52/push-edx # . . call e8/call slice-to-string/disp32 # . . discard args - 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp -#? # dump word-slice {{{ + 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp + # eax = h->payload + 8b/copy 1/mod/*+disp8 3/rm32/ebx . . . 0/r32/eax 4/disp8 . # copy *(ebx+4) to eax + # skip payload->allocid + 05/add-to-eax 4/imm32 +#? # dump eax {{{ #? # . write(2/stderr, "AA: ") #? # . . push args #? 68/push "AA: "/imm32 @@ -1195,6 +1212,8 @@ test-slice-to-string: e8/call check-ints-equal/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32 # add to esp + # . reclaim locals + 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x18/imm32 # add to esp # . epilogue 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . . # copy ebp to esp 5d/pop-to-ebp |