-
Notifications
You must be signed in to change notification settings - Fork 133
Add support for otp25 opcodes #436
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
f6bd7da to
65d517b
Compare
96f9741 to
f7d50aa
Compare
f7d50aa to
d4f4b2d
Compare
7f29a04 to
d0f26f5
Compare
src/libAtomVM/defaultatoms.c
Outdated
| static const char *const avm_floatsize_atom = "\xD" "avm_floatsize"; | ||
|
|
||
| static const char *const append_atom = "\x6" "append"; | ||
| static const char *const private_append_atom = "\xD" "private_append"; |
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.
I counted 14 chars, so it should be "\xE".
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.
Obviously this isn't tested. I haven't encountered private_append in generated beam code but found it in BEAM source code.
Not sure if we should remove the value.
Meanwhile, I did fix the length byte.
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.
default atoms allows us to reference them as constants, that can be used with statements such as switch, therefore if it is not referenced in our code it can be safely discarded.
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.
In addition it does consume memory even if not referenced. I would prefer that defaultatoms.[ch] have a very conservative set of declarations that have a high probability of being used. ok, error, undefined all come to mind. Maybe a few others.
If possible I would err on the side of instantiating the atom only when needed, instead of at load time, but that is my personal opinion.
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.
private_append was used in the code but we had no test. I knew about it, it was a shortcoming of this PR, and was just too lazy to build an example. But then @bettio 's sharp eyes found out that it wouldn't work because the atom was wrongly defined.
So please let me do this properly as it should have been done. Scanning all OTP beams, I found many modules where this is genereated and will create a test case accordingly.
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.
I will try to take a look to this
d0f26f5 to
24b44f7
Compare
24b44f7 to
d498d02
Compare
Add the following three OTP-25 opcodes: - bs_create_bin/7 - call_fun2/3 - badrecord/1 The following opcode isn't part of this commit: - nif_start/0 But we probably do not need it. Also add the following two opcodes to extend support of bs_create_bin: - bs_init_writable - bs_private_append This adds (limited) support to binary comprehensions. Unaligned binaries are still not supported. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
Show the support for all opcodes we need to tests Signed-off-by: Paul Guyot <pguyot@kallisys.net>
d498d02 to
45ea90d
Compare
Tests pass with beams compiled with OTP-25.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later