author | coleenp |
Wed, 14 Aug 2019 10:07:00 -0400 | |
changeset 57745 | 789e967c2731 |
parent 51618 | 54b344d9dd4e |
child 58554 | 8c3c39710a08 |
permissions | -rw-r--r-- |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
1 |
/* |
48717
7a5835a47adf
8196503: PPC64: vtableStubs gtest fails after 8174962
mdoerr
parents:
48585
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
7a5835a47adf
8196503: PPC64: vtableStubs gtest fails after 8174962
mdoerr
parents:
48585
diff
changeset
|
3 |
* Copyright (c) 2012, 2018 SAP SE. All rights reserved. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
5 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
9 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
14 |
* accompanied this code). |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
15 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
19 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
22 |
* questions. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
23 |
* |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
24 |
*/ |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
25 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
26 |
#include "precompiled.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
27 |
#include "asm/macroAssembler.inline.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
28 |
#include "code/vtableStubs.hpp" |
40010 | 29 |
#include "interp_masm_ppc.hpp" |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
30 |
#include "memory/resourceArea.hpp" |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
31 |
#include "oops/compiledICHolder.hpp" |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
32 |
#include "oops/instanceKlass.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
33 |
#include "oops/klassVtable.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
34 |
#include "runtime/sharedRuntime.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
35 |
#include "vmreg_ppc.inline.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
36 |
#ifdef COMPILER2 |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
37 |
#include "opto/runtime.hpp" |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
38 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
39 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
40 |
#define __ masm-> |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
41 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
42 |
#ifndef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
43 |
extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
44 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
45 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
46 |
// Used by compiler only; may use only caller saved, non-argument registers. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
47 |
VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
48 |
// 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:
48717
diff
changeset
|
49 |
const int stub_code_length = code_size_limit(true); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
50 |
VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
51 |
// Can be NULL if there is no free space in the code cache. |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
52 |
if (s == NULL) { |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
53 |
return NULL; |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
54 |
} |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
55 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
56 |
// Count unused bytes in instruction sequences of variable size. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
57 |
// We add them to the computed buffer size in order to avoid |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
58 |
// overflow in subsequently generated stubs. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
59 |
address start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
60 |
int slop_bytes = 8; // just a two-instruction safety net |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
61 |
int slop_delta = 0; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
62 |
|
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
63 |
ResourceMark rm; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
64 |
CodeBuffer cb(s->entry_point(), stub_code_length); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
65 |
MacroAssembler* masm = new MacroAssembler(&cb); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
66 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
67 |
#if (!defined(PRODUCT) && defined(COMPILER2)) |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
68 |
if (CountCompiledCalls) { |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
69 |
start_pc = __ pc(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
70 |
int load_const_maxLen = 5*BytesPerInstWord; // load_const generates 5 instructions. Assume that as max size for laod_const_optimized |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
71 |
int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
72 |
slop_delta = load_const_maxLen - (__ pc() - start_pc); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
73 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
74 |
assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
75 |
__ lwz(R12_scratch2, offs, R11_scratch1); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
76 |
__ addi(R12_scratch2, R12_scratch2, 1); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
77 |
__ stw(R12_scratch2, offs, R11_scratch1); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
78 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
79 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
80 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
81 |
assert(VtableStub::receiver_location() == R3_ARG1->as_VMReg(), "receiver expected in R3_ARG1"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
82 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
83 |
const Register rcvr_klass = R11_scratch1; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
84 |
address npe_addr = __ pc(); // npe = null pointer exception |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
85 |
// check if we must do an explicit check (implicit checks disabled, offset too large). |
35085 | 86 |
__ null_check(R3, oopDesc::klass_offset_in_bytes(), /*implicit only*/NULL); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
87 |
// Get receiver klass. |
35085 | 88 |
__ load_klass(rcvr_klass, R3); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
89 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
90 |
#ifndef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
91 |
if (DebugVtables) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
92 |
Label L; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
93 |
// Check offset vs vtable length. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
94 |
const Register vtable_len = R12_scratch2; |
35899 | 95 |
__ lwz(vtable_len, in_bytes(Klass::vtable_length_offset()), rcvr_klass); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
96 |
__ cmpwi(CCR0, vtable_len, vtable_index*vtableEntry::size()); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
97 |
__ bge(CCR0, L); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
98 |
__ li(R12_scratch2, vtable_index); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
99 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), R3_ARG1, R12_scratch2, false); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
100 |
__ bind(L); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
101 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
102 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
103 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
104 |
int entry_offset = in_bytes(Klass::vtable_start_offset()) + |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
105 |
vtable_index*vtableEntry::size_in_bytes(); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
106 |
int v_off = entry_offset + vtableEntry::method_offset_in_bytes(); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
107 |
|
48717
7a5835a47adf
8196503: PPC64: vtableStubs gtest fails after 8174962
mdoerr
parents:
48585
diff
changeset
|
108 |
__ ld(R19_method, (RegisterOrConstant)v_off, rcvr_klass); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
109 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
110 |
#ifndef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
111 |
if (DebugVtables) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
112 |
Label L; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
113 |
__ cmpdi(CCR0, R19_method, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
114 |
__ bne(CCR0, L); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
115 |
__ stop("Vtable entry is ZERO", 102); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
116 |
__ bind(L); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
117 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
118 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
119 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
120 |
address ame_addr = __ pc(); // ame = abstract method error |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
121 |
// if the vtable entry is null, the method is abstract |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
122 |
// NOTE: for vtable dispatches, the vtable entry will never be null. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
123 |
|
35085 | 124 |
__ null_check(R19_method, in_bytes(Method::from_compiled_offset()), /*implicit only*/NULL); |
125 |
__ ld(R12_scratch2, in_bytes(Method::from_compiled_offset()), R19_method); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
126 |
__ mtctr(R12_scratch2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
127 |
__ bctr(); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
128 |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
129 |
masm->flush(); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
130 |
bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
131 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
132 |
return s; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
133 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
134 |
|
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
135 |
VtableStub* VtableStubs::create_itable_stub(int itable_index) { |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
136 |
// 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:
48717
diff
changeset
|
137 |
const int stub_code_length = code_size_limit(false); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
138 |
VtableStub* s = new(stub_code_length) VtableStub(false, itable_index); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
139 |
// Can be NULL if there is no free space in the code cache. |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
140 |
if (s == NULL) { |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
141 |
return NULL; |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
142 |
} |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
143 |
// Count unused bytes in instruction sequences of variable size. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
144 |
// We add them to the computed buffer size in order to avoid |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
145 |
// overflow in subsequently generated stubs. |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
146 |
address start_pc; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
147 |
int slop_bytes = 8; // just a two-instruction safety net |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
148 |
int slop_delta = 0; |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
149 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
150 |
ResourceMark rm; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
151 |
CodeBuffer cb(s->entry_point(), stub_code_length); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
152 |
MacroAssembler* masm = new MacroAssembler(&cb); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
153 |
int load_const_maxLen = 5*BytesPerInstWord; // load_const generates 5 instructions. Assume that as max size for laod_const_optimized |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
154 |
|
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
155 |
#if (!defined(PRODUCT) && defined(COMPILER2)) |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
156 |
if (CountCompiledCalls) { |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
157 |
start_pc = __ pc(); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
158 |
int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
159 |
slop_delta = load_const_maxLen - (__ pc() - start_pc); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
160 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
161 |
assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
162 |
__ lwz(R12_scratch2, offs, R11_scratch1); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
163 |
__ addi(R12_scratch2, R12_scratch2, 1); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
164 |
__ stw(R12_scratch2, offs, R11_scratch1); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
165 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
166 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
167 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
168 |
assert(VtableStub::receiver_location() == R3_ARG1->as_VMReg(), "receiver expected in R3_ARG1"); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
169 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
170 |
// Entry arguments: |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
171 |
// R19_method: Interface |
22861 | 172 |
// R3_ARG1: Receiver |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
173 |
|
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
174 |
Label L_no_such_interface; |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
175 |
const Register rcvr_klass = R11_scratch1, |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
176 |
interface = R12_scratch2, |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
177 |
tmp1 = R21_tmp1, |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
178 |
tmp2 = R22_tmp2; |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
179 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
180 |
address npe_addr = __ pc(); // npe = null pointer exception |
35085 | 181 |
__ null_check(R3_ARG1, oopDesc::klass_offset_in_bytes(), /*implicit only*/NULL); |
182 |
__ load_klass(rcvr_klass, R3_ARG1); |
|
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
183 |
|
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
184 |
// Receiver subtype check against REFC. |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
185 |
__ ld(interface, CompiledICHolder::holder_klass_offset(), R19_method); |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
186 |
__ lookup_interface_method(rcvr_klass, interface, noreg, |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
187 |
R0, tmp1, tmp2, |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
188 |
L_no_such_interface, /*return_method=*/ false); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
189 |
|
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
190 |
// Get Method* and entrypoint for compiler |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
191 |
__ ld(interface, CompiledICHolder::holder_metadata_offset(), R19_method); |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
192 |
__ lookup_interface_method(rcvr_klass, interface, itable_index, |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
193 |
R19_method, tmp1, tmp2, |
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
194 |
L_no_such_interface, /*return_method=*/ true); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
195 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
196 |
#ifndef PRODUCT |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
197 |
if (DebugVtables) { |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
198 |
Label ok; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
199 |
__ cmpd(CCR0, R19_method, 0); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
200 |
__ bne(CCR0, ok); |
23492 | 201 |
__ stop("method is null", 103); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
202 |
__ bind(ok); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
203 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
204 |
#endif |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
205 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
206 |
// If the vtable entry is null, the method is abstract. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
207 |
address ame_addr = __ pc(); // ame = abstract method error |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
208 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
209 |
// Must do an explicit check if implicit checks are disabled. |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
210 |
__ null_check(R19_method, in_bytes(Method::from_compiled_offset()), &L_no_such_interface); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
211 |
__ ld(R12_scratch2, in_bytes(Method::from_compiled_offset()), R19_method); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
212 |
__ mtctr(R12_scratch2); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
213 |
__ bctr(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
214 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
215 |
// Handle IncompatibleClassChangeError in itable stubs. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
216 |
// More detailed error message. |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
217 |
// We force resolving of the call site by jumping to the "handle |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
218 |
// wrong method" stub, and so let the interpreter runtime do all the |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
219 |
// dirty work. |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
220 |
__ bind(L_no_such_interface); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
221 |
start_pc = __ pc(); |
48585
d9fcb7ba8133
8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents:
47216
diff
changeset
|
222 |
__ load_const_optimized(R11_scratch1, SharedRuntime::get_handle_wrong_method_stub(), R12_scratch2); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
223 |
slop_delta = load_const_maxLen - (__ pc() - start_pc); |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
224 |
slop_bytes += slop_delta; |
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
225 |
assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
226 |
__ mtctr(R11_scratch1); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
227 |
__ bctr(); |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
228 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
229 |
masm->flush(); |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
230 |
bookkeeping(masm, tty, s, npe_addr, ame_addr, false, itable_index, slop_bytes, 0); |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
231 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
232 |
return s; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
233 |
} |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
234 |
|
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
235 |
int VtableStub::pd_code_alignment() { |
51618
54b344d9dd4e
8207343: Automate vtable/itable stub size calculation
lucy
parents:
48717
diff
changeset
|
236 |
// Power cache line size is 128 bytes, but we want to limit alignment loss. |
22824
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
237 |
const unsigned int icache_line_size = 32; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
238 |
return icache_line_size; |
28258dd5cb2e
8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff
changeset
|
239 |
} |