-
Notifications
You must be signed in to change notification settings - Fork 197
Implement float primitives for 4.13 #1113
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
Conversation
|
You can declare externals in your test directly. Just copy paste signature from ocaml master |
|
I'd probably put new functions in the ieee_754.js file next to other related functions |
|
Moved the functions to var caml_sinh_float = Math.sinh || function (x) { return (Math.exp(x) - Math.exp(-x)) / 2; } |
|
Looks like Anyway, I take it that tests should go in |
runtime/ieee_754.js
Outdated
| return function cbrt(x) { | ||
| return x < 0 ? -pow(x, 1/3) : pow(x, 1/3); | ||
| }; | ||
| })(Math.pow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pass pow in like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these polyfill implementations are taken from the MDN docs. This one, in particular was taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt
|
Added some tests. The situation is not ideal because the ocaml stdlib doesn't have these functions defined yet, so these tests can't be run in native mode (I disabled native mode for all the tests in this directory, but if there's no workaround, I should probably put the float tests in their own library so we can disable native code for just the float tests. |
We don't need polyfill for things that are well supported. It's possible that polyfill were added in the past if support was not great at the time. |
Maybe move the tests in theirs on lib for now. |
The fma implementation is taken from https://gist.github.com/Yaffle/fb47de4c18b63147699e0b621f1031f7 The tests were taken directly from the ocaml testsuite and modified to be expect-tests.
|
I've tested your PR with 4.13 and made a small fix regarding nan printing in the tests. I've also rebased your work on top of the latest master. |
|
Would you mind adding a changelog entry ? |
|
Ahh, sorry for being slow to correct the formatting and changelog. Thanks! |
|
Thanks for working on this |
…s_of_ocaml-ppx_deriving_json, js_of_ocaml-ppx, js_of_ocaml-ocamlbuild, js_of_ocaml-lwt and js_of_ocaml-compiler (3.10.0) CHANGES: ## Features/Changes * Compiler: add support for OCaml 4.13 * Compiler: new tool to check for missing primitives * Compiler: drop support for OCaml 4.03 and bellow * Lib: add offsetX and offsetY to Dom_html.mouseEvent * Lib: add innerText property for Dom_html * Runtime: add dummy implementation for many dummy primitives * Runtime: add runtime for new float operation in 4.13 ocsigen/js_of_ocaml#1113 (by pmwhite) ## Misc * manual/rev_bindings.wiki: fix compilation error
fix #897
This isn't finished by any means. What's missing is
fmaMy plan for 1 is to port the native ocaml runtime's C implementation to javascript. However, I'm not sure how to do 2, since the stdlib for ocaml 4.12 does not provide functions like
Float.atanhorFloat.acosh, so I can't even access the primitives in a straightforward way.If I were to write tests and run them locally using an opam switch with the 4.13 compiler, it would still break the current CI. This seems like blocker for merging this PR, since it presumably will be impossible to test until 4.13 is released.
Am I understanding things correctly?