author | goetz |
Tue, 30 Aug 2016 16:08:52 +0200 | |
changeset 41086 | 06b10263e509 |
parent 40631 | ed82623d7831 |
child 46729 | c62d2e8b2728 |
permissions | -rw-r--r-- |
40383
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
1 |
/* |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
4 |
* |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
8 |
* |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
13 |
* accompanied this code). |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
14 |
* |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
18 |
* |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
21 |
* questions. |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
22 |
*/ |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
23 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
24 |
/* |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
25 |
* @test |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
26 |
* @key nmt |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
27 |
* @summary Running with NMT detail should produce expected stack traces. |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40383
diff
changeset
|
28 |
* @library /test/lib |
40383
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
30 |
* java.management |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
31 |
*/ |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
32 |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40383
diff
changeset
|
33 |
import jdk.test.lib.Platform; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40383
diff
changeset
|
34 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40383
diff
changeset
|
35 |
import jdk.test.lib.process.OutputAnalyzer; |
40383
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
36 |
import java.util.regex.Matcher; |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
37 |
import java.util.regex.Pattern; |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
38 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
39 |
public class CheckForProperDetailStackTrace { |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
40 |
/* The stack trace we look for by default. Note that :: has been replaced by .* |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
41 |
to make sure it maches even if the symbol is not unmangled. */ |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
42 |
public static String stackTraceDefault = |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
43 |
".*ModuleEntryTable.*new_entry.*\n" + |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
44 |
".*ModuleEntryTable.*locked_create_entry_or_null.*\n" + |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
45 |
".*Modules.*define_module.*\n" + |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
46 |
".*JVM_DefineModule.*\n"; |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
47 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
48 |
/* The stack trace we look for on Solaris and Windows slowdebug builds. For some |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
49 |
reason ALWAYSINLINE for AllocateHeap is ignored, so it appears in the stack strace. */ |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
50 |
public static String stackTraceAllocateHeap = |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
51 |
".*AllocateHeap.*\n" + |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
52 |
".*ModuleEntryTable.*new_entry.*\n" + |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
53 |
".*ModuleEntryTable.*locked_create_entry_or_null.*\n" + |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
54 |
".*Modules.*define_module.*\n"; |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
55 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
56 |
/* A symbol that should always be present in NMT detail output. */ |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
57 |
private static String expectedSymbol = |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
58 |
"locked_create_entry_or_null"; |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
59 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
60 |
public static void main(String args[]) throws Exception { |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
61 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
62 |
"-XX:+UnlockDiagnosticVMOptions", |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
63 |
"-XX:NativeMemoryTracking=detail", |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
64 |
"-XX:+PrintNMTStatistics", |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
65 |
"-version"); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
66 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
67 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
68 |
output.shouldHaveExitValue(0); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
69 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
70 |
// We should never see either of these frames because they are supposed to be skipped. */ |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
71 |
output.shouldNotContain("NativeCallStack::NativeCallStack"); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
72 |
output.shouldNotContain("os::get_native_stack"); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
73 |
|
41086
06b10263e509
8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents:
40631
diff
changeset
|
74 |
// AllocateHeap shouldn't be in the output because it is supposed to always be inlined. |
06b10263e509
8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents:
40631
diff
changeset
|
75 |
// We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds |
06b10263e509
8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents:
40631
diff
changeset
|
76 |
// because the compiler ends up not inlining AllocateHeap. |
40383
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
77 |
Boolean okToHaveAllocateHeap = |
41086
06b10263e509
8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents:
40631
diff
changeset
|
78 |
Platform.isSlowDebugBuild() && |
06b10263e509
8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents:
40631
diff
changeset
|
79 |
(Platform.isAix() || Platform.isSolaris() || Platform.isWindows()); |
40383
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
80 |
if (!okToHaveAllocateHeap) { |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
81 |
output.shouldNotContain("AllocateHeap"); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
82 |
} |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
83 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
84 |
// See if we have any stack trace symbols in the output |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
85 |
boolean hasSymbols = |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
86 |
output.getStdout().contains(expectedSymbol) || output.getStderr().contains(expectedSymbol); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
87 |
if (!hasSymbols) { |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
88 |
// It's ok for ARM not to have symbols, because it does not support NMT detail |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
89 |
// when targeting thumb2. It's also ok for Windows not to have symbols, because |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
90 |
// they are only available if the symbols file is included with the build. |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
91 |
if (Platform.isWindows() || Platform.isARM()) { |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
92 |
return; // we are done |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
93 |
} |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
94 |
output.reportDiagnosticSummary(); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
95 |
throw new RuntimeException("Expected symbol missing missing from output: " + expectedSymbol); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
96 |
} |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
97 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
98 |
/* Make sure the expected NMT detail stack trace is found. */ |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
99 |
String expectedStackTrace = |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
100 |
(okToHaveAllocateHeap ? stackTraceAllocateHeap : stackTraceDefault); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
101 |
if (!stackTraceMatches(expectedStackTrace, output)) { |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
102 |
output.reportDiagnosticSummary(); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
103 |
throw new RuntimeException("Expected stack trace missing missing from output: " + expectedStackTrace); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
104 |
} |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
105 |
} |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
106 |
|
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
107 |
public static boolean stackTraceMatches(String stackTrace, OutputAnalyzer output) { |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
108 |
Matcher stdoutMatcher = Pattern.compile(stackTrace, Pattern.MULTILINE).matcher(output.getStdout()); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
109 |
Matcher stderrMatcher = Pattern.compile(stackTrace, Pattern.MULTILINE).matcher(output.getStderr()); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
110 |
return (stdoutMatcher.find() || stderrMatcher.find()); |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
111 |
} |
1ebc8c5aed30
8133747: NMT includes an extra stack frame due to assumption NMT is making on tail calls being used
cjplummer
parents:
diff
changeset
|
112 |
} |