Skip to content

Commit 44ac53c

Browse files
committed
Fix bug in spawn and document todo
1 parent 943225e commit 44ac53c

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

libraries/common/io.effekt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern async def spawn(task: Task[Unit]): Unit =
1616
js "$effekt.capture(k => { setTimeout(() => k($effekt.unit), 0); return $effekt.run(${task}) })"
1717
llvm """
1818
call void @c_yield(%Stack %stack)
19-
call void @run(%Pos %task)
19+
call void @run(%Pos ${task})
2020
ret void
2121
"""
2222

libraries/common/io/network.effekt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ namespace internal {
5353
ret void
5454
"""
5555

56+
/// The buffer must be kept alive by using it after the call
5657
extern async def read(handle: Int, buffer: ByteArray, offset: Int, size: Int): Int =
5758
llvm """
5859
call void @c_tcp_read(%Int ${handle}, %Pos ${buffer}, %Int ${offset}, %Int ${size}, %Stack %stack)
5960
ret void
6061
"""
6162

63+
/// The buffer must be kept alive by using it after the call
6264
extern async def write(handle: Int, buffer: ByteArray, offset: Int, size: Int): Int =
6365
llvm """
6466
call void @c_tcp_write(%Int ${handle}, %Pos ${buffer}, %Int ${offset}, %Int ${size}, %Stack %stack)

libraries/llvm/io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ void c_tcp_read(Int handle, struct Pos buffer, Int offset, Int size, Stack stack
263263

264264
char* buffer_ptr = (char*)(c_bytearray_data(buffer) + offset);
265265
erasePositive(buffer);
266+
// TODO panic if this was the last reference
266267

267268
tcp_read_closure_t* read_closure = malloc(sizeof(tcp_read_closure_t));
268269
read_closure->stack = stack;
@@ -290,6 +291,7 @@ void c_tcp_write(Int handle, struct Pos buffer, Int offset, Int size, Stack stac
290291

291292
uv_buf_t buf = uv_buf_init((char*)(c_bytearray_data(buffer) + offset), size);
292293
erasePositive(buffer);
294+
// TODO panic if this was the last reference
293295

294296
uv_write_t* request = malloc(sizeof(uv_write_t));
295297
request->data = stack;

0 commit comments

Comments
 (0)