Age | Commit message (Collapse) | Author |
|
For a long time, there has been the two macros IS_SSMALL() and
MY_IS_SSMALL() that do exactly the same thing.
There should only be one, and it should be called IS_SSMALL().
However, we must decide which implementation to use. When
MY_IS_SSMALL() was introduced a long time ago, it was the most
efficient. In a modern C compiler, there might not be any
difference.
To find out, I used the following small C program to examine
the code generation:
#include <stdio.h>
typedef unsigned int Uint32;
typedef unsigned long Uint64;
typedef long Sint;
#define SWORD_CONSTANT(Const) Const##L
#define SMALL_BITS (64-4)
#define MAX_SMALL ((SWORD_CONSTANT(1) << (SMALL_BITS-1))-1)
#define MIN_SMALL (-(SWORD_CONSTANT(1) << (SMALL_BITS-1)))
#define MY_IS_SSMALL32(x) (((Uint32) ((((x)) >> (SMALL_BITS-1)) + 1)) < 2)
#define MY_IS_SSMALL64(x) (((Uint64) ((((x)) >> (SMALL_BITS-1)) + 1)) < 2)
#define MY_IS_SSMALL(x) (sizeof(x) == sizeof(Uint32) ? MY_IS_SSMALL32(x) : MY_IS_SSMALL64(x))
#define IS_SSMALL(x) (((x) >= MIN_SMALL) && ((x) <= MAX_SMALL))
void original(Sint n)
{
if (IS_SSMALL(n)) {
printf("yes\n");
}
}
void enhanced(Sint n)
{
if (MY_IS_SSMALL(n)) {
printf("yes\n");
}
}
gcc 7.2 produced the following code for the original() function:
.LC0:
.string "yes"
original(long):
movabs rax, 576460752303423488
add rdi, rax
movabs rax, 1152921504606846975
cmp rdi, rax
jbe .L4
rep ret
.L4:
mov edi, OFFSET FLAT:.LC0
jmp puts
clang 5.0.0 produced the following code which is slightly better:
original(long):
movabs rax, 576460752303423488
add rax, rdi
shr rax, 60
jne .LBB0_1
mov edi, .Lstr
jmp puts # TAILCALL
.LBB0_1:
ret
.Lstr:
.asciz "yes"
However, in the context of beam_emu.c, clang could produce
similar to what gcc produced.
gcc 7.2 produced the following code when MY_IS_SSMALL() was used:
.LC0:
.string "yes"
enhanced(long):
sar rdi, 59
add rdi, 1
cmp rdi, 1
jbe .L4
rep ret
.L4:
mov edi, OFFSET FLAT:.LC0
jmp puts
clang produced similar code.
This code seems to be the cheapest. There are four instructions, and
there is no loading of huge integer constants.
|
|
|
|
|
|
* lukas/erts/fix_threads_error_printout:
erts: Print the error reason when threads fail to start
|
|
* kvakvs/zero-size-read_file/ERL-327/PR-1524/OTP-14637:
erts: On zero-size files attempt to read until EOF
|
|
|
|
|
|
* dgud/stdlib/unicode-string-bench:
stdlib: Add unicode string benchmarks
|
|
|
|
fix off by one error in docs
|
|
|
|
* bjorn/speed-up-disassembler:
Add testing of erts_debug:df() to the emulator smoke tests
Speed up erts_debug:df()
|
|
|
|
|
|
|
|
|
|
The byte_offset of sub-binaries wasn't taken into account for
ProcBins, subtly ruining the results. The test suite didn't catch
it since it didn't check for sub-binaries in particular, and only
checked for equality between variations -- not whether the output
was equal to the input.
|
|
* maint:
stdlib: Remove gs removed warning
|
|
* dgud/stdlib/remove-gs-depr:
stdlib: Remove gs removed warning
|
|
|
|
|
|
|
|
Caused warnings which could not be suppressed, if old 'gs' application
was compiled and used together with otp-20, which is fair usage even
if OTP does not support the application anymore.
|
|
It is too easy to break the disassembler. Make sure that we notice.
|
|
The test case erts_debug_SUITE:df/1 in the emulator test suite is
about 4 times faster with this change.
|
|
|
|
* siri/observer/dont-use-old-string-api:
[cdv] Don't use old string API
|
|
|
|
|
|
|
|
* anders/diameter/doc/OTP-14561:
Document new(ish) options in diameter_tcp/sctp
|
|
* anders/diameter/SoC/OTP-10927:
Simplify/complete Standards Compliance doc
|
|
|
|
* lars/make/fop-font-cache/OTP-14622:
Change number of parameters
Fix fop font-cache handling during pdf build
|
|
|
|
Two parallell doc builds running fop (as same user) could both
update the fop font-cache at the same time. The cache is now
created as an artifact in the build process.
|
|
* maint:
fprof: Make sure the receiving file can handle Unicode
|
|
* hasse/tools/fprof_unicode_fix:
fprof: Make sure the receiving file can handle Unicode
|
|
With a table. Probably no one wants to read a commented RFC, it's been
unfinished for some time, and it's difficult to get an overview from it.
|
|
See commits d3829525 (unordered), c591056b (packet), eadf4efc (sender),
636a7199 (tcp message_cb), 373cd07c (sctp message_cb)
|
|
|
|
|
|
* ingela/public_key/cert-gen/OTP-14181:
public_key, ssl: Prepare for release
public_key, ssl: Provide certitifate test data generation function in public_key
|
|
OTP-14236 requires ssl runtime dependencies to update to latest public_key.
OTP-14181 makes ssl test cases dependent on latest version latest public_key.
|
|
The ssl application uses the new function in many of its test cases.
|
|
* maint:
erts, stdlib: Fix xmllint warning
Update runtime deps to depend on new stdlib functionality
|
|
* dgud/update-runtime-deps:
Update runtime deps to depend on new stdlib functionality
|
|
|
|
It is assumed that I/O devices can handle character codes greater
than 255.
|
|
Conflicts:
lib/observer/src/crashdump_viewer.erl
lib/sasl/src/sasl.appup.src
lib/stdlib/src/stdlib.appup.src
|