author | jlaskey |
Thu, 06 Jun 2019 12:24:44 -0300 | |
changeset 55260 | cc0f117f4405 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
34362 | 1 |
/* |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
34362 | 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. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
package java.lang; |
|
26 |
||
27 |
final class LiveStackFrameInfo extends StackFrameInfo implements LiveStackFrame { |
|
28 |
private static Object[] EMPTY_ARRAY = new Object[0]; |
|
29 |
||
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
30 |
// These flags must match the values maintained in the VM |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
31 |
private static final int MODE_INTERPRETED = 0x01; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
32 |
private static final int MODE_COMPILED = 0x02; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
33 |
|
34362 | 34 |
LiveStackFrameInfo(StackWalker walker) { |
35 |
super(walker); |
|
36 |
} |
|
37 |
||
38 |
// These fields are initialized by the VM if ExtendedOption.LOCALS_AND_OPERANDS is set |
|
39 |
private Object[] monitors = EMPTY_ARRAY; |
|
40 |
private Object[] locals = EMPTY_ARRAY; |
|
41 |
private Object[] operands = EMPTY_ARRAY; |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
42 |
private int mode = 0; |
34362 | 43 |
|
44 |
@Override |
|
45 |
public Object[] getMonitors() { |
|
46 |
return monitors; |
|
47 |
} |
|
48 |
||
49 |
@Override |
|
50 |
public Object[] getLocals() { |
|
51 |
return locals; |
|
52 |
} |
|
53 |
||
54 |
@Override |
|
55 |
public Object[] getStack() { |
|
56 |
return operands; |
|
57 |
} |
|
58 |
||
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
59 |
@Override |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
60 |
public String toString() { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
61 |
StringBuilder retVal = new StringBuilder(super.toString()); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
62 |
if (mode != 0) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
63 |
retVal.append("("); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
64 |
if ((mode & MODE_INTERPRETED) == MODE_INTERPRETED) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
65 |
retVal.append(" interpreted "); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
66 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
67 |
if ((mode & MODE_COMPILED) == MODE_COMPILED) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
68 |
retVal.append(" compiled "); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
69 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
70 |
retVal.append(")"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
71 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
72 |
return retVal.toString(); |
34362 | 73 |
} |
74 |
||
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
75 |
/* |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
76 |
* Convert primitive value to {@code PrimitiveSlot} object to represent |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
77 |
* a local variable or an element on the operand stack of primitive type. |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
78 |
*/ |
34362 | 79 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
80 |
static PrimitiveSlot asPrimitive(int value) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
81 |
return new PrimitiveSlot32(value); |
34362 | 82 |
} |
83 |
||
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
84 |
static PrimitiveSlot asPrimitive(long value) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
85 |
return new PrimitiveSlot64(value); |
34362 | 86 |
} |
87 |
||
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
88 |
private static class PrimitiveSlot32 extends PrimitiveSlot { |
34362 | 89 |
final int value; |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
90 |
PrimitiveSlot32(int value) { |
34362 | 91 |
this.value = value; |
92 |
} |
|
93 |
||
94 |
@Override |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
95 |
public int size() { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
96 |
return 4; |
34362 | 97 |
} |
98 |
||
99 |
@Override |
|
100 |
public int intValue() { |
|
101 |
return value; |
|
102 |
} |
|
103 |
||
104 |
@Override |
|
105 |
public String toString() { |
|
106 |
return String.valueOf(value); |
|
107 |
} |
|
108 |
} |
|
109 |
||
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
110 |
private static class PrimitiveSlot64 extends PrimitiveSlot { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
111 |
final long value; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
112 |
PrimitiveSlot64(long value) { |
34362 | 113 |
this.value = value; |
114 |
} |
|
115 |
||
116 |
@Override |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
117 |
public int size() { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
34362
diff
changeset
|
118 |
return 8; |
34362 | 119 |
} |
120 |
||
121 |
@Override |
|
122 |
public long longValue() { |
|
123 |
return value; |
|
124 |
} |
|
125 |
||
126 |
@Override |
|
127 |
public String toString() { |
|
128 |
return String.valueOf(value); |
|
129 |
} |
|
130 |
} |
|
131 |
} |