Skip to content

Commit e89617c

Browse files
committed
Run boxes only
1 parent 4ff2690 commit e89617c

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

libraries/common/io.effekt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +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-
%unboxed = call ccc %Neg @unbox(%Pos ${task})
20-
call void @run(%Neg %unboxed)
19+
call void @run(%Pos %task)
2120
ret void
2221
"""
2322

libraries/llvm/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ void c_tcp_accept_cb(uv_stream_t* server, int status) {
401401
}
402402

403403
sharePositive(accept_closure->handler);
404-
run_Int(unbox(accept_closure->handler), (int64_t)client);
404+
run_Int(accept_closure->handler, (int64_t)client);
405405
}
406406

407407
void c_tcp_accept(Int listener, struct Pos handler, Stack stack) {

libraries/llvm/rts.ll

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,10 @@ define void @resume_Pos(%Stack %stack, %Pos %argument) {
726726
ret void
727727
}
728728

729-
define void @run(%Neg %f) {
729+
define void @run(%Pos %boxed) {
730+
; unbox
731+
%f = call %Neg @unbox(%Pos %boxed)
732+
730733
; fresh stack
731734
%stack = call %Stack @withEmptyStack()
732735

@@ -741,7 +744,10 @@ define void @run(%Neg %f) {
741744
ret void
742745
}
743746

744-
define void @run_Int(%Neg %f, i64 %argument) {
747+
define void @run_Int(%Pos %boxed, i64 %argument) {
748+
; unbox
749+
%f = call %Neg @unbox(%Pos %boxed)
750+
745751
; fresh stack
746752
%stack = call %Stack @withEmptyStack()
747753

@@ -756,7 +762,10 @@ define void @run_Int(%Neg %f, i64 %argument) {
756762
ret void
757763
}
758764

759-
define void @run_Pos(%Neg %f, %Pos %argument) {
765+
define void @run_Pos(%Pos %boxed, %Pos %argument) {
766+
; unbox
767+
%f = call %Neg @unbox(%Pos %boxed)
768+
760769
; fresh stack
761770
%stack = call %Stack @withEmptyStack()
762771

libraries/llvm/types.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@ typedef struct StackValue* Stack;
3434

3535
// Defined in rts.ll
3636

37-
extern struct Pos box(struct Neg);
38-
extern struct Neg unbox(struct Pos);
39-
4037
extern void resume_Int(Stack, Int);
4138
extern void resume_Pos(Stack, struct Pos);
4239

43-
extern void run(struct Neg);
44-
extern void run_Int(struct Neg, Int);
45-
extern void run_Pos(struct Neg, struct Pos);
40+
extern void run(struct Pos);
41+
extern void run_Int(struct Pos, Int);
42+
extern void run_Pos(struct Pos, struct Pos);
4643

4744
// Reference counting primitives defined in LLVM
4845
extern void eraseNegative(struct Neg);

0 commit comments

Comments
 (0)