Skip to content

Optimize native wrappers #1192

Description

@nikomatsakis

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).

Activity

  1. brson commented on Mar 6, 2012

    @brson
    Contributor

    The most unfortunate thing about our current scheme is the cache misses (#1801)

  2. catamorphism commented on May 27, 2013

    @catamorphism
    Contributor

    Doesn't seem like a backwards-compatibility thing. Nominating for milestone 5, production-ready.

  3. graydon commented on May 30, 2013

    @graydon
    Contributor

    native wrappers are all going away, closing this, made obsolete by #6661

  4. added a commit that references this issue on Sep 19, 2021
    c11d8f5
  5. added 2 commits that reference this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-codegenArea: Code generationI-slowIssue: Problems and improvements with respect to performance of generated code.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions