195 // for this block (a matching directive turns it back on later).
196 // These directives can be removed once the MS VS.NET 2005
197 // compiler stack overflow is fixed.
198 #if defined(_MSC_VER) && _MSC_VER >=1400 && !defined(_WIN64)
199 #pragma optimize("", off)
200 #pragma warning(disable: 4748)
201 #endif
202
203 // generator for an "interesting" set of critical values
204 enum { stretch_limit = (1<<16) * (64-16+1) };
205 static jlong stretch(jint x, int bits) {
206 // put x[high 4] into place
207 jlong h = (jlong)((x >> (16-4))) << (bits - 4);
208 // put x[low 12] into place, sign extended
209 jlong l = ((jlong)x << (64-12)) >> (64-12);
210 // move l upwards, maybe
211 l <<= (x >> 16);
212 return h ^ l;
213 }
214
215 void test_compressed_stream(int trace) {
216 CompressedWriteStream bytes(stretch_limit * 100);
217 jint n;
218 int step = 0, fails = 0;
219 #define CHECKXY(x, y, fmt) { \
220 ++step; \
221 int xlen = (pos = decode.position()) - lastpos; lastpos = pos; \
222 if (trace > 0 && (step % trace) == 0) { \
223 tty->print_cr("step %d, n=%08x: value=" fmt " (len=%d)", \
224 step, n, x, xlen); } \
225 if (x != y) { \
226 tty->print_cr("step %d, n=%d: " fmt " != " fmt, step, n, x, y); \
227 fails++; \
228 } }
229 for (n = 0; n < (1<<8); n++) {
230 jbyte x = (jbyte)n;
231 bytes.write_byte(x); ++step;
232 }
233 for (n = 0; n < stretch_limit; n++) {
234 jint x = (jint)stretch(n, 32);
258 jint y1 = decode.read_int();
259 CHECKXY(x, y1, "%du");
260 jint y2 = decode.read_signed_int();
261 CHECKXY(x, y2, "%di");
262 jint y3 = jint_cast(decode.read_float());
263 CHECKXY(x, y3, "%df");
264 }
265 for (n = 0; n < stretch_limit; n++) {
266 jlong x = stretch(n, 64);
267 jlong y1 = decode.read_long();
268 CHECKXY(x, y1, INT64_FORMAT "l");
269 jlong y2 = jlong_cast(decode.read_double());
270 CHECKXY(x, y2, INT64_FORMAT "d");
271 }
272 int length2 = decode.position();
273 if (trace != 0)
274 tty->print_cr("finished test of %d stream values, size %d", step, length2);
275 guarantee(length == length2, "bad length");
276 guarantee(fails == 0, "test failures");
277 }
278
279 #if defined(_MSC_VER) &&_MSC_VER >=1400 && !defined(_WIN64)
280 #pragma warning(default: 4748)
281 #pragma optimize("", on)
282 #endif
283
284 #endif // PRODUCT
|
195 // for this block (a matching directive turns it back on later).
196 // These directives can be removed once the MS VS.NET 2005
197 // compiler stack overflow is fixed.
198 #if defined(_MSC_VER) && _MSC_VER >=1400 && !defined(_WIN64)
199 #pragma optimize("", off)
200 #pragma warning(disable: 4748)
201 #endif
202
203 // generator for an "interesting" set of critical values
204 enum { stretch_limit = (1<<16) * (64-16+1) };
205 static jlong stretch(jint x, int bits) {
206 // put x[high 4] into place
207 jlong h = (jlong)((x >> (16-4))) << (bits - 4);
208 // put x[low 12] into place, sign extended
209 jlong l = ((jlong)x << (64-12)) >> (64-12);
210 // move l upwards, maybe
211 l <<= (x >> 16);
212 return h ^ l;
213 }
214
215 PRAGMA_DIAG_PUSH
216 PRAGMA_FORMAT_IGNORED // Someone needs to deal with this.
217 void test_compressed_stream(int trace) {
218 CompressedWriteStream bytes(stretch_limit * 100);
219 jint n;
220 int step = 0, fails = 0;
221 #define CHECKXY(x, y, fmt) { \
222 ++step; \
223 int xlen = (pos = decode.position()) - lastpos; lastpos = pos; \
224 if (trace > 0 && (step % trace) == 0) { \
225 tty->print_cr("step %d, n=%08x: value=" fmt " (len=%d)", \
226 step, n, x, xlen); } \
227 if (x != y) { \
228 tty->print_cr("step %d, n=%d: " fmt " != " fmt, step, n, x, y); \
229 fails++; \
230 } }
231 for (n = 0; n < (1<<8); n++) {
232 jbyte x = (jbyte)n;
233 bytes.write_byte(x); ++step;
234 }
235 for (n = 0; n < stretch_limit; n++) {
236 jint x = (jint)stretch(n, 32);
260 jint y1 = decode.read_int();
261 CHECKXY(x, y1, "%du");
262 jint y2 = decode.read_signed_int();
263 CHECKXY(x, y2, "%di");
264 jint y3 = jint_cast(decode.read_float());
265 CHECKXY(x, y3, "%df");
266 }
267 for (n = 0; n < stretch_limit; n++) {
268 jlong x = stretch(n, 64);
269 jlong y1 = decode.read_long();
270 CHECKXY(x, y1, INT64_FORMAT "l");
271 jlong y2 = jlong_cast(decode.read_double());
272 CHECKXY(x, y2, INT64_FORMAT "d");
273 }
274 int length2 = decode.position();
275 if (trace != 0)
276 tty->print_cr("finished test of %d stream values, size %d", step, length2);
277 guarantee(length == length2, "bad length");
278 guarantee(fails == 0, "test failures");
279 }
280 PRAGMA_DIAG_POP
281
282 #if defined(_MSC_VER) &&_MSC_VER >=1400 && !defined(_WIN64)
283 #pragma warning(default: 4748)
284 #pragma optimize("", on)
285 #endif
286
287 #endif // PRODUCT
|