jdk

Форк
0
/x
/
xBarrierSetNMethod.cpp 
83 строки · 2.7 Кб
1
/*
2
 * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
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
#include "precompiled.hpp"
25
#include "code/nmethod.hpp"
26
#include "gc/x/xBarrierSetNMethod.hpp"
27
#include "gc/x/xGlobals.hpp"
28
#include "gc/x/xLock.inline.hpp"
29
#include "gc/x/xNMethod.hpp"
30
#include "gc/x/xThreadLocalData.hpp"
31
#include "logging/log.hpp"
32
#include "runtime/threadWXSetters.inline.hpp"
33

34
bool XBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) {
35
  if (!is_armed(nm)) {
36
    // Some other thread got here first and healed the oops
37
    // and disarmed the nmethod. No need to continue.
38
    return true;
39
  }
40

41
  XLocker<XReentrantLock> locker(XNMethod::lock_for_nmethod(nm));
42
  log_trace(nmethod, barrier)("Entered critical zone for %p", nm);
43

44
  if (!is_armed(nm)) {
45
    // Some other thread managed to complete while we were
46
    // waiting for lock. No need to continue.
47
    return true;
48
  }
49

50
  MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));
51

52
  if (nm->is_unloading()) {
53
    // We don't need to take the lock when unlinking nmethods from
54
    // the Method, because it is only concurrently unlinked by
55
    // the entry barrier, which acquires the per nmethod lock.
56
    nm->unlink_from_method();
57

58
    // We can end up calling nmethods that are unloading
59
    // since we clear compiled ICs lazily. Returning false
60
    // will re-resovle the call and update the compiled IC.
61
    return false;
62
  }
63

64
  // Heal oops
65
  XNMethod::nmethod_oops_barrier(nm);
66

67

68
  // CodeCache unloading support
69
  nm->mark_as_maybe_on_stack();
70

71
  // Disarm
72
  disarm(nm);
73

74
  return true;
75
}
76

77
int* XBarrierSetNMethod::disarmed_guard_value_address() const {
78
  return (int*)XAddressBadMaskHighOrderBitsAddr;
79
}
80

81
ByteSize XBarrierSetNMethod::thread_disarmed_guard_value_offset() const {
82
  return XThreadLocalData::nmethod_disarmed_offset();
83
}
84

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

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

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

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