Skip to content

Commit 4ea60e0

Browse files
committed
deps,src: use SIMD for normal base64 encoding
1 parent acd2a32 commit 4ea60e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+7143
-0
lines changed

LICENSE

+32
Original file line numberDiff line numberDiff line change
@@ -1839,3 +1839,35 @@ The externally maintained libraries used by Node.js are:
18391839
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18401840
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18411841
"""
1842+
1843+
- base64, located at deps/base64/base64/, is licensed as follows:
1844+
"""
1845+
Copyright (c) 2005-2007, Nick Galbreath
1846+
Copyright (c) 2013-2019, Alfred Klomp
1847+
Copyright (c) 2015-2017, Wojciech Mula
1848+
Copyright (c) 2016-2017, Matthieu Darbois
1849+
All rights reserved.
1850+
1851+
Redistribution and use in source and binary forms, with or without
1852+
modification, are permitted provided that the following conditions are
1853+
met:
1854+
1855+
- Redistributions of source code must retain the above copyright notice,
1856+
this list of conditions and the following disclaimer.
1857+
1858+
- Redistributions in binary form must reproduce the above copyright
1859+
notice, this list of conditions and the following disclaimer in the
1860+
documentation and/or other materials provided with the distribution.
1861+
1862+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
1863+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1864+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
1865+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1866+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1867+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
1868+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1869+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
1870+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
1871+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1872+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1873+
"""

deps/base64/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# base64
2+
3+
This project boosts base64 encoding/decoding performance by utilizing SIMD
4+
operations where possible.
5+
6+
The source is pulled from: https://github.com/aklomp/base64
7+
8+
Active development occurs in the default branch (currently named `master`).
9+
10+
## Updating
11+
12+
```sh
13+
$ git clone https://github.com/aklomp/base64
14+
```

deps/base64/base64.gyp

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
{
2+
'variables': {
3+
'arm_fpu%': '',
4+
'target_arch%': '',
5+
},
6+
'targets': [
7+
{
8+
'target_name': 'base64',
9+
'type': 'static_library',
10+
'include_dirs': [ 'base64/include', 'base64/lib' ],
11+
'direct_dependent_settings': {
12+
'include_dirs': [ 'base64/include' ],
13+
},
14+
'sources': [
15+
'base64/include/libbase64.h',
16+
'base64/lib/arch/generic/codec.c',
17+
'base64/lib/tables/tables.c',
18+
'base64/lib/codec_choose.c',
19+
'base64/lib/codecs.h',
20+
'base64/lib/lib.c',
21+
],
22+
23+
'conditions': [
24+
[ 'arm_fpu=="neon" and target_arch=="arm"', {
25+
'defines': [ 'HAVE_NEON32=1' ],
26+
'dependencies': [ 'base64_neon32' ],
27+
}, {
28+
'sources': [ 'base64/lib/arch/neon32/codec.c' ],
29+
}],
30+
31+
# arm64 requires NEON, so it's safe to always use it
32+
[ 'target_arch=="arm64"', {
33+
'defines': [ 'HAVE_NEON64=1' ],
34+
'dependencies': [ 'base64_neon64' ],
35+
}, {
36+
'sources': [ 'base64/lib/arch/neon64/codec.c' ],
37+
}],
38+
39+
# Runtime detection will happen for x86 CPUs
40+
[ 'target_arch in "ia32 x64 x32"', {
41+
'defines': [
42+
'HAVE_SSSE3=1',
43+
'HAVE_SSE41=1',
44+
'HAVE_SSE42=1',
45+
'HAVE_AVX=1',
46+
'HAVE_AVX2=1',
47+
],
48+
'dependencies': [
49+
'base64_ssse3',
50+
'base64_sse41',
51+
'base64_sse42',
52+
'base64_avx',
53+
'base64_avx2',
54+
],
55+
}, {
56+
'sources': [
57+
'base64/lib/arch/ssse3/codec.c',
58+
'base64/lib/arch/sse41/codec.c',
59+
'base64/lib/arch/sse42/codec.c',
60+
'base64/lib/arch/avx/codec.c',
61+
'base64/lib/arch/avx2/codec.c',
62+
],
63+
}],
64+
],
65+
},
66+
67+
{
68+
'target_name': 'base64_ssse3',
69+
'type': 'static_library',
70+
'include_dirs': [ 'base64/include', 'base64/lib' ],
71+
'sources': [ 'base64/lib/arch/ssse3/codec.c' ],
72+
'defines': [ 'HAVE_SSSE3=1' ],
73+
'conditions': [
74+
[ 'OS!="win"', {
75+
'cflags': [ '-mssse3' ],
76+
'xcode_settings': {
77+
'OTHER_CFLAGS': [ '-mssse3' ]
78+
},
79+
}],
80+
],
81+
},
82+
83+
{
84+
'target_name': 'base64_sse41',
85+
'type': 'static_library',
86+
'include_dirs': [ 'base64/include', 'base64/lib' ],
87+
'sources': [ 'base64/lib/arch/sse41/codec.c' ],
88+
'defines': [ 'HAVE_SSE41=1' ],
89+
'conditions': [
90+
[ 'OS!="win"', {
91+
'cflags': [ '-msse4.1' ],
92+
'xcode_settings': {
93+
'OTHER_CFLAGS': [ '-msse4.1' ]
94+
},
95+
}],
96+
],
97+
},
98+
99+
{
100+
'target_name': 'base64_sse42',
101+
'type': 'static_library',
102+
'include_dirs': [ 'base64/include', 'base64/lib' ],
103+
'sources': [ 'base64/lib/arch/sse42/codec.c' ],
104+
'defines': [ 'HAVE_SSE42=1' ],
105+
'conditions': [
106+
[ 'OS!="win"', {
107+
'cflags': [ '-msse4.2' ],
108+
'xcode_settings': {
109+
'OTHER_CFLAGS': [ '-msse4.2' ]
110+
},
111+
}],
112+
],
113+
},
114+
115+
{
116+
'target_name': 'base64_avx',
117+
'type': 'static_library',
118+
'include_dirs': [ 'base64/include', 'base64/lib' ],
119+
'sources': [ 'base64/lib/arch/avx/codec.c' ],
120+
'defines': [ 'HAVE_AVX=1' ],
121+
'conditions': [
122+
[ 'OS!="win"', {
123+
'cflags': [ '-mavx' ],
124+
'xcode_settings': {
125+
'OTHER_CFLAGS': [ '-mavx' ]
126+
},
127+
}],
128+
],
129+
},
130+
131+
{
132+
'target_name': 'base64_avx2',
133+
'type': 'static_library',
134+
'include_dirs': [ 'base64/include', 'base64/lib' ],
135+
'sources': [ 'base64/lib/arch/avx2/codec.c' ],
136+
'defines': [ 'HAVE_AVX2=1' ],
137+
'conditions': [
138+
[ 'OS!="win"', {
139+
'cflags': [ '-mavx2' ],
140+
'xcode_settings': {
141+
'OTHER_CFLAGS': [ '-mavx2' ]
142+
},
143+
}],
144+
],
145+
},
146+
147+
{
148+
'target_name': 'base64_neon32',
149+
'type': 'static_library',
150+
'include_dirs': [ 'base64/include', 'base64/lib' ],
151+
'sources': [ 'base64/lib/arch/neon32/codec.c' ],
152+
'defines': [ 'HAVE_NEON32=1' ],
153+
'conditions': [
154+
[ 'OS!="win"', {
155+
'cflags': [ '-mfpu=neon' ],
156+
'xcode_settings': {
157+
'OTHER_CFLAGS': [ '-mfpu=neon' ]
158+
},
159+
}],
160+
],
161+
},
162+
163+
{
164+
'target_name': 'base64_neon64',
165+
'type': 'static_library',
166+
'include_dirs': [ 'base64/include', 'base64/lib' ],
167+
'sources': [ 'base64/lib/arch/neon64/codec.c' ],
168+
'defines': [ 'HAVE_NEON64=1' ],
169+
# NEON is required in arm64, so no -mfpu flag is needed
170+
}
171+
172+
]
173+
}

deps/base64/base64/.editorconfig

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# https://EditorConfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
indent_style = tab
10+
tab_width = 8
11+
indent_size = 8
12+
13+
[CMakeLists.txt]
14+
tab_width = 4
15+
indent_style = space
16+
[*.cmake]
17+
tab_width = 4
18+
indent_style = space
19+
20+
[*.py]
21+
tab_width = 4
22+
indent_style = space
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
makefile-test:
7+
name: makefile-${{ matrix.runner }}-amd64-${{ matrix.compiler }} ${{ ((matrix.openmp == 1) && '+openmp') || '' }}
8+
runs-on: ${{ matrix.runner }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
runner: ["ubuntu-18.04"]
13+
compiler: ["gcc", "clang"]
14+
openmp: ["0", "1"]
15+
include:
16+
- runner: "macos-11"
17+
compiler: "clang"
18+
openmp: "0"
19+
env:
20+
OPENMP: ${{ matrix.openmp }}
21+
OMP_NUM_THREADS: ${{ ((matrix.openmp == 1) && '2') || '0' }}
22+
CC: ${{ matrix.compiler }}
23+
OBJCOPY: ${{ (startsWith(matrix.runner, 'macos') && 'echo') || 'objcopy' }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
- name: Run tests
28+
run: ./test/ci/test.sh
29+
30+
cmake-test:
31+
name: cmake-${{ matrix.runner }}
32+
runs-on: ${{ matrix.runner }}
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
runner: ["ubuntu-18.04", "macos-11", "windows-2019"]
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v3
40+
- name: CMake Configure
41+
run: >
42+
cmake
43+
-B out
44+
-Werror=dev
45+
-DBASE64_BUILD_TESTS=ON
46+
${{ runner.os != 'Windows' && '-DCMAKE_BUILD_TYPE=Release' || '' }}
47+
${{ runner.os == 'macOS' && '-DBASE64_WITH_AVX2=OFF' || '' }}
48+
- name: CMake Build
49+
run: cmake --build out --config Release --verbose
50+
- name: CTest
51+
run: ctest --no-tests=error --test-dir out -VV --build-config Release
52+
53+
alpine-makefile-test:
54+
name: makefile-alpine-amd64-gcc
55+
runs-on: ubuntu-latest
56+
container:
57+
image: alpine:3.12
58+
env:
59+
CC: gcc
60+
steps:
61+
- name: Install deps
62+
run: apk add --update bash build-base git
63+
- name: Checkout
64+
uses: actions/checkout@v3
65+
- name: Run tests
66+
run: ./test/ci/test.sh
67+
68+
alpine-cmake-test:
69+
name: cmake-alpine-amd64-gcc
70+
runs-on: ubuntu-latest
71+
container:
72+
image: alpine:3.12
73+
steps:
74+
- name: Install deps
75+
run: apk add --update bash build-base cmake git
76+
- name: Checkout
77+
uses: actions/checkout@v3
78+
- name: CMake Configure
79+
run: cmake -B out -Werror=dev -DBASE64_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
80+
- name: CMake Build
81+
run: cmake --build out --config Release --verbose
82+
- name: CTest
83+
run: ctest --no-tests=error -VV --build-config Release
84+
working-directory: ./out
85+
86+
alpine-alt-arch-makefile-test:
87+
name: makefile-alpine-${{matrix.arch}}-${{matrix.cc}}
88+
runs-on: ubuntu-latest
89+
strategy:
90+
fail-fast: false
91+
matrix:
92+
arch: [armv7, aarch64, s390x, ppc64le]
93+
cc: [gcc, clang]
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v3
97+
- uses: uraimo/run-on-arch-action@v2
98+
with:
99+
arch: ${{matrix.arch}}
100+
distro: alpine_latest
101+
env: |
102+
CC: ${{matrix.cc}}
103+
install: apk add --update bash build-base cmake git ${{matrix.cc}}
104+
run: ./test/ci/test.sh
105+
106+
alpine-alt-arch-cmake-test:
107+
name: cmake-alpine-${{matrix.arch}}-${{matrix.cc}}
108+
runs-on: ubuntu-latest
109+
strategy:
110+
fail-fast: false
111+
matrix:
112+
arch: [armv7, aarch64, s390x, ppc64le]
113+
cc: [gcc, clang]
114+
steps:
115+
- name: Checkout
116+
uses: actions/checkout@v3
117+
- uses: uraimo/run-on-arch-action@v2
118+
with:
119+
arch: ${{matrix.arch}}
120+
distro: alpine_latest
121+
env: |
122+
CC: ${{matrix.cc}}
123+
install: apk add --update bash build-base cmake git ${{matrix.cc}}
124+
run: |
125+
echo "::group::CMake Configure"
126+
cmake -B out -Werror=dev -DBASE64_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
127+
echo "::endgroup::CMake Configure"
128+
echo "::group::CMake Build"
129+
cmake --build out --config Release --verbose
130+
echo "::endgroup::CMake Build"
131+
echo "::group::CTest"
132+
ctest --no-tests=error --test-dir out -VV --build-config Release
133+
echo "::endgroup::CTest"

deps/base64/base64/.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.o
2+
bin/base64
3+
lib/config.h
4+
test/benchmark
5+
test/test_base64
6+
7+
# visual studio symbol db, etc.
8+
.vs/
9+
# build directory used by CMakePresets
10+
out/
11+
# private cmake presets
12+
CMakeUserPresets.json

0 commit comments

Comments
 (0)