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
codebytere committed Oct 13, 2022
1 parent b83cb0c commit a2787fb
Showing 1 changed file with 231 additions and 2 deletions.
233 changes: 231 additions & 2 deletions patches/node/build_add_gn_build_files.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ This adds GN build files for Node, so we don't have to build with GYP.

diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..a47875642d8f825c84ba1e82e3892a97e98e76e4
index 0000000000000000000000000000000000000000..bc826db98fff63e9c87332c45928e9118b8a0732
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,438 @@
@@ -0,0 +1,439 @@
+import("//v8/gni/v8.gni")
+import("node.gni")
+
Expand Down Expand Up @@ -224,6 +224,7 @@ index 0000000000000000000000000000000000000000..a47875642d8f825c84ba1e82e3892a97
+ ":node_js2c",
+ "deps/googletest:gtest",
+ "deps/uvwasi",
+ "deps/base64",
+ "//third_party/zlib",
+ "//third_party/brotli:dec",
+ "//third_party/brotli:enc",
Expand Down Expand Up @@ -449,6 +450,234 @@ index 0000000000000000000000000000000000000000..a47875642d8f825c84ba1e82e3892a97
+ ":tar_headers",
+ ]
+}
diff --git a/deps/base64/BUILD.gn b/deps/base64/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..196d074b914d0a4394c4fb9ca6c4a063a41db72a
--- /dev/null
+++ b/deps/base64/BUILD.gn
@@ -0,0 +1,194 @@
+config("base64_config") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib",
+ ]
+
+ defines = [ "BASE64_STATIC_DEFINE" ]
+}
+
+static_library("base64") {
+ defines = [ "BASE64_STATIC_DEFINE" ]
+ deps = []
+
+ public_configs = [ ":base64_config" ]
+
+ include_dirs = [
+ "base64/include",
+ "base64/lib",
+ ]
+
+ cflags_c = [ "-Wno-implicit-fallthrough" ]
+
+ 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",
+ ]
+
+ if (target_cpu == "arm") {
+ defines += ["HAVE_NEON32=1"]
+ deps += [":base64_neon32"]
+ } else {
+ sources += [ "base64/lib/arch/neon32/neon32_codec.c" ]
+ }
+
+ if (target_cpu == "arm64") {
+ defines += ["HAVE_NEON64=1"]
+ deps += [":base64_neon64"]
+ } else {
+ sources += [ "base64/lib/arch/neon64/neon64_codec.c" ]
+ }
+
+ if (target_cpu == "ia32" || target_cpu == "x64" || target_cpu == "x32") {
+ defines += [
+ "HAVE_SSSE3=1",
+ "HAVE_SSE41=1",
+ "HAVE_SSE42=1",
+ "HAVE_AVX=1",
+ "HAVE_AVX2=1",
+ ]
+
+ deps += [
+ ":base64_ssse3",
+ ":base64_sse41",
+ ":base64_sse42",
+ ":base64_avx",
+ ":base64_avx2",
+ ]
+ } else {
+ sources += [
+ "base64/lib/arch/ssse3/ssse3_codec.c",
+ "base64/lib/arch/sse41/sse41_codec.c",
+ "base64/lib/arch/sse42/sse42_codec.c",
+ "base64/lib/arch/avx/avx_codec.c",
+ "base64/lib/arch/avx2/avx2_codec.c",
+ ]
+ }
+}
+
+static_library("base64_ssse3") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib"
+ ]
+
+ defines = [
+ "BASE64_STATIC_DEFINE",
+ "HAVE_SSSE3=1"
+ ]
+
+ sources = [ "base64/lib/arch/ssse3/ssse3_codec.c" ]
+
+ if (!is_win) {
+ cflags = ["-mssse3"]
+ }
+}
+
+
+static_library("base64_sse41") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib"
+ ]
+
+ defines = [
+ "BASE64_STATIC_DEFINE",
+ "HAVE_SSE41=1"
+ ]
+
+ sources = [ "base64/lib/arch/sse41/sse41_codec.c" ]
+
+ if (!is_win) {
+ cflags = ["-msse4.1"]
+ }
+}
+
+static_library("base64_sse42") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib"
+ ]
+
+ defines = [
+ "BASE64_STATIC_DEFINE",
+ "HAVE_SSE42=1"
+ ]
+
+ sources = [ "base64/lib/arch/sse42/sse42_codec.c" ]
+
+ if (!is_win) {
+ cflags = ["-msse4.2"]
+ }
+}
+
+static_library("base64_avx") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib"
+ ]
+
+ defines = [
+ "BASE64_STATIC_DEFINE",
+ "HAVE_AVX=1"
+ ]
+
+ sources = [ "base64/lib/arch/avx/avx_codec.c" ]
+
+ if (!is_win) {
+ cflags = ["-mavx"]
+ }
+}
+
+static_library("base64_avx2") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib"
+ ]
+
+ defines = [
+ "BASE64_STATIC_DEFINE",
+ "HAVE_AVX2=1"
+ ]
+
+ sources = [ "base64/lib/arch/avx2/avx2_codec.c" ]
+
+ if (!is_win) {
+ cflags = ["-mavx2"]
+ }
+}
+
+static_library("base64_neon32") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib"
+ ]
+
+ defines = [
+ "BASE64_STATIC_DEFINE",
+ "HAVE_NEON32=1"
+ ]
+
+ cflags_c = [ "-Wno-implicit-fallthrough" ]
+
+ sources = [ "base64/lib/arch/neon32/neon32_codec.c" ]
+}
+
+static_library("base64_neon64") {
+ include_dirs = [
+ "base64/include",
+ "base64/lib"
+ ]
+
+ defines = [
+ "BASE64_STATIC_DEFINE",
+ "HAVE_NEON64=1"
+ ]
+
+ cflags_c = [ "-Wno-implicit-fallthrough" ]
+
+ sources = [ "base64/lib/arch/neon64/neon64_codec.c" ]
+}
diff --git a/deps/base64/base64/lib/arch/avx/codec.c b/deps/base64/base64/lib/arch/avx/avx_codec.c
similarity index 100%
rename from deps/base64/base64/lib/arch/avx/codec.c
rename to deps/base64/base64/lib/arch/avx/avx_codec.c
diff --git a/deps/base64/base64/lib/arch/avx2/codec.c b/deps/base64/base64/lib/arch/avx2/avx2_codec.c
similarity index 100%
rename from deps/base64/base64/lib/arch/avx2/codec.c
rename to deps/base64/base64/lib/arch/avx2/avx2_codec.c
diff --git a/deps/base64/base64/lib/arch/neon32/codec.c b/deps/base64/base64/lib/arch/neon32/neon32_codec.c
similarity index 100%
rename from deps/base64/base64/lib/arch/neon32/codec.c
rename to deps/base64/base64/lib/arch/neon32/neon32_codec.c
diff --git a/deps/base64/base64/lib/arch/neon64/codec.c b/deps/base64/base64/lib/arch/neon64/neon64_codec.c
similarity index 100%
rename from deps/base64/base64/lib/arch/neon64/codec.c
rename to deps/base64/base64/lib/arch/neon64/neon64_codec.c
diff --git a/deps/base64/base64/lib/arch/sse41/codec.c b/deps/base64/base64/lib/arch/sse41/sse41_codec.c
similarity index 100%
rename from deps/base64/base64/lib/arch/sse41/codec.c
rename to deps/base64/base64/lib/arch/sse41/sse41_codec.c
diff --git a/deps/base64/base64/lib/arch/sse42/codec.c b/deps/base64/base64/lib/arch/sse42/sse42_codec.c
similarity index 100%
rename from deps/base64/base64/lib/arch/sse42/codec.c
rename to deps/base64/base64/lib/arch/sse42/sse42_codec.c
diff --git a/deps/base64/base64/lib/arch/ssse3/codec.c b/deps/base64/base64/lib/arch/ssse3/ssse3_codec.c
similarity index 100%
rename from deps/base64/base64/lib/arch/ssse3/codec.c
rename to deps/base64/base64/lib/arch/ssse3/ssse3_codec.c
diff --git a/deps/cares/BUILD.gn b/deps/cares/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..71a37834f4e693c190eb7e7d04e3f5ce67c487ad
Expand Down

0 comments on commit a2787fb

Please sign in to comment.