author | duke |
Wed, 05 Jul 2017 21:46:33 +0200 | |
changeset 38602 | b72e50a81d43 |
parent 38347 | a3fdbd11148f |
child 40684 | 2e37c119dc2a |
permissions | -rw-r--r-- |
38347
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
1 |
/* |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
2 |
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
4 |
* |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
8 |
* |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
13 |
* accompanied this code). |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
14 |
* |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
18 |
* |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
21 |
* questions. |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
22 |
*/ |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
23 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
24 |
/* |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
25 |
* @test |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
26 |
* @bug 8147039 |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
27 |
* @summary Test for -Xcomp crash that happened before 8147039 fix |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
28 |
* @run testng/othervm -Xcomp LocalsCrash |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
29 |
*/ |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
30 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
31 |
import org.testng.annotations.*; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
32 |
import java.lang.reflect.*; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
33 |
import java.util.List; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
34 |
import java.util.stream.Collectors; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
35 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
36 |
public class LocalsCrash { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
37 |
static Class<?> liveStackFrameClass; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
38 |
static Method getStackWalker; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
39 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
40 |
static { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
41 |
try { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
42 |
liveStackFrameClass = Class.forName("java.lang.LiveStackFrame"); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
43 |
getStackWalker = liveStackFrameClass.getMethod("getStackWalker"); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
44 |
getStackWalker.setAccessible(true); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
45 |
} catch (Throwable t) { throw new RuntimeException(t); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
46 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
47 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
48 |
private StackWalker walker; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
49 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
50 |
LocalsCrash() { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
51 |
try { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
52 |
walker = (StackWalker) getStackWalker.invoke(null); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
53 |
} catch (Exception e) { throw new RuntimeException(e); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
54 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
55 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
56 |
@Test |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
57 |
public void test00() { doStackWalk(); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
58 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
59 |
@Test |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
60 |
public void test01() { doStackWalk(); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
61 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
62 |
private synchronized List<StackWalker.StackFrame> doStackWalk() { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
63 |
try { |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
64 |
// Unused local variables will become dead |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
65 |
int x = 10; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
66 |
char c = 'z'; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
67 |
String hi = "himom"; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
68 |
long l = 1000000L; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
69 |
double d = 3.1415926; |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
70 |
|
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
71 |
return walker.walk(s -> s.collect(Collectors.toList())); |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
72 |
} catch (Exception e) { throw new RuntimeException(e); } |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
73 |
} |
a3fdbd11148f
8147039: Incorrect locals and operands in compiled frames
bchristi
parents:
diff
changeset
|
74 |
} |