1 /* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
9 #if (defined (MLTON_GC_INTERNAL_TYPES))
12 * Weak objects have the following layout:
16 * link (native-pointer) ::
17 * objptr (object-pointer)
19 * The object type indexed by the header determines whether the weak
20 * is valid or not. If the type has numObjptrs == 1, then the weak
21 * pointer is valid. Otherwise, the type has numObjptrs == 0 and the
22 * weak pointer is not valid.
24 * There may be zero or more bytes of padding for alignment purposes.
26 * The link native-pointer is used to chain the live weaks together
27 * during a copying/mark-compact gc and is otherwise unused.
29 * The final component is the weak object-pointer.
31 * Note that the order of the fields is important. The non-objptr
32 * field must be first, because a weak object is sometimes treated as
35 typedef struct GC_weak
{
38 } __attribute__ ((packed
)) *GC_weak
;
40 COMPILE_TIME_ASSERT(GC_weak__packed
,
41 sizeof(struct GC_weak
) ==
42 sizeof(struct GC_weak
*)
45 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */
47 #if (defined (MLTON_GC_INTERNAL_FUNCS))
49 static inline size_t sizeofWeak (GC_state s
);
50 static inline size_t offsetofWeak (GC_state s
);
52 #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */
54 #if (defined (MLTON_GC_INTERNAL_BASIS))
56 PRIVATE
uint32_t GC_weakCanGet (GC_state s
, pointer p
);
57 PRIVATE pointer
GC_weakGet (GC_state s
, pointer p
);
58 PRIVATE pointer
GC_weakNew (GC_state s
, GC_header header
, pointer p
);
60 #endif /* (defined (MLTON_GC_INTERNAL_BASIS)) */