deps,src: use SIMD for normal base64 encoding · nodejs/node@2ec8092 · GitHub
Skip to content

Commit 2ec8092

Browse files
mscdexdanielleadams
authored andcommitted
deps,src: use SIMD for normal base64 encoding
PR-URL: #39775 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 9b53a69 commit 2ec8092

78 files changed

Lines changed: 7161 additions & 0 deletions

Some content is hidden

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

LICENSE

Lines changed: 32 additions & 0 deletions

deps/base64/README.md

Lines changed: 14 additions & 0 deletions
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

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

deps/base64/base64/.editorconfig

Lines changed: 22 additions & 0 deletions
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
Lines changed: 133 additions & 0 deletions

0 commit comments

Comments
 (0)