0
|
1 /*
|
|
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
8 *
|
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
|
13 * accompanied this code).
|
|
14 *
|
|
15 * You should have received a copy of the GNU General Public License version
|
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 package sun.jvm.hotspot.code;
|
|
26
|
|
27 import sun.jvm.hotspot.debugger.*;
|
|
28
|
|
29 /** NOTE that this class takes the address of a buffer. This means
|
|
30 that it can read previously-generated debug information directly
|
|
31 from the target VM. However, it also means that you can't create a
|
|
32 "wrapper" object for a CompressedStream down in the VM. It looks
|
|
33 like these are only kept persistently in OopMaps, and the code has
|
|
34 been special-cased in OopMap.java to handle this. */
|
|
35
|
|
36 public class CompressedStream {
|
|
37 protected Address buffer;
|
|
38 protected int position;
|
|
39
|
|
40 /** Equivalent to CompressedStream(buffer, 0) */
|
|
41 public CompressedStream(Address buffer) {
|
|
42 this(buffer, 0);
|
|
43 }
|
|
44
|
|
45 public CompressedStream(Address buffer, int position) {
|
|
46 this.buffer = buffer;
|
|
47 this.position = position;
|
|
48 }
|
|
49
|
|
50 public Address getBuffer() {
|
|
51 return buffer;
|
|
52 }
|
|
53
|
|
54 public static final int LogBitsPerByte = 3;
|
|
55 public static final int BitsPerByte = 1 << 3;
|
|
56
|
|
57 // Constants for UNSIGNED5 coding of Pack200
|
|
58 public static final int lg_H = 6;
|
|
59 public static final int H = 1<<lg_H; // number of high codes (64)
|
|
60 public static final int L = (1<<BitsPerByte) - H; // number of low codes (192)
|
|
61 public static final int MAX_i = 4; // bytes are numbered in (0..4)
|
|
62
|
|
63 // Positioning
|
|
64 public int getPosition() {
|
|
65 return position;
|
|
66 }
|
|
67 public void setPosition(int position) {
|
|
68 this.position = position;
|
|
69 }
|
|
70
|
|
71 // 32-bit one-to-one sign encoding taken from Pack200
|
|
72 // converts leading sign bits into leading zeros with trailing sign bit
|
|
73 public int encodeSign(int value) {
|
|
74 return (value << 1) ^ (value >> 31);
|
|
75 }
|
|
76
|
|
77 public int decodeSign(int value) {
|
|
78 return (value >>> 1) ^ -(value & 1);
|
|
79 }
|
|
80
|
|
81 // 32-bit self-inverse encoding of float bits
|
|
82 // converts trailing zeros (common in floats) to leading zeros
|
|
83 public int reverseInt(int i) {
|
|
84 // Hacker's Delight, Figure 7-1
|
|
85 i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555;
|
|
86 i = (i & 0x33333333) << 3 | (i >>> 2) & 0x33333333;
|
|
87 i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f;
|
|
88 i = (i << 24) | ((i & 0xff00) << 8) | ((i >>> 8) & 0xff00) | (i >>> 24);
|
|
89 return i;
|
|
90 }
|
|
91 }
|