Mercurial > hg > graal-compiler
diff src/cpu/sparc/vm/vtableStubs_sparc.cpp @ 623:9adddb8c0fc8
6812831: factor duplicated assembly code for megamorphic invokeinterface (for 6655638)
Summary: Code in vtableStubs and templateTable moved into MacroAssembler.
Reviewed-by: kvn
author | jrose |
---|---|
date | Fri, 06 Mar 2009 21:36:50 -0800 |
parents | d1605aabd0a1 |
children | 660978a2a31a |
line wrap: on
line diff
--- a/src/cpu/sparc/vm/vtableStubs_sparc.cpp Wed Mar 04 09:58:39 2009 -0800 +++ b/src/cpu/sparc/vm/vtableStubs_sparc.cpp Fri Mar 06 21:36:50 2009 -0800 @@ -106,6 +106,15 @@ __ delayed()->nop(); masm->flush(); + + if (PrintMiscellaneous && (WizardMode || Verbose)) { + tty->print_cr("vtable #%d at "PTR_FORMAT"[%d] left over: %d", + vtable_index, s->entry_point(), + (int)(s->code_end() - s->entry_point()), + (int)(s->code_end() - __ pc())); + } + guarantee(__ pc() <= s->code_end(), "overflowed buffer"); + s->set_exception_points(npe_addr, ame_addr); return s; } @@ -113,9 +122,9 @@ // NOTE: %%%% if any change is made to this stub make sure that the function // pd_code_size_limit is changed to ensure the correct size for VtableStub -VtableStub* VtableStubs::create_itable_stub(int vtable_index) { +VtableStub* VtableStubs::create_itable_stub(int itable_index) { const int sparc_code_length = VtableStub::pd_code_size_limit(false); - VtableStub* s = new(sparc_code_length) VtableStub(false, vtable_index); + VtableStub* s = new(sparc_code_length) VtableStub(false, itable_index); ResourceMark rm; CodeBuffer cb(s->entry_point(), sparc_code_length); MacroAssembler* masm = new MacroAssembler(&cb); @@ -139,7 +148,6 @@ // are passed in the %o registers. Instead, longs are passed in G1 and G4 // and so those registers are not available here. __ save(SP,-frame::register_save_words*wordSize,SP); - Register I0_receiver = I0; // Location of receiver after save #ifndef PRODUCT if (CountCompiledCalls) { @@ -151,63 +159,31 @@ } #endif /* PRODUCT */ - // load start of itable entries into L0 register - const int base = instanceKlass::vtable_start_offset() * wordSize; - __ ld(Address(G3_klassOop, 0, instanceKlass::vtable_length_offset() * wordSize), L0); - - // %%% Could store the aligned, prescaled offset in the klassoop. - __ sll(L0, exact_log2(vtableEntry::size() * wordSize), L0); - // see code for instanceKlass::start_of_itable! - const int vtable_alignment = align_object_offset(1); - assert(vtable_alignment == 1 || vtable_alignment == 2, ""); - const int odd_bit = vtableEntry::size() * wordSize; - if (vtable_alignment == 2) { - __ and3(L0, odd_bit, L1); // isolate the odd bit - } - __ add(G3_klassOop, L0, L0); - if (vtable_alignment == 2) { - __ add(L0, L1, L0); // double the odd bit, to align up - } + Label throw_icce; - // Loop over all itable entries until desired interfaceOop (G5_interface) found - __ bind(search); - - // %%%% Could load both offset and interface in one ldx, if they were - // in the opposite order. This would save a load. - __ ld_ptr(L0, base + itableOffsetEntry::interface_offset_in_bytes(), L1); - - // If the entry is NULL then we've reached the end of the table - // without finding the expected interface, so throw an exception - Label throw_icce; - __ bpr(Assembler::rc_z, false, Assembler::pn, L1, throw_icce); - __ delayed()->cmp(G5_interface, L1); - __ brx(Assembler::notEqual, true, Assembler::pn, search); - __ delayed()->add(L0, itableOffsetEntry::size() * wordSize, L0); - - // entry found and L0 points to it, move offset of vtable for interface into L0 - __ ld(L0, base + itableOffsetEntry::offset_offset_in_bytes(), L0); - - // Compute itableMethodEntry and get methodOop(G5_method) and entrypoint(L0) for compiler - const int method_offset = (itableMethodEntry::size() * wordSize * vtable_index) + itableMethodEntry::method_offset_in_bytes(); - __ add(G3_klassOop, L0, L1); - __ ld_ptr(L1, method_offset, G5_method); + Register L5_method = L5; + __ lookup_interface_method(// inputs: rec. class, interface, itable index + G3_klassOop, G5_interface, itable_index, + // outputs: method, scan temp. reg + L5_method, L2, L3, + throw_icce); #ifndef PRODUCT if (DebugVtables) { Label L01; - __ ld_ptr(L1, method_offset, G5_method); - __ bpr(Assembler::rc_nz, false, Assembler::pt, G5_method, L01); + __ bpr(Assembler::rc_nz, false, Assembler::pt, L5_method, L01); __ delayed()->nop(); __ stop("methodOop is null"); __ bind(L01); - __ verify_oop(G5_method); + __ verify_oop(L5_method); } #endif // If the following load is through a NULL pointer, we'll take an OS // exception that should translate into an AbstractMethodError. We need the // window count to be correct at that time. - __ restore(); // Restore registers BEFORE the AME point + __ restore(L5_method, 0, G5_method); + // Restore registers *before* the AME point. address ame_addr = __ pc(); // if the vtable entry is null, the method is abstract __ ld_ptr(G5_method, in_bytes(methodOopDesc::from_compiled_offset()), G3_scratch); @@ -225,6 +201,12 @@ masm->flush(); + if (PrintMiscellaneous && (WizardMode || Verbose)) { + tty->print_cr("itable #%d at "PTR_FORMAT"[%d] left over: %d", + itable_index, s->entry_point(), + (int)(s->code_end() - s->entry_point()), + (int)(s->code_end() - __ pc())); + } guarantee(__ pc() <= s->code_end(), "overflowed buffer"); s->set_exception_points(npe_addr, ame_addr); @@ -243,8 +225,7 @@ (UseCompressedOops ? 2*BytesPerInstWord : 0); return basic + slop; } else { - // save, ld, ld, sll, and, add, add, ld, cmp, br, add, ld, add, ld, ld, jmp, restore, sethi, jmpl, restore - const int basic = (20 LP64_ONLY(+ 6)) * BytesPerInstWord + + const int basic = (28 LP64_ONLY(+ 6)) * BytesPerInstWord + // shift;add for load_klass (UseCompressedOops ? 2*BytesPerInstWord : 0); return (basic + slop);