-
Notifications
You must be signed in to change notification settings - Fork 189
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
Making the OCaml compiler more friendly to Js_of_ocaml #117
Comments
One more PR that might break js_of_ocaml. see comment ocaml/ocaml#14 (comment) |
What about more debug (event) information ? |
What do you mean? |
could we improve sourcemap generation with more debug information ? |
Do you have anything specific in mind? I would say we already have all the needed information: for code with debugg information, we should be able to associate to any bytecode instruction a corresponding location in the source code. |
Code like It would be better if a specific primitive |
I'm wondering whether we could do something for recursive modules as well. At the moment, we have a hack that replaces the bytecode implementation of CamlinternalMod by a JavaScript implementation. |
caml_alloc_dummy_closure => https://github.com/hhugo/ocaml/compare/jsoo_friendly |
limits due to runtime representation should/could be set from the runtime.
|
If |
OCaml is switching to immutable strings. However, as they are implemented imperatively, based on byte sequence operations, there does not seem to be any easy way to take advantage of this. |
We should probably map OCaml values to JavaScript objects rather than JavaScript arrays. Indeed, this is more memory efficient (V8 has a high overhead for arrays; the block tag would not need to be stored in the object) and potentially faster (no need for bound check when accessing fields). However, the same bytecode instruction |
How would you compile OCaml value to Js Object ? One constructor per tag and size couple ? |
@vouillon, a quick experiment with compiling ocaml blocks to Js objects shows poor performances. x2.5 slower on @jordwalke example. (deriving and marshall not updated) |
This is because you are using numeric fields. Here is what I get by manually tweaking the JavaScript output:
|
I've update the code (regression inside) to use non-numeric fields. It's better but still a little bit slower than the current implem. |
Which JavaScript engine did you try? Which version? |
this is very interesting discussion, @vouillon , how did you get such numbers? btw, it is not always correct to compile blocks and arrays differently, since some internal hacks of the compiler treat array and object in a uniform way |
That's the timings for a single program, that I manually rewrote. You're right that for making this work the OCaml compiler would have to be modified. |
This is now gone |
x-links: #1745 #1721 ocaml/ocaml#13438 |
I have recently proposed to change the definition of
Pervasives.min/max_int
so that Js_of_ocaml does not have to patch the bytecode (ocaml/ocaml#19). I'm wondering what other changes we could propose that would be useful to Js_of_ocaml.Pervasives.min/max_int
caml_alloc_dummy_closure
Sys.int_size
Sys.max_array_length
The text was updated successfully, but these errors were encountered: