annotate src/share/vm/code/compressedStream.cpp @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents 78bbf4d43a14
children 52b4284cb496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17467
diff changeset
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "code/compressedStream.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "utilities/ostream.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // 32-bit one-to-one sign encoding taken from Pack200
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // converts leading sign bits into leading zeroes with trailing sign bit
a61af66fc99e Initial load
duke
parents:
diff changeset
31 inline juint CompressedStream::encode_sign(jint value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 return (value << 1) ^ (value >> 31);
a61af66fc99e Initial load
duke
parents:
diff changeset
33 }
a61af66fc99e Initial load
duke
parents:
diff changeset
34 inline jint CompressedStream::decode_sign(juint value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 return (value >> 1) ^ -(jint)(value & 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
36 }
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // 32-bit self-inverse encoding of float bits
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // converts trailing zeroes (common in floats) to leading zeroes
a61af66fc99e Initial load
duke
parents:
diff changeset
40 inline juint CompressedStream::reverse_int(juint i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Hacker's Delight, Figure 7-1
a61af66fc99e Initial load
duke
parents:
diff changeset
42 i = (i & 0x55555555) << 1 | (i >> 1) & 0x55555555;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 i = (i & 0x33333333) << 2 | (i >> 2) & 0x33333333;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 i = (i & 0x0f0f0f0f) << 4 | (i >> 4) & 0x0f0f0f0f;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 i = (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 return i;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 jint CompressedReadStream::read_signed_int() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 return decode_sign(read_int());
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Compressing floats is simple, because the only common pattern
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // is trailing zeroes. (Compare leading sign bits on ints.)
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Since floats are left-justified, as opposed to right-justified
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // ints, we can bit-reverse them in order to take advantage of int
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // compression.
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 jfloat CompressedReadStream::read_float() {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 int rf = read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 int f = reverse_int(rf);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 return jfloat_cast(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 jdouble CompressedReadStream::read_double() {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 jint rh = read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 jint rl = read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 jint h = reverse_int(rh);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 jint l = reverse_int(rl);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return jdouble_cast(jlong_from(h, l));
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 jlong CompressedReadStream::read_long() {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 jint low = read_signed_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 jint high = read_signed_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return jlong_from(high, low);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 CompressedWriteStream::CompressedWriteStream(int initial_size) : CompressedStream(NULL, 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _buffer = NEW_RESOURCE_ARRAY(u_char, initial_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _size = initial_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 _position = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void CompressedWriteStream::grow() {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 u_char* _new_buffer = NEW_RESOURCE_ARRAY(u_char, _size * 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 memcpy(_new_buffer, _buffer, _position);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _buffer = _new_buffer;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _size = _size * 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void CompressedWriteStream::write_signed_int(jint value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // this encoding, called SIGNED5, is taken from Pack200
a61af66fc99e Initial load
duke
parents:
diff changeset
95 write_int(encode_sign(value));
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void CompressedWriteStream::write_float(jfloat value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 juint f = jint_cast(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 juint rf = reverse_int(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 assert(f == reverse_int(rf), "can re-read same bits");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 write_int(rf);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void CompressedWriteStream::write_double(jdouble value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 juint h = high(jlong_cast(value));
a61af66fc99e Initial load
duke
parents:
diff changeset
107 juint l = low( jlong_cast(value));
a61af66fc99e Initial load
duke
parents:
diff changeset
108 juint rh = reverse_int(h);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 juint rl = reverse_int(l);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 assert(h == reverse_int(rh), "can re-read same bits");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 assert(l == reverse_int(rl), "can re-read same bits");
a61af66fc99e Initial load
duke
parents:
diff changeset
112 write_int(rh);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 write_int(rl);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void CompressedWriteStream::write_long(jlong value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 write_signed_int(low(value));
a61af66fc99e Initial load
duke
parents:
diff changeset
118 write_signed_int(high(value));
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 /// The remaining details
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // set this to trigger unit test
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void test_compressed_stream(int trace);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 bool test_compressed_stream_enabled = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // This encoding, called UNSIGNED5, is taken from J2SE Pack200.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // It assumes that most values have lots of leading zeroes.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Very small values, in the range [0..191], code in one byte.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Any 32-bit value (including negatives) can be coded, in
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // up to five bytes. The grammar is:
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // low_byte = [0..191]
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // high_byte = [192..255]
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // any_byte = low_byte | high_byte
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // coding = low_byte
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // | high_byte low_byte
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // | high_byte high_byte low_byte
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // | high_byte high_byte high_byte low_byte
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // | high_byte high_byte high_byte high_byte any_byte
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Each high_byte contributes six bits of payload.
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // The encoding is one-to-one (except for integer overflow)
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // and easy to parse and unparse.
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 jint CompressedReadStream::read_int_mb(jint b0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 int pos = position() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 u_char* buf = buffer() + pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 assert(buf[0] == b0 && b0 >= L, "correctly called");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 jint sum = b0;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // must collect more bytes: b[1]...b[4]
a61af66fc99e Initial load
duke
parents:
diff changeset
153 int lg_H_i = lg_H;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 for (int i = 0; ; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 jint b_i = buf[++i]; // b_i = read(); ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 sum += b_i << lg_H_i; // sum += b[i]*(64**i)
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (b_i < L || i == MAX_i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 set_position(pos+i+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return sum;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 lg_H_i += lg_H;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 void CompressedWriteStream::write_int_mb(jint value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 debug_only(int pos1 = position());
a61af66fc99e Initial load
duke
parents:
diff changeset
167 juint sum = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 for (int i = 0; ; ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 if (sum < L || i == MAX_i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // remainder is either a "low code" or the 5th byte
a61af66fc99e Initial load
duke
parents:
diff changeset
171 assert(sum == (u_char)sum, "valid byte");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 write((u_char)sum);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 sum -= L;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 int b_i = L + (sum % H); // this is a "high code"
a61af66fc99e Initial load
duke
parents:
diff changeset
177 sum >>= lg_H; // extracted 6 bits
a61af66fc99e Initial load
duke
parents:
diff changeset
178 write(b_i); ++i;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (test_compressed_stream_enabled) { // hack to enable this stress test
a61af66fc99e Initial load
duke
parents:
diff changeset
183 test_compressed_stream_enabled = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 test_compressed_stream(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
191 /// a unit test (can be run by hand from a debugger)
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // Avoid a VS2005 compiler stack overflow w/ fastdebug build.
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // The following pragma optimize turns off optimization ONLY
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // for this block (a matching directive turns it back on later).
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // These directives can be removed once the MS VS.NET 2005
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // compiler stack overflow is fixed.
8721
47bc9800972c 8006498: #if <symbol> is wrong in the code.
jprovino
parents: 2000
diff changeset
198 #if defined(_MSC_VER) && _MSC_VER >=1400 && !defined(_WIN64)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
199 #pragma optimize("", off)
2000
5fa559508216 7007229: Fix warnings with VS2010 in compressedStream.cpp
iveresov
parents: 1972
diff changeset
200 #pragma warning(disable: 4748)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
201 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // generator for an "interesting" set of critical values
a61af66fc99e Initial load
duke
parents:
diff changeset
204 enum { stretch_limit = (1<<16) * (64-16+1) };
a61af66fc99e Initial load
duke
parents:
diff changeset
205 static jlong stretch(jint x, int bits) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // put x[high 4] into place
a61af66fc99e Initial load
duke
parents:
diff changeset
207 jlong h = (jlong)((x >> (16-4))) << (bits - 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // put x[low 12] into place, sign extended
a61af66fc99e Initial load
duke
parents:
diff changeset
209 jlong l = ((jlong)x << (64-12)) >> (64-12);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // move l upwards, maybe
a61af66fc99e Initial load
duke
parents:
diff changeset
211 l <<= (x >> 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 return h ^ l;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17467
diff changeset
215 PRAGMA_DIAG_PUSH
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17467
diff changeset
216 PRAGMA_FORMAT_IGNORED // Someone needs to deal with this.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 void test_compressed_stream(int trace) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 CompressedWriteStream bytes(stretch_limit * 100);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 jint n;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 int step = 0, fails = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 #define CHECKXY(x, y, fmt) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
222 ++step; \
a61af66fc99e Initial load
duke
parents:
diff changeset
223 int xlen = (pos = decode.position()) - lastpos; lastpos = pos; \
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (trace > 0 && (step % trace) == 0) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
225 tty->print_cr("step %d, n=%08x: value=" fmt " (len=%d)", \
a61af66fc99e Initial load
duke
parents:
diff changeset
226 step, n, x, xlen); } \
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (x != y) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
228 tty->print_cr("step %d, n=%d: " fmt " != " fmt, step, n, x, y); \
a61af66fc99e Initial load
duke
parents:
diff changeset
229 fails++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
230 } }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 for (n = 0; n < (1<<8); n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 jbyte x = (jbyte)n;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 bytes.write_byte(x); ++step;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 for (n = 0; n < stretch_limit; n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 jint x = (jint)stretch(n, 32);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 bytes.write_int(x); ++step;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 bytes.write_signed_int(x); ++step;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 bytes.write_float(jfloat_cast(x)); ++step;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 for (n = 0; n < stretch_limit; n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 jlong x = stretch(n, 64);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 bytes.write_long(x); ++step;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 bytes.write_double(jdouble_cast(x)); ++step;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 int length = bytes.position();
a61af66fc99e Initial load
duke
parents:
diff changeset
247 if (trace != 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
248 tty->print_cr("set up test of %d stream values, size %d", step, length);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 step = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // now decode it all
a61af66fc99e Initial load
duke
parents:
diff changeset
251 CompressedReadStream decode(bytes.buffer());
a61af66fc99e Initial load
duke
parents:
diff changeset
252 int pos, lastpos = decode.position();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 for (n = 0; n < (1<<8); n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 jbyte x = (jbyte)n;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 jbyte y = decode.read_byte();
a61af66fc99e Initial load
duke
parents:
diff changeset
256 CHECKXY(x, y, "%db");
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 for (n = 0; n < stretch_limit; n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 jint x = (jint)stretch(n, 32);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 jint y1 = decode.read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
261 CHECKXY(x, y1, "%du");
a61af66fc99e Initial load
duke
parents:
diff changeset
262 jint y2 = decode.read_signed_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
263 CHECKXY(x, y2, "%di");
a61af66fc99e Initial load
duke
parents:
diff changeset
264 jint y3 = jint_cast(decode.read_float());
a61af66fc99e Initial load
duke
parents:
diff changeset
265 CHECKXY(x, y3, "%df");
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 for (n = 0; n < stretch_limit; n++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 jlong x = stretch(n, 64);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 jlong y1 = decode.read_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
270 CHECKXY(x, y1, INT64_FORMAT "l");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 jlong y2 = jlong_cast(decode.read_double());
a61af66fc99e Initial load
duke
parents:
diff changeset
272 CHECKXY(x, y2, INT64_FORMAT "d");
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 int length2 = decode.position();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 if (trace != 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
276 tty->print_cr("finished test of %d stream values, size %d", step, length2);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 guarantee(length == length2, "bad length");
a61af66fc99e Initial load
duke
parents:
diff changeset
278 guarantee(fails == 0, "test failures");
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17467
diff changeset
280 PRAGMA_DIAG_POP
0
a61af66fc99e Initial load
duke
parents:
diff changeset
281
8721
47bc9800972c 8006498: #if <symbol> is wrong in the code.
jprovino
parents: 2000
diff changeset
282 #if defined(_MSC_VER) &&_MSC_VER >=1400 && !defined(_WIN64)
2000
5fa559508216 7007229: Fix warnings with VS2010 in compressedStream.cpp
iveresov
parents: 1972
diff changeset
283 #pragma warning(default: 4748)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
284 #pragma optimize("", on)
a61af66fc99e Initial load
duke
parents:
diff changeset
285 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 #endif // PRODUCT