/* -----------------------------------------------------------------------------
- * $Id: Linker.c,v 1.107 2002/12/11 15:36:42 simonmar Exp $
+ * $Id: Linker.c,v 1.108 2002/12/19 14:33:22 simonmar Exp $
*
* (c) The GHC Team, 2000, 2001
*
SymX(newArrayzh_fast) \
SymX(newBCOzh_fast) \
SymX(newByteArrayzh_fast) \
- SymX(newCAF) \
+ SymX_redirect(newCAF, newDynCAF) \
SymX(newMVarzh_fast) \
SymX(newMutVarzh_fast) \
SymX(atomicModifyMutVarzh_fast) \
/* entirely bogus claims about types of these symbols */
#define Sym(vvv) extern void (vvv);
#define SymX(vvv) /**/
+#define SymX_redirect(vvv,xxx) /**/
RTS_SYMBOLS
RTS_LONG_LONG_SYMS
RTS_EXTRA_SYMBOLS
(void*)(&(vvv)) },
#define SymX(vvv) Sym(vvv)
+// SymX_redirect allows us to redirect references to one symbol to
+// another symbol. See newCAF/newDynCAF for an example.
+#define SymX_redirect(vvv,xxx) \
+ { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \
+ (void*)(&(xxx)) },
+
static RtsSymbolVal rtsSyms[] = {
RTS_SYMBOLS
RTS_LONG_LONG_SYMS
/* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.72 2002/12/13 19:17:02 wolfgang Exp $
+ * $Id: Storage.c,v 1.73 2002/12/19 14:33:23 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
*/
ACQUIRE_SM_LOCK;
- if (0 /*TODO: is_dynamically_loaded_rwdata_ptr((StgPtr)caf)*/) {
- ((StgIndStatic *)caf)->saved_info = (StgInfoTable *)caf->header.info;
- ((StgIndStatic *)caf)->static_link = caf_list;
- caf_list = caf;
- } else {
- ((StgIndStatic *)caf)->saved_info = NULL;
- ((StgMutClosure *)caf)->mut_link = oldest_gen->mut_once_list;
- oldest_gen->mut_once_list = (StgMutClosure *)caf;
- }
+ ((StgIndStatic *)caf)->saved_info = NULL;
+ ((StgMutClosure *)caf)->mut_link = oldest_gen->mut_once_list;
+ oldest_gen->mut_once_list = (StgMutClosure *)caf;
RELEASE_SM_LOCK;
#endif /* PAR */
}
+// An alternate version of newCaf which is used for dynamically loaded
+// object code in GHCi. In this case we want to retain *all* CAFs in
+// the object code, because they might be demanded at any time from an
+// expression evaluated on the command line.
+//
+// The linker hackily arranges that references to newCaf from dynamic
+// code end up pointing to newDynCAF.
+void
+newDynCAF(StgClosure *caf)
+{
+ ACQUIRE_SM_LOCK;
+
+ ((StgIndStatic *)caf)->saved_info = (StgInfoTable *)caf->header.info;
+ ((StgIndStatic *)caf)->static_link = caf_list;
+ caf_list = caf;
+
+ RELEASE_SM_LOCK;
+}
+
/* -----------------------------------------------------------------------------
Nursery management.
-------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
- * $Id: StoragePriv.h,v 1.23 2002/12/11 15:36:54 simonmar Exp $
+ * $Id: StoragePriv.h,v 1.24 2002/12/19 14:33:23 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
extern generation *oldest_gen;
extern void newCAF(StgClosure*);
+extern void newDynCAF(StgClosure *);
extern void move_TSO(StgTSO *src, StgTSO *dest);
extern StgTSO *relocate_stack(StgTSO *dest, ptrdiff_t diff);