diff -r fd16c54261b3 -r 489c9b5090e2 hotspot/src/share/vm/code/compressedStream.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/share/vm/code/compressedStream.hpp Sat Dec 01 00:00:00 2007 +0000 @@ -0,0 +1,120 @@ +/* + * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + */ + +// Simple interface for filing out and filing in basic types +// Used for writing out and reading in debugging information. + +class CompressedStream : public ResourceObj { + friend class VMStructs; + protected: + u_char* _buffer; + int _position; + + enum { + // Constants for UNSIGNED5 coding of Pack200 + lg_H = 6, H = 1<= _size; + } + void store(u_char b) { + _buffer[_position++] = b; + } + void write(u_char b) { + if (full()) grow(); + store(b); + } + void grow(); + + void write_int_mb(jint value); // UNSIGNED5 coding, 1-5 byte cases + + protected: + int _size; + + public: + CompressedWriteStream(int initial_size); + CompressedWriteStream(u_char* buffer, int initial_size, int position = 0) + : CompressedStream(buffer, position) { _size = initial_size; } + + void write_bool(jboolean value) { write(value); } + void write_byte(jbyte value) { write(value); } + void write_char(jchar value) { write_int(value); } + void write_short(jshort value) { write_signed_int(value); } + void write_int(jint value) { if ((juint)value < L && !full()) + store((u_char)value); + else write_int_mb(value); } + void write_signed_int(jint value); // write_int(encode_sign(value)) + void write_float(jfloat value); // write_int(reverse_int(jint_cast(v))) + void write_double(jdouble value); // write_int(reverse_int()) + void write_long(jlong value); // write_signed_int() +};