3 ms·
Understood, but I'm not ready to give up on this just yet :-) I know you think this is a futile effort, but I'd welcome any improvements from someone who knows
by udp 15y ago
Understood, but I'm not ready to give up on this just yet :-)
I know you think this is a futile effort, but I'd welcome any improvements from someone who knows more about the engine internals than I do. I'm currently working out what I can do instead of rooting every ValueRef.
- apaprocki 15y agoFor the rooting, you can't know if someone is storing you on the stack unless you get hack-y[1]. So you'd have to assume the opposite, that the caller is storing you on the stack and give them something like .root() to call if they are not. [1] In the end, the way stack-scanning GC works is that it has OS-specific code (see jsnativestack.cpp[2] in SM) to get the highest stack address (stack grows down in all the archs you care about). Then since you know someone is calling into your constructor, you can declare a variable on the stack and get its address to find out the current stack pointer. If 'this' is between the current stack pointer and the stack base, you are on the stack and do not need to root yourself.[3] [2] http://hg.mozilla.org/mozilla-central/file/a1b89b4913ca/js/src/jsnativestack.cpp http://hg.mozilla.org/mozilla-central/file/a1b89b4913ca/js/s... [3] I coded an example up to show you (it uses an OSX-specific pthread API to get the stack base -- see the SM code for other platforms) http://pastebin.com/dVDGWJP5 http://pastebin.com/dVDGWJP5