Wed, 07 Jan 2009 11:23:28 -0800
6790182: matcher.cpp:1375: assert(false,"bad AD file")
Summary: Add a match rule for regD_low in regD definition.
Reviewed-by: never
duke@435 | 1 | /* |
xdono@631 | 2 | * Copyright 1997-2008 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | #include "incls/_precompiled.incl" |
duke@435 | 26 | #include "incls/_vtableStubs_sparc.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | // machine-dependent part of VtableStubs: create vtableStub of correct size and |
duke@435 | 29 | // initialize its code |
duke@435 | 30 | |
duke@435 | 31 | #define __ masm-> |
duke@435 | 32 | |
duke@435 | 33 | |
duke@435 | 34 | #ifndef PRODUCT |
duke@435 | 35 | extern "C" void bad_compiled_vtable_index(JavaThread* thread, oopDesc* receiver, int index); |
duke@435 | 36 | #endif |
duke@435 | 37 | |
duke@435 | 38 | |
duke@435 | 39 | // Used by compiler only; may use only caller saved, non-argument registers |
duke@435 | 40 | // NOTE: %%%% if any change is made to this stub make sure that the function |
duke@435 | 41 | // pd_code_size_limit is changed to ensure the correct size for VtableStub |
duke@435 | 42 | VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { |
duke@435 | 43 | const int sparc_code_length = VtableStub::pd_code_size_limit(true); |
duke@435 | 44 | VtableStub* s = new(sparc_code_length) VtableStub(true, vtable_index); |
duke@435 | 45 | ResourceMark rm; |
duke@435 | 46 | CodeBuffer cb(s->entry_point(), sparc_code_length); |
duke@435 | 47 | MacroAssembler* masm = new MacroAssembler(&cb); |
duke@435 | 48 | |
duke@435 | 49 | #ifndef PRODUCT |
duke@435 | 50 | if (CountCompiledCalls) { |
duke@435 | 51 | Address ctr(G5, SharedRuntime::nof_megamorphic_calls_addr()); |
duke@435 | 52 | __ sethi(ctr); |
duke@435 | 53 | __ ld(ctr, G3_scratch); |
duke@435 | 54 | __ inc(G3_scratch); |
duke@435 | 55 | __ st(G3_scratch, ctr); |
duke@435 | 56 | } |
duke@435 | 57 | #endif /* PRODUCT */ |
duke@435 | 58 | |
duke@435 | 59 | assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0"); |
duke@435 | 60 | |
duke@435 | 61 | // get receiver klass |
duke@435 | 62 | address npe_addr = __ pc(); |
coleenp@548 | 63 | __ load_klass(O0, G3_scratch); |
duke@435 | 64 | |
duke@435 | 65 | // set methodOop (in case of interpreted method), and destination address |
duke@435 | 66 | int entry_offset = instanceKlass::vtable_start_offset() + vtable_index*vtableEntry::size(); |
duke@435 | 67 | #ifndef PRODUCT |
duke@435 | 68 | if (DebugVtables) { |
duke@435 | 69 | Label L; |
duke@435 | 70 | // check offset vs vtable length |
duke@435 | 71 | __ ld(G3_scratch, instanceKlass::vtable_length_offset()*wordSize, G5); |
duke@435 | 72 | __ cmp(G5, vtable_index*vtableEntry::size()); |
duke@435 | 73 | __ br(Assembler::greaterUnsigned, false, Assembler::pt, L); |
duke@435 | 74 | __ delayed()->nop(); |
duke@435 | 75 | __ set(vtable_index, O2); |
duke@435 | 76 | __ call_VM(noreg, CAST_FROM_FN_PTR(address, bad_compiled_vtable_index), O0, O2); |
duke@435 | 77 | __ bind(L); |
duke@435 | 78 | } |
duke@435 | 79 | #endif |
duke@435 | 80 | int v_off = entry_offset*wordSize + vtableEntry::method_offset_in_bytes(); |
duke@435 | 81 | if( __ is_simm13(v_off) ) { |
duke@435 | 82 | __ ld_ptr(G3, v_off, G5_method); |
duke@435 | 83 | } else { |
duke@435 | 84 | __ set(v_off,G5); |
duke@435 | 85 | __ ld_ptr(G3, G5, G5_method); |
duke@435 | 86 | } |
duke@435 | 87 | |
duke@435 | 88 | #ifndef PRODUCT |
duke@435 | 89 | if (DebugVtables) { |
duke@435 | 90 | Label L; |
duke@435 | 91 | __ br_notnull(G5_method, false, Assembler::pt, L); |
duke@435 | 92 | __ delayed()->nop(); |
duke@435 | 93 | __ stop("Vtable entry is ZERO"); |
duke@435 | 94 | __ bind(L); |
duke@435 | 95 | } |
duke@435 | 96 | #endif |
duke@435 | 97 | |
duke@435 | 98 | address ame_addr = __ pc(); // if the vtable entry is null, the method is abstract |
duke@435 | 99 | // NOTE: for vtable dispatches, the vtable entry will never be null. |
duke@435 | 100 | |
duke@435 | 101 | __ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch); |
duke@435 | 102 | |
duke@435 | 103 | // jump to target (either compiled code or c2iadapter) |
duke@435 | 104 | __ JMP(G3_scratch, 0); |
duke@435 | 105 | // load methodOop (in case we call c2iadapter) |
duke@435 | 106 | __ delayed()->nop(); |
duke@435 | 107 | |
duke@435 | 108 | masm->flush(); |
duke@435 | 109 | s->set_exception_points(npe_addr, ame_addr); |
duke@435 | 110 | return s; |
duke@435 | 111 | } |
duke@435 | 112 | |
duke@435 | 113 | |
duke@435 | 114 | // NOTE: %%%% if any change is made to this stub make sure that the function |
duke@435 | 115 | // pd_code_size_limit is changed to ensure the correct size for VtableStub |
duke@435 | 116 | VtableStub* VtableStubs::create_itable_stub(int vtable_index) { |
duke@435 | 117 | const int sparc_code_length = VtableStub::pd_code_size_limit(false); |
duke@435 | 118 | VtableStub* s = new(sparc_code_length) VtableStub(false, vtable_index); |
duke@435 | 119 | ResourceMark rm; |
duke@435 | 120 | CodeBuffer cb(s->entry_point(), sparc_code_length); |
duke@435 | 121 | MacroAssembler* masm = new MacroAssembler(&cb); |
duke@435 | 122 | |
duke@435 | 123 | Register G3_klassOop = G3_scratch; |
duke@435 | 124 | Register G5_interface = G5; // Passed in as an argument |
duke@435 | 125 | Label search; |
duke@435 | 126 | |
duke@435 | 127 | // Entry arguments: |
duke@435 | 128 | // G5_interface: Interface |
duke@435 | 129 | // O0: Receiver |
duke@435 | 130 | assert(VtableStub::receiver_location() == O0->as_VMReg(), "receiver expected in O0"); |
duke@435 | 131 | |
duke@435 | 132 | // get receiver klass (also an implicit null-check) |
duke@435 | 133 | address npe_addr = __ pc(); |
coleenp@548 | 134 | __ load_klass(O0, G3_klassOop); |
duke@435 | 135 | __ verify_oop(G3_klassOop); |
duke@435 | 136 | |
duke@435 | 137 | // Push a new window to get some temp registers. This chops the head of all |
duke@435 | 138 | // my 64-bit %o registers in the LION build, but this is OK because no longs |
duke@435 | 139 | // are passed in the %o registers. Instead, longs are passed in G1 and G4 |
duke@435 | 140 | // and so those registers are not available here. |
duke@435 | 141 | __ save(SP,-frame::register_save_words*wordSize,SP); |
duke@435 | 142 | Register I0_receiver = I0; // Location of receiver after save |
duke@435 | 143 | |
duke@435 | 144 | #ifndef PRODUCT |
duke@435 | 145 | if (CountCompiledCalls) { |
duke@435 | 146 | Address ctr(L0, SharedRuntime::nof_megamorphic_calls_addr()); |
duke@435 | 147 | __ sethi(ctr); |
duke@435 | 148 | __ ld(ctr, L1); |
duke@435 | 149 | __ inc(L1); |
duke@435 | 150 | __ st(L1, ctr); |
duke@435 | 151 | } |
duke@435 | 152 | #endif /* PRODUCT */ |
duke@435 | 153 | |
duke@435 | 154 | // load start of itable entries into L0 register |
duke@435 | 155 | const int base = instanceKlass::vtable_start_offset() * wordSize; |
duke@435 | 156 | __ ld(Address(G3_klassOop, 0, instanceKlass::vtable_length_offset() * wordSize), L0); |
duke@435 | 157 | |
duke@435 | 158 | // %%% Could store the aligned, prescaled offset in the klassoop. |
duke@435 | 159 | __ sll(L0, exact_log2(vtableEntry::size() * wordSize), L0); |
duke@435 | 160 | // see code for instanceKlass::start_of_itable! |
duke@435 | 161 | const int vtable_alignment = align_object_offset(1); |
duke@435 | 162 | assert(vtable_alignment == 1 || vtable_alignment == 2, ""); |
duke@435 | 163 | const int odd_bit = vtableEntry::size() * wordSize; |
duke@435 | 164 | if (vtable_alignment == 2) { |
duke@435 | 165 | __ and3(L0, odd_bit, L1); // isolate the odd bit |
duke@435 | 166 | } |
duke@435 | 167 | __ add(G3_klassOop, L0, L0); |
duke@435 | 168 | if (vtable_alignment == 2) { |
duke@435 | 169 | __ add(L0, L1, L0); // double the odd bit, to align up |
duke@435 | 170 | } |
duke@435 | 171 | |
duke@435 | 172 | // Loop over all itable entries until desired interfaceOop (G5_interface) found |
duke@435 | 173 | __ bind(search); |
duke@435 | 174 | |
duke@435 | 175 | // %%%% Could load both offset and interface in one ldx, if they were |
duke@435 | 176 | // in the opposite order. This would save a load. |
duke@435 | 177 | __ ld_ptr(L0, base + itableOffsetEntry::interface_offset_in_bytes(), L1); |
duke@435 | 178 | |
dcubed@451 | 179 | // If the entry is NULL then we've reached the end of the table |
dcubed@451 | 180 | // without finding the expected interface, so throw an exception |
dcubed@451 | 181 | Label throw_icce; |
dcubed@451 | 182 | __ bpr(Assembler::rc_z, false, Assembler::pn, L1, throw_icce); |
dcubed@451 | 183 | __ delayed()->cmp(G5_interface, L1); |
duke@435 | 184 | __ brx(Assembler::notEqual, true, Assembler::pn, search); |
duke@435 | 185 | __ delayed()->add(L0, itableOffsetEntry::size() * wordSize, L0); |
duke@435 | 186 | |
duke@435 | 187 | // entry found and L0 points to it, move offset of vtable for interface into L0 |
duke@435 | 188 | __ ld(L0, base + itableOffsetEntry::offset_offset_in_bytes(), L0); |
duke@435 | 189 | |
duke@435 | 190 | // Compute itableMethodEntry and get methodOop(G5_method) and entrypoint(L0) for compiler |
duke@435 | 191 | const int method_offset = (itableMethodEntry::size() * wordSize * vtable_index) + itableMethodEntry::method_offset_in_bytes(); |
duke@435 | 192 | __ add(G3_klassOop, L0, L1); |
duke@435 | 193 | __ ld_ptr(L1, method_offset, G5_method); |
duke@435 | 194 | |
duke@435 | 195 | #ifndef PRODUCT |
duke@435 | 196 | if (DebugVtables) { |
duke@435 | 197 | Label L01; |
duke@435 | 198 | __ ld_ptr(L1, method_offset, G5_method); |
duke@435 | 199 | __ bpr(Assembler::rc_nz, false, Assembler::pt, G5_method, L01); |
duke@435 | 200 | __ delayed()->nop(); |
duke@435 | 201 | __ stop("methodOop is null"); |
duke@435 | 202 | __ bind(L01); |
duke@435 | 203 | __ verify_oop(G5_method); |
duke@435 | 204 | } |
duke@435 | 205 | #endif |
duke@435 | 206 | |
duke@435 | 207 | // If the following load is through a NULL pointer, we'll take an OS |
duke@435 | 208 | // exception that should translate into an AbstractMethodError. We need the |
duke@435 | 209 | // window count to be correct at that time. |
duke@435 | 210 | __ restore(); // Restore registers BEFORE the AME point |
duke@435 | 211 | |
duke@435 | 212 | address ame_addr = __ pc(); // if the vtable entry is null, the method is abstract |
duke@435 | 213 | __ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch); |
duke@435 | 214 | |
duke@435 | 215 | // G5_method: methodOop |
duke@435 | 216 | // O0: Receiver |
duke@435 | 217 | // G3_scratch: entry point |
duke@435 | 218 | __ JMP(G3_scratch, 0); |
duke@435 | 219 | __ delayed()->nop(); |
duke@435 | 220 | |
dcubed@451 | 221 | __ bind(throw_icce); |
dcubed@451 | 222 | Address icce(G3_scratch, StubRoutines::throw_IncompatibleClassChangeError_entry()); |
dcubed@451 | 223 | __ jump_to(icce, 0); |
dcubed@451 | 224 | __ delayed()->restore(); |
dcubed@451 | 225 | |
duke@435 | 226 | masm->flush(); |
dcubed@451 | 227 | |
dcubed@451 | 228 | guarantee(__ pc() <= s->code_end(), "overflowed buffer"); |
dcubed@451 | 229 | |
duke@435 | 230 | s->set_exception_points(npe_addr, ame_addr); |
duke@435 | 231 | return s; |
duke@435 | 232 | } |
duke@435 | 233 | |
duke@435 | 234 | |
duke@435 | 235 | int VtableStub::pd_code_size_limit(bool is_vtable_stub) { |
dcubed@451 | 236 | if (TraceJumps || DebugVtables || CountCompiledCalls || VerifyOops) return 1000; |
duke@435 | 237 | else { |
duke@435 | 238 | const int slop = 2*BytesPerInstWord; // sethi;add (needed for long offsets) |
duke@435 | 239 | if (is_vtable_stub) { |
coleenp@548 | 240 | // ld;ld;ld,jmp,nop |
coleenp@548 | 241 | const int basic = 5*BytesPerInstWord + |
coleenp@548 | 242 | // shift;add for load_klass |
coleenp@548 | 243 | (UseCompressedOops ? 2*BytesPerInstWord : 0); |
duke@435 | 244 | return basic + slop; |
duke@435 | 245 | } else { |
dcubed@451 | 246 | // save, ld, ld, sll, and, add, add, ld, cmp, br, add, ld, add, ld, ld, jmp, restore, sethi, jmpl, restore |
coleenp@548 | 247 | const int basic = (20 LP64_ONLY(+ 6)) * BytesPerInstWord + |
coleenp@548 | 248 | // shift;add for load_klass |
coleenp@548 | 249 | (UseCompressedOops ? 2*BytesPerInstWord : 0); |
duke@435 | 250 | return (basic + slop); |
duke@435 | 251 | } |
duke@435 | 252 | } |
duke@435 | 253 | } |
duke@435 | 254 | |
duke@435 | 255 | |
duke@435 | 256 | int VtableStub::pd_code_alignment() { |
duke@435 | 257 | // UltraSPARC cache line size is 8 instructions: |
duke@435 | 258 | const unsigned int icache_line_size = 32; |
duke@435 | 259 | return icache_line_size; |
duke@435 | 260 | } |