- Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathcompilationFailureInfo.cpp
124 lines (107 loc) · 3.66 KB
/
compilationFailureInfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#if defined(COMPILER1) || defined(COMPILER2)
#ifdef COMPILER1
#include"c1/c1_Compilation.hpp"
#endif
#include"ci/ciEnv.hpp"
#include"compiler/abstractCompiler.hpp"
#include"compiler/compilationFailureInfo.hpp"
#include"compiler/compileTask.hpp"
#ifdef COMPILER2
#include"opto/compile.hpp"
#include"opto/node.hpp"
#endif
#include"runtime/os.hpp"
#include"utilities/nativeCallStack.hpp"
#include"utilities/ostream.hpp"
intCompilationFailureInfo::current_compile_id_or_0() {
ciEnv* env = ciEnv::current();
return (env != nullptr) ? env->compile_id() : 0;
}
CompilationFailureInfo::CompilationFailureInfo(constchar* failure_reason) :
_stack(2),
_failure_reason(os::strdup(failure_reason)),
_elapsed_seconds(os::elapsedTime()),
_compile_id(current_compile_id_or_0())
{}
CompilationFailureInfo::~CompilationFailureInfo() {
os::free(_failure_reason);
}
voidCompilationFailureInfo::print_on(outputStream* st) const {
st->print(" Time: ");
os::print_elapsed_time(st, _elapsed_seconds);
st->print_cr(" Compile id: %d", _compile_id);
st->print_cr(" Reason: '%s'", _failure_reason);
st->print_cr(" Callstack: ");
_stack.print_on(st);
st->cr();
}
// Convenience function to print current compile failure iff
// current thread is compiler thread and there is a pending failure.
// Otherwise prints nothing.
boolCompilationFailureInfo::print_pending_compilation_failure(outputStream* st) {
const CompilationFailureInfo* info = nullptr;
// Carefully tiptoeing because we are called from the error reporter and
// nothing is certain.
const Thread* const t = Thread::current();
if (t == nullptr || !t->is_Compiler_thread()) {
returnfalse;
}
const ciEnv* const env = ciEnv::current();
if (env == nullptr) {
returnfalse;
}
const CompileTask* const task = env->task();
if (task == nullptr) {
returnfalse;
}
const AbstractCompiler* const compiler = task->compiler();
if (compiler == nullptr) {
returnfalse;
}
#ifdef COMPILER1
if (compiler->type() == compiler_c1) {
const Compilation* const C = (Compilation*)env->compiler_data();
if (C != nullptr) {
info = C->first_failure_details();
}
}
#endif
#ifdef COMPILER2
if (compiler->type() == compiler_c2) {
const Compile* const C = (Compile*)env->compiler_data();
if (C != nullptr) {
info = C->first_failure_details();
}
}
#endif
if (info != nullptr) {
st->print_cr("Pending compilation failure details for thread " PTR_FORMAT ":", p2i(t));
info->print_on(st);
}
returntrue;
}
#endif// defined(COMPILER1) || defined(COMPILER2)