1 /* Copyright (C) 1999-2008 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))
11 /* ---------------------------------------------------------------- */
12 /* Object hash consing */
13 /* ---------------------------------------------------------------- */
15 typedef uint32_t GC_hash
;
16 #define GC_HASH_SIZE sizeof(GC_hash)
17 #define PRIxHASH PRIx32
18 #define FMTHASH "0x%08"PRIxHASH
20 typedef struct GC_objectHashElement
{
23 } *GC_objectHashElement
;
25 typedef struct GC_objectHashTable
{
26 struct GC_objectHashElement
*elements
;
27 bool elementsIsInHeap
;
28 uint32_t elementsLengthCur
;
29 uint32_t elementsLengthMax
;
30 uint32_t elementsLengthMaxLog2
;
32 } *GC_objectHashTable
;
34 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */
36 #if (defined (MLTON_GC_INTERNAL_FUNCS))
38 static inline GC_objectHashTable
allocHashTable (GC_state s
);
39 static inline void freeHashTable (GC_objectHashTable t
);
41 static inline pointer
insertHashTableElem (GC_state s
,
42 GC_objectHashTable t
, GC_hash hash
,
43 pointer object
, pointer max
, bool mightBeThere
);
44 static inline void growHashTableMaybe (GC_state s
, GC_objectHashTable t
);
46 static pointer
hashConsPointer (GC_state s
, pointer object
, bool countBytesHashConsed
);
47 static inline void shareObjptr (GC_state s
, objptr
*opp
);
49 static void printBytesHashConsedMessage (size_t bytesHashConsed
, size_t bytesExamined
);
51 #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */