graydon/rust — Issue #1192: Optimize native wrappers
Author: nikomatsakis
Created: 2011-11-19 02:10:00+00:00
State: open

As of @b6af844, we generate Rust wrappers for native functions. These allow for easy interop with Rust code but introduce some performance inefficiencies. This could be improved in two ways:

1. Inline the calls to the wrapper functions. Ideally, this would be done at the LLVM level as part of a general inlining pass, so as not to complicate trans.

2. Specialize to the i386 architecture (and possibly other targets as well). In i386 in particular, we could eliminate some copies by writing the function arguments directly into memory allocated using alloc_on_c_stack(), as we used to do originally. This was removed because it does not apply to x86_64 nor does it work well for stdcall functions (layout on stack is different), whereas the current technique lets LLVM handle details of the target calling convention. Nonetheless, if it is deemed worthwhile, we could specialize the case of cdecl functions on i386 (and stdcall, for that matter).