Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Vadim <vadimcn <at> gmail.com>
Subject: Position-independent stacks
Newsgroups: gmane.comp.compilers.llvm.devel
Date: Thursday 23rd January 2014 06:10:59 UTC (over 3 years ago)
Hi,
I am toying with an idea of having LLVM generate code that has
position-independent stacks.   This would be a very useful property for
implementing all sorts of micro-thread libraries (I am thinking something
similar to Python greenlets <http://stackoverflow.com/a/17447308>),
because
you'd be able to easily save threadlet state from one OS thread and later
restore it into another.

On the surface, it seems entirely do-able - basically, one needs to get rid
of all the things that point into the stack.  It should be sufficient to:
1. write a function pass that finds all local variables, whose address is
ever taken, and hoists them into a heap-allocated secondary "stack frame",
2. either turn off frame base pointers, or make sure they are adjusted
after the stack had been relocated,
3. ... can't think of anything else, actually.

What do you guys think?  Any reasons this approach wouldn't fly?

Vadim
 
CD: 3ms