author | jwilhelm |
Thu, 12 Sep 2019 03:21:11 +0200 | |
changeset 58094 | 0f6c749acd15 |
parent 52351 | 0ecb4e520110 |
child 58942 | 5db99b3d6023 |
permissions | -rw-r--r-- |
42664 | 1 |
/* |
50380
bec342339138
8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents:
49368
diff
changeset
|
2 |
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
42664 | 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 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "asm/assembler.hpp" |
|
50380
bec342339138
8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents:
49368
diff
changeset
|
27 |
#include "asm/macroAssembler.inline.hpp" |
42664 | 28 |
#include "assembler_arm.inline.hpp" |
29 |
#include "code/vtableStubs.hpp" |
|
30 |
#include "interp_masm_arm.hpp" |
|
31 |
#include "memory/resourceArea.hpp" |
|
48557 | 32 |
#include "oops/compiledICHolder.hpp" |
42664 | 33 |
#include "oops/instanceKlass.hpp" |
34 |
#include "oops/klassVtable.hpp" |
|
35 |
#include "runtime/sharedRuntime.hpp" |
|
36 |
#include "vmreg_arm.inline.hpp" |
|
37 |
#ifdef COMPILER2 |
|
38 |
#include "opto/runtime.hpp" |
|
39 |
#endif |
|
40 |
||
41 |
// machine-dependent part of VtableStubs: create VtableStub of correct size and |
|
42 |
// initialize its code |
|
43 |
||
44 |
#define __ masm-> |
|
45 |
||
46 |
#ifndef PRODUCT |
|
47 |
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index); |
|
48 |
#endif |
|
49 |
||
50 |
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
51 |
// Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
52 |
const int stub_code_length = code_size_limit(true); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
53 |
VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index); |
42664 | 54 |
// Can be NULL if there is no free space in the code cache. |
55 |
if (s == NULL) { |
|
56 |
return NULL; |
|
57 |
} |
|
58 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
59 |
// Count unused bytes in instruction sequences of variable size. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
60 |
// We add them to the computed buffer size in order to avoid |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
61 |
// overflow in subsequently generated stubs. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
62 |
address start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
63 |
int slop_bytes = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
64 |
int slop_delta = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
65 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
66 |
ResourceMark rm; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
67 |
CodeBuffer cb(s->entry_point(), stub_code_length); |
42664 | 68 |
MacroAssembler* masm = new MacroAssembler(&cb); |
69 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
70 |
#if (!defined(PRODUCT) && defined(COMPILER2)) |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
71 |
if (CountCompiledCalls) { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
72 |
// Implementation required? |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
73 |
} |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
74 |
#endif |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
75 |
|
42664 | 76 |
assert(VtableStub::receiver_location() == R0->as_VMReg(), "receiver expected in R0"); |
77 |
||
78 |
const Register tmp = Rtemp; // Rtemp OK, should be free at call sites |
|
79 |
||
80 |
address npe_addr = __ pc(); |
|
81 |
__ load_klass(tmp, R0); |
|
82 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
83 |
#ifndef PRODUCT |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
84 |
if (DebugVtables) { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
85 |
// Implementation required? |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
86 |
} |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
87 |
#endif |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
88 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
89 |
start_pc = __ pc(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
90 |
{ // lookup virtual method |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
91 |
int entry_offset = in_bytes(Klass::vtable_start_offset()) + vtable_index * vtableEntry::size_in_bytes(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
92 |
int method_offset = vtableEntry::method_offset_in_bytes() + entry_offset; |
42664 | 93 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
94 |
assert ((method_offset & (wordSize - 1)) == 0, "offset should be aligned"); |
52351 | 95 |
int offset_mask = 0xfff; |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
96 |
if (method_offset & ~offset_mask) { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
97 |
__ add(tmp, tmp, method_offset & ~offset_mask); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
98 |
} |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
99 |
__ ldr(Rmethod, Address(tmp, method_offset & offset_mask)); |
42664 | 100 |
} |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
101 |
slop_delta = 8 - (int)(__ pc() - start_pc); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
102 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
103 |
assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
104 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
105 |
#ifndef PRODUCT |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
106 |
if (DebugVtables) { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
107 |
// Implementation required? |
42664 | 108 |
} |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
109 |
#endif |
42664 | 110 |
|
111 |
address ame_addr = __ pc(); |
|
112 |
__ ldr(PC, Address(Rmethod, Method::from_compiled_offset())); |
|
113 |
||
114 |
masm->flush(); |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
115 |
bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0); |
42664 | 116 |
|
117 |
return s; |
|
118 |
} |
|
119 |
||
120 |
VtableStub* VtableStubs::create_itable_stub(int itable_index) { |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
121 |
// Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
122 |
const int stub_code_length = code_size_limit(false); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
123 |
VtableStub* s = new(stub_code_length) VtableStub(false, itable_index); |
42664 | 124 |
// Can be NULL if there is no free space in the code cache. |
125 |
if (s == NULL) { |
|
126 |
return NULL; |
|
127 |
} |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
128 |
// Count unused bytes in instruction sequences of variable size. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
129 |
// We add them to the computed buffer size in order to avoid |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
130 |
// overflow in subsequently generated stubs. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
131 |
address start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
132 |
int slop_bytes = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
133 |
int slop_delta = 0; |
42664 | 134 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
135 |
ResourceMark rm; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
136 |
CodeBuffer cb(s->entry_point(), stub_code_length); |
42664 | 137 |
MacroAssembler* masm = new MacroAssembler(&cb); |
138 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
139 |
#if (!defined(PRODUCT) && defined(COMPILER2)) |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
140 |
if (CountCompiledCalls) { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
141 |
// Implementation required? |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
142 |
} |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
143 |
#endif |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
144 |
|
42664 | 145 |
assert(VtableStub::receiver_location() == R0->as_VMReg(), "receiver expected in R0"); |
146 |
||
147 |
// R0-R3 / R0-R7 registers hold the arguments and cannot be spoiled |
|
52351 | 148 |
const Register Rclass = R4; |
149 |
const Register Rintf = R5; |
|
150 |
const Register Rscan = R6; |
|
42664 | 151 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
152 |
Label L_no_such_interface; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
153 |
|
48557 | 154 |
assert_different_registers(Ricklass, Rclass, Rintf, Rscan, Rtemp); |
42664 | 155 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
156 |
start_pc = __ pc(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
157 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
158 |
// get receiver klass (also an implicit null-check) |
42664 | 159 |
address npe_addr = __ pc(); |
160 |
__ load_klass(Rclass, R0); |
|
161 |
||
48557 | 162 |
// Receiver subtype check against REFC. |
163 |
__ ldr(Rintf, Address(Ricklass, CompiledICHolder::holder_klass_offset())); |
|
164 |
__ lookup_interface_method(// inputs: rec. class, interface, itable index |
|
165 |
Rclass, Rintf, noreg, |
|
166 |
// outputs: temp reg1, temp reg2 |
|
167 |
noreg, Rscan, Rtemp, |
|
168 |
L_no_such_interface); |
|
42664 | 169 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
170 |
const ptrdiff_t typecheckSize = __ pc() - start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
171 |
start_pc = __ pc(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
172 |
|
48557 | 173 |
// Get Method* and entry point for compiler |
174 |
__ ldr(Rintf, Address(Ricklass, CompiledICHolder::holder_metadata_offset())); |
|
175 |
__ lookup_interface_method(// inputs: rec. class, interface, itable index |
|
176 |
Rclass, Rintf, itable_index, |
|
177 |
// outputs: temp reg1, temp reg2, temp reg3 |
|
178 |
Rmethod, Rscan, Rtemp, |
|
179 |
L_no_such_interface); |
|
42664 | 180 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
181 |
const ptrdiff_t lookupSize = __ pc() - start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
182 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
183 |
// Reduce "estimate" such that "padding" does not drop below 8. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
184 |
const ptrdiff_t estimate = 140; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
185 |
const ptrdiff_t codesize = typecheckSize + lookupSize; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
186 |
slop_delta = (int)(estimate - codesize); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
187 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
188 |
assert(slop_delta >= 0, "itable #%d: Code size estimate (%d) for lookup_interface_method too small, required: %d", itable_index, (int)estimate, (int)codesize); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
189 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
190 |
#ifndef PRODUCT |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
191 |
if (DebugVtables) { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
192 |
// Implementation required? |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
193 |
} |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
194 |
#endif |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
195 |
|
42664 | 196 |
address ame_addr = __ pc(); |
197 |
||
198 |
__ ldr(PC, Address(Rmethod, Method::from_compiled_offset())); |
|
199 |
||
48557 | 200 |
__ bind(L_no_such_interface); |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
201 |
// Handle IncompatibleClassChangeError in itable stubs. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
202 |
// More detailed error message. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
203 |
// We force resolving of the call site by jumping to the "handle |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
204 |
// wrong method" stub, and so let the interpreter runtime do all the |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
205 |
// dirty work. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
206 |
assert(SharedRuntime::get_handle_wrong_method_stub() != NULL, "check initialization order"); |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
207 |
__ jump(SharedRuntime::get_handle_wrong_method_stub(), relocInfo::runtime_call_type, Rtemp); |
48557 | 208 |
|
42664 | 209 |
masm->flush(); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
210 |
bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, 0); |
42664 | 211 |
|
212 |
return s; |
|
213 |
} |
|
214 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
215 |
int VtableStub::pd_code_alignment() { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
216 |
// ARM32 cache line size is not an architected constant. We just align on word size. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
217 |
const unsigned int icache_line_size = wordSize; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
50380
diff
changeset
|
218 |
return icache_line_size; |
42664 | 219 |
} |