Thu, 14 Jun 2018 09:15:08 -0700
8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
Summary: Need to add a space between macro identifier and string literal
Reviewed-by: bpittore, stefank, dholmes, kbarrett
duke@435 | 1 | /* |
dbuck@8997 | 2 | * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
twisti@4323 | 26 | #include "asm/macroAssembler.inline.hpp" |
stefank@2314 | 27 | #include "code/vtableStubs.hpp" |
stefank@2314 | 28 | #include "interp_masm_sparc.hpp" |
stefank@2314 | 29 | #include "memory/resourceArea.hpp" |
dbuck@8997 | 30 | #include "oops/compiledICHolder.hpp" |
stefank@2314 | 31 | #include "oops/instanceKlass.hpp" |
stefank@2314 | 32 | #include "oops/klassVtable.hpp" |
stefank@2314 | 33 | #include "runtime/sharedRuntime.hpp" |
stefank@2314 | 34 | #include "vmreg_sparc.inline.hpp" |
stefank@2314 | 35 | #ifdef COMPILER2 |
stefank@2314 | 36 | #include "opto/runtime.hpp" |
stefank@2314 | 37 | #endif |
duke@435 | 38 | |
duke@435 | 39 | // machine-dependent part of VtableStubs: create vtableStub of correct size and |
duke@435 | 40 | // initialize its code |
duke@435 | 41 | |
duke@435 | 42 | #define __ masm-> |
duke@435 | 43 | |
duke@435 | 44 | |
duke@435 | 45 | #ifndef PRODUCT |
duke@435 | 46 | extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index); |
duke@435 | 47 | #endif |
duke@435 | 48 | |
duke@435 | 49 | |
duke@435 | 50 | // Used by compiler only; may use only caller saved, non-argument registers |
duke@435 | 51 | // NOTE: %%%% if any change is made to this stub make sure that the function |
duke@435 | 52 | // pd_code_size_limit is changed to ensure the correct size for VtableStub |
duke@435 | 53 | VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { |
duke@435 | 54 | const int sparc_code_length = VtableStub::pd_code_size_limit(true); |
duke@435 | 55 | VtableStub* s = new(sparc_code_length) VtableStub(true, vtable_index); |
anoll@5762 | 56 | // Can be NULL if there is no free space in the code cache. |
anoll@5762 | 57 | if (s == NULL) { |
anoll@5762 | 58 | return NULL; |
anoll@5762 | 59 | } |
anoll@5762 | 60 | |
duke@435 | 61 | ResourceMark rm; |
duke@435 | 62 | CodeBuffer cb(s->entry_point(), sparc_code_length); |
duke@435 | 63 | MacroAssembler* masm = new MacroAssembler(&cb); |
duke@435 | 64 | |
duke@435 | 65 | #ifndef PRODUCT |
duke@435 | 66 | if (CountCompiledCalls) { |
twisti@1162 | 67 | __ inc_counter(SharedRuntime::nof_megamorphic_calls_addr(), G5, G3_scratch); |
duke@435 | 68 | } |
duke@435 | 69 | #endif /* PRODUCT */ |
duke@435 | 70 | |
duke@435 | 71 | assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0"); |
duke@435 | 72 | |
duke@435 | 73 | // get receiver klass |
duke@435 | 74 | address npe_addr = __ pc(); |
coleenp@548 | 75 | __ load_klass(O0, G3_scratch); |
duke@435 | 76 | |
coleenp@4037 | 77 | // set Method* (in case of interpreted method), and destination address |
duke@435 | 78 | #ifndef PRODUCT |
duke@435 | 79 | if (DebugVtables) { |
duke@435 | 80 | Label L; |
duke@435 | 81 | // check offset vs vtable length |
coleenp@4037 | 82 | __ ld(G3_scratch, InstanceKlass::vtable_length_offset()*wordSize, G5); |
kvn@3037 | 83 | __ cmp_and_br_short(G5, vtable_index*vtableEntry::size(), Assembler::greaterUnsigned, Assembler::pt, L); |
duke@435 | 84 | __ set(vtable_index, O2); |
duke@435 | 85 | __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), O0, O2); |
duke@435 | 86 | __ bind(L); |
duke@435 | 87 | } |
duke@435 | 88 | #endif |
twisti@3969 | 89 | |
twisti@3969 | 90 | __ lookup_virtual_method(G3_scratch, vtable_index, G5_method); |
duke@435 | 91 | |
duke@435 | 92 | #ifndef PRODUCT |
duke@435 | 93 | if (DebugVtables) { |
duke@435 | 94 | Label L; |
kvn@3037 | 95 | __ br_notnull_short(G5_method, Assembler::pt, L); |
duke@435 | 96 | __ stop("Vtable entry is ZERO"); |
duke@435 | 97 | __ bind(L); |
duke@435 | 98 | } |
duke@435 | 99 | #endif |
duke@435 | 100 | |
duke@435 | 101 | address ame_addr = __ pc(); // if the vtable entry is null, the method is abstract |
duke@435 | 102 | // NOTE: for vtable dispatches, the vtable entry will never be null. |
duke@435 | 103 | |
coleenp@4037 | 104 | __ ld_ptr(G5_method, in_bytes(Method::from_compiled_offset()), G3_scratch); |
duke@435 | 105 | |
duke@435 | 106 | // jump to target (either compiled code or c2iadapter) |
duke@435 | 107 | __ JMP(G3_scratch, 0); |
coleenp@4037 | 108 | // load Method* (in case we call c2iadapter) |
duke@435 | 109 | __ delayed()->nop(); |
duke@435 | 110 | |
duke@435 | 111 | masm->flush(); |
jrose@1058 | 112 | |
jrose@1058 | 113 | if (PrintMiscellaneous && (WizardMode || Verbose)) { |
kevinw@9327 | 114 | tty->print_cr("vtable #%d at " PTR_FORMAT "[%d] left over: %d", |
jrose@1058 | 115 | vtable_index, s->entry_point(), |
jrose@1058 | 116 | (int)(s->code_end() - s->entry_point()), |
jrose@1058 | 117 | (int)(s->code_end() - __ pc())); |
jrose@1058 | 118 | } |
jrose@1058 | 119 | guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
jrose@1144 | 120 | // shut the door on sizing bugs |
jrose@1144 | 121 | int slop = 2*BytesPerInstWord; // 32-bit offset is this much larger than a 13-bit one |
jrose@1144 | 122 | assert(vtable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add"); |
jrose@1058 | 123 | |
duke@435 | 124 | s->set_exception_points(npe_addr, ame_addr); |
duke@435 | 125 | return s; |
duke@435 | 126 | } |
duke@435 | 127 | |
duke@435 | 128 | |
duke@435 | 129 | // NOTE: %%%% if any change is made to this stub make sure that the function |
duke@435 | 130 | // pd_code_size_limit is changed to ensure the correct size for VtableStub |
jrose@1058 | 131 | VtableStub* VtableStubs::create_itable_stub(int itable_index) { |
duke@435 | 132 | const int sparc_code_length = VtableStub::pd_code_size_limit(false); |
jrose@1058 | 133 | VtableStub* s = new(sparc_code_length) VtableStub(false, itable_index); |
anoll@5762 | 134 | // Can be NULL if there is no free space in the code cache. |
anoll@5762 | 135 | if (s == NULL) { |
anoll@5762 | 136 | return NULL; |
anoll@5762 | 137 | } |
anoll@5762 | 138 | |
duke@435 | 139 | ResourceMark rm; |
duke@435 | 140 | CodeBuffer cb(s->entry_point(), sparc_code_length); |
duke@435 | 141 | MacroAssembler* masm = new MacroAssembler(&cb); |
duke@435 | 142 | |
coleenp@4037 | 143 | Register G3_Klass = G3_scratch; |
dbuck@8997 | 144 | Register G5_icholder = G5; // Passed in as an argument |
dbuck@8997 | 145 | Register G4_interface = G4_scratch; |
duke@435 | 146 | Label search; |
duke@435 | 147 | |
duke@435 | 148 | // Entry arguments: |
duke@435 | 149 | // G5_interface: Interface |
duke@435 | 150 | // O0: Receiver |
duke@435 | 151 | assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0"); |
duke@435 | 152 | |
duke@435 | 153 | // get receiver klass (also an implicit null-check) |
duke@435 | 154 | address npe_addr = __ pc(); |
coleenp@4037 | 155 | __ load_klass(O0, G3_Klass); |
duke@435 | 156 | |
duke@435 | 157 | // Push a new window to get some temp registers. This chops the head of all |
duke@435 | 158 | // my 64-bit %o registers in the LION build, but this is OK because no longs |
duke@435 | 159 | // are passed in the %o registers. Instead, longs are passed in G1 and G4 |
duke@435 | 160 | // and so those registers are not available here. |
duke@435 | 161 | __ save(SP,-frame::register_save_words*wordSize,SP); |
duke@435 | 162 | |
duke@435 | 163 | #ifndef PRODUCT |
duke@435 | 164 | if (CountCompiledCalls) { |
twisti@1162 | 165 | __ inc_counter(SharedRuntime::nof_megamorphic_calls_addr(), L0, L1); |
duke@435 | 166 | } |
duke@435 | 167 | #endif /* PRODUCT */ |
duke@435 | 168 | |
dbuck@8997 | 169 | Label L_no_such_interface; |
duke@435 | 170 | |
jrose@1058 | 171 | Register L5_method = L5; |
dbuck@8997 | 172 | |
dbuck@8997 | 173 | // Receiver subtype check against REFC. |
dbuck@8997 | 174 | __ ld_ptr(G5_icholder, CompiledICHolder::holder_klass_offset(), G4_interface); |
jrose@1058 | 175 | __ lookup_interface_method(// inputs: rec. class, interface, itable index |
dbuck@8997 | 176 | G3_Klass, G4_interface, itable_index, |
dbuck@8997 | 177 | // outputs: scan temp. reg1, scan temp. reg2 |
dbuck@8997 | 178 | L5_method, L2, L3, |
dbuck@8997 | 179 | L_no_such_interface, |
dbuck@8997 | 180 | /*return_method=*/ false); |
dbuck@8997 | 181 | |
dbuck@8997 | 182 | // Get Method* and entrypoint for compiler |
dbuck@8997 | 183 | __ ld_ptr(G5_icholder, CompiledICHolder::holder_metadata_offset(), G4_interface); |
dbuck@8997 | 184 | __ lookup_interface_method(// inputs: rec. class, interface, itable index |
dbuck@8997 | 185 | G3_Klass, G4_interface, itable_index, |
jrose@1058 | 186 | // outputs: method, scan temp. reg |
jrose@1058 | 187 | L5_method, L2, L3, |
dbuck@8997 | 188 | L_no_such_interface); |
duke@435 | 189 | |
duke@435 | 190 | #ifndef PRODUCT |
duke@435 | 191 | if (DebugVtables) { |
duke@435 | 192 | Label L01; |
kvn@3037 | 193 | __ br_notnull_short(L5_method, Assembler::pt, L01); |
coleenp@4037 | 194 | __ stop("Method* is null"); |
duke@435 | 195 | __ bind(L01); |
duke@435 | 196 | } |
duke@435 | 197 | #endif |
duke@435 | 198 | |
duke@435 | 199 | // If the following load is through a NULL pointer, we'll take an OS |
duke@435 | 200 | // exception that should translate into an AbstractMethodError. We need the |
duke@435 | 201 | // window count to be correct at that time. |
jrose@1058 | 202 | __ restore(L5_method, 0, G5_method); |
jrose@1058 | 203 | // Restore registers *before* the AME point. |
duke@435 | 204 | |
duke@435 | 205 | address ame_addr = __ pc(); // if the vtable entry is null, the method is abstract |
coleenp@4037 | 206 | __ ld_ptr(G5_method, in_bytes(Method::from_compiled_offset()), G3_scratch); |
duke@435 | 207 | |
coleenp@4037 | 208 | // G5_method: Method* |
duke@435 | 209 | // O0: Receiver |
duke@435 | 210 | // G3_scratch: entry point |
duke@435 | 211 | __ JMP(G3_scratch, 0); |
duke@435 | 212 | __ delayed()->nop(); |
duke@435 | 213 | |
dbuck@8997 | 214 | __ bind(L_no_such_interface); |
twisti@1162 | 215 | AddressLiteral icce(StubRoutines::throw_IncompatibleClassChangeError_entry()); |
twisti@1162 | 216 | __ jump_to(icce, G3_scratch); |
dcubed@451 | 217 | __ delayed()->restore(); |
dcubed@451 | 218 | |
duke@435 | 219 | masm->flush(); |
dcubed@451 | 220 | |
jrose@1058 | 221 | if (PrintMiscellaneous && (WizardMode || Verbose)) { |
kevinw@9327 | 222 | tty->print_cr("itable #%d at " PTR_FORMAT "[%d] left over: %d", |
jrose@1058 | 223 | itable_index, s->entry_point(), |
jrose@1058 | 224 | (int)(s->code_end() - s->entry_point()), |
jrose@1058 | 225 | (int)(s->code_end() - __ pc())); |
jrose@1058 | 226 | } |
dcubed@451 | 227 | guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
jrose@1144 | 228 | // shut the door on sizing bugs |
jrose@1144 | 229 | int slop = 2*BytesPerInstWord; // 32-bit offset is this much larger than a 13-bit one |
jrose@1144 | 230 | assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for sethi;add"); |
dcubed@451 | 231 | |
duke@435 | 232 | s->set_exception_points(npe_addr, ame_addr); |
duke@435 | 233 | return s; |
duke@435 | 234 | } |
duke@435 | 235 | |
duke@435 | 236 | |
duke@435 | 237 | int VtableStub::pd_code_size_limit(bool is_vtable_stub) { |
dcubed@451 | 238 | if (TraceJumps || DebugVtables || CountCompiledCalls || VerifyOops) return 1000; |
duke@435 | 239 | else { |
duke@435 | 240 | const int slop = 2*BytesPerInstWord; // sethi;add (needed for long offsets) |
duke@435 | 241 | if (is_vtable_stub) { |
coleenp@548 | 242 | // ld;ld;ld,jmp,nop |
coleenp@548 | 243 | const int basic = 5*BytesPerInstWord + |
kvn@1077 | 244 | // shift;add for load_klass (only shift with zero heap based) |
ehelin@5694 | 245 | (UseCompressedClassPointers ? |
hseigel@5528 | 246 | MacroAssembler::instr_size_for_decode_klass_not_null() : 0); |
duke@435 | 247 | return basic + slop; |
duke@435 | 248 | } else { |
dbuck@8997 | 249 | const int basic = (48 LP64_ONLY(+ 6)) * BytesPerInstWord + |
kvn@1077 | 250 | // shift;add for load_klass (only shift with zero heap based) |
ehelin@5694 | 251 | (UseCompressedClassPointers ? |
hseigel@5528 | 252 | MacroAssembler::instr_size_for_decode_klass_not_null() : 0); |
duke@435 | 253 | return (basic + slop); |
duke@435 | 254 | } |
duke@435 | 255 | } |
jrose@1144 | 256 | |
jrose@1144 | 257 | // In order to tune these parameters, run the JVM with VM options |
jrose@1144 | 258 | // +PrintMiscellaneous and +WizardMode to see information about |
jrose@1144 | 259 | // actual itable stubs. Look for lines like this: |
jrose@1144 | 260 | // itable #1 at 0x5551212[116] left over: 8 |
jrose@1144 | 261 | // Reduce the constants so that the "left over" number is 8 |
jrose@1144 | 262 | // Do not aim at a left-over number of zero, because a very |
jrose@1144 | 263 | // large vtable or itable offset (> 4K) will require an extra |
jrose@1144 | 264 | // sethi/or pair of instructions. |
jrose@1144 | 265 | // |
jrose@1144 | 266 | // The JVM98 app. _202_jess has a megamorphic interface call. |
jrose@1144 | 267 | // The itable code looks like this: |
jrose@1144 | 268 | // Decoding VtableStub itbl[1]@16 |
jrose@1144 | 269 | // ld [ %o0 + 4 ], %g3 |
jrose@1144 | 270 | // save %sp, -64, %sp |
jrose@1144 | 271 | // ld [ %g3 + 0xe8 ], %l2 |
jrose@1144 | 272 | // sll %l2, 2, %l2 |
jrose@1144 | 273 | // add %l2, 0x134, %l2 |
jrose@1144 | 274 | // and %l2, -8, %l2 ! NOT_LP64 only |
jrose@1144 | 275 | // add %g3, %l2, %l2 |
jrose@1144 | 276 | // add %g3, 4, %g3 |
jrose@1144 | 277 | // ld [ %l2 ], %l5 |
jrose@1144 | 278 | // brz,pn %l5, throw_icce |
jrose@1144 | 279 | // cmp %l5, %g5 |
jrose@1144 | 280 | // be %icc, success |
jrose@1144 | 281 | // add %l2, 8, %l2 |
jrose@1144 | 282 | // loop: |
jrose@1144 | 283 | // ld [ %l2 ], %l5 |
jrose@1144 | 284 | // brz,pn %l5, throw_icce |
jrose@1144 | 285 | // cmp %l5, %g5 |
jrose@1144 | 286 | // bne,pn %icc, loop |
jrose@1144 | 287 | // add %l2, 8, %l2 |
jrose@1144 | 288 | // success: |
jrose@1144 | 289 | // ld [ %l2 + -4 ], %l2 |
jrose@1144 | 290 | // ld [ %g3 + %l2 ], %l5 |
jrose@1144 | 291 | // restore %l5, 0, %g5 |
jrose@1144 | 292 | // ld [ %g5 + 0x44 ], %g3 |
jrose@1144 | 293 | // jmp %g3 |
jrose@1144 | 294 | // nop |
jrose@1144 | 295 | // throw_icce: |
jrose@1144 | 296 | // sethi %hi(throw_ICCE_entry), %g3 |
jrose@1144 | 297 | // ! 5 more instructions here, LP64_ONLY |
jrose@1144 | 298 | // jmp %g3 + %lo(throw_ICCE_entry) |
jrose@1144 | 299 | // restore |
duke@435 | 300 | } |
duke@435 | 301 | |
duke@435 | 302 | |
duke@435 | 303 | int VtableStub::pd_code_alignment() { |
duke@435 | 304 | // UltraSPARC cache line size is 8 instructions: |
duke@435 | 305 | const unsigned int icache_line_size = 32; |
duke@435 | 306 | return icache_line_size; |
duke@435 | 307 | } |