Add a new primop mkWeakNoFinalizer (#5879)
authorSimon Marlow <marlowsd@gmail.com>
Fri, 27 Apr 2012 10:12:38 +0000 (11:12 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Fri, 27 Apr 2012 11:23:31 +0000 (12:23 +0100)
compiler/prelude/primops.txt.pp
includes/stg/MiscClosures.h
rts/Linker.c
rts/PrimOps.cmm

index b1ef1d2..97fc0a5 100644 (file)
@@ -1821,6 +1821,12 @@ primop  MkWeakOp "mkWeak#" GenPrimOp
    has_side_effects = True
    out_of_line      = True
 
+primop  MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp
+   o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
+   with
+   has_side_effects = True
+   out_of_line      = True
+
 primop  MkWeakForeignEnvOp "mkWeakForeignEnv#" GenPrimOp
    o -> b -> Addr# -> Addr# -> Int# -> Addr# -> State# RealWorld -> (# State# RealWorld, Weak# b #)
    with
index 4fed346..c93cc31 100644 (file)
@@ -426,6 +426,7 @@ RTS_FUN_DECL(stg_isCurrentThreadBoundzh);
 RTS_FUN_DECL(stg_threadStatuszh);
 
 RTS_FUN_DECL(stg_mkWeakzh);
+RTS_FUN_DECL(stg_mkWeakNoFinalizzerzh);
 RTS_FUN_DECL(stg_mkWeakForeignzh);
 RTS_FUN_DECL(stg_mkWeakForeignEnvzh);
 RTS_FUN_DECL(stg_finalizzeWeakzh);
index c983403..3b51e69 100644 (file)
@@ -294,6 +294,7 @@ typedef struct _RtsSymbolVal {
 } RtsSymbolVal;
 
 #define Maybe_Stable_Names      SymI_HasProto(stg_mkWeakzh)                     \
+                                SymI_HasProto(stg_mkWeakNoFinalizzerzh)         \
                                 SymI_HasProto(stg_mkWeakForeignEnvzh)           \
                                 SymI_HasProto(stg_makeStableNamezh)             \
                                 SymI_HasProto(stg_finalizzeWeakzh)
index aaedabb..93ef23a 100644 (file)
@@ -384,14 +384,10 @@ stg_mkWeakzh
 {
   /* R1 = key
      R2 = value
-     R3 = finalizer (or NULL)
+     R3 = finalizer (or stg_NO_FINALIZER_closure)
   */
   W_ w;
 
-  if (R3 == NULL) {
-    R3 = stg_NO_FINALIZER_closure;
-  }
-
   ALLOC_PRIM( SIZEOF_StgWeak, R1_PTR & R2_PTR & R3_PTR, stg_mkWeakzh );
 
   w = Hp - SIZEOF_StgWeak + WDS(1);
@@ -416,6 +412,16 @@ stg_mkWeakzh
   RET_P(w);
 }
 
+stg_mkWeakNoFinalizzerzh
+{
+  /* R1 = key
+     R2 = value
+   */
+  R3 = stg_NO_FINALIZER_closure;
+
+  jump stg_mkWeakzh;
+}
+
 stg_mkWeakForeignEnvzh
 {
   /* R1 = key