author | bchristi |
Tue, 31 Jan 2017 11:51:02 -0800 | |
changeset 43715 | 6d72cc84759f |
parent 42338 | a60f280f803c |
permissions | -rw-r--r-- |
34372 | 1 |
/* |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
34372 | 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
26 |
* @bug 8020968 8147039 8156073 |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
27 |
* @summary Tests for locals and operands |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40684
diff
changeset
|
28 |
* @modules java.base/java.lang:open |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
29 |
* @run testng/othervm -Xint -DtestUnused=true LocalsAndOperands |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
30 |
* @run testng/othervm -Xcomp LocalsAndOperands |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
31 |
* @run testng/othervm -Xcomp -XX:-TieredCompilation LocalsAndOperands |
34372 | 32 |
*/ |
33 |
||
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
34 |
import org.testng.annotations.*; |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
35 |
import static org.testng.Assert.*; |
34372 | 36 |
import java.lang.StackWalker.StackFrame; |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
37 |
import static java.lang.StackWalker.Option.*; |
34372 | 38 |
import java.lang.reflect.*; |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
39 |
import java.util.*; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
40 |
import java.util.stream.*; |
34372 | 41 |
|
42 |
public class LocalsAndOperands { |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
43 |
static final boolean debug = false; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
44 |
static final boolean is32bit; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
45 |
static final boolean testUnused; |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
46 |
|
34372 | 47 |
static Class<?> liveStackFrameClass; |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
48 |
static Class<?> primitiveSlotClass; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
49 |
static Class<?> primitiveSlot32Class; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
50 |
static Class<?> primitiveSlot64Class; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
51 |
|
34372 | 52 |
static StackWalker extendedWalker; |
53 |
static Method getLocals; |
|
54 |
static Method getOperands; |
|
55 |
static Method getMonitors; |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
56 |
static Method primitiveSize; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
57 |
static Method primitiveLongValue; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
58 |
static Method primitiveIntValue; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
59 |
static Method getExtendedWalker; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
60 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
61 |
private static final long LOWER_LONG_VAL = 4L; // Lower bits |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
62 |
private static final long UPPER_LONG_VAL = 0x123400000000L; // Upper bits |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
63 |
private static final long NEG_LONG_VAL = Long.MIN_VALUE; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
64 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
65 |
private static final double LOWER_DOUBLE_VAL = Double.longBitsToDouble(0xABCDL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
66 |
private static final double UPPER_DOUBLE_VAL = Double.longBitsToDouble(0x432100000000L); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
67 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
68 |
static { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
69 |
try { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
70 |
liveStackFrameClass = Class.forName("java.lang.LiveStackFrame"); |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
71 |
primitiveSlotClass = Class.forName("java.lang.LiveStackFrame$PrimitiveSlot"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
72 |
primitiveSlot32Class = Class.forName("java.lang.LiveStackFrameInfo$PrimitiveSlot32"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
73 |
primitiveSlot64Class = Class.forName("java.lang.LiveStackFrameInfo$PrimitiveSlot64"); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
74 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
75 |
getLocals = liveStackFrameClass.getDeclaredMethod("getLocals"); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
76 |
getLocals.setAccessible(true); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
77 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
78 |
getOperands = liveStackFrameClass.getDeclaredMethod("getStack"); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
79 |
getOperands.setAccessible(true); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
80 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
81 |
getMonitors = liveStackFrameClass.getDeclaredMethod("getMonitors"); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
82 |
getMonitors.setAccessible(true); |
34372 | 83 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
84 |
primitiveSize = primitiveSlotClass.getDeclaredMethod("size"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
85 |
primitiveSize.setAccessible(true); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
86 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
87 |
primitiveLongValue = primitiveSlotClass.getDeclaredMethod("longValue"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
88 |
primitiveLongValue.setAccessible(true); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
89 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
90 |
primitiveIntValue = primitiveSlotClass.getDeclaredMethod("intValue"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
91 |
primitiveIntValue.setAccessible(true); |
34372 | 92 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
93 |
getExtendedWalker = liveStackFrameClass.getMethod("getStackWalker", Set.class); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
94 |
getExtendedWalker.setAccessible(true); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
95 |
extendedWalker = (StackWalker) getExtendedWalker.invoke(null, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
96 |
EnumSet.noneOf(StackWalker.Option.class)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
97 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
98 |
String dataModel = System.getProperty("sun.arch.data.model"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
99 |
if ("32".equals(dataModel)) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
100 |
is32bit = true; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
101 |
} else if ("64".equals(dataModel)) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
102 |
is32bit= false; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
103 |
} else { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
104 |
throw new RuntimeException("Weird data model:" + dataModel); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
105 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
106 |
System.out.println("VM bits: " + dataModel); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
107 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
108 |
testUnused = System.getProperty("testUnused") != null; |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
109 |
} catch (Throwable t) { throw new RuntimeException(t); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
110 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
111 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
112 |
/** Helper method to return a StackFrame's locals */ |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
113 |
static Object[] invokeGetLocals(StackFrame arg) { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
114 |
try { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
115 |
return (Object[]) getLocals.invoke(arg); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
116 |
} catch (Exception e) { throw new RuntimeException(e); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
117 |
} |
34372 | 118 |
|
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
119 |
/***************** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
120 |
* DataProviders * |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
121 |
*****************/ |
34372 | 122 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
123 |
/** Calls KnownLocalsTester.testLocals* and provides LiveStackFrames */ |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
124 |
@DataProvider |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
125 |
public static StackFrame[][] knownLocalsProvider() { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
126 |
List<StackFrame[]> list = new ArrayList<>(3); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
127 |
list.add(new KnownLocalsTester().testLocalsKeepAlive()); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
128 |
list.add(new KnownLocalsTester().testLocalsKeepAliveArgs(0xA, 'z', |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
129 |
"himom", 0x3FF00000000L + 0xFFFF, Math.PI)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
130 |
if (testUnused) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
131 |
list.add(new KnownLocalsTester().testLocalsUnused()); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
132 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
133 |
return list.toArray(new StackFrame[1][1]); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
134 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
135 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
136 |
/**************** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
137 |
* Test methods * |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
138 |
****************/ |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
139 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
140 |
/** |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
141 |
* Check for expected local values in the LiveStackFrame |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
142 |
*/ |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
143 |
@Test(dataProvider = "knownLocalsProvider") |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
144 |
public static void checkLocalValues(StackFrame... frames) { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
145 |
dumpFramesIfDebug(frames); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
146 |
try { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
147 |
Stream.of(frames) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
148 |
.filter(f -> KnownLocalsTester.TEST_METHODS.contains(f.getMethodName())) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
149 |
.forEach(LocalsAndOperands::checkFrameLocals); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
150 |
} catch (Exception e) { dumpFramesIfNotDebug(frames); throw e; } |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
151 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
152 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
153 |
/** |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
154 |
* Check the locals in the given StackFrame against the expected values. |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
155 |
*/ |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
156 |
private static void checkFrameLocals(StackFrame f) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
157 |
Object[] expectedArray = KnownLocalsTester.LOCAL_VALUES; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
158 |
Object[] locals = invokeGetLocals(f); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
159 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
160 |
for (int i = 0; i < locals.length; i++) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
161 |
Object expected = expectedArray[i]; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
162 |
Object observed = locals[i]; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
163 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
164 |
if (expected == null) { /* skip nulls in golden values */ |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
165 |
continue; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
166 |
} else if (expected instanceof KnownLocalsTester.TwoSlotValue) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
167 |
// confirm integrity of expected values |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
168 |
assertEquals(expectedArray[i+1], null, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
169 |
"Malformed array of expected values - slot after TwoSlotValue should be null"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
170 |
assertLongIsInSlots(locals[i], locals[i+1], |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
171 |
((KnownLocalsTester.TwoSlotValue)expected).value); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
172 |
i++; // skip following slot |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
173 |
} else if (primitiveSlotClass.isInstance(observed)) { // single slot primitive |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
174 |
assertTrue(primitiveValueEquals(observed, expected), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
175 |
"Local value mismatch: local " + i + " value is " + |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
176 |
observed + ", expected " + expected); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
177 |
} else if (expected instanceof Class) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
178 |
assertTrue(((Class)expected).isInstance(observed), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
179 |
"Local value mismatch: local " + i + " expected instancof " + |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
180 |
expected + " but got " + observed); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
181 |
} else if (expected instanceof String) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
182 |
assertEquals(expected, observed, "Local value mismatch: local " + |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
183 |
i + " value is " + observed + ", expected " + expected); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
184 |
} else { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
185 |
throw new RuntimeException("Unrecognized expected local value " + |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
186 |
i + ": " + expected); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
187 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
188 |
} |
34372 | 189 |
} |
190 |
||
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
191 |
/** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
192 |
* Sanity check for locals and operands, including testng/jtreg frames |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
193 |
* using all StackWalker options. |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
194 |
*/ |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
195 |
@Test |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
196 |
public synchronized void fullStackSanityCheck() throws Throwable { |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
197 |
if (debug) { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
198 |
System.out.println("Running fullStackSanityCheck"); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
199 |
} |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
200 |
StackWalker sw = (StackWalker) getExtendedWalker.invoke(null, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
201 |
EnumSet.of(SHOW_HIDDEN_FRAMES, SHOW_REFLECT_FRAMES, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
202 |
RETAIN_CLASS_REFERENCE)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
203 |
sw.forEach(f -> { |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
204 |
if (debug) { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
205 |
printLocals(f); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
206 |
} else { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
207 |
try { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
208 |
System.out.println(" " + f + ": " + |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
209 |
((Object[]) getLocals.invoke(f)).length + " locals, " + |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
210 |
((Object[]) getOperands.invoke(f)).length + " operands, " + |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
211 |
((Object[]) getMonitors.invoke(f)).length + " monitors"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
212 |
} catch (IllegalAccessException|InvocationTargetException t) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
213 |
throw new RuntimeException(t); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
214 |
} |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
215 |
} |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
216 |
}); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
217 |
} |
34934
7fbff68dbc12
8144552: java/lang/StackWalker/LocalsAndOperands.java fails with java.lang.NullPointerException
bchristi
parents:
34372
diff
changeset
|
218 |
|
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
219 |
/** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
220 |
* Test that LiveStackFrames are not provided with the default StackWalker |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
221 |
* options. |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
222 |
*/ |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
223 |
@Test |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
224 |
public static void noLocalsSanityCheck() { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
225 |
StackWalker sw = StackWalker.getInstance(); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
226 |
sw.forEach(f -> { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
227 |
assertFalse(liveStackFrameClass.isInstance(f), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
228 |
"should not be LiveStackFrame"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
229 |
}); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
230 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
231 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
232 |
/** |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
233 |
* Class stack-walking methods with a known set of methods and local variables. |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
234 |
*/ |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
235 |
static class KnownLocalsTester { |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
236 |
private StackWalker walker; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
237 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
238 |
KnownLocalsTester() { |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
239 |
this.walker = extendedWalker; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
240 |
} |
34372 | 241 |
|
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
242 |
/** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
243 |
* Perform stackwalk without keeping local variables alive and return an |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
244 |
* array of the collected StackFrames |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
245 |
*/ |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
246 |
private synchronized StackFrame[] testLocalsUnused() { |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
247 |
// Unused local variables will become dead |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
248 |
int x = 0xA; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
249 |
char c = 'z'; // 0x7A |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
250 |
String hi = "himom"; |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
251 |
long l = 0x3FF00000000L + 0xFFFFL; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
252 |
double d = Math.PI; |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
253 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
254 |
return walker.walk(s -> |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
255 |
s.filter(f -> TEST_METHODS.contains(f.getMethodName())) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
256 |
.toArray(StackFrame[]::new) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
257 |
); |
34372 | 258 |
} |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
259 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
260 |
/** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
261 |
* Perform stackwalk, keeping local variables alive, and return a list of |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
262 |
* the collected StackFrames |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
263 |
*/ |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
264 |
private synchronized StackFrame[] testLocalsKeepAlive() { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
265 |
int x = 0xA; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
266 |
char c = 'z'; // 0x7A |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
267 |
String hi = "himom"; |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
268 |
long l = 0x3FF00000000L + 0xFFFFL; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
269 |
double d = Math.PI; |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
270 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
271 |
StackFrame[] frames = walker.walk(s -> |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
272 |
s.filter(f -> TEST_METHODS.contains(f.getMethodName())) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
273 |
.toArray(StackFrame[]::new) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
274 |
); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
275 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
276 |
// Use local variables so they stay alive |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
277 |
System.out.println("Stayin' alive: "+this+" "+x+" "+c+" "+hi+" "+l+" "+d); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
278 |
return frames; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
279 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
280 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
281 |
/** |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
282 |
* Perform stackwalk, keeping method arguments alive, and return a list of |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
283 |
* the collected StackFrames |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
284 |
*/ |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
285 |
private synchronized StackFrame[] testLocalsKeepAliveArgs(int x, char c, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
286 |
String hi, long l, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
287 |
double d) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
288 |
StackFrame[] frames = walker.walk(s -> |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
289 |
s.filter(f -> TEST_METHODS.contains(f.getMethodName())) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
290 |
.toArray(StackFrame[]::new) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
291 |
); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
292 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
293 |
// Use local variables so they stay alive |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
294 |
System.out.println("Stayin' alive: "+this+" "+x+" "+c+" "+hi+" "+l+" "+d); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
295 |
return frames; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
296 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
297 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
298 |
// An expected two-slot local (i.e. long or double) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
299 |
static class TwoSlotValue { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
300 |
public long value; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
301 |
public TwoSlotValue(long value) { this.value = value; } |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
302 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
303 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
304 |
// Expected values for locals in KnownLocalsTester.testLocals* methods |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
305 |
private final static Object[] LOCAL_VALUES = new Object[] { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
306 |
LocalsAndOperands.KnownLocalsTester.class, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
307 |
Integer.valueOf(0xA), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
308 |
Integer.valueOf(0x7A), |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
309 |
"himom", |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
310 |
new TwoSlotValue(0x3FF00000000L + 0xFFFFL), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
311 |
null, // 2nd slot |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
312 |
new TwoSlotValue(Double.doubleToRawLongBits(Math.PI)), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
313 |
null, // 2nd slot |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
314 |
Integer.valueOf(0) |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
315 |
}; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
316 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
317 |
private final static List<String> TEST_METHODS = |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
318 |
List.of("testLocalsUnused", |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
319 |
"testLocalsKeepAlive", |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
320 |
"testLocalsKeepAliveArgs"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
321 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
322 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
323 |
/* Simpler tests of long & double arguments */ |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
324 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
325 |
@Test |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
326 |
public static void testUsedLongArg() throws Exception { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
327 |
usedLong(LOWER_LONG_VAL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
328 |
usedLong(UPPER_LONG_VAL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
329 |
usedLong(NEG_LONG_VAL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
330 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
331 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
332 |
private static void usedLong(long longArg) throws Exception { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
333 |
StackFrame[] frames = extendedWalker.walk(s -> |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
334 |
s.filter(f -> "usedLong".equals(f.getMethodName())) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
335 |
.toArray(StackFrame[]::new) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
336 |
); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
337 |
try { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
338 |
dumpFramesIfDebug(frames); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
339 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
340 |
Object[] locals = (Object[]) getLocals.invoke(frames[0]); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
341 |
assertLongIsInSlots(locals[0], locals[1], longArg); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
342 |
System.out.println("Stayin' alive: " + longArg); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
343 |
} catch (Exception t) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
344 |
dumpFramesIfNotDebug(frames); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
345 |
throw t; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
346 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
347 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
348 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
349 |
@Test |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
350 |
public static void testUnusedLongArg() throws Exception { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
351 |
if (testUnused) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
352 |
unusedLong(NEG_LONG_VAL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
353 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
354 |
} |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
355 |
|
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
356 |
private static void unusedLong(long longArg) throws Exception { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
357 |
StackFrame[] frames = extendedWalker.walk(s -> |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
358 |
s.filter(f -> "unusedLong".equals(f.getMethodName())) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
359 |
.toArray(StackFrame[]::new) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
360 |
); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
361 |
try { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
362 |
dumpFramesIfDebug(frames); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
363 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
364 |
final Object[] locals = (Object[]) getLocals.invoke(frames[0]); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
365 |
assertLongIsInSlots(locals[0], locals[1], NEG_LONG_VAL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
366 |
} catch (Exception t) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
367 |
dumpFramesIfNotDebug(frames); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
368 |
throw t; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
369 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
370 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
371 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
372 |
@Test |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
373 |
public static void testUsedDoubleArg() throws Exception { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
374 |
usedDouble(LOWER_DOUBLE_VAL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
375 |
usedDouble(UPPER_DOUBLE_VAL); |
34372 | 376 |
} |
377 |
||
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
378 |
private static void usedDouble(double doubleArg) throws Exception { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
379 |
StackFrame[] frames = extendedWalker.walk(s -> |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
380 |
s.filter(f -> "usedDouble".equals(f.getMethodName())) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
381 |
.toArray(StackFrame[]::new) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
382 |
); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
383 |
try { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
384 |
dumpFramesIfDebug(frames); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
385 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
386 |
Object[] locals = (Object[]) getLocals.invoke(frames[0]); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
387 |
assertDoubleIsInSlots(locals[0], locals[1], doubleArg); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
388 |
System.out.println("Stayin' alive: " + doubleArg); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
389 |
} catch (Exception t) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
390 |
dumpFramesIfNotDebug(frames); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
391 |
throw t; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
392 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
393 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
394 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
395 |
/******************* |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
396 |
* Utility Methods * |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
397 |
*******************/ |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
398 |
|
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
399 |
/** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
400 |
* Print stack trace with locals |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
401 |
*/ |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
402 |
public static void dumpStackWithLocals(StackFrame...frames) { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
403 |
Stream.of(frames).forEach(LocalsAndOperands::printLocals); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
404 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
405 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
406 |
public static void dumpFramesIfDebug(StackFrame...frames) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
407 |
if (debug) { dumpStackWithLocals(frames); } |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
408 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
409 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
410 |
public static void dumpFramesIfNotDebug(StackFrame...frames) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
411 |
if (!debug) { dumpStackWithLocals(frames); } |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
412 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
413 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
414 |
/** |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
415 |
* Print the StackFrame and an indexed list of its locals |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
416 |
*/ |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
417 |
public static void printLocals(StackWalker.StackFrame frame) { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
418 |
try { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
419 |
System.out.println("Locals for: " + frame); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
420 |
Object[] locals = (Object[]) getLocals.invoke(frame); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
421 |
for (int i = 0; i < locals.length; i++) { |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
422 |
String localStr = null; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
423 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
424 |
if (primitiveSlot64Class.isInstance(locals[i])) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
425 |
localStr = String.format("0x%X", |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
426 |
(Long)primitiveLongValue.invoke(locals[i])); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
427 |
} else if (primitiveSlot32Class.isInstance(locals[i])) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
428 |
localStr = String.format("0x%X", |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
429 |
(Integer)primitiveIntValue.invoke(locals[i])); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
430 |
} else if (locals[i] != null) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
431 |
localStr = locals[i].toString(); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
432 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
433 |
System.out.format(" local %d: %s type %s\n", i, localStr, type(locals[i])); |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
434 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
435 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
436 |
Object[] operands = (Object[]) getOperands.invoke(frame); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
437 |
for (int i = 0; i < operands.length; i++) { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
438 |
System.out.format(" operand %d: %s type %s%n", i, operands[i], |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
439 |
type(operands[i])); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
440 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
441 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
442 |
Object[] monitors = (Object[]) getMonitors.invoke(frame); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
443 |
for (int i = 0; i < monitors.length; i++) { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
444 |
System.out.format(" monitor %d: %s%n", i, monitors[i]); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
445 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
446 |
} catch (Exception e) { throw new RuntimeException(e); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
447 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
448 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
449 |
private static String type(Object o) { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
450 |
try { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
451 |
if (o == null) { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
452 |
return "null"; |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
453 |
} else if (primitiveSlotClass.isInstance(o)) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
454 |
int s = (int)primitiveSize.invoke(o); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
455 |
return s + "-byte primitive"; |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
456 |
} else { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
457 |
return o.getClass().getName(); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
458 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
34934
diff
changeset
|
459 |
} catch(Exception e) { throw new RuntimeException(e); } |
34372 | 460 |
} |
43715
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
461 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
462 |
/* |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
463 |
* Check if the PrimitiveValue "primVal" contains the specified value, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
464 |
* either a Long or an Integer. |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
465 |
*/ |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
466 |
static boolean primitiveValueEquals(Object primVal, Object expectedVal) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
467 |
try { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
468 |
if (expectedVal instanceof Long) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
469 |
assertFalse(is32bit); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
470 |
assertTrue(primitiveSlot64Class.isInstance(primVal)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
471 |
assertTrue(8 == (int)primitiveSize.invoke(primVal)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
472 |
return Objects.equals(primitiveLongValue.invoke(primVal), expectedVal); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
473 |
} else if (expectedVal instanceof Integer) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
474 |
int expectedInt = (Integer)expectedVal; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
475 |
if (is32bit) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
476 |
assertTrue(primitiveSlot32Class.isInstance(primVal), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
477 |
"expected a PrimitiveSlot32 on 32-bit VM"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
478 |
assertTrue(4 == (int)primitiveSize.invoke(primVal)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
479 |
return expectedInt == (int)primitiveIntValue.invoke(primVal); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
480 |
} else { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
481 |
assertTrue(primitiveSlot64Class.isInstance(primVal), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
482 |
"expected a PrimitiveSlot64 on 64-bit VM"); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
483 |
assertTrue(8 == (int)primitiveSize.invoke(primVal)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
484 |
// Look for int expectedVal in high- or low-order 32 bits |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
485 |
long primValLong = (long)primitiveLongValue.invoke(primVal); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
486 |
return (int)(primValLong & 0x00000000FFFFFFFFL) == expectedInt || |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
487 |
(int)(primValLong >>> 32) == expectedInt; |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
488 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
489 |
} else { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
490 |
throw new RuntimeException("Called with non-Integer/Long: " + expectedVal); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
491 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
492 |
} catch (IllegalAccessException|InvocationTargetException e) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
493 |
throw new RuntimeException(e); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
494 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
495 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
496 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
497 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
498 |
/* |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
499 |
* Assert that the expected 2-slot long value is stored somewhere in the |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
500 |
* pair of slots. |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
501 |
* Throw exception if long value isn't in the two slots given. |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
502 |
* Accounts for 32 vs 64 bit, but is lax on endianness (accepts either) |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
503 |
*/ |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
504 |
static void assertLongIsInSlots(Object primVal0, Object primVal1, long expected) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
505 |
try { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
506 |
if (is32bit) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
507 |
int upper = (int)(expected & 0xFFFFFFFFL); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
508 |
int lower = (int)(expected >> 32); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
509 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
510 |
if (!((primitiveValueEquals(primVal0, upper) && |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
511 |
primitiveValueEquals(primVal1, lower)) || |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
512 |
(primitiveValueEquals(primVal0, lower) && |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
513 |
primitiveValueEquals(primVal1, upper)))) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
514 |
throw new RuntimeException(String.format("0x%X and 0x%X of 0x%016X not found in 0x%X and 0x%X", |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
515 |
upper, lower, expected, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
516 |
(int)primitiveIntValue.invoke(primVal0), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
517 |
(int)primitiveIntValue.invoke(primVal1))); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
518 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
519 |
} else { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
520 |
if (!(primitiveValueEquals(primVal0, expected) || |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
521 |
primitiveValueEquals(primVal1, expected))) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
522 |
throw new RuntimeException(String.format("0x%016X not found in 0x%016X or 0x%016X", |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
523 |
expected, |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
524 |
(long)primitiveLongValue.invoke(primVal0), |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
525 |
(long)primitiveLongValue.invoke(primVal1))); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
526 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
527 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
528 |
} catch (IllegalAccessException|InvocationTargetException e) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
529 |
throw new RuntimeException(e); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
530 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
531 |
} |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
532 |
|
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
533 |
static void assertDoubleIsInSlots(Object primVal0, Object primVal1, double expected) { |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
534 |
assertLongIsInSlots(primVal0, primVal1, Double.doubleToRawLongBits(expected)); |
6d72cc84759f
8156073: 2-slot LiveStackFrame locals (long and double) are incorrect
bchristi
parents:
42338
diff
changeset
|
535 |
} |
34372 | 536 |
} |