multi_compress 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/GET_STARTED.md +4 -2
- data/README.md +1 -1
- data/THIRD_PARTY_NOTICES.md +2 -2
- data/ext/multi_compress/exports.darwin +1 -0
- data/ext/multi_compress/exports.map +4 -0
- data/ext/multi_compress/extconf.rb +20 -0
- data/ext/multi_compress/multi_compress.c +123 -73
- data/ext/multi_compress/vendor/.vendored +1 -1
- data/ext/multi_compress/vendor/zstd/lib/BUCK +10 -5
- data/ext/multi_compress/vendor/zstd/lib/README.md +25 -5
- data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +6 -2
- data/ext/multi_compress/vendor/zstd/lib/common/bits.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +3 -3
- data/ext/multi_compress/vendor/zstd/lib/common/bmi2.h +40 -0
- data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +37 -11
- data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +7 -6
- data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +4 -3
- data/ext/multi_compress/vendor/zstd/lib/common/pool.c +16 -19
- data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +31 -0
- data/ext/multi_compress/vendor/zstd/lib/common/threading.c +16 -2
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +9 -0
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +4 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +300 -3
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +4 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +4 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +775 -214
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +35 -6
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +9 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +14 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +2 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +2 -2
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +49 -5
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +11 -11
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +11 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +16 -18
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +3 -3
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +64 -39
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +30 -2
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +78 -64
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +182 -18
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +59 -27
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +11 -0
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +194 -93
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +225 -85
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +19 -2
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +136 -91
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.c +77 -77
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +48 -42
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +18 -14
- data/ext/multi_compress/vendor/zstd/lib/dll/example/build_package.bat +66 -20
- data/ext/multi_compress/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +10 -6
- data/ext/multi_compress/vendor/zstd/lib/install_oses.mk +17 -0
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +10 -8
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +5 -364
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +4 -5
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +7 -3
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +8 -5
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +3 -3
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +1 -0
- data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +8 -7
- data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +1 -0
- data/ext/multi_compress/vendor/zstd/lib/module.modulemap +0 -21
- data/ext/multi_compress/vendor/zstd/lib/zstd.h +209 -112
- data/lib/multi_compress/reader/read_operations.rb +2 -0
- data/lib/multi_compress/version.rb +1 -1
- data/multi_compress.gemspec +2 -0
- data/mysql_udf/Makefile +12 -5
- data/mysql_udf/multi_compress_mysql.exports +6 -0
- data/postgres_extension/Makefile +2 -1
- data/postgres_extension/test/run_e2e.sh +28 -10
- metadata +6 -5
- data/ext/multi_compress/vendor/lz4/lib/Makefile +0 -244
- data/ext/multi_compress/vendor/lz4/lib/dll/example/Makefile +0 -63
- data/ext/multi_compress/vendor/zstd/lib/Makefile +0 -389
- data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +0 -48
|
@@ -38,6 +38,16 @@
|
|
|
38
38
|
|
|
39
39
|
#endif
|
|
40
40
|
|
|
41
|
+
// There appears to be an unreconcilable syntax difference between Linux and Darwin assemblers.
|
|
42
|
+
// Name of a private label (i.e. not exported to symbol table) on Darwin has to start with "L",
|
|
43
|
+
// on Linux has to start with ".". There's no way to have a name start with both "." and "L", so
|
|
44
|
+
// we have to use a macro.
|
|
45
|
+
#if defined(__APPLE__)
|
|
46
|
+
#define LOCAL_LABEL(label) L_ ## label
|
|
47
|
+
#else
|
|
48
|
+
#define LOCAL_LABEL(label) .L_ ## label
|
|
49
|
+
#endif
|
|
50
|
+
|
|
41
51
|
#if ZSTD_ENABLE_ASM_X86_64_BMI2
|
|
42
52
|
|
|
43
53
|
/* Calling convention:
|
|
@@ -117,22 +127,55 @@ ZSTD_HIDE_ASM_FUNCTION(_HUF_decompress4X1_usingDTable_internal_fast_asm_loop)
|
|
|
117
127
|
_HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
118
128
|
HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
119
129
|
ZSTD_CET_ENDBRANCH
|
|
130
|
+
.cfi_startproc
|
|
131
|
+
.cfi_def_cfa_offset 8
|
|
132
|
+
.cfi_offset %rip, -8
|
|
120
133
|
/* Save all registers - even if they are callee saved for simplicity. */
|
|
121
134
|
push %rax
|
|
135
|
+
.cfi_def_cfa_offset 16
|
|
136
|
+
.cfi_offset rax, -16
|
|
122
137
|
push %rbx
|
|
138
|
+
.cfi_def_cfa_offset 24
|
|
139
|
+
.cfi_offset rbx, -24
|
|
123
140
|
push %rcx
|
|
141
|
+
.cfi_def_cfa_offset 32
|
|
142
|
+
.cfi_offset rcx, -32
|
|
124
143
|
push %rdx
|
|
144
|
+
.cfi_def_cfa_offset 40
|
|
145
|
+
.cfi_offset rdx, -40
|
|
125
146
|
push %rbp
|
|
147
|
+
.cfi_def_cfa_offset 48
|
|
148
|
+
.cfi_offset rbp, -48
|
|
126
149
|
push %rsi
|
|
150
|
+
.cfi_def_cfa_offset 56
|
|
151
|
+
.cfi_offset rsi, -56
|
|
127
152
|
push %rdi
|
|
153
|
+
.cfi_def_cfa_offset 64
|
|
154
|
+
.cfi_offset rdi, -64
|
|
128
155
|
push %r8
|
|
156
|
+
.cfi_def_cfa_offset 72
|
|
157
|
+
.cfi_offset r8, -72
|
|
129
158
|
push %r9
|
|
159
|
+
.cfi_def_cfa_offset 80
|
|
160
|
+
.cfi_offset r9, -80
|
|
130
161
|
push %r10
|
|
162
|
+
.cfi_def_cfa_offset 88
|
|
163
|
+
.cfi_offset r10, -88
|
|
131
164
|
push %r11
|
|
165
|
+
.cfi_def_cfa_offset 96
|
|
166
|
+
.cfi_offset r11, -96
|
|
132
167
|
push %r12
|
|
168
|
+
.cfi_def_cfa_offset 104
|
|
169
|
+
.cfi_offset r12, -104
|
|
133
170
|
push %r13
|
|
171
|
+
.cfi_def_cfa_offset 112
|
|
172
|
+
.cfi_offset r13, -112
|
|
134
173
|
push %r14
|
|
174
|
+
.cfi_def_cfa_offset 120
|
|
175
|
+
.cfi_offset r14, -120
|
|
135
176
|
push %r15
|
|
177
|
+
.cfi_def_cfa_offset 128
|
|
178
|
+
.cfi_offset r15, -128
|
|
136
179
|
|
|
137
180
|
/* Read HUF_DecompressAsmArgs* args from %rax */
|
|
138
181
|
#if defined(_WIN32)
|
|
@@ -154,13 +197,18 @@ HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
|
154
197
|
movq 88(%rax), %bits3
|
|
155
198
|
movq 96(%rax), %dtable
|
|
156
199
|
push %rax /* argument */
|
|
200
|
+
.cfi_def_cfa_offset 136
|
|
157
201
|
push 104(%rax) /* ilowest */
|
|
202
|
+
.cfi_def_cfa_offset 144
|
|
158
203
|
push 112(%rax) /* oend */
|
|
204
|
+
.cfi_def_cfa_offset 152
|
|
159
205
|
push %olimit /* olimit space */
|
|
206
|
+
.cfi_def_cfa_offset 160
|
|
160
207
|
|
|
161
208
|
subq $24, %rsp
|
|
209
|
+
.cfi_def_cfa_offset 184
|
|
162
210
|
|
|
163
|
-
|
|
211
|
+
LOCAL_LABEL(4X1_compute_olimit):
|
|
164
212
|
/* Computes how many iterations we can do safely
|
|
165
213
|
* %r15, %rax may be clobbered
|
|
166
214
|
* rbx, rdx must be saved
|
|
@@ -207,19 +255,19 @@ HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
|
207
255
|
/* If (op3 + 20 > olimit) */
|
|
208
256
|
movq %op3, %rax /* rax = op3 */
|
|
209
257
|
cmpq %rax, %olimit /* op3 == olimit */
|
|
210
|
-
je
|
|
258
|
+
je LOCAL_LABEL(4X1_exit)
|
|
211
259
|
|
|
212
260
|
/* If (ip1 < ip0) go to exit */
|
|
213
261
|
cmpq %ip0, %ip1
|
|
214
|
-
jb
|
|
262
|
+
jb LOCAL_LABEL(4X1_exit)
|
|
215
263
|
|
|
216
264
|
/* If (ip2 < ip1) go to exit */
|
|
217
265
|
cmpq %ip1, %ip2
|
|
218
|
-
jb
|
|
266
|
+
jb LOCAL_LABEL(4X1_exit)
|
|
219
267
|
|
|
220
268
|
/* If (ip3 < ip2) go to exit */
|
|
221
269
|
cmpq %ip2, %ip3
|
|
222
|
-
jb
|
|
270
|
+
jb LOCAL_LABEL(4X1_exit)
|
|
223
271
|
|
|
224
272
|
/* Reads top 11 bits from bits[n]
|
|
225
273
|
* Loads dt[bits[n]] into var[n]
|
|
@@ -280,7 +328,7 @@ HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
|
280
328
|
|
|
281
329
|
.p2align 6
|
|
282
330
|
|
|
283
|
-
|
|
331
|
+
LOCAL_LABEL(4X1_loop_body):
|
|
284
332
|
/* Decode 5 symbols in each of the 4 streams (20 total)
|
|
285
333
|
* Must have called GET_NEXT_DELT for each stream
|
|
286
334
|
*/
|
|
@@ -318,7 +366,7 @@ HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
|
318
366
|
|
|
319
367
|
/* If op3 < olimit: continue the loop */
|
|
320
368
|
cmp %op3, 24(%rsp)
|
|
321
|
-
ja
|
|
369
|
+
ja LOCAL_LABEL(4X1_loop_body)
|
|
322
370
|
|
|
323
371
|
/* Reload ip[1,2,3] from stack */
|
|
324
372
|
movq 0(%rsp), %ip1
|
|
@@ -326,20 +374,25 @@ HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
|
326
374
|
movq 16(%rsp), %ip3
|
|
327
375
|
|
|
328
376
|
/* Re-compute olimit */
|
|
329
|
-
jmp
|
|
377
|
+
jmp LOCAL_LABEL(4X1_compute_olimit)
|
|
330
378
|
|
|
331
379
|
#undef GET_NEXT_DELT
|
|
332
380
|
#undef DECODE_FROM_DELT
|
|
333
381
|
#undef DECODE
|
|
334
382
|
#undef RELOAD_BITS
|
|
335
|
-
|
|
383
|
+
LOCAL_LABEL(4X1_exit):
|
|
336
384
|
addq $24, %rsp
|
|
385
|
+
.cfi_def_cfa_offset 160
|
|
337
386
|
|
|
338
387
|
/* Restore stack (oend & olimit) */
|
|
339
388
|
pop %rax /* olimit */
|
|
389
|
+
.cfi_def_cfa_offset 152
|
|
340
390
|
pop %rax /* oend */
|
|
391
|
+
.cfi_def_cfa_offset 144
|
|
341
392
|
pop %rax /* ilowest */
|
|
393
|
+
.cfi_def_cfa_offset 136
|
|
342
394
|
pop %rax /* arg */
|
|
395
|
+
.cfi_def_cfa_offset 128
|
|
343
396
|
|
|
344
397
|
/* Save ip / op / bits */
|
|
345
398
|
movq %ip0, 0(%rax)
|
|
@@ -357,41 +410,105 @@ HUF_decompress4X1_usingDTable_internal_fast_asm_loop:
|
|
|
357
410
|
|
|
358
411
|
/* Restore registers */
|
|
359
412
|
pop %r15
|
|
413
|
+
.cfi_restore r15
|
|
414
|
+
.cfi_def_cfa_offset 120
|
|
360
415
|
pop %r14
|
|
416
|
+
.cfi_restore r14
|
|
417
|
+
.cfi_def_cfa_offset 112
|
|
361
418
|
pop %r13
|
|
419
|
+
.cfi_restore r13
|
|
420
|
+
.cfi_def_cfa_offset 104
|
|
362
421
|
pop %r12
|
|
422
|
+
.cfi_restore r12
|
|
423
|
+
.cfi_def_cfa_offset 96
|
|
363
424
|
pop %r11
|
|
425
|
+
.cfi_restore r11
|
|
426
|
+
.cfi_def_cfa_offset 88
|
|
364
427
|
pop %r10
|
|
428
|
+
.cfi_restore r10
|
|
429
|
+
.cfi_def_cfa_offset 80
|
|
365
430
|
pop %r9
|
|
431
|
+
.cfi_restore r9
|
|
432
|
+
.cfi_def_cfa_offset 72
|
|
366
433
|
pop %r8
|
|
434
|
+
.cfi_restore r8
|
|
435
|
+
.cfi_def_cfa_offset 64
|
|
367
436
|
pop %rdi
|
|
437
|
+
.cfi_restore rdi
|
|
438
|
+
.cfi_def_cfa_offset 56
|
|
368
439
|
pop %rsi
|
|
440
|
+
.cfi_restore rsi
|
|
441
|
+
.cfi_def_cfa_offset 48
|
|
369
442
|
pop %rbp
|
|
443
|
+
.cfi_restore rbp
|
|
444
|
+
.cfi_def_cfa_offset 40
|
|
370
445
|
pop %rdx
|
|
446
|
+
.cfi_restore rdx
|
|
447
|
+
.cfi_def_cfa_offset 32
|
|
371
448
|
pop %rcx
|
|
449
|
+
.cfi_restore rcx
|
|
450
|
+
.cfi_def_cfa_offset 24
|
|
372
451
|
pop %rbx
|
|
452
|
+
.cfi_restore rbx
|
|
453
|
+
.cfi_def_cfa_offset 16
|
|
373
454
|
pop %rax
|
|
455
|
+
.cfi_restore rax
|
|
456
|
+
.cfi_def_cfa_offset 8
|
|
374
457
|
ret
|
|
458
|
+
.cfi_endproc
|
|
375
459
|
|
|
376
460
|
_HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
|
|
377
461
|
HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
|
|
378
462
|
ZSTD_CET_ENDBRANCH
|
|
463
|
+
.cfi_startproc
|
|
464
|
+
.cfi_def_cfa_offset 8
|
|
465
|
+
.cfi_offset %rip, -8
|
|
379
466
|
/* Save all registers - even if they are callee saved for simplicity. */
|
|
380
467
|
push %rax
|
|
468
|
+
.cfi_def_cfa_offset 16
|
|
469
|
+
.cfi_offset rax, -16
|
|
381
470
|
push %rbx
|
|
471
|
+
.cfi_def_cfa_offset 24
|
|
472
|
+
.cfi_offset rbx, -24
|
|
382
473
|
push %rcx
|
|
474
|
+
.cfi_def_cfa_offset 32
|
|
475
|
+
.cfi_offset rcx, -32
|
|
383
476
|
push %rdx
|
|
477
|
+
.cfi_def_cfa_offset 40
|
|
478
|
+
.cfi_offset rdx, -40
|
|
384
479
|
push %rbp
|
|
480
|
+
.cfi_def_cfa_offset 48
|
|
481
|
+
.cfi_offset rbp, -48
|
|
385
482
|
push %rsi
|
|
483
|
+
.cfi_def_cfa_offset 56
|
|
484
|
+
.cfi_offset rsi, -56
|
|
386
485
|
push %rdi
|
|
486
|
+
.cfi_def_cfa_offset 64
|
|
487
|
+
.cfi_offset rdi, -64
|
|
387
488
|
push %r8
|
|
489
|
+
.cfi_def_cfa_offset 72
|
|
490
|
+
.cfi_offset r8, -72
|
|
388
491
|
push %r9
|
|
492
|
+
.cfi_def_cfa_offset 80
|
|
493
|
+
.cfi_offset r9, -80
|
|
389
494
|
push %r10
|
|
495
|
+
.cfi_def_cfa_offset 88
|
|
496
|
+
.cfi_offset r10, -88
|
|
390
497
|
push %r11
|
|
498
|
+
.cfi_def_cfa_offset 96
|
|
499
|
+
.cfi_offset r11, -96
|
|
391
500
|
push %r12
|
|
501
|
+
.cfi_def_cfa_offset 104
|
|
502
|
+
.cfi_offset r12, -104
|
|
392
503
|
push %r13
|
|
504
|
+
.cfi_def_cfa_offset 112
|
|
505
|
+
.cfi_offset r13, -112
|
|
393
506
|
push %r14
|
|
507
|
+
.cfi_def_cfa_offset 120
|
|
508
|
+
.cfi_offset r14, -120
|
|
394
509
|
push %r15
|
|
510
|
+
.cfi_def_cfa_offset 128
|
|
511
|
+
.cfi_offset r15, -128
|
|
395
512
|
|
|
396
513
|
/* Read HUF_DecompressAsmArgs* args from %rax */
|
|
397
514
|
#if defined(_WIN32)
|
|
@@ -413,25 +530,33 @@ HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
|
|
|
413
530
|
movq 88(%rax), %bits3
|
|
414
531
|
movq 96(%rax), %dtable
|
|
415
532
|
push %rax /* argument */
|
|
533
|
+
.cfi_def_cfa_offset 136
|
|
416
534
|
push %rax /* olimit */
|
|
535
|
+
.cfi_def_cfa_offset 144
|
|
417
536
|
push 104(%rax) /* ilowest */
|
|
537
|
+
.cfi_def_cfa_offset 152
|
|
418
538
|
|
|
419
539
|
movq 112(%rax), %rax
|
|
420
540
|
push %rax /* oend3 */
|
|
541
|
+
.cfi_def_cfa_offset 160
|
|
421
542
|
|
|
422
543
|
movq %op3, %rax
|
|
423
544
|
push %rax /* oend2 */
|
|
545
|
+
.cfi_def_cfa_offset 168
|
|
424
546
|
|
|
425
547
|
movq %op2, %rax
|
|
426
548
|
push %rax /* oend1 */
|
|
549
|
+
.cfi_def_cfa_offset 176
|
|
427
550
|
|
|
428
551
|
movq %op1, %rax
|
|
429
552
|
push %rax /* oend0 */
|
|
553
|
+
.cfi_def_cfa_offset 184
|
|
430
554
|
|
|
431
555
|
/* Scratch space */
|
|
432
556
|
subq $8, %rsp
|
|
557
|
+
.cfi_def_cfa_offset 192
|
|
433
558
|
|
|
434
|
-
|
|
559
|
+
LOCAL_LABEL(4X2_compute_olimit):
|
|
435
560
|
/* Computes how many iterations we can do safely
|
|
436
561
|
* %r15, %rax may be clobbered
|
|
437
562
|
* rdx must be saved
|
|
@@ -495,19 +620,19 @@ HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
|
|
|
495
620
|
/* If (op3 + 10 > olimit) */
|
|
496
621
|
movq %op3, %rax /* rax = op3 */
|
|
497
622
|
cmpq %rax, %olimit /* op3 == olimit */
|
|
498
|
-
je
|
|
623
|
+
je LOCAL_LABEL(4X2_exit)
|
|
499
624
|
|
|
500
625
|
/* If (ip1 < ip0) go to exit */
|
|
501
626
|
cmpq %ip0, %ip1
|
|
502
|
-
jb
|
|
627
|
+
jb LOCAL_LABEL(4X2_exit)
|
|
503
628
|
|
|
504
629
|
/* If (ip2 < ip1) go to exit */
|
|
505
630
|
cmpq %ip1, %ip2
|
|
506
|
-
jb
|
|
631
|
+
jb LOCAL_LABEL(4X2_exit)
|
|
507
632
|
|
|
508
633
|
/* If (ip3 < ip2) go to exit */
|
|
509
634
|
cmpq %ip2, %ip3
|
|
510
|
-
jb
|
|
635
|
+
jb LOCAL_LABEL(4X2_exit)
|
|
511
636
|
|
|
512
637
|
#define DECODE(n, idx) \
|
|
513
638
|
movq %bits##n, %rax; \
|
|
@@ -534,7 +659,7 @@ HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
|
|
|
534
659
|
|
|
535
660
|
.p2align 6
|
|
536
661
|
|
|
537
|
-
|
|
662
|
+
LOCAL_LABEL(4X2_loop_body):
|
|
538
663
|
/* We clobber r8, so store it on the stack */
|
|
539
664
|
movq %r8, 0(%rsp)
|
|
540
665
|
|
|
@@ -551,21 +676,29 @@ HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
|
|
|
551
676
|
FOR_EACH_STREAM(RELOAD_BITS)
|
|
552
677
|
|
|
553
678
|
cmp %op3, 48(%rsp)
|
|
554
|
-
ja
|
|
555
|
-
jmp
|
|
679
|
+
ja LOCAL_LABEL(4X2_loop_body)
|
|
680
|
+
jmp LOCAL_LABEL(4X2_compute_olimit)
|
|
556
681
|
|
|
557
682
|
#undef DECODE
|
|
558
683
|
#undef RELOAD_BITS
|
|
559
|
-
|
|
684
|
+
LOCAL_LABEL(4X2_exit):
|
|
560
685
|
addq $8, %rsp
|
|
686
|
+
.cfi_def_cfa_offset 184
|
|
561
687
|
/* Restore stack (oend & olimit) */
|
|
562
688
|
pop %rax /* oend0 */
|
|
689
|
+
.cfi_def_cfa_offset 176
|
|
563
690
|
pop %rax /* oend1 */
|
|
691
|
+
.cfi_def_cfa_offset 168
|
|
564
692
|
pop %rax /* oend2 */
|
|
693
|
+
.cfi_def_cfa_offset 160
|
|
565
694
|
pop %rax /* oend3 */
|
|
695
|
+
.cfi_def_cfa_offset 152
|
|
566
696
|
pop %rax /* ilowest */
|
|
697
|
+
.cfi_def_cfa_offset 144
|
|
567
698
|
pop %rax /* olimit */
|
|
699
|
+
.cfi_def_cfa_offset 136
|
|
568
700
|
pop %rax /* arg */
|
|
701
|
+
.cfi_def_cfa_offset 128
|
|
569
702
|
|
|
570
703
|
/* Save ip / op / bits */
|
|
571
704
|
movq %ip0, 0(%rax)
|
|
@@ -583,20 +716,51 @@ HUF_decompress4X2_usingDTable_internal_fast_asm_loop:
|
|
|
583
716
|
|
|
584
717
|
/* Restore registers */
|
|
585
718
|
pop %r15
|
|
719
|
+
.cfi_restore r15
|
|
720
|
+
.cfi_def_cfa_offset 120
|
|
586
721
|
pop %r14
|
|
722
|
+
.cfi_restore r14
|
|
723
|
+
.cfi_def_cfa_offset 112
|
|
587
724
|
pop %r13
|
|
725
|
+
.cfi_restore r13
|
|
726
|
+
.cfi_def_cfa_offset 104
|
|
588
727
|
pop %r12
|
|
728
|
+
.cfi_restore r12
|
|
729
|
+
.cfi_def_cfa_offset 96
|
|
589
730
|
pop %r11
|
|
731
|
+
.cfi_restore r11
|
|
732
|
+
.cfi_def_cfa_offset 88
|
|
590
733
|
pop %r10
|
|
734
|
+
.cfi_restore r10
|
|
735
|
+
.cfi_def_cfa_offset 80
|
|
591
736
|
pop %r9
|
|
737
|
+
.cfi_restore r9
|
|
738
|
+
.cfi_def_cfa_offset 72
|
|
592
739
|
pop %r8
|
|
740
|
+
.cfi_restore r8
|
|
741
|
+
.cfi_def_cfa_offset 64
|
|
593
742
|
pop %rdi
|
|
743
|
+
.cfi_restore rdi
|
|
744
|
+
.cfi_def_cfa_offset 56
|
|
594
745
|
pop %rsi
|
|
746
|
+
.cfi_restore rsi
|
|
747
|
+
.cfi_def_cfa_offset 48
|
|
595
748
|
pop %rbp
|
|
749
|
+
.cfi_restore rbp
|
|
750
|
+
.cfi_def_cfa_offset 40
|
|
596
751
|
pop %rdx
|
|
752
|
+
.cfi_restore rdx
|
|
753
|
+
.cfi_def_cfa_offset 32
|
|
597
754
|
pop %rcx
|
|
755
|
+
.cfi_restore rcx
|
|
756
|
+
.cfi_def_cfa_offset 24
|
|
598
757
|
pop %rbx
|
|
758
|
+
.cfi_restore rbx
|
|
759
|
+
.cfi_def_cfa_offset 16
|
|
599
760
|
pop %rax
|
|
761
|
+
.cfi_restore rax
|
|
762
|
+
.cfi_def_cfa_offset 8
|
|
600
763
|
ret
|
|
764
|
+
.cfi_endproc
|
|
601
765
|
|
|
602
766
|
#endif
|
|
@@ -35,8 +35,9 @@
|
|
|
35
35
|
*********************************************************/
|
|
36
36
|
struct ZSTD_DDict_s {
|
|
37
37
|
void* dictBuffer;
|
|
38
|
-
const void* dictContent;
|
|
38
|
+
const void* dictContent; /* complete dictionary, including any header */
|
|
39
39
|
size_t dictSize;
|
|
40
|
+
size_t dictHeaderSize; /* excluded from matchable history */
|
|
40
41
|
ZSTD_entropyDTables_t entropy;
|
|
41
42
|
U32 dictID;
|
|
42
43
|
U32 entropyPresent;
|
|
@@ -57,13 +58,20 @@ size_t ZSTD_DDict_dictSize(const ZSTD_DDict* ddict)
|
|
|
57
58
|
|
|
58
59
|
void ZSTD_copyDDictParameters(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
|
|
59
60
|
{
|
|
61
|
+
const void* content;
|
|
60
62
|
DEBUGLOG(4, "ZSTD_copyDDictParameters");
|
|
61
63
|
assert(dctx != NULL);
|
|
62
64
|
assert(ddict != NULL);
|
|
65
|
+
content = ddict->dictHeaderSize != 0
|
|
66
|
+
? (const BYTE*)ddict->dictContent + ddict->dictHeaderSize
|
|
67
|
+
: ddict->dictContent;
|
|
63
68
|
dctx->dictID = ddict->dictID;
|
|
64
|
-
dctx->prefixStart =
|
|
65
|
-
dctx->virtualStart =
|
|
66
|
-
|
|
69
|
+
dctx->prefixStart = content;
|
|
70
|
+
dctx->virtualStart = content;
|
|
71
|
+
/* An empty DDict may have NULL content. */
|
|
72
|
+
dctx->dictEnd = ddict->dictSize != 0
|
|
73
|
+
? (const BYTE*)ddict->dictContent + ddict->dictSize
|
|
74
|
+
: ddict->dictContent;
|
|
67
75
|
dctx->previousDstEnd = dctx->dictEnd;
|
|
68
76
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
|
69
77
|
dctx->dictContentBeginForFuzzing = dctx->prefixStart;
|
|
@@ -91,6 +99,7 @@ ZSTD_loadEntropy_intoDDict(ZSTD_DDict* ddict,
|
|
|
91
99
|
ZSTD_dictContentType_e dictContentType)
|
|
92
100
|
{
|
|
93
101
|
ddict->dictID = 0;
|
|
102
|
+
ddict->dictHeaderSize = 0;
|
|
94
103
|
ddict->entropyPresent = 0;
|
|
95
104
|
if (dictContentType == ZSTD_dct_rawContent) return 0;
|
|
96
105
|
|
|
@@ -109,9 +118,12 @@ ZSTD_loadEntropy_intoDDict(ZSTD_DDict* ddict,
|
|
|
109
118
|
ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + ZSTD_FRAMEIDSIZE);
|
|
110
119
|
|
|
111
120
|
/* load entropy tables */
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
dictionary_corrupted, "");
|
|
121
|
+
{ size_t const headerSize = ZSTD_loadDEntropy(
|
|
122
|
+
&ddict->entropy, ddict->dictContent, ddict->dictSize);
|
|
123
|
+
RETURN_ERROR_IF(ZSTD_isError(headerSize), dictionary_corrupted, "");
|
|
124
|
+
assert(headerSize <= ddict->dictSize);
|
|
125
|
+
ddict->dictHeaderSize = headerSize;
|
|
126
|
+
}
|
|
115
127
|
ddict->entropyPresent = 1;
|
|
116
128
|
return 0;
|
|
117
129
|
}
|
|
@@ -122,6 +134,8 @@ static size_t ZSTD_initDDict_internal(ZSTD_DDict* ddict,
|
|
|
122
134
|
ZSTD_dictLoadMethod_e dictLoadMethod,
|
|
123
135
|
ZSTD_dictContentType_e dictContentType)
|
|
124
136
|
{
|
|
137
|
+
/* An empty dictionary has no referenced storage, even in by-copy mode. */
|
|
138
|
+
if (dictSize == 0) dict = NULL;
|
|
125
139
|
if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dict) || (!dictSize)) {
|
|
126
140
|
ddict->dictBuffer = NULL;
|
|
127
141
|
ddict->dictContent = dict;
|
|
@@ -142,25 +156,41 @@ static size_t ZSTD_initDDict_internal(ZSTD_DDict* ddict,
|
|
|
142
156
|
return 0;
|
|
143
157
|
}
|
|
144
158
|
|
|
159
|
+
size_t ZSTD_createDDict_advanced_internal(ZSTD_DDict** ddictPtr,
|
|
160
|
+
const void* dict, size_t dictSize,
|
|
161
|
+
ZSTD_dictLoadMethod_e dictLoadMethod,
|
|
162
|
+
ZSTD_dictContentType_e dictContentType,
|
|
163
|
+
ZSTD_customMem customMem)
|
|
164
|
+
{
|
|
165
|
+
ZSTD_DDict* ddict;
|
|
166
|
+
*ddictPtr = NULL;
|
|
167
|
+
RETURN_ERROR_IF((!customMem.customAlloc) ^ (!customMem.customFree),
|
|
168
|
+
parameter_combination_unsupported, "Invalid custom allocator");
|
|
169
|
+
|
|
170
|
+
ddict = (ZSTD_DDict*) ZSTD_customMalloc(sizeof(ZSTD_DDict), customMem);
|
|
171
|
+
RETURN_ERROR_IF(ddict == NULL, memory_allocation, "");
|
|
172
|
+
ddict->cMem = customMem;
|
|
173
|
+
{ size_t const initResult = ZSTD_initDDict_internal(ddict,
|
|
174
|
+
dict, dictSize,
|
|
175
|
+
dictLoadMethod, dictContentType);
|
|
176
|
+
if (ZSTD_isError(initResult)) {
|
|
177
|
+
ZSTD_freeDDict(ddict);
|
|
178
|
+
return initResult;
|
|
179
|
+
} }
|
|
180
|
+
*ddictPtr = ddict;
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
|
|
145
184
|
ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
|
|
146
185
|
ZSTD_dictLoadMethod_e dictLoadMethod,
|
|
147
186
|
ZSTD_dictContentType_e dictContentType,
|
|
148
187
|
ZSTD_customMem customMem)
|
|
149
188
|
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{ size_t const initResult = ZSTD_initDDict_internal(ddict,
|
|
156
|
-
dict, dictSize,
|
|
157
|
-
dictLoadMethod, dictContentType);
|
|
158
|
-
if (ZSTD_isError(initResult)) {
|
|
159
|
-
ZSTD_freeDDict(ddict);
|
|
160
|
-
return NULL;
|
|
161
|
-
} }
|
|
162
|
-
return ddict;
|
|
163
|
-
}
|
|
189
|
+
ZSTD_DDict* ddict;
|
|
190
|
+
size_t const err = ZSTD_createDDict_advanced_internal(&ddict,
|
|
191
|
+
dict, dictSize, dictLoadMethod, dictContentType, customMem);
|
|
192
|
+
if (ZSTD_isError(err)) return NULL;
|
|
193
|
+
return ddict;
|
|
164
194
|
}
|
|
165
195
|
|
|
166
196
|
/*! ZSTD_createDDict() :
|
|
@@ -190,14 +220,13 @@ const ZSTD_DDict* ZSTD_initStaticDDict(
|
|
|
190
220
|
ZSTD_dictLoadMethod_e dictLoadMethod,
|
|
191
221
|
ZSTD_dictContentType_e dictContentType)
|
|
192
222
|
{
|
|
193
|
-
size_t const neededSpace =
|
|
194
|
-
+ (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
|
|
223
|
+
size_t const neededSpace = ZSTD_estimateDDictSize(dictSize, dictLoadMethod);
|
|
195
224
|
ZSTD_DDict* const ddict = (ZSTD_DDict*)sBuffer;
|
|
196
225
|
assert(sBuffer != NULL);
|
|
197
|
-
assert(dict != NULL);
|
|
226
|
+
assert(dict != NULL || dictSize == 0);
|
|
198
227
|
if ((size_t)sBuffer & 7) return NULL; /* 8-aligned */
|
|
199
|
-
if (sBufferSize < neededSpace) return NULL;
|
|
200
|
-
if (dictLoadMethod == ZSTD_dlm_byCopy) {
|
|
228
|
+
if (ZSTD_isError(neededSpace) || sBufferSize < neededSpace) return NULL;
|
|
229
|
+
if (dictLoadMethod == ZSTD_dlm_byCopy && dictSize != 0) {
|
|
201
230
|
ZSTD_memcpy(ddict+1, dict, dictSize); /* local copy */
|
|
202
231
|
dict = ddict+1;
|
|
203
232
|
}
|
|
@@ -224,7 +253,10 @@ size_t ZSTD_freeDDict(ZSTD_DDict* ddict)
|
|
|
224
253
|
* Note : dictionary created by reference using ZSTD_dlm_byRef are smaller */
|
|
225
254
|
size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod)
|
|
226
255
|
{
|
|
227
|
-
|
|
256
|
+
if (dictLoadMethod == ZSTD_dlm_byRef) return sizeof(ZSTD_DDict);
|
|
257
|
+
RETURN_ERROR_IF(dictSize > (size_t)-1 - sizeof(ZSTD_DDict),
|
|
258
|
+
memory_allocation, "DDict size overflow");
|
|
259
|
+
return sizeof(ZSTD_DDict) + dictSize;
|
|
228
260
|
}
|
|
229
261
|
|
|
230
262
|
size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict)
|
|
@@ -34,11 +34,22 @@
|
|
|
34
34
|
* ZSTD_getDictID_fromDict()
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
+
/* The complete dictionary blob, including its header. Legacy decoders need
|
|
38
|
+
* the original bytes; ZSTD_copyDDictParameters() excludes the header from
|
|
39
|
+
* modern match history. */
|
|
37
40
|
const void* ZSTD_DDict_dictContent(const ZSTD_DDict* ddict);
|
|
38
41
|
size_t ZSTD_DDict_dictSize(const ZSTD_DDict* ddict);
|
|
39
42
|
|
|
40
43
|
void ZSTD_copyDDictParameters(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
|
|
41
44
|
|
|
45
|
+
/* Same as ZSTD_createDDict_advanced(), but returns the error code on failure,
|
|
46
|
+
* in which case *ddictPtr is set to NULL. */
|
|
47
|
+
size_t ZSTD_createDDict_advanced_internal(ZSTD_DDict** ddictPtr,
|
|
48
|
+
const void* dict, size_t dictSize,
|
|
49
|
+
ZSTD_dictLoadMethod_e dictLoadMethod,
|
|
50
|
+
ZSTD_dictContentType_e dictContentType,
|
|
51
|
+
ZSTD_customMem customMem);
|
|
52
|
+
|
|
42
53
|
|
|
43
54
|
|
|
44
55
|
#endif /* ZSTD_DDICT_H */
|