Skip to content

Commit

Permalink
deps,src: use SIMD for normal base64 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Aug 13, 2021
1 parent 1150cfe commit 6a01a3f
Show file tree
Hide file tree
Showing 60 changed files with 5,630 additions and 0 deletions.
32 changes: 32 additions & 0 deletions LICENSE
Expand Up @@ -1603,3 +1603,35 @@ The externally maintained libraries used by Node.js are:
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

- base64, located at deps/base64/base64/, is licensed as follows:
"""
Copyright (c) 2005-2007, Nick Galbreath
Copyright (c) 2013-2019, Alfred Klomp
Copyright (c) 2015-2017, Wojciech Mula
Copyright (c) 2016-2017, Matthieu Darbois
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
173 changes: 173 additions & 0 deletions deps/base64/base64.gyp
@@ -0,0 +1,173 @@
{
'variables': {
'arm_fpu%': '',
'target_arch%': '',
},
'targets': [
{
'target_name': 'base64',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'direct_dependent_settings': {
'include_dirs': [ 'base64/include' ],
},
'sources': [
'base64/include/libbase64.h',
'base64/lib/arch/generic/codec.c',
'base64/lib/tables/tables.c',
'base64/lib/codec_choose.c',
'base64/lib/codecs.h',
'base64/lib/lib.c',
],

'conditions': [
[ 'arm_fpu=="neon" and target_arch=="arm"', {
'defines': [ 'HAVE_NEON32=1' ],
'dependencies': [ 'base64_neon32' ],
}, {
'sources': [ 'base64/lib/arch/neon32/codec.c' ],
}],

# arm64 requires NEON, so it's safe to always use it
[ 'target_arch=="arm64"', {
'defines': [ 'HAVE_NEON64=1' ],
'dependencies': [ 'base64_neon64' ],
}, {
'sources': [ 'base64/lib/arch/neon64/codec.c' ],
}],

# Runtime detection will happen for x86 CPUs
[ 'target_arch in "ia32 x64 x32"', {
'defines': [
'HAVE_SSSE3=1',
'HAVE_SSE41=1',
'HAVE_SSE42=1',
'HAVE_AVX=1',
'HAVE_AVX2=1',
],
'dependencies': [
'base64_ssse3',
'base64_sse41',
'base64_sse42',
'base64_avx',
'base64_avx2',
],
}, {
'sources': [
'base64/lib/arch/ssse3/codec.c',
'base64/lib/arch/sse41/codec.c',
'base64/lib/arch/sse42/codec.c',
'base64/lib/arch/avx/codec.c',
'base64/lib/arch/avx2/codec.c',
],
}],
],
},

{
'target_name': 'base64_ssse3',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'sources': [ 'base64/lib/arch/ssse3/codec.c' ],
'defines': [ 'HAVE_SSSE3=1' ],
'conditions': [
[ 'OS!="win"', {
'cflags': [ '-mssse3' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-mssse3' ]
},
}],
],
},

{
'target_name': 'base64_sse41',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'sources': [ 'base64/lib/arch/sse41/codec.c' ],
'defines': [ 'HAVE_SSE41=1' ],
'conditions': [
[ 'OS!="win"', {
'cflags': [ '-msse4.1' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-msse4.1' ]
},
}],
],
},

{
'target_name': 'base64_sse42',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'sources': [ 'base64/lib/arch/sse42/codec.c' ],
'defines': [ 'HAVE_SSE42=1' ],
'conditions': [
[ 'OS!="win"', {
'cflags': [ '-msse4.2' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-msse4.2' ]
},
}],
],
},

{
'target_name': 'base64_avx',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'sources': [ 'base64/lib/arch/avx/codec.c' ],
'defines': [ 'HAVE_AVX=1' ],
'conditions': [
[ 'OS!="win"', {
'cflags': [ '-mavx' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-mavx' ]
},
}],
],
},

{
'target_name': 'base64_avx2',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'sources': [ 'base64/lib/arch/avx2/codec.c' ],
'defines': [ 'HAVE_AVX2=1' ],
'conditions': [
[ 'OS!="win"', {
'cflags': [ '-mavx2' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-mavx2' ]
},
}],
],
},

{
'target_name': 'base64_neon32',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'sources': [ 'base64/lib/arch/neon32/codec.c' ],
'defines': [ 'HAVE_NEON32=1' ],
'conditions': [
[ 'OS!="win"', {
'cflags': [ '-mfpu=neon' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-mfpu=neon' ]
},
}],
],
},

{
'target_name': 'base64_neon64',
'type': 'static_library',
'include_dirs': [ 'base64/include', 'base64/lib' ],
'sources': [ 'base64/lib/arch/neon64/codec.c' ],
'defines': [ 'HAVE_NEON64=1' ],
# NEON is required in arm64, so no -mfpu flag is needed
}

]
}
5 changes: 5 additions & 0 deletions deps/base64/base64/.gitignore
@@ -0,0 +1,5 @@
*.o
bin/base64
lib/config.h
test/benchmark
test/test_base64
71 changes: 71 additions & 0 deletions deps/base64/base64/.travis.yml
@@ -0,0 +1,71 @@
language: c
services: docker

jobs:
allow_failures:
- os: osx
- arch: ppc64le

include:
- name: linux-amd64-gcc
os: linux
arch: amd64
compiler: gcc
script: test/ci/amd64.sh

- name: linux-amd64-gcc +openmp
os: linux
arch: amd64
compiler: gcc
env: OPENMP=1 OMP_NUM_THREADS=4
script: test/ci/amd64.sh

- name: linux-amd64-clang
os: linux
arch: amd64
compiler: clang
script: test/ci/amd64.sh

- name: linux-arm32-gcc
compiler: gcc
script: test/ci/docker-arm32.sh

- name: linux-arm32-clang
compiler: clang
script: test/ci/docker-arm32.sh

- name: linux-powerpc-gcc
compiler: gcc
script: test/ci/docker-powerpc.sh

- name: linux-arm64-gcc
os: linux
arch: arm64
compiler: gcc
env: NEON64_CFLAGS="-march=armv8-a"
script: test/ci/generic.sh

- name: linux-arm64-clang
os: linux
arch: arm64
compiler: clang
env: NEON64_CFLAGS="-march=armv8-a"
script: test/ci/generic.sh

- name: linux-s390x-gcc
os: linux
arch: s390x
compiler: gcc
script: test/ci/generic.sh

- name: linux-ppc64le-gcc
os: linux
arch: ppc64le
compiler: gcc
script: test/ci/generic.sh

- name: osx-amd64-clang
os: osx
arch: amd64
compiler: clang
script: test/ci/amd64.sh
28 changes: 28 additions & 0 deletions deps/base64/base64/LICENSE
@@ -0,0 +1,28 @@
Copyright (c) 2005-2007, Nick Galbreath
Copyright (c) 2013-2019, Alfred Klomp
Copyright (c) 2015-2017, Wojciech Mula
Copyright (c) 2016-2017, Matthieu Darbois
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 comments on commit 6a01a3f

Please sign in to comment.