Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeTableswitch.java @ 3972:4f93f0d00802
7059019: G1: add G1 support to the SA
Summary: Extend the SA to recognize the G1CollectedHeap and implement any code that's needed by our serviceability tools (jmap, jinfo, jstack, etc.) that depend on the SA.
Reviewed-by: never, poonam, johnc
author | tonyp |
---|---|
date | Tue, 20 Sep 2011 09:59:59 -0400 |
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) 2001, 2003, 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.interpreter; | |
26 | |
27 import sun.jvm.hotspot.oops.*; | |
28 import sun.jvm.hotspot.utilities.*; | |
29 | |
30 public class BytecodeTableswitch extends Bytecode { | |
31 BytecodeTableswitch(Method method, int bci) { | |
32 super(method, bci); | |
33 } | |
34 | |
35 | |
36 // Attributes | |
37 public int defaultOffset() { return javaSignedWordAt(alignedOffset(1 + 0*jintSize)); } | |
38 public int lowKey() { return javaSignedWordAt(alignedOffset(1 + 1*jintSize)); } | |
39 public int highKey() { return javaSignedWordAt(alignedOffset(1 + 2*jintSize)); } | |
40 public int length() { return highKey()-lowKey()+1; } | |
41 public int destOffsetAt(int i) { | |
42 int x2 = alignedOffset(1 + (3 + i)*jintSize); | |
43 int val = javaSignedWordAt(x2); | |
44 return javaSignedWordAt(alignedOffset(1 + (3 + i)*jintSize)); | |
45 } | |
46 | |
47 public void verify() { | |
48 if (Assert.ASSERTS_ENABLED) { | |
49 Assert.that(isValid(), "check tableswitch"); | |
50 } | |
51 } | |
52 | |
53 public boolean isValid() { | |
54 boolean result = javaCode() == Bytecodes._tableswitch; | |
55 if (result == false) return false; | |
56 int lo = lowKey(); | |
57 int hi = highKey(); | |
58 if (hi < lo) // incorrect hi/lo values in tableswitch | |
59 return false; | |
60 | |
61 int i = hi - lo - 1 ; | |
62 while (i-- > 0) { | |
63 // no special check needed | |
64 } | |
65 return true; | |
66 } | |
67 | |
68 public static BytecodeTableswitch at(Method method, int bci) { | |
69 BytecodeTableswitch b = new BytecodeTableswitch(method, bci); | |
70 if (Assert.ASSERTS_ENABLED) { | |
71 b.verify(); | |
72 } | |
73 return b; | |
74 } | |
75 | |
76 /** Like at, but returns null if the BCI is not at tableswitch */ | |
77 public static BytecodeTableswitch atCheck(Method method, int bci) { | |
78 BytecodeTableswitch b = new BytecodeTableswitch(method, bci); | |
79 return (b.isValid() ? b : null); | |
80 } | |
81 | |
82 public static BytecodeTableswitch at(BytecodeStream bcs) { | |
83 return new BytecodeTableswitch(bcs.method(), bcs.bci()); | |
84 } | |
85 | |
86 public String toString() { | |
87 StringBuffer buf = new StringBuffer(); | |
88 buf.append("tableswitch"); | |
89 buf.append(spaces); | |
90 buf.append("default: "); | |
91 buf.append(Integer.toString(bci() + defaultOffset())); | |
92 buf.append(comma); | |
93 int lo = lowKey(); | |
94 int hi = highKey(); | |
95 int i = hi - lo - 1 ; | |
96 while (i-- > 0) { | |
97 buf.append("case "); | |
98 buf.append(Integer.toString(lo + i)); | |
99 buf.append(':'); | |
100 buf.append(Integer.toString(bci() + destOffsetAt(i))); | |
101 buf.append(comma); | |
102 } | |
103 return buf.toString(); | |
104 } | |
105 } |