diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-02-10 05:12:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-25 10:04:57 -0400 |
commit | bea2b592fd18eb8ffa3fc4ad380610632d03a38f (patch) | |
tree | 82a139e42a1812111dacc5a23b8b5fcb39058396 /lib | |
parent | 7085a7401ba54e92bbb5aa24d6f428071e18e509 (diff) |
lib/lz4: Pull out constant tables
There's no reason to allocate the dec{32,64}table on the stack; it
just wastes a bunch of instructions setting them up and, of course,
also consumes quite a bit of stack. Using size_t for such small
integers is a little excessive.
$ scripts/bloat-o-meter /tmp/built-in.o lib/built-in.o
add/remove: 2/2 grow/shrink: 2/0 up/down: 1304/-1548 (-244)
function old new delta
lz4_decompress_unknownoutputsize 55 718 +663
lz4_decompress 55 632 +577
dec64table - 32 +32
dec32table - 32 +32
lz4_uncompress 747 - -747
lz4_uncompress_unknownoutputsize 801 - -801
The now inlined lz4_uncompress functions used to have a stack
footprint of 176 bytes (according to -fstack-usage); their inlinees
have increased their stack use from 32 bytes to 48 and 80 bytes,
respectively.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4/lz4_decompress.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c index f0f5c5c3de12..26cc6029b280 100644 --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c | |||
@@ -47,6 +47,11 @@ | |||
47 | 47 | ||
48 | #include "lz4defs.h" | 48 | #include "lz4defs.h" |
49 | 49 | ||
50 | static const int dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; | ||
51 | #if LZ4_ARCH64 | ||
52 | static const int dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; | ||
53 | #endif | ||
54 | |||
50 | static int lz4_uncompress(const char *source, char *dest, int osize) | 55 | static int lz4_uncompress(const char *source, char *dest, int osize) |
51 | { | 56 | { |
52 | const BYTE *ip = (const BYTE *) source; | 57 | const BYTE *ip = (const BYTE *) source; |
@@ -56,10 +61,6 @@ static int lz4_uncompress(const char *source, char *dest, int osize) | |||
56 | BYTE *cpy; | 61 | BYTE *cpy; |
57 | unsigned token; | 62 | unsigned token; |
58 | size_t length; | 63 | size_t length; |
59 | size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; | ||
60 | #if LZ4_ARCH64 | ||
61 | size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; | ||
62 | #endif | ||
63 | 64 | ||
64 | while (1) { | 65 | while (1) { |
65 | 66 | ||
@@ -116,7 +117,7 @@ static int lz4_uncompress(const char *source, char *dest, int osize) | |||
116 | /* copy repeated sequence */ | 117 | /* copy repeated sequence */ |
117 | if (unlikely((op - ref) < STEPSIZE)) { | 118 | if (unlikely((op - ref) < STEPSIZE)) { |
118 | #if LZ4_ARCH64 | 119 | #if LZ4_ARCH64 |
119 | size_t dec64 = dec64table[op - ref]; | 120 | int dec64 = dec64table[op - ref]; |
120 | #else | 121 | #else |
121 | const int dec64 = 0; | 122 | const int dec64 = 0; |
122 | #endif | 123 | #endif |
@@ -177,11 +178,6 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, | |||
177 | BYTE * const oend = op + maxoutputsize; | 178 | BYTE * const oend = op + maxoutputsize; |
178 | BYTE *cpy; | 179 | BYTE *cpy; |
179 | 180 | ||
180 | size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; | ||
181 | #if LZ4_ARCH64 | ||
182 | size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; | ||
183 | #endif | ||
184 | |||
185 | /* Main Loop */ | 181 | /* Main Loop */ |
186 | while (ip < iend) { | 182 | while (ip < iend) { |
187 | 183 | ||
@@ -249,7 +245,7 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, | |||
249 | /* copy repeated sequence */ | 245 | /* copy repeated sequence */ |
250 | if (unlikely((op - ref) < STEPSIZE)) { | 246 | if (unlikely((op - ref) < STEPSIZE)) { |
251 | #if LZ4_ARCH64 | 247 | #if LZ4_ARCH64 |
252 | size_t dec64 = dec64table[op - ref]; | 248 | int dec64 = dec64table[op - ref]; |
253 | #else | 249 | #else |
254 | const int dec64 = 0; | 250 | const int dec64 = 0; |
255 | #endif | 251 | #endif |