Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
1122-Introduce-erts_copy_bits_restricted.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1122-Introduce-erts_copy_bits_restricted.patch of Package erlang
From 162529c5a0685e24072a22d8302b1b76c704c7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Tue, 17 May 2022 10:19:33 +0200 Subject: [PATCH 2/3] Introduce erts_copy_bits_restricted() Useful for the JIT because it has fewer arguments and thus can be called using fewer instructions. --- erts/emulator/beam/erl_bits.c | 21 ++++++++++++++++++++- erts/emulator/beam/erl_bits.h | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/erts/emulator/beam/erl_bits.c b/erts/emulator/beam/erl_bits.c index 108842a54f..da24aae054 100644 --- a/erts/emulator/beam/erl_bits.c +++ b/erts/emulator/beam/erl_bits.c @@ -884,7 +884,7 @@ erts_new_bs_put_integer(ERL_BITS_PROTO_3(Eterm arg, Uint num_bits, unsigned flag if (fmt_int(iptr, NBYTES(num_bits), arg, num_bits, flags) < 0) { return 0; } - erts_copy_bits(iptr, 0, 1, erts_current_bin, bin_offset, 1, num_bits); + erts_copy_bits_restricted(iptr, erts_current_bin, bin_offset, num_bits); } erts_bin_offset = bin_offset + num_bits; return 1; @@ -2150,6 +2150,25 @@ erts_cmp_bits(byte* a_ptr, size_t a_offs, byte* b_ptr, size_t b_offs, size_t siz return 0; } +/* + * Restricted version of copy_bits() for copying from a buffer into + * a binary. Direction is always forward and the source offset is always + * zero. + */ +void +erts_copy_bits_restricted(byte* src, /* Base pointer to source. */ + byte* dst, /* Base pointer to destination. */ + size_t doffs, /* Bit offset for destination relative to dst. */ + size_t n) /* Number of bits to copy. */ +{ + if (doffs == 0) { + abort(); + } + ASSERT(n != 0); + ASSERT(doffs != 0); + erts_copy_bits(src, 0, 1, dst, doffs, 1, n); +} + /* * The basic bit copy operation. Copies n bits from the source buffer to * the destination buffer. Depending on the directions, it can reverse the diff --git a/erts/emulator/beam/erl_bits.h b/erts/emulator/beam/erl_bits.h index 34af1051d4..136d3357ce 100644 --- a/erts/emulator/beam/erl_bits.h +++ b/erts/emulator/beam/erl_bits.h @@ -188,7 +188,8 @@ Eterm erts_bs_init_writable(Process* p, Eterm sz); * Common utilities. */ void erts_copy_bits(byte* src, size_t soffs, int sdir, - byte* dst, size_t doffs,int ddir, size_t n); + byte* dst, size_t doffs,int ddir, size_t n); +void erts_copy_bits_restricted(byte* src, byte* dst, size_t doffs, size_t n); int erts_cmp_bits(byte* a_ptr, size_t a_offs, byte* b_ptr, size_t b_offs, size_t size); -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor