src/cpu/x86/vm/vtableStubs_x86_64.cpp

changeset 8997
f8a45a60bc6b
parent 6680
78bbf4d43a14
child 9041
95a08233f46c
child 9327
f96fcd9e1e1b
equal deleted inserted replaced
8996:2667e5c45e24 8997:f8a45a60bc6b
1 /* 1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "asm/macroAssembler.hpp" 26 #include "asm/macroAssembler.hpp"
27 #include "code/vtableStubs.hpp" 27 #include "code/vtableStubs.hpp"
28 #include "interp_masm_x86.hpp" 28 #include "interp_masm_x86.hpp"
29 #include "memory/resourceArea.hpp" 29 #include "memory/resourceArea.hpp"
30 #include "oops/compiledICHolder.hpp"
30 #include "oops/instanceKlass.hpp" 31 #include "oops/instanceKlass.hpp"
31 #include "oops/klassVtable.hpp" 32 #include "oops/klassVtable.hpp"
32 #include "runtime/sharedRuntime.hpp" 33 #include "runtime/sharedRuntime.hpp"
33 #include "vmreg_x86.inline.hpp" 34 #include "vmreg_x86.inline.hpp"
34 #ifdef COMPILER2 35 #ifdef COMPILER2
147 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr())); 148 __ incrementl(ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
148 } 149 }
149 #endif 150 #endif
150 151
151 // Entry arguments: 152 // Entry arguments:
152 // rax: Interface 153 // rax: CompiledICHolder
153 // j_rarg0: Receiver 154 // j_rarg0: Receiver
154
155 // Free registers (non-args) are rax (interface), rbx
156
157 // get receiver (need to skip return address on top of stack)
158
159 assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
160 // get receiver klass (also an implicit null-check)
161 address npe_addr = __ pc();
162 155
163 // Most registers are in use; we'll use rax, rbx, r10, r11 156 // Most registers are in use; we'll use rax, rbx, r10, r11
164 // (various calling sequences use r[cd]x, r[sd]i, r[89]; stay away from them) 157 // (various calling sequences use r[cd]x, r[sd]i, r[89]; stay away from them)
165 __ load_klass(r10, j_rarg0); 158 const Register recv_klass_reg = r10;
159 const Register holder_klass_reg = rax; // declaring interface klass (DECC)
160 const Register resolved_klass_reg = rbx; // resolved interface klass (REFC)
161 const Register temp_reg = r11;
162
163 Label L_no_such_interface;
164
165 const Register icholder_reg = rax;
166 __ movptr(resolved_klass_reg, Address(icholder_reg, CompiledICHolder::holder_klass_offset()));
167 __ movptr(holder_klass_reg, Address(icholder_reg, CompiledICHolder::holder_metadata_offset()));
168
169 // get receiver klass (also an implicit null-check)
170 assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
171 address npe_addr = __ pc();
172 __ load_klass(recv_klass_reg, j_rarg0);
173
174 // Receiver subtype check against REFC.
175 // Destroys recv_klass_reg value.
176 __ lookup_interface_method(// inputs: rec. class, interface
177 recv_klass_reg, resolved_klass_reg, noreg,
178 // outputs: scan temp. reg1, scan temp. reg2
179 recv_klass_reg, temp_reg,
180 L_no_such_interface,
181 /*return_method=*/false);
182
183 // Get selected method from declaring class and itable index
184 const Register method = rbx;
185 __ load_klass(recv_klass_reg, j_rarg0); // restore recv_klass_reg
186 __ lookup_interface_method(// inputs: rec. class, interface, itable index
187 recv_klass_reg, holder_klass_reg, itable_index,
188 // outputs: method, scan temp. reg
189 method, temp_reg,
190 L_no_such_interface);
166 191
167 // If we take a trap while this arg is on the stack we will not 192 // If we take a trap while this arg is on the stack we will not
168 // be able to walk the stack properly. This is not an issue except 193 // be able to walk the stack properly. This is not an issue except
169 // when there are mistakes in this assembly code that could generate 194 // when there are mistakes in this assembly code that could generate
170 // a spurious fault. Ask me how I know... 195 // a spurious fault. Ask me how I know...
171
172 const Register method = rbx;
173 Label throw_icce;
174
175 // Get Method* and entrypoint for compiler
176 __ lookup_interface_method(// inputs: rec. class, interface, itable index
177 r10, rax, itable_index,
178 // outputs: method, scan temp. reg
179 method, r11,
180 throw_icce);
181 196
182 // method (rbx): Method* 197 // method (rbx): Method*
183 // j_rarg0: receiver 198 // j_rarg0: receiver
184 199
185 #ifdef ASSERT 200 #ifdef ASSERT
197 // rbx: Method* 212 // rbx: Method*
198 // j_rarg0: receiver 213 // j_rarg0: receiver
199 address ame_addr = __ pc(); 214 address ame_addr = __ pc();
200 __ jmp(Address(method, Method::from_compiled_offset())); 215 __ jmp(Address(method, Method::from_compiled_offset()));
201 216
202 __ bind(throw_icce); 217 __ bind(L_no_such_interface);
203 __ jump(RuntimeAddress(StubRoutines::throw_IncompatibleClassChangeError_entry())); 218 __ jump(RuntimeAddress(StubRoutines::throw_IncompatibleClassChangeError_entry()));
204 219
205 __ flush(); 220 __ flush();
206 221
207 if (PrintMiscellaneous && (WizardMode || Verbose)) { 222 if (PrintMiscellaneous && (WizardMode || Verbose)) {
224 // Vtable stub size 239 // Vtable stub size
225 return (DebugVtables ? 512 : 24) + (CountCompiledCalls ? 13 : 0) + 240 return (DebugVtables ? 512 : 24) + (CountCompiledCalls ? 13 : 0) +
226 (UseCompressedClassPointers ? MacroAssembler::instr_size_for_decode_klass_not_null() : 0); 241 (UseCompressedClassPointers ? MacroAssembler::instr_size_for_decode_klass_not_null() : 0);
227 } else { 242 } else {
228 // Itable stub size 243 // Itable stub size
229 return (DebugVtables ? 512 : 74) + (CountCompiledCalls ? 13 : 0) + 244 return (DebugVtables ? 512 : 140) + (CountCompiledCalls ? 13 : 0) +
230 (UseCompressedClassPointers ? MacroAssembler::instr_size_for_decode_klass_not_null() : 0); 245 (UseCompressedClassPointers ? 2 * MacroAssembler::instr_size_for_decode_klass_not_null() : 0);
231 } 246 }
232 // In order to tune these parameters, run the JVM with VM options 247 // In order to tune these parameters, run the JVM with VM options
233 // +PrintMiscellaneous and +WizardMode to see information about 248 // +PrintMiscellaneous and +WizardMode to see information about
234 // actual itable stubs. Look for lines like this: 249 // actual itable stubs. Look for lines like this:
235 // itable #1 at 0x5551212[71] left over: 3 250 // itable #1 at 0x5551212[71] left over: 3

mercurial