summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-06-30 15:06:25 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-07-16 07:21:51 -0400
commit4ef1c65d76ef4aeb0fbd6a3667be628571c86f54 (patch)
treeae40e58d4f3c414efa1db2d73ff58822d744420e /rts
parent4beb9f3c367e1f7ee80b5458318d9f91622e4568 (diff)
downloadhaskell-4ef1c65d76ef4aeb0fbd6a3667be628571c86f54.tar.gz
Make keepAlive# out-of-line
This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203
Diffstat (limited to 'rts')
-rw-r--r--rts/PrimOps.cmm20
-rw-r--r--rts/RtsSymbols.c1
-rw-r--r--rts/include/rts/storage/Closures.h6
-rw-r--r--rts/include/stg/MiscClosures.h2
4 files changed, 29 insertions, 0 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index b865092ed1..430824e155 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -2924,3 +2924,23 @@ stg_setThreadAllocationCounterzh ( I64 counter )
StgTSO_alloc_limit(CurrentTSO) = counter + TO_I64(offset);
return ();
}
+
+
+#define KEEP_ALIVE_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,c) \
+ w_ info_ptr, \
+ PROF_HDR_FIELDS(w_,p1,p2) \
+ p_ c
+
+stg_keepAlivezh ( P_ c, /* :: v */
+ P_ io /* :: IO p */ )
+{
+ STK_CHK_GEN();
+ jump stg_ap_v_fast
+ (KEEP_ALIVE_FRAME_FIELDS(,,stg_keepAlive_frame_info, CCCS, 0, c))(io);
+}
+
+INFO_TABLE_RET(stg_keepAlive_frame, RET_SMALL, KEEP_ALIVE_FRAME_FIELDS(W_,P_, info_ptr, p1, p2, c))
+ return (P_ ret)
+{
+ return (ret);
+}
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index f695cbd041..9731f4febf 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -785,6 +785,7 @@ extern char **environ;
SymI_HasDataProto(stg_raiseUnderflowzh) \
SymI_HasDataProto(stg_raiseOverflowzh) \
SymI_HasDataProto(stg_raiseIOzh) \
+ SymI_HasDataProto(stg_keepAlivezh) \
SymI_HasDataProto(stg_paniczh) \
SymI_HasDataProto(stg_absentErrorzh) \
SymI_HasDataProto(stg_readTVarzh) \
diff --git a/rts/include/rts/storage/Closures.h b/rts/include/rts/storage/Closures.h
index 09c7bfdb88..84971d92a6 100644
--- a/rts/include/rts/storage/Closures.h
+++ b/rts/include/rts/storage/Closures.h
@@ -256,6 +256,12 @@ typedef struct _StgUpdateFrame {
} StgUpdateFrame;
+// Closure types: RET_SMALL
+typedef struct {
+ StgHeader header;
+ StgClosure *c;
+} StgKeepAliveFrame;
+
// Stack frame, when we call catch one of these will be put on the stack so we
// know to handle exceptions with the supplied handler
//
diff --git a/rts/include/stg/MiscClosures.h b/rts/include/stg/MiscClosures.h
index b5efd9636b..c1f9d3e94d 100644
--- a/rts/include/stg/MiscClosures.h
+++ b/rts/include/stg/MiscClosures.h
@@ -61,6 +61,7 @@ RTS_RET(stg_unmaskAsyncExceptionszh_ret);
RTS_RET(stg_maskUninterruptiblezh_ret);
RTS_RET(stg_maskAsyncExceptionszh_ret);
RTS_RET(stg_stack_underflow_frame);
+RTS_RET(stg_keepAlive_frame);
RTS_RET(stg_restore_cccs);
RTS_RET(stg_restore_cccs_eval);
@@ -498,6 +499,7 @@ RTS_FUN_DECL(stg_raiseUnderflowzh);
RTS_FUN_DECL(stg_raiseOverflowzh);
RTS_FUN_DECL(stg_raiseIOzh);
RTS_FUN_DECL(stg_paniczh);
+RTS_FUN_DECL(stg_keepAlivezh);
RTS_FUN_DECL(stg_absentErrorzh);
RTS_FUN_DECL(stg_makeStableNamezh);