Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/code/CompressedStream.java @ 6782:5a98bf7d847b
6879063: SA should use hsdis for disassembly
Summary: We should in SA to use hsdis for it like the JVM does to replace the current java based disassembler.
Reviewed-by: twisti, jrose, sla
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 24 Sep 2012 12:44:00 -0700 |
parents | c18cbe5936b8 |
children |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
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 | 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 } |