/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "asm/assembler.hpp"
#include "assembler_sparc.inline.hpp"
#include "code/vtableStubs.hpp"
#include "interp_masm_sparc.hpp"
#include "memory/resourceArea.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/klassVtable.hpp"
#include "runtime/sharedRuntime.hpp"
#include "vmreg_sparc.inline.hpp"
#ifdef COMPILER2
#include "opto/runtime.hpp"
#endif
// machine-dependent part of VtableStubs: create vtableStub of correct size and
// initialize its code
#ifndef PRODUCT
#endif
// Used by compiler only; may use only caller saved, non-argument registers
// 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
#ifndef PRODUCT
if (CountCompiledCalls) {
}
#endif /* PRODUCT */
// get receiver klass
// set methodOop (in case of interpreted method), and destination address
#ifndef PRODUCT
if (DebugVtables) {
Label L;
// check offset vs vtable length
__ cmp_and_br_short(G5, vtable_index*vtableEntry::size(), Assembler::greaterUnsigned, Assembler::pt, L);
}
#endif
#ifndef PRODUCT
if (DebugVtables) {
Label L;
}
#endif
// NOTE: for vtable dispatches, the vtable entry will never be null.
// jump to target (either compiled code or c2iadapter)
// load methodOop (in case we call c2iadapter)
vtable_index, s->entry_point(),
(int)(s->code_end() - s->entry_point()),
}
// shut the door on sizing bugs
return s;
}
// 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
// Entry arguments:
// G5_interface: Interface
// O0: Receiver
// get receiver klass (also an implicit null-check)
// Push a new window to get some temp registers. This chops the head of all
// my 64-bit %o registers in the LION build, but this is OK because no longs
// are passed in the %o registers. Instead, longs are passed in G1 and G4
// and so those registers are not available here.
#ifndef PRODUCT
if (CountCompiledCalls) {
}
#endif /* PRODUCT */
// outputs: method, scan temp. reg
#ifndef PRODUCT
if (DebugVtables) {
}
#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 registers *before* the AME point.
// G5_method: methodOop
// O0: Receiver
// G3_scratch: entry point
itable_index, s->entry_point(),
(int)(s->code_end() - s->entry_point()),
}
// shut the door on sizing bugs
return s;
}
else {
if (is_vtable_stub) {
// ld;ld;ld,jmp,nop
// shift;add for load_klass (only shift with zero heap based)
} else {
// shift;add for load_klass (only shift with zero heap based)
}
}
// In order to tune these parameters, run the JVM with VM options
// +PrintMiscellaneous and +WizardMode to see information about
// actual itable stubs. Look for lines like this:
// itable #1 at 0x5551212[116] left over: 8
// Reduce the constants so that the "left over" number is 8
// Do not aim at a left-over number of zero, because a very
// large vtable or itable offset (> 4K) will require an extra
//
// The JVM98 app. _202_jess has a megamorphic interface call.
// The itable code looks like this:
// Decoding VtableStub itbl[1]@16
// ld [ %o0 + 4 ], %g3
// save %sp, -64, %sp
// ld [ %g3 + 0xe8 ], %l2
// sll %l2, 2, %l2
// add %l2, 0x134, %l2
// and %l2, -8, %l2 ! NOT_LP64 only
// add %g3, %l2, %l2
// add %g3, 4, %g3
// ld [ %l2 ], %l5
// brz,pn %l5, throw_icce
// cmp %l5, %g5
// be %icc, success
// add %l2, 8, %l2
// loop:
// ld [ %l2 ], %l5
// brz,pn %l5, throw_icce
// cmp %l5, %g5
// bne,pn %icc, loop
// add %l2, 8, %l2
// success:
// ld [ %l2 + -4 ], %l2
// ld [ %g3 + %l2 ], %l5
// restore %l5, 0, %g5
// ld [ %g5 + 0x44 ], %g3
// jmp %g3
// nop
// throw_icce:
// sethi %hi(throw_ICCE_entry), %g3
// ! 5 more instructions here, LP64_ONLY
// jmp %g3 + %lo(throw_ICCE_entry)
// restore
}
// UltraSPARC cache line size is 8 instructions:
return icache_line_size;
}