Skip to content

Commit

Permalink
feature: we added the '-msse4.2' and '-march' CC options to always dy…
Browse files Browse the repository at this point in the history
…namically enable the CRC32 string hashing optimization.
  • Loading branch information
thibaultcha committed Jan 14, 2020
1 parent 07c120e commit ca7271f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ local newstate = jit.prngstate(123456)
**syntax:** *ok = jit.crc32()*

Returns a boolean value indicating if the current architecture supports a CRC32
instruction set.

CRC32 support will be checked at runtime if LuaJIT was compiled with `-msse4.2`
on x64 architectures, or `-march=armv8-a+crc` on ARM64.
instruction set. CRC32 support will be checked at runtime on x64 and ARM64
platforms.

CRC32 support allows for this branch to use an optimized string hashing
algorithm. See the [String hashing](#string-hashing) section for details on
Expand Down Expand Up @@ -285,10 +283,8 @@ but makes hash collision attacks harder for strings up to 127 bytes of size
(see `lj_str_new()`).

This optimization is only available for x64 and ARM64 architectures, and will
be enabled if:

1. LuaJIT is compiled with `-msse4.2` on x64, or `-march=armv8-a+crc` on ARM64.
2. A CRC32 instruction set is detected at runtime (see [jit.crc32](#jitcrc32)).
be enabled if a CRC32 instruction set is detected at runtime (see
[jit.crc32](#jitcrc32)).

**Note:** This optimization can be disabled by compiling LuaJIT with
`-DLJ_OR_DISABLE_STRHASHCRC32`.
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ CCOPT= -O2 -fomit-frame-pointer
# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
# the binaries to a different machine you could also use: -march=native
#
CCOPT_x86= -march=i686 -msse -msse2 -mfpmath=sse
CCOPT_x86= -march=i686 -msse -msse2 -msse4.2 -mfpmath=sse
CCOPT_x64=
CCOPT_arm=
CCOPT_arm64=
CCOPT_arm64= -march=armv8-a+crc
CCOPT_ppc=
CCOPT_mips=
#
Expand Down

0 comments on commit ca7271f

Please sign in to comment.