js_of_ocaml icon indicating copy to clipboard operation
js_of_ocaml copied to clipboard

function inlining can prevent optimization

Open hhugo opened this issue 11 years ago • 4 comments

inlining the code of an optimizable function could make this code unoptimized https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#2-unsupported-syntax

hhugo avatar Sep 10 '14 14:09 hhugo

Indeed, we should probably disable inlining when any of the inner or outer function contain a try...with.

Also, at the moment, the toplevel of all modules are concatenated, so if there is a try...with at toplevel in any of the modules, this will affect all other modules.

vouillon avatar Sep 10 '14 19:09 vouillon

partially implemented in https://github.com/ocsigen/js_of_ocaml/pull/230 Do you see a way to split toplevels of modules into their own functions ?

hhugo avatar Sep 16 '14 21:09 hhugo

here is a simple example that fails because of the wrapping of try catch in toplevel.

let x = try 5. ** 2. with e -> raise e
let f y = y +. x
let _ = print_float (f 1.)

@Drup (is not a bug). This is the bug responsible of Failure("Some variables escaped (#1)")

hhugo avatar Sep 28 '14 13:09 hhugo

@vouillon , I have disabled try-catch wrapping for now (https://github.com/ocsigen/js_of_ocaml/commit/24f13d6d580ac98addb833aa4e71df34fcee9027)

hhugo avatar Sep 28 '14 13:09 hhugo