Skip to content

Commit

Permalink
Use __builtin_ctz in dlmalloc
Browse files Browse the repository at this point in the history
This operation maps to the WebAssembly instruction `i32.ctz`. Without this, the
`compute_bit2idx` macro falls back to a C implementation which does not seem to
be detected as a ctz operation by clang at `-O3`.
  • Loading branch information
binji committed Nov 11, 2022
1 parent e05f385 commit 39a7a63
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion system/lib/dlmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\

/* index corresponding to given bit. Use x86 asm if possible */

#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__) || defined(__EMSCRIPTEN__))
#define compute_bit2idx(X, I)\
{\
unsigned int J;\
Expand Down

0 comments on commit 39a7a63

Please sign in to comment.