Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement named return value optimization in the frontend #788

Closed
steveklabnik opened this issue Feb 2, 2015 · 3 comments
Closed

implement named return value optimization in the frontend #788

steveklabnik opened this issue Feb 2, 2015 · 3 comments

Comments

@steveklabnik
Copy link
Member

Issue by mahkoh
Monday Oct 27, 2014 at 13:24 GMT

For earlier discussion, see rust-lang/rust#18363

This issue was labelled with: I-enhancement, I-slow in the Rust repository


extern crate test;

pub struct X {
    x: [u8, ..1 << 10],
}

pub fn f() -> X {
    let mut x: X = unsafe { std::mem::uninitialized() };
    for i in range(0, x.x.len()) {
        x.x[i] = i as u8;
    }
    x
}

fn main() {
    let x = f();
    test::black_box(&x);
}

This function needs 2k stack space even though f is being inlined.

@michaelwu
Copy link

Having this would help a bunch with the spidermonkey upgrade in servo. Spidermonkey needs us to provide pointers to structs on the stack, but we can't easily do it in the constructor function since the struct is moved when returned. We're currently using return_address() to work around this, but this doesn't scale well when constructors are nested.

@briansmith
Copy link

Wasn't it a mistake to move this to the RFC repo? It is just a missed optimization. I don't think it requires an RFC.

@emberian
Copy link
Member

this should be closed in favor of rust-lang/rust#32966

@eddyb eddyb closed this as completed Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants