Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | /* Copyright (C) 1999-2005 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 | void numStackFramesAux (GC_state s, | |
10 | __attribute__ ((unused)) GC_frameIndex i) { | |
11 | s->callStackState.numStackFrames++; | |
12 | } | |
13 | ||
14 | uint32_t GC_numStackFrames (GC_state s) { | |
15 | s->callStackState.numStackFrames = 0; | |
16 | foreachStackFrame (s, numStackFramesAux); | |
17 | if (DEBUG_CALL_STACK) | |
18 | fprintf (stderr, "%"PRIu32" = GC_numStackFrames\n", | |
19 | s->callStackState.numStackFrames); | |
20 | return s->callStackState.numStackFrames; | |
21 | } | |
22 | ||
23 | void callStackAux (GC_state s, GC_frameIndex i) { | |
24 | if (DEBUG_CALL_STACK) | |
25 | fprintf (stderr, "callStackAux ("FMTFI")\n", i); | |
26 | s->callStackState.callStack[s->callStackState.numStackFrames] = i; | |
27 | s->callStackState.numStackFrames++; | |
28 | } | |
29 | ||
30 | void GC_callStack (GC_state s, pointer p) { | |
31 | if (DEBUG_CALL_STACK) | |
32 | fprintf (stderr, "GC_callStack\n"); | |
33 | s->callStackState.numStackFrames = 0; | |
34 | s->callStackState.callStack = (uint32_t*)p; | |
35 | foreachStackFrame (s, callStackAux); | |
36 | } | |
37 | ||
38 | uint32_t* GC_frameIndexSourceSeq (GC_state s, GC_frameIndex frameIndex) { | |
39 | uint32_t *res; | |
40 | ||
41 | res = s->sourceMaps.sourceSeqs[s->sourceMaps.frameSources[frameIndex]]; | |
42 | if (DEBUG_CALL_STACK) | |
43 | fprintf (stderr, FMTPTR" = GC_frameIndexSourceSeq ("FMTFI")\n", | |
44 | (uintptr_t)res, frameIndex); | |
45 | return res; | |
46 | } |