/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "code/compressedStream.hpp"
#include "utilities/ostream.hpp"
// 32-bit one-to-one sign encoding taken from Pack200
// converts leading sign bits into leading zeroes with trailing sign bit
}
}
// 32-bit self-inverse encoding of float bits
// converts trailing zeroes (common in floats) to leading zeroes
// Hacker's Delight, Figure 7-1
i = (i & 0x55555555) << 1 | (i >> 1) & 0x55555555;
i = (i & 0x33333333) << 2 | (i >> 2) & 0x33333333;
i = (i & 0x0f0f0f0f) << 4 | (i >> 4) & 0x0f0f0f0f;
i = (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
return i;
}
return decode_sign(read_int());
}
// Compressing floats is simple, because the only common pattern
// is trailing zeroes. (Compare leading sign bits on ints.)
// Since floats are left-justified, as opposed to right-justified
// ints, we can bit-reverse them in order to take advantage of int
// compression.
int f = reverse_int(rf);
return jfloat_cast(f);
}
return jdouble_cast(jlong_from(h, l));
}
}
_position = 0;
}
}
// this encoding, called SIGNED5, is taken from Pack200
}
}
}
}
/// The remaining details
#ifndef PRODUCT
// set this to trigger unit test
void test_compressed_stream(int trace);
bool test_compressed_stream_enabled = false;
#endif
// This encoding, called UNSIGNED5, is taken from J2SE Pack200.
// It assumes that most values have lots of leading zeroes.
// Very small values, in the range [0..191], code in one byte.
// Any 32-bit value (including negatives) can be coded, in
// up to five bytes. The grammar is:
// low_byte = [0..191]
// high_byte = [192..255]
// any_byte = low_byte | high_byte
// coding = low_byte
// | high_byte low_byte
// | high_byte high_byte low_byte
// | high_byte high_byte high_byte low_byte
// | high_byte high_byte high_byte high_byte any_byte
// Each high_byte contributes six bits of payload.
// The encoding is one-to-one (except for integer overflow)
// and easy to parse and unparse.
// must collect more bytes: b[1]...b[4]
for (int i = 0; ; ) {
return sum;
}
}
}
for (int i = 0; ; ) {
// remainder is either a "low code" or the 5th byte
break;
}
sum -= L;
}
#ifndef PRODUCT
if (test_compressed_stream_enabled) { // hack to enable this stress test
test_compressed_stream_enabled = false;
}
#endif
}
#ifndef PRODUCT
/// a unit test (can be run by hand from a debugger)
// Avoid a VS2005 compiler stack overflow w/ fastdebug build.
// The following pragma optimize turns off optimization ONLY
// for this block (a matching directive turns it back on later).
// These directives can be removed once the MS VS.NET 2005
// compiler stack overflow is fixed.
#endif
// generator for an "interesting" set of critical values
// put x[high 4] into place
// put x[low 12] into place, sign extended
// move l upwards, maybe
l <<= (x >> 16);
return h ^ l;
}
jint n;
++step; \
if (x != y) { \
fails++; \
} }
for (n = 0; n < (1<<8); n++) {
}
for (n = 0; n < stretch_limit; n++) {
}
for (n = 0; n < stretch_limit; n++) {
}
if (trace != 0)
step = 0;
// now decode it all
for (n = 0; n < (1<<8); n++) {
CHECKXY(x, y, "%db");
}
for (n = 0; n < stretch_limit; n++) {
}
for (n = 0; n < stretch_limit; n++) {
}
if (trace != 0)
}
#pragma warning(default: 4748)
#endif
#endif // PRODUCT