Skip to content
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

Refactor the code for bit syntax construction #8697

Merged

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Aug 5, 2024

Refactor and clean up code for the construction of integer segments of dynamic size. See the description of each commit for more details.

Since the next commits touch code that create float segments,
make sure that we have thorough tests for constructing
float segments.
The first implementation of the bit syntax was done in Erlang/OTP R7B
before the SMP emulator (the multi-threaded runtime system).
Therefore, global variables were used to keep track of the binary
being constructed.

When the SMP emulator was introduced, the state of the
binary being constructed needed to be local for each
scheduler thread. To reduce the need for extensive rewrites,
macros were used to automagically pass references
to the binary construction state to the helper functions
in erl_bits.c.

Now bite the bullet and remove these macros. Also take the opportunity
to remove the "new" part from function names. They are not exactly
new.
The main optimization is breaking apart the `erts_bs_put_integer()`
function into the two functions `erts_bs_put_integer_be()` and
`erts_bs_put_integer_le()` to avoid runtime checks of the endianness.
@bjorng bjorng added team:VM Assigned to OTP team VM enhancement testing currently being tested, tag is used by OTP internal CI labels Aug 5, 2024
@bjorng bjorng requested a review from jhogberg August 5, 2024 08:19
@bjorng bjorng self-assigned this Aug 5, 2024
Copy link
Contributor

github-actions bot commented Aug 5, 2024

CT Test Results

    3 files    141 suites   50m 34s ⏱️
1 587 tests 1 537 ✅ 49 💤 1 ❌
2 291 runs  2 221 ✅ 69 💤 1 ❌

For more details on these failures, see this check.

Results for commit 10b6aee.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

erts/emulator/beam/erl_bits.c Outdated Show resolved Hide resolved
The `erts_copy_bits()` function is overly general, preventing the C
compiler from doing any serious loop optimization. Replace it with the
new `erts_copy_bits_fwd()` and `erts_copy_bits_rev()` functions.
@bjorng bjorng force-pushed the bjorn/erts/refactor-bit-syntax-construction branch from aebac34 to 10b6aee Compare August 23, 2024 05:13
@bjorng bjorng merged commit 0671a3f into erlang:master Aug 30, 2024
15 of 17 checks passed
@bjorng bjorng deleted the bjorn/erts/refactor-bit-syntax-construction branch August 30, 2024 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants