Skip to content

Commit

Permalink
deps: update zlib to 1.2.13.1-motley-61dc0bd
Browse files Browse the repository at this point in the history
PR-URL: nodejs#48788
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
  • Loading branch information
nodejs-github-bot authored and pluris committed Aug 7, 2023
1 parent fac8a0e commit 340270a
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 123 deletions.
63 changes: 25 additions & 38 deletions deps/zlib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -124,45 +124,40 @@ source_set("zlib_adler32_simd") {

if (use_arm_neon_optimizations) {
config("zlib_arm_crc32_config") {
# Disabled for iPhone, as described in DDI0487C_a_armv8_arm:
# "All implementations of the ARMv8.1 architecture are required to
# implement the CRC32* instructions. These are optional in ARMv8.0."
if (!is_ios) {
defines = [ "CRC32_ARMV8_CRC32" ]
if (is_android) {
defines += [ "ARMV8_OS_ANDROID" ]
} else if (is_linux || is_chromeos) {
defines += [ "ARMV8_OS_LINUX" ]
} else if (is_mac) {
defines += [ "ARMV8_OS_MACOS" ]
} else if (is_fuchsia) {
defines += [ "ARMV8_OS_FUCHSIA" ]
} else if (is_win) {
defines += [ "ARMV8_OS_WINDOWS" ]
} else {
assert(false, "Unsupported ARM OS")
}
defines = [ "CRC32_ARMV8_CRC32" ]
if (is_android) {
defines += [ "ARMV8_OS_ANDROID" ]
} else if (is_linux || is_chromeos) {
defines += [ "ARMV8_OS_LINUX" ]
} else if (is_mac) {
defines += [ "ARMV8_OS_MACOS" ]
} else if (is_ios) {
defines += [ "ARMV8_OS_IOS" ]
} else if (is_fuchsia) {
defines += [ "ARMV8_OS_FUCHSIA" ]
} else if (is_win) {
defines += [ "ARMV8_OS_WINDOWS" ]
} else {
assert(false, "Unsupported ARM OS")
}
}

source_set("zlib_arm_crc32") {
visibility = [ ":*" ]

if (!is_ios) {
include_dirs = [ "." ]

if (!is_win && !is_clang) {
assert(!use_thin_lto,
"ThinLTO fails mixing different module-level targets")
cflags_c = [ "-march=armv8-a+aes+crc" ]
}
include_dirs = [ "." ]

sources = [
"crc32_simd.c",
"crc32_simd.h",
]
if (!is_win && !is_clang) {
assert(!use_thin_lto,
"ThinLTO fails mixing different module-level targets")
cflags_c = [ "-march=armv8-a+aes+crc" ]
}

sources = [
"crc32_simd.c",
"crc32_simd.h",
]

configs += [ ":zlib_internal_config" ]

public_configs = [ ":zlib_arm_crc32_config" ]
Expand Down Expand Up @@ -332,14 +327,6 @@ component("zlib") {
defines += [ "CPU_NO_SIMD" ]
}

if (is_ios) {
# iOS@ARM is a special case where we always have NEON but don't check
# for crypto extensions.
# TODO(cavalcantii): verify what is the current state of CPU features
# shipped on latest iOS devices.
defines += [ "ARM_OS_IOS" ]
}

if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
deps += [
":zlib_adler32_simd",
Expand Down
1 change: 1 addition & 0 deletions deps/zlib/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ URL: http://zlib.net/
Version: 1.2.13
CPEPrefix: cpe:/a:zlib:zlib:1.2.13
Security Critical: yes
Shipped: yes
License: Custom license
License File: LICENSE
License Android Compatible: yes
Expand Down
63 changes: 43 additions & 20 deletions deps/zlib/contrib/bench/zlib_bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ void check_file(const Data& file, zlib_wrapper type, int mode) {
error_exit("check file: error writing output", 3);
}

void zlib_file(const char* name, zlib_wrapper type, int width, int check) {
void zlib_file(const char* name,
zlib_wrapper type,
int width,
int check,
bool output_csv_format) {
/*
* Read the file data.
*/
Expand All @@ -257,7 +261,9 @@ void zlib_file(const char* name, zlib_wrapper type, int width, int check) {
* Report compression strategy and file name.
*/
const char* strategy = zlib_level_strategy_name(zlib_compression_level);
printf("%s%-40s :\n", strategy, name);
if (!output_csv_format) {
printf("%s%-40s :\n", strategy, name);
}

/*
* Chop the data into blocks.
Expand Down Expand Up @@ -329,19 +335,28 @@ void zlib_file(const char* name, zlib_wrapper type, int width, int check) {
std::sort(ctime, ctime + runs);
std::sort(utime, utime + runs);

double deflate_rate_med = length * repeats / mega_byte / ctime[runs / 2];
double inflate_rate_med = length * repeats / mega_byte / utime[runs / 2];
double deflate_rate_max = length * repeats / mega_byte / ctime[0];
double inflate_rate_max = length * repeats / mega_byte / utime[0];

// type, block size, compression ratio, etc
printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%",
zlib_wrapper_name(type), block_size / (1 << 20), width, length, width,
unsigned(output_length), output_length * 100.0 / length);

// compress / uncompress median (max) rates
printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n",
deflate_rate_med, deflate_rate_max, inflate_rate_med, inflate_rate_max);
double deflate_rate_med, inflate_rate_med, deflate_rate_max, inflate_rate_max;
deflate_rate_med = length * repeats / mega_byte / ctime[runs / 2];
inflate_rate_med = length * repeats / mega_byte / utime[runs / 2];
deflate_rate_max = length * repeats / mega_byte / ctime[0];
inflate_rate_max = length * repeats / mega_byte / utime[0];
double compress_ratio = output_length * 100.0 / length;

if (!output_csv_format) {
// type, block size, compression ratio, etc
printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%", zlib_wrapper_name(type),
block_size / (1 << 20), width, length, width,
unsigned(output_length), compress_ratio);

// compress / uncompress median (max) rates
printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n",
deflate_rate_med, deflate_rate_max, inflate_rate_med,
inflate_rate_max);
} else {
printf("%s\t%.5lf\t%.5lf\t%.5lf\t%.5lf\t%.5lf\n", name, deflate_rate_med,
inflate_rate_med, deflate_rate_max, inflate_rate_max,
compress_ratio);
}
}

static int argn = 1;
Expand All @@ -363,8 +378,10 @@ void get_field_width(int argc, char* argv[], int& value) {
}

void usage_exit(const char* program) {
static auto* options = "gzip|zlib|raw"
" [--compression 0:9] [--huffman|--rle] [--field width] [--check]";
static auto* options =
"gzip|zlib|raw"
" [--compression 0:9] [--huffman|--rle] [--field width] [--check]"
" [--csv]";
printf("usage: %s %s files ...\n", program, options);
printf("zlib version: %s\n", ZLIB_VERSION);
exit(1);
Expand All @@ -383,7 +400,7 @@ int main(int argc, char* argv[]) {

int size_field_width = 0;
int file_check = 0;

bool output_csv = false;
while (argn < argc && argv[argn][0] == '-') {
if (get_option(argc, argv, "--compression")) {
if (!get_compression(argc, argv, zlib_compression_level))
Expand All @@ -398,6 +415,11 @@ int main(int argc, char* argv[]) {
file_check = 2;
} else if (get_option(argc, argv, "--field")) {
get_field_width(argc, argv, size_field_width);
} else if (get_option(argc, argv, "--csv")) {
output_csv = true;
printf(
"filename\tcompression\tdecompression\tcomp_max\t"
"decomp_max\tcompress_ratio\n");
} else {
usage_exit(argv[0]);
}
Expand All @@ -408,8 +430,9 @@ int main(int argc, char* argv[]) {

if (size_field_width < 6)
size_field_width = 6;
while (argn < argc)
zlib_file(argv[argn++], type, size_field_width, file_check);
while (argn < argc) {
zlib_file(argv[argn++], type, size_field_width, file_check, output_csv);
}

return 0;
}
1 change: 1 addition & 0 deletions deps/zlib/contrib/minizip/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ URL: https://github.com/madler/zlib/tree/master/contrib/minizip
Version: 1.2.12
License: Zlib
Security Critical: yes
Shipped: yes

Description:
Minizip provides API on top of zlib that can enumerate and extract ZIP archive
Expand Down
26 changes: 18 additions & 8 deletions deps/zlib/cpu_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0;

#ifndef CPU_NO_SIMD

#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA)
#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(ARMV8_OS_IOS)
#include <pthread.h>
#endif

Expand All @@ -50,17 +50,19 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0;
#include <zircon/types.h>
#elif defined(ARMV8_OS_WINDOWS) || defined(X86_WINDOWS)
#include <windows.h>
#elif defined(ARMV8_OS_IOS)
#include <sys/sysctl.h>
#elif !defined(_MSC_VER)
#include <pthread.h>
#else
#error cpu_features.c CPU feature detection in not defined for your platform
#endif

#if !defined(CPU_NO_SIMD) && !defined(ARMV8_OS_MACOS) && !defined(ARM_OS_IOS)
#if !defined(CPU_NO_SIMD) && !defined(ARMV8_OS_MACOS)
static void _cpu_check_features(void);
#endif

#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS)
#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS) || defined(ARMV8_OS_IOS)
#if !defined(ARMV8_OS_MACOS)
// _cpu_check_features() doesn't need to do anything on mac/arm since all
// features are known at build time, so don't call it.
Expand Down Expand Up @@ -89,11 +91,7 @@ void ZLIB_INTERNAL cpu_check_features(void)
#endif

#if (defined(__ARM_NEON__) || defined(__ARM_NEON))
/*
* iOS@ARM is a special case where we always have NEON but don't check
* for crypto extensions.
*/
#if !defined(ARMV8_OS_MACOS) && !defined(ARM_OS_IOS)
#if !defined(ARMV8_OS_MACOS)
/*
* See http://bit.ly/2CcoEsr for run-time detection of ARM features and also
* crbug.com/931275 for android_getCpuFeatures() use in the Android sandbox.
Expand Down Expand Up @@ -127,6 +125,18 @@ static void _cpu_check_features(void)
#elif defined(ARMV8_OS_WINDOWS)
arm_cpu_enable_crc32 = IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
arm_cpu_enable_pmull = IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
#elif defined(ARMV8_OS_IOS)
// Determine what features are supported dynamically. This code is applicable to macOS
// as well if we wish to do that dynamically on that platform in the future.
// See https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics
int val = 0;
size_t len = sizeof(val);
arm_cpu_enable_crc32 = sysctlbyname("hw.optional.armv8_crc32", &val, &len, 0, 0) == 0
&& val != 0;
val = 0;
len = sizeof(val);
arm_cpu_enable_pmull = sysctlbyname("hw.optional.arm.FEAT_PMULL", &val, &len, 0, 0) == 0
&& val != 0;
#endif
}
#endif
Expand Down
Loading

0 comments on commit 340270a

Please sign in to comment.