hotspot/src/share/vm/code/compressedStream.cpp
author jwilhelm
Thu, 06 Jul 2017 01:50:26 +0200
changeset 46630 75aa3e39d02c
parent 46600 fdde0f192cde
permissions -rw-r--r--
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8 8182656: Make the required changes in GC code to build on OSX 10 + Xcode 8 8182657: Make the required changes in Runtime code to build on OSX 10 + Xcode 8 8182658: Make the required changes in Compiler code to build on OSX 10 + Xcode 8 Reviewed-by: jwilhelm, ehelin, phh Contributed-by: phh <hohensee@amazon.com>, jwilhelm <jesper.wilhelmsson@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46600
diff changeset
     2
 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "code/compressedStream.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "utilities/ostream.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// 32-bit one-to-one sign encoding taken from Pack200
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// converts leading sign bits into leading zeroes with trailing sign bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
inline juint CompressedStream::encode_sign(jint  value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  return (value << 1) ^ (value >> 31);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
inline jint  CompressedStream::decode_sign(juint value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  return (value >> 1) ^ -(jint)(value & 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// 32-bit self-inverse encoding of float bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// converts trailing zeroes (common in floats) to leading zeroes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
inline juint CompressedStream::reverse_int(juint i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  // Hacker's Delight, Figure 7-1
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46600
diff changeset
    42
  i = (i & 0x55555555) << 1 | ((i >> 1) & 0x55555555);
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46600
diff changeset
    43
  i = (i & 0x33333333) << 2 | ((i >> 2) & 0x33333333);
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46600
diff changeset
    44
  i = (i & 0x0f0f0f0f) << 4 | ((i >> 4) & 0x0f0f0f0f);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  i = (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  return i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
jint CompressedReadStream::read_signed_int() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  return decode_sign(read_int());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// Compressing floats is simple, because the only common pattern
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// is trailing zeroes.  (Compare leading sign bits on ints.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// Since floats are left-justified, as opposed to right-justified
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
// ints, we can bit-reverse them in order to take advantage of int
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// compression.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
jfloat CompressedReadStream::read_float() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  int rf = read_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  int f  = reverse_int(rf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  return jfloat_cast(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
jdouble CompressedReadStream::read_double() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  jint rh = read_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  jint rl = read_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  jint h  = reverse_int(rh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  jint l  = reverse_int(rl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  return jdouble_cast(jlong_from(h, l));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
jlong CompressedReadStream::read_long() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  jint low  = read_signed_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  jint high = read_signed_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  return jlong_from(high, low);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
CompressedWriteStream::CompressedWriteStream(int initial_size) : CompressedStream(NULL, 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  _buffer   = NEW_RESOURCE_ARRAY(u_char, initial_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  _size     = initial_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  _position = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
void CompressedWriteStream::grow() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  u_char* _new_buffer = NEW_RESOURCE_ARRAY(u_char, _size * 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  memcpy(_new_buffer, _buffer, _position);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  _buffer = _new_buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  _size   = _size * 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
void CompressedWriteStream::write_signed_int(jint value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // this encoding, called SIGNED5, is taken from Pack200
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  write_int(encode_sign(value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
void CompressedWriteStream::write_float(jfloat value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  juint f = jint_cast(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  juint rf = reverse_int(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  assert(f == reverse_int(rf), "can re-read same bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  write_int(rf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
void CompressedWriteStream::write_double(jdouble value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  juint h  = high(jlong_cast(value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  juint l  = low( jlong_cast(value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  juint rh = reverse_int(h);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  juint rl = reverse_int(l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  assert(h == reverse_int(rh), "can re-read same bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  assert(l == reverse_int(rl), "can re-read same bits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  write_int(rh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  write_int(rl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
void CompressedWriteStream::write_long(jlong value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  write_signed_int(low(value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  write_signed_int(high(value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
/// The remaining details
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
// set this to trigger unit test
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
void test_compressed_stream(int trace);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
bool test_compressed_stream_enabled = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
void CompressedWriteStream::write_int_mb(jint value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  debug_only(int pos1 = position());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  juint sum = value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  for (int i = 0; ; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    if (sum < L || i == MAX_i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      // remainder is either a "low code" or the 5th byte
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      assert(sum == (u_char)sum, "valid byte");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
      write((u_char)sum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    sum -= L;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    int b_i = L + (sum % H);  // this is a "high code"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    sum >>= lg_H;             // extracted 6 bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    write(b_i); ++i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  if (test_compressed_stream_enabled) {  // hack to enable this stress test
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    test_compressed_stream_enabled = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    test_compressed_stream(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
/// a unit test (can be run by hand from a debugger)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
// Avoid a VS2005 compiler stack overflow w/ fastdebug build.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// The following pragma optimize turns off optimization ONLY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
// for this block (a matching directive turns it back on later).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// These directives can be removed once the MS VS.NET 2005
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
// compiler stack overflow is fixed.
15937
fd3d2d0175f9 8006498: #if <symbol> is wrong in the code.
jprovino
parents: 7425
diff changeset
   163
#if defined(_MSC_VER) && _MSC_VER >=1400 && !defined(_WIN64)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
#pragma optimize("", off)
7425
7361a8d313c3 7007229: Fix warnings with VS2010 in compressedStream.cpp
iveresov
parents: 7397
diff changeset
   165
#pragma warning(disable: 4748)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
// generator for an "interesting" set of critical values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
enum { stretch_limit = (1<<16) * (64-16+1) };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
static jlong stretch(jint x, int bits) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // put x[high 4] into place
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  jlong h = (jlong)((x >> (16-4))) << (bits - 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // put x[low 12] into place, sign extended
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  jlong l = ((jlong)x << (64-12)) >> (64-12);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // move l upwards, maybe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  l <<= (x >> 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  return h ^ l;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 22234
diff changeset
   180
PRAGMA_DIAG_PUSH
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 22234
diff changeset
   181
PRAGMA_FORMAT_IGNORED // Someone needs to deal with this.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
void test_compressed_stream(int trace) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  CompressedWriteStream bytes(stretch_limit * 100);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  jint n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  int step = 0, fails = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
#define CHECKXY(x, y, fmt) { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    ++step; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    int xlen = (pos = decode.position()) - lastpos; lastpos = pos; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    if (trace > 0 && (step % trace) == 0) { \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      tty->print_cr("step %d, n=%08x: value=" fmt " (len=%d)", \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
                    step, n, x, xlen); } \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    if (x != y) {                                                     \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      tty->print_cr("step %d, n=%d: " fmt " != " fmt, step, n, x, y); \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      fails++; \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    } }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  for (n = 0; n < (1<<8); n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    jbyte x = (jbyte)n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    bytes.write_byte(x); ++step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  for (n = 0; n < stretch_limit; n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    jint x = (jint)stretch(n, 32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    bytes.write_int(x); ++step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    bytes.write_signed_int(x); ++step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    bytes.write_float(jfloat_cast(x)); ++step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  for (n = 0; n < stretch_limit; n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    jlong x = stretch(n, 64);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    bytes.write_long(x); ++step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    bytes.write_double(jdouble_cast(x)); ++step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  int length = bytes.position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  if (trace != 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
    tty->print_cr("set up test of %d stream values, size %d", step, length);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  step = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // now decode it all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  CompressedReadStream decode(bytes.buffer());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  int pos, lastpos = decode.position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  for (n = 0; n < (1<<8); n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    jbyte x = (jbyte)n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    jbyte y = decode.read_byte();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    CHECKXY(x, y, "%db");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  for (n = 0; n < stretch_limit; n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    jint x = (jint)stretch(n, 32);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    jint y1 = decode.read_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    CHECKXY(x, y1, "%du");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    jint y2 = decode.read_signed_int();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    CHECKXY(x, y2, "%di");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    jint y3 = jint_cast(decode.read_float());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    CHECKXY(x, y3, "%df");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  for (n = 0; n < stretch_limit; n++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    jlong x = stretch(n, 64);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    jlong y1 = decode.read_long();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    CHECKXY(x, y1, INT64_FORMAT "l");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    jlong y2 = jlong_cast(decode.read_double());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    CHECKXY(x, y2, INT64_FORMAT "d");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  int length2 = decode.position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  if (trace != 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    tty->print_cr("finished test of %d stream values, size %d", step, length2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  guarantee(length == length2, "bad length");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  guarantee(fails == 0, "test failures");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
}
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 22234
diff changeset
   245
PRAGMA_DIAG_POP
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
15937
fd3d2d0175f9 8006498: #if <symbol> is wrong in the code.
jprovino
parents: 7425
diff changeset
   247
#if defined(_MSC_VER) &&_MSC_VER >=1400 && !defined(_WIN64)
7425
7361a8d313c3 7007229: Fix warnings with VS2010 in compressedStream.cpp
iveresov
parents: 7397
diff changeset
   248
#pragma warning(default: 4748)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
#pragma optimize("", on)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
#endif // PRODUCT