Import Upstream version 20180207
[hcoop/debian/mlton.git] / runtime / gc / sources.h
CommitLineData
7f918cf1
CE
1/* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 */
8
9#if (defined (MLTON_GC_INTERNAL_TYPES))
10
11typedef uint32_t GC_sourceNameIndex;
12#define PRISNI PRIu32
13#define FMTSNI "%"PRISNI
14
15typedef uint32_t GC_sourceLabelIndex;
16#define PRISLI PRIu32
17#define FMTSLI "%"PRISLI
18
19typedef uint32_t GC_sourceIndex;
20#define PRISI PRIu32
21#define FMTSI "%"PRISI
22
23#define SOURCES_INDEX_UNKNOWN 0
24#define SOURCES_INDEX_GC 1
25
26typedef uint32_t GC_sourceSeqIndex;
27#define PRISSI PRIu32
28#define FMTSSI "%"PRISSI
29
30#define SOURCE_SEQ_UNKNOWN 0
31#define SOURCE_SEQ_GC 1
32
33typedef struct GC_source {
34 GC_sourceNameIndex sourceNameIndex;
35 GC_sourceSeqIndex successorSourceSeqIndex;
36} *GC_source;
37
38typedef struct GC_sourceLabel {
39 code_pointer label;
40 GC_sourceSeqIndex sourceSeqIndex;
41} *GC_sourceLabel;
42
43struct 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.
48 */
49 GC_sourceSeqIndex *frameSources;
50 uint32_t frameSourcesLength;
51 struct GC_sourceLabel *sourceLabels;
52 uint32_t sourceLabelsLength;
53 char **sourceNames;
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.
57 */
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.
63 */
64 struct GC_source *sources;
65 uint32_t sourcesLength;
66};
67
68#endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */
69
70#if (defined (MLTON_GC_INTERNAL_FUNCS))
71
72static inline GC_sourceSeqIndex getCachedStackTopFrameSourceSeqIndex (GC_state s);
73
74static inline char* getSourceName (GC_state s, GC_sourceIndex i);
75
76#if HAS_TIME_PROFILING
77static inline int compareSourceLabels (const void *v1, const void *v2);
78static void sortSourceLabels (GC_state s);
79static void compressSourceLabels (GC_state s);
80static void initSourceLabels (GC_state s);
81#endif
82
83static void showSources (GC_state s);
84
85#endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */
86
87#if (defined (MLTON_GC_INTERNAL_BASIS))
88
89PRIVATE char* GC_sourceName (GC_state s, GC_sourceIndex i);
90
91#endif /* (defined (MLTON_GC_INTERNAL_BASIS)) */