jdk

Форк
0
/
compiledIC_aarch64.cpp 
140 строк · 4.8 Кб
1
/*
2
 * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
3
 * Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved.
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
#include "asm/macroAssembler.inline.hpp"
28
#include "code/compiledIC.hpp"
29
#include "code/nmethod.hpp"
30
#include "logging/log.hpp"
31
#include "memory/resourceArea.hpp"
32
#include "runtime/mutexLocker.hpp"
33
#include "runtime/safepoint.hpp"
34

35
// ----------------------------------------------------------------------------
36

37
#define __ masm->
38
address CompiledDirectCall::emit_to_interp_stub(MacroAssembler *masm, address mark) {
39
  precond(__ code()->stubs()->start() != badAddress);
40
  precond(__ code()->stubs()->end() != badAddress);
41

42
  // Stub is fixed up when the corresponding call is converted from
43
  // calling compiled code to calling interpreted code.
44
  // mov rmethod, 0
45
  // jmp -4 # to self
46

47
  if (mark == nullptr) {
48
    mark = __ inst_mark();  // Get mark within main instrs section.
49
  }
50

51
  address base = __ start_a_stub(to_interp_stub_size());
52
  int offset = __ offset();
53
  if (base == nullptr) {
54
    return nullptr;  // CodeBuffer::expand failed
55
  }
56
  // static stub relocation stores the instruction address of the call
57
  __ relocate(static_stub_Relocation::spec(mark));
58

59
  {
60
    __ emit_static_call_stub();
61
  }
62

63
  assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big");
64
  __ end_a_stub();
65
  return base;
66
}
67
#undef __
68

69
int CompiledDirectCall::to_interp_stub_size() {
70
  return MacroAssembler::static_call_stub_size();
71
}
72

73
int CompiledDirectCall::to_trampoline_stub_size() {
74
  // Somewhat pessimistically, we count 3 instructions here (although
75
  // there are only two) because we sometimes emit an alignment nop.
76
  // Trampoline stubs are always word aligned.
77
  return MacroAssembler::max_trampoline_stub_size();
78
}
79

80
// Relocation entries for call stub, compiled java to interpreter.
81
int CompiledDirectCall::reloc_to_interp_stub() {
82
  return 4; // 3 in emit_to_interp_stub + 1 in emit_call
83
}
84

85
void CompiledDirectCall::set_to_interpreted(const methodHandle& callee, address entry) {
86
  address stub = find_stub();
87
  guarantee(stub != nullptr, "stub not found");
88

89
  // Creation also verifies the object.
90
  NativeMovConstReg* method_holder
91
    = nativeMovConstReg_at(stub + NativeInstruction::instruction_size);
92

93
#ifdef ASSERT
94
  NativeGeneralJump* jump = nativeGeneralJump_at(method_holder->next_instruction_address());
95
  verify_mt_safe(callee, entry, method_holder, jump);
96
#endif
97

98
  // Update stub.
99
  method_holder->set_data((intptr_t)callee());
100
  NativeGeneralJump::insert_unconditional(method_holder->next_instruction_address(), entry);
101
  ICache::invalidate_range(stub, to_interp_stub_size());
102
  // Update jump to call.
103
  set_destination_mt_safe(stub);
104
}
105

106
void CompiledDirectCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
107
  // Reset stub.
108
  address stub = static_stub->addr();
109
  assert(stub != nullptr, "stub not found");
110
  assert(CompiledICLocker::is_safe(stub), "mt unsafe call");
111
  // Creation also verifies the object.
112
  NativeMovConstReg* method_holder
113
    = nativeMovConstReg_at(stub + NativeInstruction::instruction_size);
114
  method_holder->set_data(0);
115
  NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
116
  jump->set_jump_destination((address)-1);
117
}
118

119
//-----------------------------------------------------------------------------
120
// Non-product mode code
121
#ifndef PRODUCT
122

123
void CompiledDirectCall::verify() {
124
  // Verify call.
125
  _call->verify();
126
  _call->verify_alignment();
127

128
  // Verify stub.
129
  address stub = find_stub();
130
  assert(stub != nullptr, "no stub found for static call");
131
  // Creation also verifies the object.
132
  NativeMovConstReg* method_holder
133
    = nativeMovConstReg_at(stub + NativeInstruction::instruction_size);
134
  NativeJump* jump = nativeJump_at(method_holder->next_instruction_address());
135

136
  // Verify state.
137
  assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
138
}
139

140
#endif // !PRODUCT
141

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

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

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

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