author | mdoerr |
Mon, 12 Aug 2019 10:02:25 +0200 | |
changeset 57710 | 05ff6e27de45 |
parent 51618 | 54b344d9dd4e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
13728
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
7397 | 27 |
#include "code/vtableStubs.hpp" |
21095
1a04f7b3946e
8026251: New type profiling points: parameters to methods
roland
parents:
20072
diff
changeset
|
28 |
#include "interp_masm_x86.hpp" |
7397 | 29 |
#include "memory/resourceArea.hpp" |
48557 | 30 |
#include "oops/compiledICHolder.hpp" |
7397 | 31 |
#include "oops/instanceKlass.hpp" |
32 |
#include "oops/klassVtable.hpp" |
|
33 |
#include "runtime/sharedRuntime.hpp" |
|
34 |
#include "vmreg_x86.inline.hpp" |
|
35 |
#ifdef COMPILER2 |
|
36 |
#include "opto/runtime.hpp" |
|
37 |
#endif |
|
1 | 38 |
|
39 |
// machine-dependent part of VtableStubs: create VtableStub of correct size and |
|
40 |
// initialize its code |
|
41 |
||
42 |
#define __ masm-> |
|
43 |
||
44 |
#ifndef PRODUCT |
|
45 |
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oop receiver, int index); |
|
46 |
#endif |
|
47 |
||
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
48 |
// These stubs are used by the compiler only. |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
49 |
// Argument registers, which must be preserved: |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
50 |
// rcx - receiver (always first argument) |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
51 |
// rdx - second argument (if any) |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
52 |
// Other registers that might be usable: |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
53 |
// rax - inline cache register (is interface for itable stub) |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
54 |
// rbx - method (used when calling out to interpreter) |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
55 |
// Available now, but may become callee-save at some point: |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
56 |
// rsi, rdi |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
57 |
// Note that rax and rdx are also used for return values. |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
58 |
|
1 | 59 |
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
60 |
// 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:
49368
diff
changeset
|
61 |
const int stub_code_length = code_size_limit(true); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
62 |
VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index); |
20072 | 63 |
// Can be NULL if there is no free space in the code cache. |
64 |
if (s == NULL) { |
|
65 |
return NULL; |
|
66 |
} |
|
67 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
68 |
// Count unused bytes in instruction sequences of variable size. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
69 |
// We add them to the computed buffer size in order to avoid |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
70 |
// overflow in subsequently generated stubs. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
71 |
address start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
72 |
int slop_bytes = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
73 |
int slop_delta = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
74 |
// No variance was detected in vtable stub sizes. Setting index_dependent_slop == 0 will unveil any deviation from this observation. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
75 |
const int index_dependent_slop = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
76 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
77 |
ResourceMark rm; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
78 |
CodeBuffer cb(s->entry_point(), stub_code_length); |
1 | 79 |
MacroAssembler* masm = new MacroAssembler(&cb); |
80 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
81 |
#if (!defined(PRODUCT) && defined(COMPILER2)) |
1 | 82 |
if (CountCompiledCalls) { |
1066 | 83 |
__ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr())); |
1 | 84 |
} |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
85 |
#endif |
1 | 86 |
|
87 |
// get receiver (need to skip return address on top of stack) |
|
88 |
assert(VtableStub::receiver_location() == rcx->as_VMReg(), "receiver expected in rcx"); |
|
89 |
||
90 |
// get receiver klass |
|
91 |
address npe_addr = __ pc(); |
|
1066 | 92 |
__ movptr(rax, Address(rcx, oopDesc::klass_offset_in_bytes())); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
93 |
|
1 | 94 |
#ifndef PRODUCT |
95 |
if (DebugVtables) { |
|
96 |
Label L; |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
97 |
start_pc = __ pc(); |
1 | 98 |
// check offset vs vtable length |
35899 | 99 |
__ cmpl(Address(rax, Klass::vtable_length_offset()), vtable_index*vtableEntry::size()); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
100 |
slop_delta = 6 - (__ pc() - start_pc); // cmpl varies in length, depending on data |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
101 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
102 |
assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
103 |
|
1 | 104 |
__ jcc(Assembler::greater, L); |
105 |
__ movl(rbx, vtable_index); |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
106 |
// VTABLE TODO: find upper bound for call_VM length. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
107 |
start_pc = __ pc(); |
1 | 108 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), rcx, rbx); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
109 |
slop_delta = 480 - (__ pc() - start_pc); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
110 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
111 |
assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta); |
1 | 112 |
__ bind(L); |
113 |
} |
|
114 |
#endif // PRODUCT |
|
115 |
||
116 |
const Register method = rbx; |
|
117 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
118 |
// load Method* and target address |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
119 |
start_pc = __ pc(); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
120 |
__ lookup_virtual_method(rax, vtable_index, method); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
121 |
slop_delta = 6 - (int)(__ pc() - start_pc); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
122 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
123 |
assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7397
diff
changeset
|
124 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
125 |
#ifndef PRODUCT |
1 | 126 |
if (DebugVtables) { |
127 |
Label L; |
|
1066 | 128 |
__ cmpptr(method, (int32_t)NULL_WORD); |
1 | 129 |
__ jcc(Assembler::equal, L); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
130 |
__ cmpptr(Address(method, Method::from_compiled_offset()), (int32_t)NULL_WORD); |
1 | 131 |
__ jcc(Assembler::notZero, L); |
132 |
__ stop("Vtable entry is NULL"); |
|
133 |
__ bind(L); |
|
134 |
} |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
135 |
#endif // PRODUCT |
1 | 136 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
137 |
// rax: receiver klass |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
138 |
// method (rbx): Method* |
1 | 139 |
// rcx: receiver |
140 |
address ame_addr = __ pc(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
141 |
__ jmp( Address(method, Method::from_compiled_offset())); |
1 | 142 |
|
143 |
masm->flush(); |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
144 |
slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
145 |
bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, index_dependent_slop); |
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
146 |
|
1 | 147 |
return s; |
148 |
} |
|
149 |
||
150 |
||
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
151 |
VtableStub* VtableStubs::create_itable_stub(int itable_index) { |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
152 |
// 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:
49368
diff
changeset
|
153 |
const int stub_code_length = code_size_limit(false); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
154 |
VtableStub* s = new(stub_code_length) VtableStub(false, itable_index); |
20072 | 155 |
// Can be NULL if there is no free space in the code cache. |
156 |
if (s == NULL) { |
|
157 |
return NULL; |
|
158 |
} |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
159 |
// Count unused bytes in instruction sequences of variable size. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
160 |
// We add them to the computed buffer size in order to avoid |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
161 |
// overflow in subsequently generated stubs. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
162 |
address start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
163 |
int slop_bytes = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
164 |
int slop_delta = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
165 |
const int index_dependent_slop = (itable_index == 0) ? 4 : // code size change with transition from 8-bit to 32-bit constant (@index == 32). |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
166 |
(itable_index < 32) ? 3 : 0; // index == 0 generates even shorter code. |
20072 | 167 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
168 |
ResourceMark rm; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
169 |
CodeBuffer cb(s->entry_point(), stub_code_length); |
1 | 170 |
MacroAssembler* masm = new MacroAssembler(&cb); |
171 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
172 |
#if (!defined(PRODUCT) && defined(COMPILER2)) |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
173 |
if (CountCompiledCalls) { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
174 |
__ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr())); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
175 |
} |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
176 |
#endif /* PRODUCT */ |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
177 |
|
1 | 178 |
// Entry arguments: |
48557 | 179 |
// rax: CompiledICHolder |
1 | 180 |
// rcx: Receiver |
181 |
||
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
182 |
// Most registers are in use; we'll use rax, rbx, rsi, rdi |
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
183 |
// (If we need to make rsi, rdi callee-save, do a push/pop here.) |
48557 | 184 |
const Register recv_klass_reg = rsi; |
185 |
const Register holder_klass_reg = rax; // declaring interface klass (DECC) |
|
186 |
const Register resolved_klass_reg = rbx; // resolved interface klass (REFC) |
|
187 |
const Register temp_reg = rdi; |
|
188 |
||
189 |
const Register icholder_reg = rax; |
|
190 |
__ movptr(resolved_klass_reg, Address(icholder_reg, CompiledICHolder::holder_klass_offset())); |
|
191 |
__ movptr(holder_klass_reg, Address(icholder_reg, CompiledICHolder::holder_metadata_offset())); |
|
192 |
||
193 |
Label L_no_such_interface; |
|
194 |
||
195 |
// get receiver klass (also an implicit null-check) |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
196 |
assert(VtableStub::receiver_location() == rcx->as_VMReg(), "receiver expected in rcx"); |
48557 | 197 |
address npe_addr = __ pc(); |
198 |
__ load_klass(recv_klass_reg, rcx); |
|
199 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
200 |
start_pc = __ pc(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
201 |
|
48557 | 202 |
// Receiver subtype check against REFC. |
203 |
// Destroys recv_klass_reg value. |
|
204 |
__ lookup_interface_method(// inputs: rec. class, interface |
|
205 |
recv_klass_reg, resolved_klass_reg, noreg, |
|
206 |
// outputs: scan temp. reg1, scan temp. reg2 |
|
207 |
recv_klass_reg, temp_reg, |
|
208 |
L_no_such_interface, |
|
209 |
/*return_method=*/false); |
|
210 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
211 |
const ptrdiff_t typecheckSize = __ pc() - start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
212 |
start_pc = __ pc(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
213 |
|
48557 | 214 |
// Get selected method from declaring class and itable index |
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
215 |
const Register method = rbx; |
48557 | 216 |
__ load_klass(recv_klass_reg, rcx); // restore recv_klass_reg |
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
217 |
__ lookup_interface_method(// inputs: rec. class, interface, itable index |
48557 | 218 |
recv_klass_reg, holder_klass_reg, itable_index, |
2149
3d362637b307
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
jrose
parents:
1217
diff
changeset
|
219 |
// outputs: method, scan temp. reg |
48557 | 220 |
method, temp_reg, |
221 |
L_no_such_interface); |
|
1 | 222 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
223 |
const ptrdiff_t lookupSize = __ pc() - start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
224 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
225 |
// We expect we need index_dependent_slop extra bytes. Reason: |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
226 |
// The emitted code in lookup_interface_method changes when itable_index exceeds 31. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
227 |
// For windows, a narrow estimate was found to be 104. Other OSes not tested. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
228 |
const ptrdiff_t estimate = 104; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
229 |
const ptrdiff_t codesize = typecheckSize + lookupSize + index_dependent_slop; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
230 |
slop_delta = (int)(estimate - codesize); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
231 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
232 |
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:
49368
diff
changeset
|
233 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
234 |
// method (rbx): Method* |
1 | 235 |
// rcx: receiver |
236 |
||
237 |
#ifdef ASSERT |
|
238 |
if (DebugVtables) { |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
239 |
Label L1; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
240 |
__ cmpptr(method, (int32_t)NULL_WORD); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
241 |
__ jcc(Assembler::equal, L1); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
242 |
__ cmpptr(Address(method, Method::from_compiled_offset()), (int32_t)NULL_WORD); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
243 |
__ jcc(Assembler::notZero, L1); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
244 |
__ stop("Method* is null"); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
245 |
__ bind(L1); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
246 |
} |
1 | 247 |
#endif // ASSERT |
248 |
||
249 |
address ame_addr = __ pc(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
250 |
__ jmp(Address(method, Method::from_compiled_offset())); |
1 | 251 |
|
48557 | 252 |
__ bind(L_no_such_interface); |
49368
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
253 |
// Handle IncompatibleClassChangeError in itable stubs. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
254 |
// More detailed error message. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
255 |
// 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
|
256 |
// 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
|
257 |
// dirty work. |
2ed1c37df3a5
8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents:
48557
diff
changeset
|
258 |
__ jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub())); |
48557 | 259 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
260 |
masm->flush(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
261 |
slop_bytes += index_dependent_slop; // add'l slop for size variance due to large itable offsets |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
262 |
bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, index_dependent_slop); |
189
4248c8e21063
6664627: Merge changes made only in hotspot 11 forward to jdk 7
dcubed
parents:
1
diff
changeset
|
263 |
|
1 | 264 |
return s; |
265 |
} |
|
266 |
||
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
267 |
int VtableStub::pd_code_alignment() { |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
268 |
// x86 cache line size is 64 bytes, but we want to limit alignment loss. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
269 |
const unsigned int icache_line_size = wordSize; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
49368
diff
changeset
|
270 |
return icache_line_size; |
1 | 271 |
} |