Commit 77c06647 authored by bratell@opera.com's avatar bratell@opera.com

Different SPDY Hpack constant table for startup time and footprint (60KB).

The hpack constant table was 40-60 KB (gcc: 40 KB, clang: 60KB), for 
storing 2 KB of data. Not optimal.

By making it an ordinary static data table we save 60 KB with clang:

Total change: -64153 bytes
==========================
  1 added, totalling +2056 bytes across 1 sources
  1 removed, totalling -66215 bytes across 1 sources
  1 grown, for a net change of +14 bytes (367 bytes before, 381 bytes after) across 1 sources
  1 shrunk, for a net change of -8 bytes (10504 bytes before, 10496 bytes after) across 1 sources

and save 40 KB with gcc:

Total change: -41382 bytes
==========================
  1 added, totalling +2056 bytes across 1 sources
  2 removed, totalling -43597 bytes across 2 sources
  1 grown, for a net change of +167 bytes (341 bytes before, 508 bytes after) across 1 sources
  1 shrunk, for a net change of -8 bytes (10576 bytes before, 10568 bytes after) across 1 sources

BUG=394269

Review URL: https://codereview.chromium.org/393573002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284698 0039d316-1c4b-4281-b951-d872f2087c98
parent 9232de03
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "net/spdy/hpack_constants.h" #include "net/spdy/hpack_constants.h"
#include <bitset>
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
...@@ -15,9 +13,6 @@ namespace net { ...@@ -15,9 +13,6 @@ namespace net {
namespace { namespace {
uint32 bits32(const std::string& bitstring) {
return std::bitset<32>(bitstring).to_ulong();
}
// SharedHpackHuffmanTable is a Singleton wrapping a HpackHuffmanTable // SharedHpackHuffmanTable is a Singleton wrapping a HpackHuffmanTable
// instance initialized with |kHpackHuffmanCode|. // instance initialized with |kHpackHuffmanCode|.
...@@ -40,284 +35,274 @@ struct SharedHpackHuffmanTable { ...@@ -40,284 +35,274 @@ struct SharedHpackHuffmanTable {
} // namespace } // namespace
// Produced by applying the python program [1] to tables provided by [2]. // Produced by applying the python program [1] with tables
// [1] // provided by [2] (inserted into the source of the python program)
// import re, sys // and copy-paste them into this file.
// count = 0
// for l in sys.stdin:
// m = re.match(
// r"^ +('.+'|EOS)? \( *(\d+)\) \|([10\|]+) +\w+ \[ ?(\d+)\]", l)
// if m:
// g = m.groups()
// print(' {0b%s, %02s, %03s},%s' % (
// g[2].replace('|','').ljust(32,'0'), g[3], g[1],
// (' // %s' % g[0]) if g[0] else ''))
// count += 1
// print("Total: %s" % count)
// //
// [2] http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07 // [1] net/tools/build_hpack_constants.py
// [2] http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
// HpackHuffmanSymbol entries are initialized as {code, length, id}. // HpackHuffmanSymbol entries are initialized as {code, length, id}.
// Codes are specified in the |length| most-significant bits of |code|. // Codes are specified in the |length| most-significant bits of |code|.
std::vector<HpackHuffmanSymbol> HpackHuffmanCode() { std::vector<HpackHuffmanSymbol> HpackHuffmanCode() {
const HpackHuffmanSymbol kHpackHuffmanCode[] = { static const HpackHuffmanSymbol kHpackHuffmanCode[] = {
{bits32("11111111110000000000000000000000"), 13, 0}, {0xffc00000ul, 13, 0}, // 11111111|11000
{bits32("11111111111111111011000000000000"), 23, 1}, {0xffffb000ul, 23, 1}, // 11111111|11111111|1011000
{bits32("11111111111111111111111000100000"), 28, 2}, {0xfffffe20ul, 28, 2}, // 11111111|11111111|11111110|0010
{bits32("11111111111111111111111000110000"), 28, 3}, {0xfffffe30ul, 28, 3}, // 11111111|11111111|11111110|0011
{bits32("11111111111111111111111001000000"), 28, 4}, {0xfffffe40ul, 28, 4}, // 11111111|11111111|11111110|0100
{bits32("11111111111111111111111001010000"), 28, 5}, {0xfffffe50ul, 28, 5}, // 11111111|11111111|11111110|0101
{bits32("11111111111111111111111001100000"), 28, 6}, {0xfffffe60ul, 28, 6}, // 11111111|11111111|11111110|0110
{bits32("11111111111111111111111001110000"), 28, 7}, {0xfffffe70ul, 28, 7}, // 11111111|11111111|11111110|0111
{bits32("11111111111111111111111010000000"), 28, 8}, {0xfffffe80ul, 28, 8}, // 11111111|11111111|11111110|1000
{bits32("11111111111111111110101000000000"), 24, 9}, {0xffffea00ul, 24, 9}, // 11111111|11111111|11101010
{bits32("11111111111111111111111111110000"), 30, 10}, {0xfffffff0ul, 30, 10}, // 11111111|11111111|11111111|111100
{bits32("11111111111111111111111010010000"), 28, 11}, {0xfffffe90ul, 28, 11}, // 11111111|11111111|11111110|1001
{bits32("11111111111111111111111010100000"), 28, 12}, {0xfffffea0ul, 28, 12}, // 11111111|11111111|11111110|1010
{bits32("11111111111111111111111111110100"), 30, 13}, {0xfffffff4ul, 30, 13}, // 11111111|11111111|11111111|111101
{bits32("11111111111111111111111010110000"), 28, 14}, {0xfffffeb0ul, 28, 14}, // 11111111|11111111|11111110|1011
{bits32("11111111111111111111111011000000"), 28, 15}, {0xfffffec0ul, 28, 15}, // 11111111|11111111|11111110|1100
{bits32("11111111111111111111111011010000"), 28, 16}, {0xfffffed0ul, 28, 16}, // 11111111|11111111|11111110|1101
{bits32("11111111111111111111111011100000"), 28, 17}, {0xfffffee0ul, 28, 17}, // 11111111|11111111|11111110|1110
{bits32("11111111111111111111111011110000"), 28, 18}, {0xfffffef0ul, 28, 18}, // 11111111|11111111|11111110|1111
{bits32("11111111111111111111111100000000"), 28, 19}, {0xffffff00ul, 28, 19}, // 11111111|11111111|11111111|0000
{bits32("11111111111111111111111100010000"), 28, 20}, {0xffffff10ul, 28, 20}, // 11111111|11111111|11111111|0001
{bits32("11111111111111111111111100100000"), 28, 21}, {0xffffff20ul, 28, 21}, // 11111111|11111111|11111111|0010
{bits32("11111111111111111111111111111000"), 30, 22}, {0xfffffff8ul, 30, 22}, // 11111111|11111111|11111111|111110
{bits32("11111111111111111111111100110000"), 28, 23}, {0xffffff30ul, 28, 23}, // 11111111|11111111|11111111|0011
{bits32("11111111111111111111111101000000"), 28, 24}, {0xffffff40ul, 28, 24}, // 11111111|11111111|11111111|0100
{bits32("11111111111111111111111101010000"), 28, 25}, {0xffffff50ul, 28, 25}, // 11111111|11111111|11111111|0101
{bits32("11111111111111111111111101100000"), 28, 26}, {0xffffff60ul, 28, 26}, // 11111111|11111111|11111111|0110
{bits32("11111111111111111111111101110000"), 28, 27}, {0xffffff70ul, 28, 27}, // 11111111|11111111|11111111|0111
{bits32("11111111111111111111111110000000"), 28, 28}, {0xffffff80ul, 28, 28}, // 11111111|11111111|11111111|1000
{bits32("11111111111111111111111110010000"), 28, 29}, {0xffffff90ul, 28, 29}, // 11111111|11111111|11111111|1001
{bits32("11111111111111111111111110100000"), 28, 30}, {0xffffffa0ul, 28, 30}, // 11111111|11111111|11111111|1010
{bits32("11111111111111111111111110110000"), 28, 31}, {0xffffffb0ul, 28, 31}, // 11111111|11111111|11111111|1011
{bits32("01010000000000000000000000000000"), 6, 32}, // ' ' {0x50000000ul, 6, 32}, // ' ' 010100
{bits32("11111110000000000000000000000000"), 10, 33}, // '!' {0xfe000000ul, 10, 33}, // '!' 11111110|00
{bits32("11111110010000000000000000000000"), 10, 34}, // '"' {0xfe400000ul, 10, 34}, // '"' 11111110|01
{bits32("11111111101000000000000000000000"), 12, 35}, // '#' {0xffa00000ul, 12, 35}, // '#' 11111111|1010
{bits32("11111111110010000000000000000000"), 13, 36}, // '$' {0xffc80000ul, 13, 36}, // '$' 11111111|11001
{bits32("01010100000000000000000000000000"), 6, 37}, // '%' {0x54000000ul, 6, 37}, // '%' 010101
{bits32("11111000000000000000000000000000"), 8, 38}, // '&' {0xf8000000ul, 8, 38}, // '&' 11111000
{bits32("11111111010000000000000000000000"), 11, 39}, // ''' {0xff400000ul, 11, 39}, // ''' 11111111|010
{bits32("11111110100000000000000000000000"), 10, 40}, // '(' {0xfe800000ul, 10, 40}, // '(' 11111110|10
{bits32("11111110110000000000000000000000"), 10, 41}, // ')' {0xfec00000ul, 10, 41}, // ')' 11111110|11
{bits32("11111001000000000000000000000000"), 8, 42}, // '*' {0xf9000000ul, 8, 42}, // '*' 11111001
{bits32("11111111011000000000000000000000"), 11, 43}, // '+' {0xff600000ul, 11, 43}, // '+' 11111111|011
{bits32("11111010000000000000000000000000"), 8, 44}, // ',' {0xfa000000ul, 8, 44}, // ',' 11111010
{bits32("01011000000000000000000000000000"), 6, 45}, // '-' {0x58000000ul, 6, 45}, // '-' 010110
{bits32("01011100000000000000000000000000"), 6, 46}, // '.' {0x5c000000ul, 6, 46}, // '.' 010111
{bits32("01100000000000000000000000000000"), 6, 47}, // '/' {0x60000000ul, 6, 47}, // '/' 011000
{bits32("00000000000000000000000000000000"), 5, 48}, // '0' {0x00000000ul, 5, 48}, // '0' 00000
{bits32("00001000000000000000000000000000"), 5, 49}, // '1' {0x08000000ul, 5, 49}, // '1' 00001
{bits32("00010000000000000000000000000000"), 5, 50}, // '2' {0x10000000ul, 5, 50}, // '2' 00010
{bits32("01100100000000000000000000000000"), 6, 51}, // '3' {0x64000000ul, 6, 51}, // '3' 011001
{bits32("01101000000000000000000000000000"), 6, 52}, // '4' {0x68000000ul, 6, 52}, // '4' 011010
{bits32("01101100000000000000000000000000"), 6, 53}, // '5' {0x6c000000ul, 6, 53}, // '5' 011011
{bits32("01110000000000000000000000000000"), 6, 54}, // '6' {0x70000000ul, 6, 54}, // '6' 011100
{bits32("01110100000000000000000000000000"), 6, 55}, // '7' {0x74000000ul, 6, 55}, // '7' 011101
{bits32("01111000000000000000000000000000"), 6, 56}, // '8' {0x78000000ul, 6, 56}, // '8' 011110
{bits32("01111100000000000000000000000000"), 6, 57}, // '9' {0x7c000000ul, 6, 57}, // '9' 011111
{bits32("10111000000000000000000000000000"), 7, 58}, // ':' {0xb8000000ul, 7, 58}, // ':' 1011100
{bits32("11111011000000000000000000000000"), 8, 59}, // ';' {0xfb000000ul, 8, 59}, // ';' 11111011
{bits32("11111111111110000000000000000000"), 15, 60}, // '<' {0xfff80000ul, 15, 60}, // '<' 11111111|1111100
{bits32("10000000000000000000000000000000"), 6, 61}, // '=' {0x80000000ul, 6, 61}, // '=' 100000
{bits32("11111111101100000000000000000000"), 12, 62}, // '>' {0xffb00000ul, 12, 62}, // '>' 11111111|1011
{bits32("11111111000000000000000000000000"), 10, 63}, // '?' {0xff000000ul, 10, 63}, // '?' 11111111|00
{bits32("11111111110100000000000000000000"), 13, 64}, // '@' {0xffd00000ul, 13, 64}, // '@' 11111111|11010
{bits32("10000100000000000000000000000000"), 6, 65}, // 'A' {0x84000000ul, 6, 65}, // 'A' 100001
{bits32("10111010000000000000000000000000"), 7, 66}, // 'B' {0xba000000ul, 7, 66}, // 'B' 1011101
{bits32("10111100000000000000000000000000"), 7, 67}, // 'C' {0xbc000000ul, 7, 67}, // 'C' 1011110
{bits32("10111110000000000000000000000000"), 7, 68}, // 'D' {0xbe000000ul, 7, 68}, // 'D' 1011111
{bits32("11000000000000000000000000000000"), 7, 69}, // 'E' {0xc0000000ul, 7, 69}, // 'E' 1100000
{bits32("11000010000000000000000000000000"), 7, 70}, // 'F' {0xc2000000ul, 7, 70}, // 'F' 1100001
{bits32("11000100000000000000000000000000"), 7, 71}, // 'G' {0xc4000000ul, 7, 71}, // 'G' 1100010
{bits32("11000110000000000000000000000000"), 7, 72}, // 'H' {0xc6000000ul, 7, 72}, // 'H' 1100011
{bits32("11001000000000000000000000000000"), 7, 73}, // 'I' {0xc8000000ul, 7, 73}, // 'I' 1100100
{bits32("11001010000000000000000000000000"), 7, 74}, // 'J' {0xca000000ul, 7, 74}, // 'J' 1100101
{bits32("11001100000000000000000000000000"), 7, 75}, // 'K' {0xcc000000ul, 7, 75}, // 'K' 1100110
{bits32("11001110000000000000000000000000"), 7, 76}, // 'L' {0xce000000ul, 7, 76}, // 'L' 1100111
{bits32("11010000000000000000000000000000"), 7, 77}, // 'M' {0xd0000000ul, 7, 77}, // 'M' 1101000
{bits32("11010010000000000000000000000000"), 7, 78}, // 'N' {0xd2000000ul, 7, 78}, // 'N' 1101001
{bits32("11010100000000000000000000000000"), 7, 79}, // 'O' {0xd4000000ul, 7, 79}, // 'O' 1101010
{bits32("11010110000000000000000000000000"), 7, 80}, // 'P' {0xd6000000ul, 7, 80}, // 'P' 1101011
{bits32("11011000000000000000000000000000"), 7, 81}, // 'Q' {0xd8000000ul, 7, 81}, // 'Q' 1101100
{bits32("11011010000000000000000000000000"), 7, 82}, // 'R' {0xda000000ul, 7, 82}, // 'R' 1101101
{bits32("11011100000000000000000000000000"), 7, 83}, // 'S' {0xdc000000ul, 7, 83}, // 'S' 1101110
{bits32("11011110000000000000000000000000"), 7, 84}, // 'T' {0xde000000ul, 7, 84}, // 'T' 1101111
{bits32("11100000000000000000000000000000"), 7, 85}, // 'U' {0xe0000000ul, 7, 85}, // 'U' 1110000
{bits32("11100010000000000000000000000000"), 7, 86}, // 'V' {0xe2000000ul, 7, 86}, // 'V' 1110001
{bits32("11100100000000000000000000000000"), 7, 87}, // 'W' {0xe4000000ul, 7, 87}, // 'W' 1110010
{bits32("11111100000000000000000000000000"), 8, 88}, // 'X' {0xfc000000ul, 8, 88}, // 'X' 11111100
{bits32("11100110000000000000000000000000"), 7, 89}, // 'Y' {0xe6000000ul, 7, 89}, // 'Y' 1110011
{bits32("11111101000000000000000000000000"), 8, 90}, // 'Z' {0xfd000000ul, 8, 90}, // 'Z' 11111101
{bits32("11111111110110000000000000000000"), 13, 91}, // '[' {0xffd80000ul, 13, 91}, // '[' 11111111|11011
{bits32("11111111111111100000000000000000"), 19, 92}, // '\' {0xfffe0000ul, 19, 92}, // '\' 11111111|11111110|000
{bits32("11111111111000000000000000000000"), 13, 93}, // ']' {0xffe00000ul, 13, 93}, // ']' 11111111|11100
{bits32("11111111111100000000000000000000"), 14, 94}, // '^' {0xfff00000ul, 14, 94}, // '^' 11111111|111100
{bits32("10001000000000000000000000000000"), 6, 95}, // '_' {0x88000000ul, 6, 95}, // '_' 100010
{bits32("11111111111110100000000000000000"), 15, 96}, // '`' {0xfffa0000ul, 15, 96}, // '`' 11111111|1111101
{bits32("00011000000000000000000000000000"), 5, 97}, // 'a' {0x18000000ul, 5, 97}, // 'a' 00011
{bits32("10001100000000000000000000000000"), 6, 98}, // 'b' {0x8c000000ul, 6, 98}, // 'b' 100011
{bits32("00100000000000000000000000000000"), 5, 99}, // 'c' {0x20000000ul, 5, 99}, // 'c' 00100
{bits32("10010000000000000000000000000000"), 6, 100}, // 'd' {0x90000000ul, 6, 100}, // 'd' 100100
{bits32("00101000000000000000000000000000"), 5, 101}, // 'e' {0x28000000ul, 5, 101}, // 'e' 00101
{bits32("10010100000000000000000000000000"), 6, 102}, // 'f' {0x94000000ul, 6, 102}, // 'f' 100101
{bits32("10011000000000000000000000000000"), 6, 103}, // 'g' {0x98000000ul, 6, 103}, // 'g' 100110
{bits32("10011100000000000000000000000000"), 6, 104}, // 'h' {0x9c000000ul, 6, 104}, // 'h' 100111
{bits32("00110000000000000000000000000000"), 5, 105}, // 'i' {0x30000000ul, 5, 105}, // 'i' 00110
{bits32("11101000000000000000000000000000"), 7, 106}, // 'j' {0xe8000000ul, 7, 106}, // 'j' 1110100
{bits32("11101010000000000000000000000000"), 7, 107}, // 'k' {0xea000000ul, 7, 107}, // 'k' 1110101
{bits32("10100000000000000000000000000000"), 6, 108}, // 'l' {0xa0000000ul, 6, 108}, // 'l' 101000
{bits32("10100100000000000000000000000000"), 6, 109}, // 'm' {0xa4000000ul, 6, 109}, // 'm' 101001
{bits32("10101000000000000000000000000000"), 6, 110}, // 'n' {0xa8000000ul, 6, 110}, // 'n' 101010
{bits32("00111000000000000000000000000000"), 5, 111}, // 'o' {0x38000000ul, 5, 111}, // 'o' 00111
{bits32("10101100000000000000000000000000"), 6, 112}, // 'p' {0xac000000ul, 6, 112}, // 'p' 101011
{bits32("11101100000000000000000000000000"), 7, 113}, // 'q' {0xec000000ul, 7, 113}, // 'q' 1110110
{bits32("10110000000000000000000000000000"), 6, 114}, // 'r' {0xb0000000ul, 6, 114}, // 'r' 101100
{bits32("01000000000000000000000000000000"), 5, 115}, // 's' {0x40000000ul, 5, 115}, // 's' 01000
{bits32("01001000000000000000000000000000"), 5, 116}, // 't' {0x48000000ul, 5, 116}, // 't' 01001
{bits32("10110100000000000000000000000000"), 6, 117}, // 'u' {0xb4000000ul, 6, 117}, // 'u' 101101
{bits32("11101110000000000000000000000000"), 7, 118}, // 'v' {0xee000000ul, 7, 118}, // 'v' 1110111
{bits32("11110000000000000000000000000000"), 7, 119}, // 'w' {0xf0000000ul, 7, 119}, // 'w' 1111000
{bits32("11110010000000000000000000000000"), 7, 120}, // 'x' {0xf2000000ul, 7, 120}, // 'x' 1111001
{bits32("11110100000000000000000000000000"), 7, 121}, // 'y' {0xf4000000ul, 7, 121}, // 'y' 1111010
{bits32("11110110000000000000000000000000"), 7, 122}, // 'z' {0xf6000000ul, 7, 122}, // 'z' 1111011
{bits32("11111111111111000000000000000000"), 15, 123}, // '{' {0xfffc0000ul, 15, 123}, // '{' 11111111|1111110
{bits32("11111111100000000000000000000000"), 11, 124}, // '|' {0xff800000ul, 11, 124}, // '|' 11111111|100
{bits32("11111111111101000000000000000000"), 14, 125}, // '}' {0xfff40000ul, 14, 125}, // '}' 11111111|111101
{bits32("11111111111010000000000000000000"), 13, 126}, // '~' {0xffe80000ul, 13, 126}, // '~' 11111111|11101
{bits32("11111111111111111111111111000000"), 28, 127}, {0xffffffc0ul, 28, 127}, // 11111111|11111111|11111111|1100
{bits32("11111111111111100110000000000000"), 20, 128}, {0xfffe6000ul, 20, 128}, // 11111111|11111110|0110
{bits32("11111111111111110100100000000000"), 22, 129}, {0xffff4800ul, 22, 129}, // 11111111|11111111|010010
{bits32("11111111111111100111000000000000"), 20, 130}, {0xfffe7000ul, 20, 130}, // 11111111|11111110|0111
{bits32("11111111111111101000000000000000"), 20, 131}, {0xfffe8000ul, 20, 131}, // 11111111|11111110|1000
{bits32("11111111111111110100110000000000"), 22, 132}, {0xffff4c00ul, 22, 132}, // 11111111|11111111|010011
{bits32("11111111111111110101000000000000"), 22, 133}, {0xffff5000ul, 22, 133}, // 11111111|11111111|010100
{bits32("11111111111111110101010000000000"), 22, 134}, {0xffff5400ul, 22, 134}, // 11111111|11111111|010101
{bits32("11111111111111111011001000000000"), 23, 135}, {0xffffb200ul, 23, 135}, // 11111111|11111111|1011001
{bits32("11111111111111110101100000000000"), 22, 136}, {0xffff5800ul, 22, 136}, // 11111111|11111111|010110
{bits32("11111111111111111011010000000000"), 23, 137}, {0xffffb400ul, 23, 137}, // 11111111|11111111|1011010
{bits32("11111111111111111011011000000000"), 23, 138}, {0xffffb600ul, 23, 138}, // 11111111|11111111|1011011
{bits32("11111111111111111011100000000000"), 23, 139}, {0xffffb800ul, 23, 139}, // 11111111|11111111|1011100
{bits32("11111111111111111011101000000000"), 23, 140}, {0xffffba00ul, 23, 140}, // 11111111|11111111|1011101
{bits32("11111111111111111011110000000000"), 23, 141}, {0xffffbc00ul, 23, 141}, // 11111111|11111111|1011110
{bits32("11111111111111111110101100000000"), 24, 142}, {0xffffeb00ul, 24, 142}, // 11111111|11111111|11101011
{bits32("11111111111111111011111000000000"), 23, 143}, {0xffffbe00ul, 23, 143}, // 11111111|11111111|1011111
{bits32("11111111111111111110110000000000"), 24, 144}, {0xffffec00ul, 24, 144}, // 11111111|11111111|11101100
{bits32("11111111111111111110110100000000"), 24, 145}, {0xffffed00ul, 24, 145}, // 11111111|11111111|11101101
{bits32("11111111111111110101110000000000"), 22, 146}, {0xffff5c00ul, 22, 146}, // 11111111|11111111|010111
{bits32("11111111111111111100000000000000"), 23, 147}, {0xffffc000ul, 23, 147}, // 11111111|11111111|1100000
{bits32("11111111111111111110111000000000"), 24, 148}, {0xffffee00ul, 24, 148}, // 11111111|11111111|11101110
{bits32("11111111111111111100001000000000"), 23, 149}, {0xffffc200ul, 23, 149}, // 11111111|11111111|1100001
{bits32("11111111111111111100010000000000"), 23, 150}, {0xffffc400ul, 23, 150}, // 11111111|11111111|1100010
{bits32("11111111111111111100011000000000"), 23, 151}, {0xffffc600ul, 23, 151}, // 11111111|11111111|1100011
{bits32("11111111111111111100100000000000"), 23, 152}, {0xffffc800ul, 23, 152}, // 11111111|11111111|1100100
{bits32("11111111111111101110000000000000"), 21, 153}, {0xfffee000ul, 21, 153}, // 11111111|11111110|11100
{bits32("11111111111111110110000000000000"), 22, 154}, {0xffff6000ul, 22, 154}, // 11111111|11111111|011000
{bits32("11111111111111111100101000000000"), 23, 155}, {0xffffca00ul, 23, 155}, // 11111111|11111111|1100101
{bits32("11111111111111110110010000000000"), 22, 156}, {0xffff6400ul, 22, 156}, // 11111111|11111111|011001
{bits32("11111111111111111100110000000000"), 23, 157}, {0xffffcc00ul, 23, 157}, // 11111111|11111111|1100110
{bits32("11111111111111111100111000000000"), 23, 158}, {0xffffce00ul, 23, 158}, // 11111111|11111111|1100111
{bits32("11111111111111111110111100000000"), 24, 159}, {0xffffef00ul, 24, 159}, // 11111111|11111111|11101111
{bits32("11111111111111110110100000000000"), 22, 160}, {0xffff6800ul, 22, 160}, // 11111111|11111111|011010
{bits32("11111111111111101110100000000000"), 21, 161}, {0xfffee800ul, 21, 161}, // 11111111|11111110|11101
{bits32("11111111111111101001000000000000"), 20, 162}, {0xfffe9000ul, 20, 162}, // 11111111|11111110|1001
{bits32("11111111111111110110110000000000"), 22, 163}, {0xffff6c00ul, 22, 163}, // 11111111|11111111|011011
{bits32("11111111111111110111000000000000"), 22, 164}, {0xffff7000ul, 22, 164}, // 11111111|11111111|011100
{bits32("11111111111111111101000000000000"), 23, 165}, {0xffffd000ul, 23, 165}, // 11111111|11111111|1101000
{bits32("11111111111111111101001000000000"), 23, 166}, {0xffffd200ul, 23, 166}, // 11111111|11111111|1101001
{bits32("11111111111111101111000000000000"), 21, 167}, {0xfffef000ul, 21, 167}, // 11111111|11111110|11110
{bits32("11111111111111111101010000000000"), 23, 168}, {0xffffd400ul, 23, 168}, // 11111111|11111111|1101010
{bits32("11111111111111110111010000000000"), 22, 169}, {0xffff7400ul, 22, 169}, // 11111111|11111111|011101
{bits32("11111111111111110111100000000000"), 22, 170}, {0xffff7800ul, 22, 170}, // 11111111|11111111|011110
{bits32("11111111111111111111000000000000"), 24, 171}, {0xfffff000ul, 24, 171}, // 11111111|11111111|11110000
{bits32("11111111111111101111100000000000"), 21, 172}, {0xfffef800ul, 21, 172}, // 11111111|11111110|11111
{bits32("11111111111111110111110000000000"), 22, 173}, {0xffff7c00ul, 22, 173}, // 11111111|11111111|011111
{bits32("11111111111111111101011000000000"), 23, 174}, {0xffffd600ul, 23, 174}, // 11111111|11111111|1101011
{bits32("11111111111111111101100000000000"), 23, 175}, {0xffffd800ul, 23, 175}, // 11111111|11111111|1101100
{bits32("11111111111111110000000000000000"), 21, 176}, {0xffff0000ul, 21, 176}, // 11111111|11111111|00000
{bits32("11111111111111110000100000000000"), 21, 177}, {0xffff0800ul, 21, 177}, // 11111111|11111111|00001
{bits32("11111111111111111000000000000000"), 22, 178}, {0xffff8000ul, 22, 178}, // 11111111|11111111|100000
{bits32("11111111111111110001000000000000"), 21, 179}, {0xffff1000ul, 21, 179}, // 11111111|11111111|00010
{bits32("11111111111111111101101000000000"), 23, 180}, {0xffffda00ul, 23, 180}, // 11111111|11111111|1101101
{bits32("11111111111111111000010000000000"), 22, 181}, {0xffff8400ul, 22, 181}, // 11111111|11111111|100001
{bits32("11111111111111111101110000000000"), 23, 182}, {0xffffdc00ul, 23, 182}, // 11111111|11111111|1101110
{bits32("11111111111111111101111000000000"), 23, 183}, {0xffffde00ul, 23, 183}, // 11111111|11111111|1101111
{bits32("11111111111111101010000000000000"), 20, 184}, {0xfffea000ul, 20, 184}, // 11111111|11111110|1010
{bits32("11111111111111111000100000000000"), 22, 185}, {0xffff8800ul, 22, 185}, // 11111111|11111111|100010
{bits32("11111111111111111000110000000000"), 22, 186}, {0xffff8c00ul, 22, 186}, // 11111111|11111111|100011
{bits32("11111111111111111001000000000000"), 22, 187}, {0xffff9000ul, 22, 187}, // 11111111|11111111|100100
{bits32("11111111111111111110000000000000"), 23, 188}, {0xffffe000ul, 23, 188}, // 11111111|11111111|1110000
{bits32("11111111111111111001010000000000"), 22, 189}, {0xffff9400ul, 22, 189}, // 11111111|11111111|100101
{bits32("11111111111111111001100000000000"), 22, 190}, {0xffff9800ul, 22, 190}, // 11111111|11111111|100110
{bits32("11111111111111111110001000000000"), 23, 191}, {0xffffe200ul, 23, 191}, // 11111111|11111111|1110001
{bits32("11111111111111111111100000000000"), 26, 192}, {0xfffff800ul, 26, 192}, // 11111111|11111111|11111000|00
{bits32("11111111111111111111100001000000"), 26, 193}, {0xfffff840ul, 26, 193}, // 11111111|11111111|11111000|01
{bits32("11111111111111101011000000000000"), 20, 194}, {0xfffeb000ul, 20, 194}, // 11111111|11111110|1011
{bits32("11111111111111100010000000000000"), 19, 195}, {0xfffe2000ul, 19, 195}, // 11111111|11111110|001
{bits32("11111111111111111001110000000000"), 22, 196}, {0xffff9c00ul, 22, 196}, // 11111111|11111111|100111
{bits32("11111111111111111110010000000000"), 23, 197}, {0xffffe400ul, 23, 197}, // 11111111|11111111|1110010
{bits32("11111111111111111010000000000000"), 22, 198}, {0xffffa000ul, 22, 198}, // 11111111|11111111|101000
{bits32("11111111111111111111011000000000"), 25, 199}, {0xfffff600ul, 25, 199}, // 11111111|11111111|11110110|0
{bits32("11111111111111111111100010000000"), 26, 200}, {0xfffff880ul, 26, 200}, // 11111111|11111111|11111000|10
{bits32("11111111111111111111100011000000"), 26, 201}, {0xfffff8c0ul, 26, 201}, // 11111111|11111111|11111000|11
{bits32("11111111111111111111100100000000"), 26, 202}, {0xfffff900ul, 26, 202}, // 11111111|11111111|11111001|00
{bits32("11111111111111111111101111000000"), 27, 203}, {0xfffffbc0ul, 27, 203}, // 11111111|11111111|11111011|110
{bits32("11111111111111111111101111100000"), 27, 204}, {0xfffffbe0ul, 27, 204}, // 11111111|11111111|11111011|111
{bits32("11111111111111111111100101000000"), 26, 205}, {0xfffff940ul, 26, 205}, // 11111111|11111111|11111001|01
{bits32("11111111111111111111000100000000"), 24, 206}, {0xfffff100ul, 24, 206}, // 11111111|11111111|11110001
{bits32("11111111111111111111011010000000"), 25, 207}, {0xfffff680ul, 25, 207}, // 11111111|11111111|11110110|1
{bits32("11111111111111100100000000000000"), 19, 208}, {0xfffe4000ul, 19, 208}, // 11111111|11111110|010
{bits32("11111111111111110001100000000000"), 21, 209}, {0xffff1800ul, 21, 209}, // 11111111|11111111|00011
{bits32("11111111111111111111100110000000"), 26, 210}, {0xfffff980ul, 26, 210}, // 11111111|11111111|11111001|10
{bits32("11111111111111111111110000000000"), 27, 211}, {0xfffffc00ul, 27, 211}, // 11111111|11111111|11111100|000
{bits32("11111111111111111111110000100000"), 27, 212}, {0xfffffc20ul, 27, 212}, // 11111111|11111111|11111100|001
{bits32("11111111111111111111100111000000"), 26, 213}, {0xfffff9c0ul, 26, 213}, // 11111111|11111111|11111001|11
{bits32("11111111111111111111110001000000"), 27, 214}, {0xfffffc40ul, 27, 214}, // 11111111|11111111|11111100|010
{bits32("11111111111111111111001000000000"), 24, 215}, {0xfffff200ul, 24, 215}, // 11111111|11111111|11110010
{bits32("11111111111111110010000000000000"), 21, 216}, {0xffff2000ul, 21, 216}, // 11111111|11111111|00100
{bits32("11111111111111110010100000000000"), 21, 217}, {0xffff2800ul, 21, 217}, // 11111111|11111111|00101
{bits32("11111111111111111111101000000000"), 26, 218}, {0xfffffa00ul, 26, 218}, // 11111111|11111111|11111010|00
{bits32("11111111111111111111101001000000"), 26, 219}, {0xfffffa40ul, 26, 219}, // 11111111|11111111|11111010|01
{bits32("11111111111111111111111111010000"), 28, 220}, {0xffffffd0ul, 28, 220}, // 11111111|11111111|11111111|1101
{bits32("11111111111111111111110001100000"), 27, 221}, {0xfffffc60ul, 27, 221}, // 11111111|11111111|11111100|011
{bits32("11111111111111111111110010000000"), 27, 222}, {0xfffffc80ul, 27, 222}, // 11111111|11111111|11111100|100
{bits32("11111111111111111111110010100000"), 27, 223}, {0xfffffca0ul, 27, 223}, // 11111111|11111111|11111100|101
{bits32("11111111111111101100000000000000"), 20, 224}, {0xfffec000ul, 20, 224}, // 11111111|11111110|1100
{bits32("11111111111111111111001100000000"), 24, 225}, {0xfffff300ul, 24, 225}, // 11111111|11111111|11110011
{bits32("11111111111111101101000000000000"), 20, 226}, {0xfffed000ul, 20, 226}, // 11111111|11111110|1101
{bits32("11111111111111110011000000000000"), 21, 227}, {0xffff3000ul, 21, 227}, // 11111111|11111111|00110
{bits32("11111111111111111010010000000000"), 22, 228}, {0xffffa400ul, 22, 228}, // 11111111|11111111|101001
{bits32("11111111111111110011100000000000"), 21, 229}, {0xffff3800ul, 21, 229}, // 11111111|11111111|00111
{bits32("11111111111111110100000000000000"), 21, 230}, {0xffff4000ul, 21, 230}, // 11111111|11111111|01000
{bits32("11111111111111111110011000000000"), 23, 231}, {0xffffe600ul, 23, 231}, // 11111111|11111111|1110011
{bits32("11111111111111111010100000000000"), 22, 232}, {0xffffa800ul, 22, 232}, // 11111111|11111111|101010
{bits32("11111111111111111010110000000000"), 22, 233}, {0xffffac00ul, 22, 233}, // 11111111|11111111|101011
{bits32("11111111111111111111011100000000"), 25, 234}, {0xfffff700ul, 25, 234}, // 11111111|11111111|11110111|0
{bits32("11111111111111111111011110000000"), 25, 235}, {0xfffff780ul, 25, 235}, // 11111111|11111111|11110111|1
{bits32("11111111111111111111010000000000"), 24, 236}, {0xfffff400ul, 24, 236}, // 11111111|11111111|11110100
{bits32("11111111111111111111010100000000"), 24, 237}, {0xfffff500ul, 24, 237}, // 11111111|11111111|11110101
{bits32("11111111111111111111101010000000"), 26, 238}, {0xfffffa80ul, 26, 238}, // 11111111|11111111|11111010|10
{bits32("11111111111111111110100000000000"), 23, 239}, {0xffffe800ul, 23, 239}, // 11111111|11111111|1110100
{bits32("11111111111111111111101011000000"), 26, 240}, {0xfffffac0ul, 26, 240}, // 11111111|11111111|11111010|11
{bits32("11111111111111111111110011000000"), 27, 241}, {0xfffffcc0ul, 27, 241}, // 11111111|11111111|11111100|110
{bits32("11111111111111111111101100000000"), 26, 242}, {0xfffffb00ul, 26, 242}, // 11111111|11111111|11111011|00
{bits32("11111111111111111111101101000000"), 26, 243}, {0xfffffb40ul, 26, 243}, // 11111111|11111111|11111011|01
{bits32("11111111111111111111110011100000"), 27, 244}, {0xfffffce0ul, 27, 244}, // 11111111|11111111|11111100|111
{bits32("11111111111111111111110100000000"), 27, 245}, {0xfffffd00ul, 27, 245}, // 11111111|11111111|11111101|000
{bits32("11111111111111111111110100100000"), 27, 246}, {0xfffffd20ul, 27, 246}, // 11111111|11111111|11111101|001
{bits32("11111111111111111111110101000000"), 27, 247}, {0xfffffd40ul, 27, 247}, // 11111111|11111111|11111101|010
{bits32("11111111111111111111110101100000"), 27, 248}, {0xfffffd60ul, 27, 248}, // 11111111|11111111|11111101|011
{bits32("11111111111111111111111111100000"), 28, 249}, {0xffffffe0ul, 28, 249}, // 11111111|11111111|11111111|1110
{bits32("11111111111111111111110110000000"), 27, 250}, {0xfffffd80ul, 27, 250}, // 11111111|11111111|11111101|100
{bits32("11111111111111111111110110100000"), 27, 251}, {0xfffffda0ul, 27, 251}, // 11111111|11111111|11111101|101
{bits32("11111111111111111111110111000000"), 27, 252}, {0xfffffdc0ul, 27, 252}, // 11111111|11111111|11111101|110
{bits32("11111111111111111111110111100000"), 27, 253}, {0xfffffde0ul, 27, 253}, // 11111111|11111111|11111101|111
{bits32("11111111111111111111111000000000"), 27, 254}, {0xfffffe00ul, 27, 254}, // 11111111|11111111|11111110|000
{bits32("11111111111111111111101110000000"), 26, 255}, {0xfffffb80ul, 26, 255}, // 11111111|11111111|11111011|10
{bits32("11111111111111111111111111111100"), 30, 256}, // EOS {0xfffffffcul, 30, 256}, // EOS 11111111|11111111|11111111|111111
}; };
return std::vector<HpackHuffmanSymbol>( return std::vector<HpackHuffmanSymbol>(
kHpackHuffmanCode, kHpackHuffmanCode,
......
#!/usr/bin/env python
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""This script builds a table that has to be manully inserted into
net/spdy/hpack_constants.cc. It also contains data that potentially
has to be updated if the http hpack algorithm changes its
constants."""
import re
# This is from
# http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
# It may include dummy rows as long as those don't look too much like real
# data.
SPEC_DATA_DRAFT_08 = r"""
code
code as bits as hex len
sym aligned to MSB aligned in
to LSB bits
( 0) |11111111|11000 1ff8 [13]
( 1) |11111111|11111111|1011000 7fffd8 [23]
( 2) |11111111|11111111|11111110|0010 fffffe2 [28]
( 3) |11111111|11111111|11111110|0011 fffffe3 [28]
( 4) |11111111|11111111|11111110|0100 fffffe4 [28]
( 5) |11111111|11111111|11111110|0101 fffffe5 [28]
( 6) |11111111|11111111|11111110|0110 fffffe6 [28]
( 7) |11111111|11111111|11111110|0111 fffffe7 [28]
( 8) |11111111|11111111|11111110|1000 fffffe8 [28]
( 9) |11111111|11111111|11101010 ffffea [24]
( 10) |11111111|11111111|11111111|111100 3ffffffc [30]
( 11) |11111111|11111111|11111110|1001 fffffe9 [28]
( 12) |11111111|11111111|11111110|1010 fffffea [28]
( 13) |11111111|11111111|11111111|111101 3ffffffd [30]
( 14) |11111111|11111111|11111110|1011 fffffeb [28]
( 15) |11111111|11111111|11111110|1100 fffffec [28]
( 16) |11111111|11111111|11111110|1101 fffffed [28]
( 17) |11111111|11111111|11111110|1110 fffffee [28]
( 18) |11111111|11111111|11111110|1111 fffffef [28]
( 19) |11111111|11111111|11111111|0000 ffffff0 [28]
( 20) |11111111|11111111|11111111|0001 ffffff1 [28]
( 21) |11111111|11111111|11111111|0010 ffffff2 [28]
( 22) |11111111|11111111|11111111|111110 3ffffffe [30]
( 23) |11111111|11111111|11111111|0011 ffffff3 [28]
( 24) |11111111|11111111|11111111|0100 ffffff4 [28]
( 25) |11111111|11111111|11111111|0101 ffffff5 [28]
( 26) |11111111|11111111|11111111|0110 ffffff6 [28]
( 27) |11111111|11111111|11111111|0111 ffffff7 [28]
( 28) |11111111|11111111|11111111|1000 ffffff8 [28]
( 29) |11111111|11111111|11111111|1001 ffffff9 [28]
( 30) |11111111|11111111|11111111|1010 ffffffa [28]
( 31) |11111111|11111111|11111111|1011 ffffffb [28]
' ' ( 32) |010100 14 [ 6]
'!' ( 33) |11111110|00 3f8 [10]
'"' ( 34) |11111110|01 3f9 [10]
'#' ( 35) |11111111|1010 ffa [12]
'$' ( 36) |11111111|11001 1ff9 [13]
'%' ( 37) |010101 15 [ 6]
'&' ( 38) |11111000 f8 [ 8]
''' ( 39) |11111111|010 7fa [11]
'(' ( 40) |11111110|10 3fa [10]
')' ( 41) |11111110|11 3fb [10]
'*' ( 42) |11111001 f9 [ 8]
'+' ( 43) |11111111|011 7fb [11]
',' ( 44) |11111010 fa [ 8]
'-' ( 45) |010110 16 [ 6]
'.' ( 46) |010111 17 [ 6]
'/' ( 47) |011000 18 [ 6]
'0' ( 48) |00000 0 [ 5]
'1' ( 49) |00001 1 [ 5]
'2' ( 50) |00010 2 [ 5]
'3' ( 51) |011001 19 [ 6]
'4' ( 52) |011010 1a [ 6]
'5' ( 53) |011011 1b [ 6]
'6' ( 54) |011100 1c [ 6]
'7' ( 55) |011101 1d [ 6]
'8' ( 56) |011110 1e [ 6]
'9' ( 57) |011111 1f [ 6]
':' ( 58) |1011100 5c [ 7]
';' ( 59) |11111011 fb [ 8]
'<' ( 60) |11111111|1111100 7ffc [15]
'=' ( 61) |100000 20 [ 6]
'>' ( 62) |11111111|1011 ffb [12]
'?' ( 63) |11111111|00 3fc [10]
'@' ( 64) |11111111|11010 1ffa [13]
'A' ( 65) |100001 21 [ 6]
'B' ( 66) |1011101 5d [ 7]
'C' ( 67) |1011110 5e [ 7]
'D' ( 68) |1011111 5f [ 7]
'E' ( 69) |1100000 60 [ 7]
'F' ( 70) |1100001 61 [ 7]
'G' ( 71) |1100010 62 [ 7]
'H' ( 72) |1100011 63 [ 7]
'I' ( 73) |1100100 64 [ 7]
'J' ( 74) |1100101 65 [ 7]
'K' ( 75) |1100110 66 [ 7]
'L' ( 76) |1100111 67 [ 7]
'M' ( 77) |1101000 68 [ 7]
'N' ( 78) |1101001 69 [ 7]
'O' ( 79) |1101010 6a [ 7]
'P' ( 80) |1101011 6b [ 7]
'Q' ( 81) |1101100 6c [ 7]
'R' ( 82) |1101101 6d [ 7]
'S' ( 83) |1101110 6e [ 7]
'T' ( 84) |1101111 6f [ 7]
'U' ( 85) |1110000 70 [ 7]
'V' ( 86) |1110001 71 [ 7]
'W' ( 87) |1110010 72 [ 7]
'X' ( 88) |11111100 fc [ 8]
'Y' ( 89) |1110011 73 [ 7]
'Z' ( 90) |11111101 fd [ 8]
'[' ( 91) |11111111|11011 1ffb [13]
'\' ( 92) |11111111|11111110|000 7fff0 [19]
']' ( 93) |11111111|11100 1ffc [13]
'^' ( 94) |11111111|111100 3ffc [14]
'_' ( 95) |100010 22 [ 6]
'`' ( 96) |11111111|1111101 7ffd [15]
'a' ( 97) |00011 3 [ 5]
'b' ( 98) |100011 23 [ 6]
'c' ( 99) |00100 4 [ 5]
'd' (100) |100100 24 [ 6]
'e' (101) |00101 5 [ 5]
'f' (102) |100101 25 [ 6]
'g' (103) |100110 26 [ 6]
'h' (104) |100111 27 [ 6]
'i' (105) |00110 6 [ 5]
'j' (106) |1110100 74 [ 7]
'k' (107) |1110101 75 [ 7]
'l' (108) |101000 28 [ 6]
'm' (109) |101001 29 [ 6]
'n' (110) |101010 2a [ 6]
'o' (111) |00111 7 [ 5]
'p' (112) |101011 2b [ 6]
'q' (113) |1110110 76 [ 7]
'r' (114) |101100 2c [ 6]
's' (115) |01000 8 [ 5]
't' (116) |01001 9 [ 5]
'u' (117) |101101 2d [ 6]
'v' (118) |1110111 77 [ 7]
'w' (119) |1111000 78 [ 7]
'x' (120) |1111001 79 [ 7]
'y' (121) |1111010 7a [ 7]
'z' (122) |1111011 7b [ 7]
'{' (123) |11111111|1111110 7ffe [15]
'|' (124) |11111111|100 7fc [11]
'}' (125) |11111111|111101 3ffd [14]
'~' (126) |11111111|11101 1ffd [13]
(127) |11111111|11111111|11111111|1100 ffffffc [28]
(128) |11111111|11111110|0110 fffe6 [20]
(129) |11111111|11111111|010010 3fffd2 [22]
(130) |11111111|11111110|0111 fffe7 [20]
(131) |11111111|11111110|1000 fffe8 [20]
(132) |11111111|11111111|010011 3fffd3 [22]
(133) |11111111|11111111|010100 3fffd4 [22]
(134) |11111111|11111111|010101 3fffd5 [22]
(135) |11111111|11111111|1011001 7fffd9 [23]
(136) |11111111|11111111|010110 3fffd6 [22]
(137) |11111111|11111111|1011010 7fffda [23]
(138) |11111111|11111111|1011011 7fffdb [23]
(139) |11111111|11111111|1011100 7fffdc [23]
(140) |11111111|11111111|1011101 7fffdd [23]
(141) |11111111|11111111|1011110 7fffde [23]
(142) |11111111|11111111|11101011 ffffeb [24]
(143) |11111111|11111111|1011111 7fffdf [23]
(144) |11111111|11111111|11101100 ffffec [24]
(145) |11111111|11111111|11101101 ffffed [24]
(146) |11111111|11111111|010111 3fffd7 [22]
(147) |11111111|11111111|1100000 7fffe0 [23]
(148) |11111111|11111111|11101110 ffffee [24]
(149) |11111111|11111111|1100001 7fffe1 [23]
(150) |11111111|11111111|1100010 7fffe2 [23]
(151) |11111111|11111111|1100011 7fffe3 [23]
(152) |11111111|11111111|1100100 7fffe4 [23]
(153) |11111111|11111110|11100 1fffdc [21]
(154) |11111111|11111111|011000 3fffd8 [22]
(155) |11111111|11111111|1100101 7fffe5 [23]
(156) |11111111|11111111|011001 3fffd9 [22]
(157) |11111111|11111111|1100110 7fffe6 [23]
(158) |11111111|11111111|1100111 7fffe7 [23]
(159) |11111111|11111111|11101111 ffffef [24]
(160) |11111111|11111111|011010 3fffda [22]
(161) |11111111|11111110|11101 1fffdd [21]
(162) |11111111|11111110|1001 fffe9 [20]
(163) |11111111|11111111|011011 3fffdb [22]
(164) |11111111|11111111|011100 3fffdc [22]
(165) |11111111|11111111|1101000 7fffe8 [23]
(166) |11111111|11111111|1101001 7fffe9 [23]
(167) |11111111|11111110|11110 1fffde [21]
(168) |11111111|11111111|1101010 7fffea [23]
(169) |11111111|11111111|011101 3fffdd [22]
(170) |11111111|11111111|011110 3fffde [22]
(171) |11111111|11111111|11110000 fffff0 [24]
(172) |11111111|11111110|11111 1fffdf [21]
(173) |11111111|11111111|011111 3fffdf [22]
(174) |11111111|11111111|1101011 7fffeb [23]
(175) |11111111|11111111|1101100 7fffec [23]
(176) |11111111|11111111|00000 1fffe0 [21]
(177) |11111111|11111111|00001 1fffe1 [21]
(178) |11111111|11111111|100000 3fffe0 [22]
(179) |11111111|11111111|00010 1fffe2 [21]
(180) |11111111|11111111|1101101 7fffed [23]
(181) |11111111|11111111|100001 3fffe1 [22]
(182) |11111111|11111111|1101110 7fffee [23]
(183) |11111111|11111111|1101111 7fffef [23]
(184) |11111111|11111110|1010 fffea [20]
(185) |11111111|11111111|100010 3fffe2 [22]
(186) |11111111|11111111|100011 3fffe3 [22]
(187) |11111111|11111111|100100 3fffe4 [22]
(188) |11111111|11111111|1110000 7ffff0 [23]
(189) |11111111|11111111|100101 3fffe5 [22]
(190) |11111111|11111111|100110 3fffe6 [22]
(191) |11111111|11111111|1110001 7ffff1 [23]
(192) |11111111|11111111|11111000|00 3ffffe0 [26]
(193) |11111111|11111111|11111000|01 3ffffe1 [26]
(194) |11111111|11111110|1011 fffeb [20]
(195) |11111111|11111110|001 7fff1 [19]
(196) |11111111|11111111|100111 3fffe7 [22]
(197) |11111111|11111111|1110010 7ffff2 [23]
(198) |11111111|11111111|101000 3fffe8 [22]
(199) |11111111|11111111|11110110|0 1ffffec [25]
(200) |11111111|11111111|11111000|10 3ffffe2 [26]
(201) |11111111|11111111|11111000|11 3ffffe3 [26]
(202) |11111111|11111111|11111001|00 3ffffe4 [26]
(203) |11111111|11111111|11111011|110 7ffffde [27]
(204) |11111111|11111111|11111011|111 7ffffdf [27]
(205) |11111111|11111111|11111001|01 3ffffe5 [26]
(206) |11111111|11111111|11110001 fffff1 [24]
(207) |11111111|11111111|11110110|1 1ffffed [25]
(208) |11111111|11111110|010 7fff2 [19]
(209) |11111111|11111111|00011 1fffe3 [21]
(210) |11111111|11111111|11111001|10 3ffffe6 [26]
(211) |11111111|11111111|11111100|000 7ffffe0 [27]
(212) |11111111|11111111|11111100|001 7ffffe1 [27]
(213) |11111111|11111111|11111001|11 3ffffe7 [26]
(214) |11111111|11111111|11111100|010 7ffffe2 [27]
(215) |11111111|11111111|11110010 fffff2 [24]
(216) |11111111|11111111|00100 1fffe4 [21]
(217) |11111111|11111111|00101 1fffe5 [21]
(218) |11111111|11111111|11111010|00 3ffffe8 [26]
(219) |11111111|11111111|11111010|01 3ffffe9 [26]
(220) |11111111|11111111|11111111|1101 ffffffd [28]
(221) |11111111|11111111|11111100|011 7ffffe3 [27]
(222) |11111111|11111111|11111100|100 7ffffe4 [27]
(223) |11111111|11111111|11111100|101 7ffffe5 [27]
(224) |11111111|11111110|1100 fffec [20]
(225) |11111111|11111111|11110011 fffff3 [24]
(226) |11111111|11111110|1101 fffed [20]
(227) |11111111|11111111|00110 1fffe6 [21]
(228) |11111111|11111111|101001 3fffe9 [22]
(229) |11111111|11111111|00111 1fffe7 [21]
(230) |11111111|11111111|01000 1fffe8 [21]
(231) |11111111|11111111|1110011 7ffff3 [23]
(232) |11111111|11111111|101010 3fffea [22]
(233) |11111111|11111111|101011 3fffeb [22]
(234) |11111111|11111111|11110111|0 1ffffee [25]
(235) |11111111|11111111|11110111|1 1ffffef [25]
(236) |11111111|11111111|11110100 fffff4 [24]
(237) |11111111|11111111|11110101 fffff5 [24]
(238) |11111111|11111111|11111010|10 3ffffea [26]
(239) |11111111|11111111|1110100 7ffff4 [23]
(240) |11111111|11111111|11111010|11 3ffffeb [26]
(241) |11111111|11111111|11111100|110 7ffffe6 [27]
(242) |11111111|11111111|11111011|00 3ffffec [26]
(243) |11111111|11111111|11111011|01 3ffffed [26]
(244) |11111111|11111111|11111100|111 7ffffe7 [27]
(245) |11111111|11111111|11111101|000 7ffffe8 [27]
(246) |11111111|11111111|11111101|001 7ffffe9 [27]
(247) |11111111|11111111|11111101|010 7ffffea [27]
(248) |11111111|11111111|11111101|011 7ffffeb [27]
(249) |11111111|11111111|11111111|1110 ffffffe [28]
(250) |11111111|11111111|11111101|100 7ffffec [27]
(251) |11111111|11111111|11111101|101 7ffffed [27]
(252) |11111111|11111111|11111101|110 7ffffee [27]
(253) |11111111|11111111|11111101|111 7ffffef [27]
(254) |11111111|11111111|11111110|000 7fffff0 [27]
(255) |11111111|11111111|11111011|10 3ffffee [26]
EOS (256) |11111111|11111111|11111111|111111 3fffffff [30]
"""
count = 0
spec_lines = SPEC_DATA_DRAFT_08.splitlines()
for l in spec_lines:
m = re.match(
r"^\s*('.+'|EOS)? \( *(\d+)\) \|([10\|]+) +\w+ \[ ?(\d+)\]", l)
if m:
g = m.groups()
spec_comment = g[0]
spec_bitstring = g[2]
bitstring = spec_bitstring.replace('|','').ljust(32,'0')
bitvalue = int(bitstring, 2)
bitcount = g[3]
valueid = g[1]
comment = ' // %s' % spec_bitstring
if spec_comment:
comment = ' // %3s %s' % (spec_comment, spec_bitstring)
else:
comment = ' // %s' % spec_bitstring
print(' {0x%08xul, %02s, %03s},%s' % (
bitvalue, bitcount, valueid, comment))
assert int(valueid) == count, "Expected data for %s, got %s." % (count,
valueid)
count += 1
print("Total: %s" % count)
assert count == 257, "Expected 257 values, got %d." % count
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment