Skip to content

Commit 6059b59

Browse files
nodejs-github-bottargos
authored andcommittedNov 26, 2023
deps: update zlib to 1.2.13.1-motley-61dc0bd
PR-URL: #48788 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
1 parent ae8bb16 commit 6059b59

File tree

7 files changed

+145
-123
lines changed

7 files changed

+145
-123
lines changed
 

‎deps/zlib/BUILD.gn

+25-38
Original file line numberDiff line numberDiff line change
@@ -124,45 +124,40 @@ source_set("zlib_adler32_simd") {
124124

125125
if (use_arm_neon_optimizations) {
126126
config("zlib_arm_crc32_config") {
127-
# Disabled for iPhone, as described in DDI0487C_a_armv8_arm:
128-
# "All implementations of the ARMv8.1 architecture are required to
129-
# implement the CRC32* instructions. These are optional in ARMv8.0."
130-
if (!is_ios) {
131-
defines = [ "CRC32_ARMV8_CRC32" ]
132-
if (is_android) {
133-
defines += [ "ARMV8_OS_ANDROID" ]
134-
} else if (is_linux || is_chromeos) {
135-
defines += [ "ARMV8_OS_LINUX" ]
136-
} else if (is_mac) {
137-
defines += [ "ARMV8_OS_MACOS" ]
138-
} else if (is_fuchsia) {
139-
defines += [ "ARMV8_OS_FUCHSIA" ]
140-
} else if (is_win) {
141-
defines += [ "ARMV8_OS_WINDOWS" ]
142-
} else {
143-
assert(false, "Unsupported ARM OS")
144-
}
127+
defines = [ "CRC32_ARMV8_CRC32" ]
128+
if (is_android) {
129+
defines += [ "ARMV8_OS_ANDROID" ]
130+
} else if (is_linux || is_chromeos) {
131+
defines += [ "ARMV8_OS_LINUX" ]
132+
} else if (is_mac) {
133+
defines += [ "ARMV8_OS_MACOS" ]
134+
} else if (is_ios) {
135+
defines += [ "ARMV8_OS_IOS" ]
136+
} else if (is_fuchsia) {
137+
defines += [ "ARMV8_OS_FUCHSIA" ]
138+
} else if (is_win) {
139+
defines += [ "ARMV8_OS_WINDOWS" ]
140+
} else {
141+
assert(false, "Unsupported ARM OS")
145142
}
146143
}
147144

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

151-
if (!is_ios) {
152-
include_dirs = [ "." ]
153-
154-
if (!is_win && !is_clang) {
155-
assert(!use_thin_lto,
156-
"ThinLTO fails mixing different module-level targets")
157-
cflags_c = [ "-march=armv8-a+aes+crc" ]
158-
}
148+
include_dirs = [ "." ]
159149

160-
sources = [
161-
"crc32_simd.c",
162-
"crc32_simd.h",
163-
]
150+
if (!is_win && !is_clang) {
151+
assert(!use_thin_lto,
152+
"ThinLTO fails mixing different module-level targets")
153+
cflags_c = [ "-march=armv8-a+aes+crc" ]
164154
}
165155

156+
sources = [
157+
"crc32_simd.c",
158+
"crc32_simd.h",
159+
]
160+
166161
configs += [ ":zlib_internal_config" ]
167162

168163
public_configs = [ ":zlib_arm_crc32_config" ]
@@ -332,14 +327,6 @@ component("zlib") {
332327
defines += [ "CPU_NO_SIMD" ]
333328
}
334329

335-
if (is_ios) {
336-
# iOS@ARM is a special case where we always have NEON but don't check
337-
# for crypto extensions.
338-
# TODO(cavalcantii): verify what is the current state of CPU features
339-
# shipped on latest iOS devices.
340-
defines += [ "ARM_OS_IOS" ]
341-
}
342-
343330
if (use_x86_x64_optimizations || use_arm_neon_optimizations) {
344331
deps += [
345332
":zlib_adler32_simd",

‎deps/zlib/README.chromium

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ URL: http://zlib.net/
44
Version: 1.2.13
55
CPEPrefix: cpe:/a:zlib:zlib:1.2.13
66
Security Critical: yes
7+
Shipped: yes
78
License: Custom license
89
License File: LICENSE
910
License Android Compatible: yes

‎deps/zlib/contrib/bench/zlib_bench.cc

+43-20
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ void check_file(const Data& file, zlib_wrapper type, int mode) {
236236
error_exit("check file: error writing output", 3);
237237
}
238238

239-
void zlib_file(const char* name, zlib_wrapper type, int width, int check) {
239+
void zlib_file(const char* name,
240+
zlib_wrapper type,
241+
int width,
242+
int check,
243+
bool output_csv_format) {
240244
/*
241245
* Read the file data.
242246
*/
@@ -257,7 +261,9 @@ void zlib_file(const char* name, zlib_wrapper type, int width, int check) {
257261
* Report compression strategy and file name.
258262
*/
259263
const char* strategy = zlib_level_strategy_name(zlib_compression_level);
260-
printf("%s%-40s :\n", strategy, name);
264+
if (!output_csv_format) {
265+
printf("%s%-40s :\n", strategy, name);
266+
}
261267

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

332-
double deflate_rate_med = length * repeats / mega_byte / ctime[runs / 2];
333-
double inflate_rate_med = length * repeats / mega_byte / utime[runs / 2];
334-
double deflate_rate_max = length * repeats / mega_byte / ctime[0];
335-
double inflate_rate_max = length * repeats / mega_byte / utime[0];
336-
337-
// type, block size, compression ratio, etc
338-
printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%",
339-
zlib_wrapper_name(type), block_size / (1 << 20), width, length, width,
340-
unsigned(output_length), output_length * 100.0 / length);
341-
342-
// compress / uncompress median (max) rates
343-
printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n",
344-
deflate_rate_med, deflate_rate_max, inflate_rate_med, inflate_rate_max);
338+
double deflate_rate_med, inflate_rate_med, deflate_rate_max, inflate_rate_max;
339+
deflate_rate_med = length * repeats / mega_byte / ctime[runs / 2];
340+
inflate_rate_med = length * repeats / mega_byte / utime[runs / 2];
341+
deflate_rate_max = length * repeats / mega_byte / ctime[0];
342+
inflate_rate_max = length * repeats / mega_byte / utime[0];
343+
double compress_ratio = output_length * 100.0 / length;
344+
345+
if (!output_csv_format) {
346+
// type, block size, compression ratio, etc
347+
printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%", zlib_wrapper_name(type),
348+
block_size / (1 << 20), width, length, width,
349+
unsigned(output_length), compress_ratio);
350+
351+
// compress / uncompress median (max) rates
352+
printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n",
353+
deflate_rate_med, deflate_rate_max, inflate_rate_med,
354+
inflate_rate_max);
355+
} else {
356+
printf("%s\t%.5lf\t%.5lf\t%.5lf\t%.5lf\t%.5lf\n", name, deflate_rate_med,
357+
inflate_rate_med, deflate_rate_max, inflate_rate_max,
358+
compress_ratio);
359+
}
345360
}
346361

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

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

384401
int size_field_width = 0;
385402
int file_check = 0;
386-
403+
bool output_csv = false;
387404
while (argn < argc && argv[argn][0] == '-') {
388405
if (get_option(argc, argv, "--compression")) {
389406
if (!get_compression(argc, argv, zlib_compression_level))
@@ -398,6 +415,11 @@ int main(int argc, char* argv[]) {
398415
file_check = 2;
399416
} else if (get_option(argc, argv, "--field")) {
400417
get_field_width(argc, argv, size_field_width);
418+
} else if (get_option(argc, argv, "--csv")) {
419+
output_csv = true;
420+
printf(
421+
"filename\tcompression\tdecompression\tcomp_max\t"
422+
"decomp_max\tcompress_ratio\n");
401423
} else {
402424
usage_exit(argv[0]);
403425
}
@@ -408,8 +430,9 @@ int main(int argc, char* argv[]) {
408430

409431
if (size_field_width < 6)
410432
size_field_width = 6;
411-
while (argn < argc)
412-
zlib_file(argv[argn++], type, size_field_width, file_check);
433+
while (argn < argc) {
434+
zlib_file(argv[argn++], type, size_field_width, file_check, output_csv);
435+
}
413436

414437
return 0;
415438
}

‎deps/zlib/contrib/minizip/README.chromium

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ URL: https://github.com/madler/zlib/tree/master/contrib/minizip
44
Version: 1.2.12
55
License: Zlib
66
Security Critical: yes
7+
Shipped: yes
78

89
Description:
910
Minizip provides API on top of zlib that can enumerate and extract ZIP archive

‎deps/zlib/cpu_features.c

+18-8
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0;
3535

3636
#ifndef CPU_NO_SIMD
3737

38-
#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA)
38+
#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_FUCHSIA) || defined(ARMV8_OS_IOS)
3939
#include <pthread.h>
4040
#endif
4141

@@ -50,17 +50,19 @@ int ZLIB_INTERNAL x86_cpu_enable_avx512 = 0;
5050
#include <zircon/types.h>
5151
#elif defined(ARMV8_OS_WINDOWS) || defined(X86_WINDOWS)
5252
#include <windows.h>
53+
#elif defined(ARMV8_OS_IOS)
54+
#include <sys/sysctl.h>
5355
#elif !defined(_MSC_VER)
5456
#include <pthread.h>
5557
#else
5658
#error cpu_features.c CPU feature detection in not defined for your platform
5759
#endif
5860

59-
#if !defined(CPU_NO_SIMD) && !defined(ARMV8_OS_MACOS) && !defined(ARM_OS_IOS)
61+
#if !defined(CPU_NO_SIMD) && !defined(ARMV8_OS_MACOS)
6062
static void _cpu_check_features(void);
6163
#endif
6264

63-
#if defined(ARMV8_OS_ANDROID) || defined(ARMV8_OS_LINUX) || defined(ARMV8_OS_MACOS) || defined(ARMV8_OS_FUCHSIA) || defined(X86_NOT_WINDOWS)
65+
#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)
6466
#if !defined(ARMV8_OS_MACOS)
6567
// _cpu_check_features() doesn't need to do anything on mac/arm since all
6668
// features are known at build time, so don't call it.
@@ -89,11 +91,7 @@ void ZLIB_INTERNAL cpu_check_features(void)
8991
#endif
9092

9193
#if (defined(__ARM_NEON__) || defined(__ARM_NEON))
92-
/*
93-
* iOS@ARM is a special case where we always have NEON but don't check
94-
* for crypto extensions.
95-
*/
96-
#if !defined(ARMV8_OS_MACOS) && !defined(ARM_OS_IOS)
94+
#if !defined(ARMV8_OS_MACOS)
9795
/*
9896
* See http://bit.ly/2CcoEsr for run-time detection of ARM features and also
9997
* crbug.com/931275 for android_getCpuFeatures() use in the Android sandbox.
@@ -127,6 +125,18 @@ static void _cpu_check_features(void)
127125
#elif defined(ARMV8_OS_WINDOWS)
128126
arm_cpu_enable_crc32 = IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
129127
arm_cpu_enable_pmull = IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
128+
#elif defined(ARMV8_OS_IOS)
129+
// Determine what features are supported dynamically. This code is applicable to macOS
130+
// as well if we wish to do that dynamically on that platform in the future.
131+
// See https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics
132+
int val = 0;
133+
size_t len = sizeof(val);
134+
arm_cpu_enable_crc32 = sysctlbyname("hw.optional.armv8_crc32", &val, &len, 0, 0) == 0
135+
&& val != 0;
136+
val = 0;
137+
len = sizeof(val);
138+
arm_cpu_enable_pmull = sysctlbyname("hw.optional.arm.FEAT_PMULL", &val, &len, 0, 0) == 0
139+
&& val != 0;
130140
#endif
131141
}
132142
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.