{"size": 1838, "ext": "scrbl", "max_stars_repo_path": "scribblings/optimizations.scrbl", "max_stars_repo_name": "pmatos/racket-binaryen", "max_stars_repo_stars_event_min_datetime": "2021-03-01T10:18:31.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-27T00:09:14.000Z", "max_issues_repo_path": "scribblings/optimizations.scrbl", "max_issues_repo_name": "pmatos/racket-binaryen", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scribblings/optimizations.scrbl", "max_forks_repo_name": "pmatos/racket-binaryen", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 12, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 57.4375, "max_line_length": 253, "alphanum_fraction": 0.739390642}
#lang scribble/manual

@title{Optimizations}

Binaryen can optimize your webassembly program and many functions depends on the global optimization levels set. This API section describes which levels can be tuned and which facilities are provided to change the levels.

@defproc[(optimize-level? [x any/c]) boolean?]{
 Checks if the value @racket[x] is a valid optimize level.}

@defproc[(shrink-level? [x any/c]) boolean?]{
 Checks if the value @racket[x] is a valid shrink level.}

@defproc[(optimize-level) exact-nonnegative-integer?]{
 Returns the current global optimize level.}

@defproc[(shrink-level) exact-nonnegative-integer?]{
 Returns the current global shrink level.}

@defproc[(set-optimize-level! [n exact-nonnegative-integer?]) void?]{
 Sets the current optimize level to @racket[n]. Any positive value is positive but it only makes a different until @racket[4], inclusive. So @racket[0] stands for the usual @tt{-O0}, @racket[1] for @tt{-O1}, etc, until @racket[4] standing for @tt{-O4}.}

@defproc[(set-shrink-level! [n exact-nonnegative-integer?]) void?]{
 Sets the current shrink level to @racket[n]. Any positive value is positive but it only makes a different until @racket[2], inclusive. So @racket[0] stands for the usual @tt{-O0}, @racket[1] for @tt{-Os}, and @racket[2] for @tt{-Oz}.}

@defform[(with-optimize-level n body ...)]{
 Evaluates the @racket[body ...] forms in sequence with the optimize level set to @racket[n]. After the evaluation of all the forms or if the control jumps out of this form, the optimize level is reset to its old value.}

@defform[(with-shrink-level n body ...)]{
 Evaluates the @racket[body ...] forms in sequence with the shrink level set to @racket[n]. After the evaluation of all the forms or if the control jumps out of this form, the shrink level is reset to its old value.}


