jdk

Форк
0
/
compilationFailureInfo.cpp 
126 строк · 3.7 Кб
1
/*
2
 * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
3
 * Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
 *
6
 * This code is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License version 2 only, as
8
 * published by the Free Software Foundation.
9
 *
10
 * This code is distributed in the hope that it will be useful, but WITHOUT
11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13
 * version 2 for more details (a copy is included in the LICENSE file that
14
 * accompanied this code).
15
 *
16
 * You should have received a copy of the GNU General Public License version
17
 * 2 along with this work; if not, write to the Free Software Foundation,
18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
 *
20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
 * or visit www.oracle.com if you need additional information or have any
22
 * questions.
23
 *
24
 */
25

26
#include "precompiled.hpp"
27

28
#if defined(COMPILER1) || defined(COMPILER2)
29

30
#ifdef COMPILER1
31
#include "c1/c1_Compilation.hpp"
32
#endif
33
#include "ci/ciEnv.hpp"
34
#include "compiler/abstractCompiler.hpp"
35
#include "compiler/compilationFailureInfo.hpp"
36
#include "compiler/compileTask.hpp"
37
#ifdef COMPILER2
38
#include "opto/node.hpp"
39
#include "opto/compile.hpp"
40
#endif
41
#include "runtime/os.hpp"
42
#include "utilities/ostream.hpp"
43
#include "utilities/nativeCallStack.hpp"
44

45
int CompilationFailureInfo::current_compile_id_or_0() {
46
  ciEnv* env = ciEnv::current();
47
  return (env != nullptr) ? env->compile_id() : 0;
48
}
49

50
CompilationFailureInfo::CompilationFailureInfo(const char* failure_reason) :
51
  _stack(2),
52
  _failure_reason(os::strdup(failure_reason)),
53
  _elapsed_seconds(os::elapsedTime()),
54
  _compile_id(current_compile_id_or_0())
55
{}
56

57
CompilationFailureInfo::~CompilationFailureInfo() {
58
  os::free(_failure_reason);
59
}
60

61
void CompilationFailureInfo::print_on(outputStream* st) const {
62
  st->print("  Time: ");
63
  os::print_elapsed_time(st, _elapsed_seconds);
64
  st->print_cr("  Compile id: %d", _compile_id);
65
  st->print_cr("  Reason: '%s'", _failure_reason);
66
  st->print_cr("  Callstack: ");
67
  _stack.print_on(st);
68
  st->cr();
69
}
70

71
// Convenience function to print current compile failure iff
72
// current thread is compiler thread and there is a pending failure.
73
// Otherwise prints nothing.
74
bool CompilationFailureInfo::print_pending_compilation_failure(outputStream* st) {
75

76
  const CompilationFailureInfo* info = nullptr;
77

78
  // Carefully tiptoeing because we are called from the error reporter and
79
  // nothing is certain.
80

81
  const Thread* const t = Thread::current();
82
  if (t == nullptr || !t->is_Compiler_thread()) {
83
    return false;
84
  }
85

86
  const ciEnv* const env = ciEnv::current();
87
  if (env == nullptr) {
88
    return false;
89
  }
90

91
  const CompileTask* const task = env->task();
92
  if (task == nullptr) {
93
    return false;
94
  }
95

96
  const AbstractCompiler* const compiler = task->compiler();
97
  if (compiler == nullptr) {
98
    return false;
99
  }
100

101
#ifdef COMPILER1
102
  if (compiler->type() == compiler_c1) {
103
    const Compilation* const C = (Compilation*)env->compiler_data();
104
    if (C != nullptr) {
105
      info = C->first_failure_details();
106
    }
107
  }
108
#endif
109
#ifdef COMPILER2
110
  if (compiler->type() == compiler_c2) {
111
    const Compile* const C = (Compile*)env->compiler_data();
112
    if (C != nullptr) {
113
      info = C->first_failure_details();
114
    }
115
  }
116
#endif
117

118
  if (info != nullptr) {
119
    st->print_cr("Pending compilation failure details for thread " PTR_FORMAT ":", p2i(t));
120
    info->print_on(st);
121
  }
122

123
  return true;
124
}
125

126
#endif // defined(COMPILER1) || defined(COMPILER2)
127

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.