Add some more "inconsistent n_bits" checks.

This uncovered a bug in the decode_huffman_fast function. A follow up commit
will actually fix the bug.

For what it's worth, some benchmark numbers are below, but they're
possibly bogus, as we might be decoding incorrect (and truncated) output
for some inputs. Everything since "f968950 Read bits up front in
decode_huffman_fast" landed possibly has bogus numbers too.

name                           old speed     new speed     delta
puffs_flate_decode_100k/clang  194MB/s ± 0%  204MB/s ± 1%   +5.02%  (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc    180MB/s ± 3%  202MB/s ± 1%  +12.09%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2017-11-05 09:23:49 +11:00
1 parent db57d8b707
commit f6e072fe77
5 files changed
+46 -11

No files matched your search

+3
View File
@@ -215,6 +215,9 @@ pri func flate_decoder.decode_blocks?(dst writer1, src reader1)() {
// decode_uncompressed decodes an uncompresed block as per the RFC section
// 3.2.4.
pri func flate_decoder.decode_uncompressed?(dst writer1, src reader1)() {
// TODO: make this "if" into a function invariant?
//
// Ditto for decode_huffman_slow and decode_huffman_fast.
if this.n_bits >= 8 {
return error "internal error: inconsistent n_bits"
}