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

Remove unnecessary logic in new_stack_fast #3566

Closed
brson opened this Issue Sep 23, 2012 · 3 comments

Comments

Projects
None yet
4 participants
@brson
Contributor

brson commented Sep 23, 2012

Currently looks like this:

    // The minimum stack size, in bytes, of a Rust stack, excluding red zone                                       
    size_t min_sz = sched_loop->min_stack_size;                                                                    

    // Try to reuse an existing stack segment                                                                      
    if (stk != NULL && stk->next != NULL) {                                                                        
        size_t next_sz = user_stack_size(stk->next);                                                               
        if (min_sz <= next_sz && requested_sz <= next_sz) {                                                        
            stk = stk->next;                                                                                       
            return;                                                                                                
        }                                                                                                          
    }  

I think that min_sz <= next_sz is an invariant. We should never be allocating a next_sz that is smaller than min_stack_siz. Change it to an assert (that it preferably disabled when RUST_NBEBUG). This saves a number of instructions and makes accessing the sched_loop unnecessary on the fast path.

@catamorphism

This comment has been minimized.

Show comment
Hide comment
@catamorphism

catamorphism May 23, 2013

Contributor

Nominating for milestone 5, production-ready

Contributor

catamorphism commented May 23, 2013

Nominating for milestone 5, production-ready

@graydon

This comment has been minimized.

Show comment
Hide comment
@graydon

graydon Jun 20, 2013

Contributor

just a bug, removing milestone/nomination.

Contributor

graydon commented Jun 20, 2013

just a bug, removing milestone/nomination.

@cmr

This comment has been minimized.

Show comment
Hide comment
@cmr

cmr Aug 19, 2013

Member

oldrt gone, closing.

Member

cmr commented Aug 19, 2013

oldrt gone, closing.

@cmr cmr closed this Aug 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment