llvm.org GIT mirror llvm / bcb265e
Fixing the stack walker. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46302 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 11 years ago
1 changed file(s) with 7 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
9696 * FIXME: This should be in a code-generator specific library, but for now this
9797 * will work for all code generators.
9898 */
99 typedef struct FrameMap FrameMap;
99100 struct FrameMap {
100101 int32_t NumRoots; // Number of roots in stack frame.
101102 int32_t NumMeta; // Number of metadata descriptors. May be < NumRoots.
102103 void *Meta[]; // May be absent for roots without metadata.
103104 };
104105
106 typedef struct StackEntry StackEntry;
105107 struct StackEntry {
106 ShadowStackEntry *Next; // Caller's stack entry.
108 StackEntry *Next; // Caller's stack entry.
107109 const FrameMap *Map; // Pointer to constant FrameMap.
108110 void *Roots[]; // Stack roots (in-place array).
109111 };
110112 StackEntry *llvm_gc_root_chain;
111113
112114 void llvm_cg_walk_gcroots(void (*FP)(void **Root, void *Meta)) {
113 for (StackEntry *R; R; R = R->Next) {
115 StackEntry *R;
116 for (R = llvm_gc_root_chain; R; R = R->Next) {
114117 unsigned i, e;
115 for (i = 0, e = R->NumMeta; i != e; ++i)
118 for (i = 0, e = R->Map->NumMeta; i != e; ++i)
116119 FP(&R->Roots[i], R->Map->Meta[i]);
117 for (e = R->NumRoots; i != e; ++i)
120 for (e = R->Map->NumRoots; i != e; ++i)
118121 FP(&R->Roots[i], NULL);
119122 }
120123 }