Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionTwosComplement.java @ 1913:3b2dea75431e
6984311: JSR 292 needs optional bootstrap method parameters
Summary: Allow CONSTANT_InvokeDynamic nodes to have any number of extra operands.
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 30 Oct 2010 13:08:23 -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, 2001, 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.debugger; | |
26 | |
27 /** Base class for all twos-complement machine descriptions, which | |
28 handles the cIntegerType{Min,Max}Value methods. */ | |
29 | |
30 public abstract class MachineDescriptionTwosComplement { | |
31 | |
32 /** Handles 1, 2, 4, and 8-byte signed integers */ | |
33 private static final long[] signedMinValues = { | |
34 Byte.MIN_VALUE, | |
35 Short.MIN_VALUE, | |
36 Integer.MIN_VALUE, | |
37 Long.MIN_VALUE | |
38 }; | |
39 | |
40 /** Handles 1, 2, 4, and 8-byte signed integers */ | |
41 private static final long[] signedMaxValues = { | |
42 Byte.MAX_VALUE, | |
43 Short.MAX_VALUE, | |
44 Integer.MAX_VALUE, | |
45 Long.MAX_VALUE | |
46 }; | |
47 | |
48 /** Handles 1, 2, and 4-byte unsigned integers properly, with a bug | |
49 in the 8-byte unsigned integer's constant */ | |
50 private static final long[] unsignedMaxValues = { | |
51 255L, | |
52 65535L, | |
53 4294967295L, | |
54 -1L | |
55 }; | |
56 | |
57 public long cIntegerTypeMaxValue(long sizeInBytes, boolean isUnsigned) { | |
58 if (isUnsigned) { | |
59 // Would be nice to signal to the caller that 8-byte unsigned | |
60 // integers are not supported properly, but it looks like doing | |
61 // so at this level will cause problems above | |
62 | |
63 return tableLookup(sizeInBytes, unsignedMaxValues); | |
64 } else { | |
65 return tableLookup(sizeInBytes, signedMaxValues); | |
66 } | |
67 }; | |
68 | |
69 public long cIntegerTypeMinValue(long sizeInBytes, boolean isUnsigned) { | |
70 if (isUnsigned) { | |
71 return 0; | |
72 } | |
73 | |
74 return tableLookup(sizeInBytes, signedMinValues); | |
75 } | |
76 | |
77 // Nearly all of the supported machines are not LP64 */ | |
78 public boolean isLP64() { | |
79 return false; | |
80 } | |
81 | |
82 private long tableLookup(long sizeInBytes, long[] table) { | |
83 switch ((int) sizeInBytes) { | |
84 case 1: | |
85 return table[0]; | |
86 case 2: | |
87 return table[1]; | |
88 case 4: | |
89 return table[2]; | |
90 case 8: | |
91 return table[3]; | |
92 default: | |
93 throw new IllegalArgumentException("C integer type of " + sizeInBytes + " not supported"); | |
94 } | |
95 } | |
96 } |