make string/bytes distinguishable in bytecode#1617
make string/bytes distinguishable in bytecode#1617hhugo wants to merge 10 commits intoocaml:trunkfrom
Conversation
|
For people reading emails only, I've amended the feature description:
|
| "%caml_string_set32u", Pstring_set_32(true); | ||
| "%caml_string_set64", Pstring_set_64(false); | ||
| "%caml_string_set64u", Pstring_set_64(true); | ||
| "%caml_string_set16", Pbytes_set_16(false); |
There was a problem hiding this comment.
Is there a good reason to keep the old names %caml_string_set*? I agree that backwards compatibility is generally good, but am just wondering.
There was a problem hiding this comment.
As @xclerc pointed out, a library such as ocp-indent will benefit from this backwards compatible change.
There was a problem hiding this comment.
Several packages were broken by a previous version of a similar change by Hongbo that turned %string_safe_set into %bytes_safe_set -- see #596 (comment) . I would be wary of changing the external-referenceable name of a primitive.
byterun/str.c
Outdated
| /** | ||
| * [caml_string_set16] is deprecated, | ||
| * use [caml_bytes_set16] instead | ||
| */ |
There was a problem hiding this comment.
What is the reason for keeping these caml_string_set* C primitives? AFAICS they are not exposed to user code and not used by the bytecode interpreter.
There was a problem hiding this comment.
I guess it is related to your previous comment, but someone might
reference them through external, e.g. ocp-endian.
There was a problem hiding this comment.
But they would reference the %caml_string_set* name, not the C primitive, right?
There was a problem hiding this comment.
Sorry, you meant "make the old OCaml primitive name point to a new C symbol"?
I think there could still be a problem, with an .o file generated by a previous version
of the compiler and then linked with the new runtime; however, if magic numbers are
bumped it should not be a problem (cannot remember whether magic numbers are
automatically bumped nowadays).
There was a problem hiding this comment.
Yes, bumping the magic number would do the trick; I don't think supporting "old-with-new" linking is a good idea anyway.
There was a problem hiding this comment.
I've made the change.
7ff7b7b to
ef36776
Compare
|
I expect the tests to pass now. |
I'm not sure what this is about.. |
|
hhugo (2018/02/20 12:24 -0800):
```
File "/home/travis/build/ocaml/ocaml/toplevel/opttopmain.ml", line 213, characters 24-29:
Error: Unbound value unset
Hint: Did you mean set?
make: *** [toplevel/opttopmain.cmx] Error 2
```
I'm not sure what this is about..
My bad, sorry.
Fixed on latest trunk.
|
|
|
|
This patch looks correct to me, and it should be backwards compatible thanks to leaving the name of old externals However, I think the |
|
Warning: this PR contains a bootstrap. (Several, actually.) According to house regulations it will have to be merged manually by a core developer. |
Indeed, but I think it was agreed recently that we'd change all the magic numbers between each major release anyway. |
|
@hhugo could you reorder the commits (moving up the marshall commit) so we only have to deal with two bootstraps instead of three? Also, rebase Changes (but not the bootstrap compilers, they are a nice reminder that we need to merge manually). |
|
Not sure what you meant by
This PR now only include 2 bootstraps |
|
I guess this PR needs a formal approval and a core-dev to manual merge & redo the bootstraps. |
|
@hhugo Yes, will do. |
Rebase of #1617 (make string/bytes distinguishable in bytecode)
|
Merged as #1659, thanks! |
|
Thanks for all the boostraps |
Follow up to #596.
This PR move the distinction between bytes and string down to the bytecode.
This should allow the js_of_ocaml compiler to choose different runtime representation for
bytesandstring(when safe-string is on).The most important changes are:
Bytes.unsafe_to_string&Bytes.unsafe_of_stringare no longer no-op and now call into the C runtime. The native compilation is unchanged.%string_unsafe_get, different from the instruction used for%bytes_unsafe_get