< prev index next >

src/share/vm/code/compressedStream.cpp

Print this page
rev 13143 : 8183001: Various inlining improvements
Reviewed-by: iklam, mikael, ehelin

*** 125,169 **** // 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. - - jint CompressedReadStream::read_int_mb(jint b0) { - int pos = position() - 1; - u_char* buf = buffer() + pos; - assert(buf[0] == b0 && b0 >= L, "correctly called"); - jint sum = b0; - // must collect more bytes: b[1]...b[4] - int lg_H_i = lg_H; - for (int i = 0; ; ) { - jint b_i = buf[++i]; // b_i = read(); ++i; - sum += b_i << lg_H_i; // sum += b[i]*(64**i) - if (b_i < L || i == MAX_i) { - set_position(pos+i+1); - return sum; - } - lg_H_i += lg_H; - } - } - void CompressedWriteStream::write_int_mb(jint value) { debug_only(int pos1 = position()); juint sum = value; for (int i = 0; ; ) { if (sum < L || i == MAX_i) { --- 125,134 ----
< prev index next >