From: Martin L. <le...@di...> - 2010-01-17 21:14:55
|
Hi All. In the TinyOS 8051 wg we would like to be able to dump some information about which functions that are called from async context. The reason we want this info, comes from optimisations that are usually applied in 8051 compilers - functions are not reentrant by default, but have to be marked individually, and we would like to use the async annotation from nesc to do that. As far as I can tell the -fnesc-dump system only dumps information on the input program, not on the generated code, but what I would like to do is be able to do something like a dump on all functions that are analyse to be async by nesc. How is not particularly important, but I have attached two patches to illustrate what I'm thinking - neither is particularly pretty, so please share your thoughts on what a real solution could look like. async_filter Adds an "async" filter, to allow something like -fnesc-dump=functions(async) async_attribute: A quick-and-dirty hack to make Nesc add an __attribute((async)) The slightly longer explanation as to why, is the following. As a way around the limited 8051 stack, Keil (and others) uses two optimisations: first a compile time stack and second it uses overlaying between separate compile-time stack elements. This approach has the drawback that all functions are by default non-reentrant. Which means that unless great care is taken the generated code could be severely broken (e.g. interrupt handlers). As a result Keil analyses the code and identifies all culprits, but it has no feature to automatically apply the appropriate fix - it relies on the user to understand and react to the warning. As we are using Keil to compile Nesc generated code this is highly unlikely. And even if appropriate markings are made in the source, the output may still contain nesc-glue functions that did not exist in the input. Disabling the optimisations altogether is not very attractive either, since this has a major impact on performance. Our current hack relies on using the warning from a previous Keil run to mark function in the next run. This is not very elegant and limited to Keil. We would like a general solution that would work with other compilers as well and we believe that taking advantage of the async context of TinyOS would be one way to do that. -- Regards Martin Leopold. |