Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/aarch32/vm/compiledIC_aarch32.cpp
32285 views
1
/*
2
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4
* Copyright (c) 2015, Linaro Ltd. All rights reserved.
5
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
*
7
* This code is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 2 only, as
9
* published by the Free Software Foundation.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*
25
*/
26
27
#include "precompiled.hpp"
28
#include "asm/macroAssembler.inline.hpp"
29
#include "code/compiledIC.hpp"
30
#include "code/icBuffer.hpp"
31
#include "code/nmethod.hpp"
32
#include "memory/resourceArea.hpp"
33
#include "runtime/mutexLocker.hpp"
34
#include "runtime/safepoint.hpp"
35
36
// Release the CompiledICHolder* associated with this call site is there is one.
37
void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) {
38
// This call site might have become stale so inspect it carefully.
39
NativeCall* call = nativeCall_at(call_site->addr());
40
if (is_icholder_entry(call->destination())) {
41
NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value());
42
InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data());
43
}
44
}
45
46
bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) {
47
// This call site might have become stale so inspect it carefully.
48
NativeCall* call = nativeCall_at(call_site->addr());
49
return is_icholder_entry(call->destination());
50
}
51
52
// ----------------------------------------------------------------------------
53
54
#define __ _masm.
55
address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
56
// Stub is fixed up when the corresponding call is converted from
57
// calling compiled code to calling interpreted code.
58
// mov rmethod, 0
59
// jmp -4 # to self
60
61
address mark = cbuf.insts_mark(); // Get mark within main instrs section.
62
63
// Note that the code buffer's insts_mark is always relative to insts.
64
// That's why we must use the macroassembler to generate a stub.
65
MacroAssembler _masm(&cbuf);
66
67
address base = __ start_a_stub(to_interp_stub_size()*2);
68
69
int offset = __ offset();
70
if (base == NULL) return NULL; // CodeBuffer::expand failed
71
// static stub relocation stores the instruction address of the call
72
__ relocate(static_stub_Relocation::spec(mark));
73
// static stub relocation also tags the Method* in the code-stream.
74
__ mov_metadata(rmethod, (Metadata*)NULL);
75
__ movptr(rscratch1, 0);
76
__ b(rscratch1);
77
78
assert((__ offset() - offset) <= (int)to_interp_stub_size(), "stub too big");
79
__ end_a_stub();
80
return base;
81
}
82
#undef __
83
84
int CompiledStaticCall::to_interp_stub_size() {
85
return 7 * NativeInstruction::arm_insn_sz;
86
}
87
88
// Relocation entries for call stub, compiled java to interpreter.
89
int CompiledStaticCall::reloc_to_interp_stub() {
90
return 4; // 3 in emit_to_interp_stub + 1 in emit_call
91
}
92
93
void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) {
94
address stub = find_stub();
95
guarantee(stub != NULL, "stub not found");
96
97
if (TraceICs) {
98
ResourceMark rm;
99
tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
100
p2i(instruction_address()),
101
callee->name_and_sig_as_C_string());
102
}
103
104
// Creation also verifies the object.
105
NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
106
NativeJump* jump = NativeJump::from(method_holder->next_instruction_address());
107
#ifndef PRODUCT
108
assert(method_holder->data() == 0 || method_holder->data() == (intptr_t)callee(),
109
"a) MT-unsafe modification of inline cache");
110
assert(method_holder->data() == 0 || jump->jump_destination() == entry,
111
"b) MT-unsafe modification of inline cache");
112
#endif
113
// Update stub.
114
method_holder->set_data((intptr_t)callee());
115
jump->set_jump_destination(entry);
116
ICache::invalidate_range(stub, to_interp_stub_size());
117
// Update jump to call.
118
set_destination_mt_safe(stub);
119
}
120
121
void CompiledStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
122
assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call");
123
// Reset stub.
124
address stub = static_stub->addr();
125
assert(stub != NULL, "stub not found");
126
// Creation also verifies the object.
127
NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
128
method_holder->set_data(0);
129
}
130
131
//-----------------------------------------------------------------------------
132
// Non-product mode code
133
#ifndef PRODUCT
134
135
void CompiledStaticCall::verify() {
136
// Verify call.
137
NativeCall::verify();
138
if (os::is_MP()) {
139
verify_alignment();
140
}
141
142
// Verify stub.
143
address stub = find_stub();
144
assert(stub != NULL, "no stub found for static call");
145
146
// Verify state.
147
assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
148
}
149
150
#endif // !PRODUCT
151
152