3 ms·
The overhead that is being talked about in the blog post is mostly the impossibility to inline/optimize the C code of the callee, setting up the stack frame, et
by anonymouz 8y ago
The overhead that is being talked about in the blog post is mostly the impossibility to inline/optimize the C code of the callee, setting up the stack frame, etc.
How would OCaml avoid that?
- toolslive 8y agoIt does a reasonable job: external my_sqrt : float -> float = "caml_sqrt_float" "sqrt" [@@unboxed] [@@noalloc] let () = let x= my_sqrt 1.0 in Printf.printf "x = %f" x becomes something like: ... camlInline__entry: .cfi_startproc subq $8, %rsp .cfi_adjust_cfa_offset 8 .L102: movsd .L103(%rip), %xmm0 sqrtsd %xmm0, %xmm0 movsd %xmm0, (%rsp) movq camlInline__6@GOTPCREL(%rip), %rbx movq camlPervasives@GOTPCREL(%rip), %rax movq 208(%rax), %rax call camlPrintf__fprintf_1291@PLT ....