[MLton-devel] walking the stack for profiling

Stephen Weeks MLton@mlton.org
Thu, 12 Dec 2002 10:59:40 -0800


I would like to write some code in the C "catcher" function used for
profiling that handles SIGPROF and bumps the appropriate counter.  I
want this code to walk down the stack frames so that I can record what
functions are on the stack.  In order to do this, I need to get access
to the stack top.  I would like to use gcState.stackTop, and I need to
make sure that it contains the correct value.  I'm not worried about
signals during GC, since I don't plan to walk the stack then.  But I
am worried about getting the correct value while user code is
running.  I have two concerns.

1. I see in x86-mlton-basic.fun that the stack top is
Classes.GCStateHold.  I assume that this means that the register
allocator can hold the stack top in a register, which would mean that
the value in gcState could be wrong.

2. I see in x86-generate-transfers.fun that when making a nontail call
the stack top is modified to point at the callee frame before pushing
the return address, and hence the stack top is pointing at a bogus
frame (for a very short time).

Would it be possible to modify the native codegen (with some
reorderings and flushes and ...) so that gcState.stackTop always
points at a reasonable stack, without significant performance impact?




-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel