1 /* Copyright (C) 1999-2006 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 typedef uint32_t GC_sourceNameIndex
;
13 #define FMTSNI "%"PRISNI
15 typedef uint32_t GC_sourceLabelIndex
;
17 #define FMTSLI "%"PRISLI
19 typedef uint32_t GC_sourceIndex
;
21 #define FMTSI "%"PRISI
23 #define SOURCES_INDEX_UNKNOWN 0
24 #define SOURCES_INDEX_GC 1
26 typedef uint32_t GC_sourceSeqIndex
;
28 #define FMTSSI "%"PRISSI
30 #define SOURCE_SEQ_UNKNOWN 0
31 #define SOURCE_SEQ_GC 1
33 typedef struct GC_source
{
34 GC_sourceNameIndex sourceNameIndex
;
35 GC_sourceSeqIndex successorSourceSeqIndex
;
38 typedef struct GC_sourceLabel
{
40 GC_sourceSeqIndex sourceSeqIndex
;
43 struct GC_sourceMaps
{
44 volatile GC_sourceSeqIndex curSourceSeqsIndex
;
45 /* frameSources is an array of cardinality frameLayoutsLength that
46 * for each stack frame, gives an index into sourceSeqs of the
47 * sequence of source functions corresponding to the frame.
49 GC_sourceSeqIndex
*frameSources
;
50 uint32_t frameSourcesLength
;
51 struct GC_sourceLabel
*sourceLabels
;
52 uint32_t sourceLabelsLength
;
54 uint32_t sourceNamesLength
;
55 /* Each entry in sourceSeqs is a vector, whose first element is a
56 * length, and subsequent elements index into sources.
58 uint32_t **sourceSeqs
;
59 uint32_t sourceSeqsLength
;
60 /* sources is an array of cardinality sourcesLength. Each entry
61 * specifies an index into sourceNames and an index into sourceSeqs,
62 * giving the name of the function and the successors, respectively.
64 struct GC_source
*sources
;
65 uint32_t sourcesLength
;
68 #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */
70 #if (defined (MLTON_GC_INTERNAL_FUNCS))
72 static inline GC_sourceSeqIndex
getCachedStackTopFrameSourceSeqIndex (GC_state s
);
74 static inline char* getSourceName (GC_state s
, GC_sourceIndex i
);
76 #if HAS_TIME_PROFILING
77 static inline int compareSourceLabels (const void *v1
, const void *v2
);
78 static void sortSourceLabels (GC_state s
);
79 static void compressSourceLabels (GC_state s
);
80 static void initSourceLabels (GC_state s
);
83 static void showSources (GC_state s
);
85 #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */
87 #if (defined (MLTON_GC_INTERNAL_BASIS))
89 PRIVATE
char* GC_sourceName (GC_state s
, GC_sourceIndex i
);
91 #endif /* (defined (MLTON_GC_INTERNAL_BASIS)) */