assembler_sparc.cpp revision 1964
0N/A/*
1472N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1964N/A#include "asm/assembler.hpp"
1879N/A#include "assembler_sparc.inline.hpp"
1879N/A#include "gc_interface/collectedHeap.inline.hpp"
1879N/A#include "interpreter/interpreter.hpp"
1879N/A#include "memory/cardTableModRefBS.hpp"
1879N/A#include "memory/resourceArea.hpp"
1879N/A#include "prims/methodHandles.hpp"
1879N/A#include "runtime/biasedLocking.hpp"
1879N/A#include "runtime/interfaceSupport.hpp"
1879N/A#include "runtime/objectMonitor.hpp"
1879N/A#include "runtime/os.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
1879N/A#include "runtime/stubRoutines.hpp"
1879N/A#ifndef SERIALGC
1879N/A#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
1879N/A#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
1879N/A#include "gc_implementation/g1/heapRegion.hpp"
1879N/A#endif
0N/A
727N/A// Convert the raw encoding form into the form expected by the
727N/A// constructor for Address.
727N/AAddress Address::make_raw(int base, int index, int scale, int disp, bool disp_is_oop) {
727N/A assert(scale == 0, "not supported");
727N/A RelocationHolder rspec;
727N/A if (disp_is_oop) {
727N/A rspec = Relocation::spec_simple(relocInfo::oop_type);
0N/A }
727N/A
727N/A Register rindex = as_Register(index);
727N/A if (rindex != G0) {
727N/A Address madr(as_Register(base), rindex);
727N/A madr._rspec = rspec;
727N/A return madr;
727N/A } else {
727N/A Address madr(as_Register(base), disp);
727N/A madr._rspec = rspec;
727N/A return madr;
727N/A }
727N/A}
727N/A
727N/AAddress Argument::address_in_frame() const {
727N/A // Warning: In LP64 mode disp will occupy more than 10 bits, but
727N/A // op codes such as ld or ldx, only access disp() to get
727N/A // their simm13 argument.
727N/A int disp = ((_number - Argument::n_register_parameters + frame::memory_parameter_word_sp_offset) * BytesPerWord) + STACK_BIAS;
727N/A if (is_in())
727N/A return Address(FP, disp); // In argument.
727N/A else
727N/A return Address(SP, disp); // Out argument.
0N/A}
0N/A
0N/Astatic const char* argumentNames[][2] = {
0N/A {"A0","P0"}, {"A1","P1"}, {"A2","P2"}, {"A3","P3"}, {"A4","P4"},
0N/A {"A5","P5"}, {"A6","P6"}, {"A7","P7"}, {"A8","P8"}, {"A9","P9"},
0N/A {"A(n>9)","P(n>9)"}
0N/A};
0N/A
0N/Aconst char* Argument::name() const {
0N/A int nofArgs = sizeof argumentNames / sizeof argumentNames[0];
0N/A int num = number();
0N/A if (num >= nofArgs) num = nofArgs - 1;
0N/A return argumentNames[num][is_in() ? 1 : 0];
0N/A}
0N/A
0N/Avoid Assembler::print_instruction(int inst) {
0N/A const char* s;
0N/A switch (inv_op(inst)) {
0N/A default: s = "????"; break;
0N/A case call_op: s = "call"; break;
0N/A case branch_op:
0N/A switch (inv_op2(inst)) {
0N/A case bpr_op2: s = "bpr"; break;
0N/A case fb_op2: s = "fb"; break;
0N/A case fbp_op2: s = "fbp"; break;
0N/A case br_op2: s = "br"; break;
0N/A case bp_op2: s = "bp"; break;
0N/A case cb_op2: s = "cb"; break;
0N/A default: s = "????"; break;
0N/A }
0N/A }
0N/A ::tty->print("%s", s);
0N/A}
0N/A
0N/A
0N/A// Patch instruction inst at offset inst_pos to refer to dest_pos
0N/A// and return the resulting instruction.
0N/A// We should have pcs, not offsets, but since all is relative, it will work out
0N/A// OK.
0N/Aint Assembler::patched_branch(int dest_pos, int inst, int inst_pos) {
0N/A
0N/A int m; // mask for displacement field
0N/A int v; // new value for displacement field
0N/A const int word_aligned_ones = -4;
0N/A switch (inv_op(inst)) {
0N/A default: ShouldNotReachHere();
0N/A case call_op: m = wdisp(word_aligned_ones, 0, 30); v = wdisp(dest_pos, inst_pos, 30); break;
0N/A case branch_op:
0N/A switch (inv_op2(inst)) {
0N/A case bpr_op2: m = wdisp16(word_aligned_ones, 0); v = wdisp16(dest_pos, inst_pos); break;
0N/A case fbp_op2: m = wdisp( word_aligned_ones, 0, 19); v = wdisp( dest_pos, inst_pos, 19); break;
0N/A case bp_op2: m = wdisp( word_aligned_ones, 0, 19); v = wdisp( dest_pos, inst_pos, 19); break;
0N/A case fb_op2: m = wdisp( word_aligned_ones, 0, 22); v = wdisp( dest_pos, inst_pos, 22); break;
0N/A case br_op2: m = wdisp( word_aligned_ones, 0, 22); v = wdisp( dest_pos, inst_pos, 22); break;
0N/A case cb_op2: m = wdisp( word_aligned_ones, 0, 22); v = wdisp( dest_pos, inst_pos, 22); break;
0N/A default: ShouldNotReachHere();
0N/A }
0N/A }
0N/A return inst & ~m | v;
0N/A}
0N/A
0N/A// Return the offset of the branch destionation of instruction inst
0N/A// at offset pos.
0N/A// Should have pcs, but since all is relative, it works out.
0N/Aint Assembler::branch_destination(int inst, int pos) {
0N/A int r;
0N/A switch (inv_op(inst)) {
0N/A default: ShouldNotReachHere();
0N/A case call_op: r = inv_wdisp(inst, pos, 30); break;
0N/A case branch_op:
0N/A switch (inv_op2(inst)) {
0N/A case bpr_op2: r = inv_wdisp16(inst, pos); break;
0N/A case fbp_op2: r = inv_wdisp( inst, pos, 19); break;
0N/A case bp_op2: r = inv_wdisp( inst, pos, 19); break;
0N/A case fb_op2: r = inv_wdisp( inst, pos, 22); break;
0N/A case br_op2: r = inv_wdisp( inst, pos, 22); break;
0N/A case cb_op2: r = inv_wdisp( inst, pos, 22); break;
0N/A default: ShouldNotReachHere();
0N/A }
0N/A }
0N/A return r;
0N/A}
0N/A
0N/Aint AbstractAssembler::code_fill_byte() {
0N/A return 0x00; // illegal instruction 0x00000000
0N/A}
0N/A
342N/AAssembler::Condition Assembler::reg_cond_to_cc_cond(Assembler::RCondition in) {
342N/A switch (in) {
342N/A case rc_z: return equal;
342N/A case rc_lez: return lessEqual;
342N/A case rc_lz: return less;
342N/A case rc_nz: return notEqual;
342N/A case rc_gz: return greater;
342N/A case rc_gez: return greaterEqual;
342N/A default:
342N/A ShouldNotReachHere();
342N/A }
342N/A return equal;
342N/A}
342N/A
0N/A// Generate a bunch 'o stuff (including v9's
0N/A#ifndef PRODUCT
0N/Avoid Assembler::test_v9() {
0N/A add( G0, G1, G2 );
0N/A add( G3, 0, G4 );
0N/A
0N/A addcc( G5, G6, G7 );
0N/A addcc( I0, 1, I1 );
0N/A addc( I2, I3, I4 );
0N/A addc( I5, -1, I6 );
0N/A addccc( I7, L0, L1 );
0N/A addccc( L2, (1 << 12) - 2, L3 );
0N/A
0N/A Label lbl1, lbl2, lbl3;
0N/A
0N/A bind(lbl1);
0N/A
0N/A bpr( rc_z, true, pn, L4, pc(), relocInfo::oop_type );
0N/A delayed()->nop();
0N/A bpr( rc_lez, false, pt, L5, lbl1);
0N/A delayed()->nop();
0N/A
0N/A fb( f_never, true, pc() + 4, relocInfo::none);
0N/A delayed()->nop();
0N/A fb( f_notEqual, false, lbl2 );
0N/A delayed()->nop();
0N/A
0N/A fbp( f_notZero, true, fcc0, pn, pc() - 4, relocInfo::none);
0N/A delayed()->nop();
0N/A fbp( f_lessOrGreater, false, fcc1, pt, lbl3 );
0N/A delayed()->nop();
0N/A
0N/A br( equal, true, pc() + 1024, relocInfo::none);
0N/A delayed()->nop();
0N/A br( lessEqual, false, lbl1 );
0N/A delayed()->nop();
0N/A br( never, false, lbl1 );
0N/A delayed()->nop();
0N/A
0N/A bp( less, true, icc, pn, pc(), relocInfo::none);
0N/A delayed()->nop();
0N/A bp( lessEqualUnsigned, false, xcc, pt, lbl2 );
0N/A delayed()->nop();
0N/A
0N/A call( pc(), relocInfo::none);
0N/A delayed()->nop();
0N/A call( lbl3 );
0N/A delayed()->nop();
0N/A
0N/A
0N/A casa( L6, L7, O0 );
0N/A casxa( O1, O2, O3, 0 );
0N/A
0N/A udiv( O4, O5, O7 );
0N/A udiv( G0, (1 << 12) - 1, G1 );
0N/A sdiv( G1, G2, G3 );
0N/A sdiv( G4, -((1 << 12) - 1), G5 );
0N/A udivcc( G6, G7, I0 );
0N/A udivcc( I1, -((1 << 12) - 2), I2 );
0N/A sdivcc( I3, I4, I5 );
0N/A sdivcc( I6, -((1 << 12) - 0), I7 );
0N/A
0N/A done();
0N/A retry();
0N/A
0N/A fadd( FloatRegisterImpl::S, F0, F1, F2 );
0N/A fsub( FloatRegisterImpl::D, F34, F0, F62 );
0N/A
0N/A fcmp( FloatRegisterImpl::Q, fcc0, F0, F60);
0N/A fcmpe( FloatRegisterImpl::S, fcc1, F31, F30);
0N/A
0N/A ftox( FloatRegisterImpl::D, F2, F4 );
0N/A ftoi( FloatRegisterImpl::Q, F4, F8 );
0N/A
0N/A ftof( FloatRegisterImpl::S, FloatRegisterImpl::Q, F3, F12 );
0N/A
0N/A fxtof( FloatRegisterImpl::S, F4, F5 );
0N/A fitof( FloatRegisterImpl::D, F6, F8 );
0N/A
0N/A fmov( FloatRegisterImpl::Q, F16, F20 );
0N/A fneg( FloatRegisterImpl::S, F6, F7 );
0N/A fabs( FloatRegisterImpl::D, F10, F12 );
0N/A
0N/A fmul( FloatRegisterImpl::Q, F24, F28, F32 );
0N/A fmul( FloatRegisterImpl::S, FloatRegisterImpl::D, F8, F9, F14 );
0N/A fdiv( FloatRegisterImpl::S, F10, F11, F12 );
0N/A
0N/A fsqrt( FloatRegisterImpl::S, F13, F14 );
0N/A
0N/A flush( L0, L1 );
0N/A flush( L2, -1 );
0N/A
0N/A flushw();
0N/A
0N/A illtrap( (1 << 22) - 2);
0N/A
0N/A impdep1( 17, (1 << 19) - 1 );
0N/A impdep2( 3, 0 );
0N/A
0N/A jmpl( L3, L4, L5 );
0N/A delayed()->nop();
0N/A jmpl( L6, -1, L7, Relocation::spec_simple(relocInfo::none));
0N/A delayed()->nop();
0N/A
0N/A
0N/A ldf( FloatRegisterImpl::S, O0, O1, F15 );
0N/A ldf( FloatRegisterImpl::D, O2, -1, F14 );
0N/A
0N/A
0N/A ldfsr( O3, O4 );
0N/A ldfsr( O5, -1 );
0N/A ldxfsr( O6, O7 );
0N/A ldxfsr( I0, -1 );
0N/A
0N/A ldfa( FloatRegisterImpl::D, I1, I2, 1, F16 );
0N/A ldfa( FloatRegisterImpl::Q, I3, -1, F36 );
0N/A
0N/A ldsb( I4, I5, I6 );
0N/A ldsb( I7, -1, G0 );
0N/A ldsh( G1, G3, G4 );
0N/A ldsh( G5, -1, G6 );
0N/A ldsw( G7, L0, L1 );
0N/A ldsw( L2, -1, L3 );
0N/A ldub( L4, L5, L6 );
0N/A ldub( L7, -1, O0 );
0N/A lduh( O1, O2, O3 );
0N/A lduh( O4, -1, O5 );
0N/A lduw( O6, O7, G0 );
0N/A lduw( G1, -1, G2 );
0N/A ldx( G3, G4, G5 );
0N/A ldx( G6, -1, G7 );
0N/A ldd( I0, I1, I2 );
0N/A ldd( I3, -1, I4 );
0N/A
0N/A ldsba( I5, I6, 2, I7 );
0N/A ldsba( L0, -1, L1 );
0N/A ldsha( L2, L3, 3, L4 );
0N/A ldsha( L5, -1, L6 );
0N/A ldswa( L7, O0, (1 << 8) - 1, O1 );
0N/A ldswa( O2, -1, O3 );
0N/A lduba( O4, O5, 0, O6 );
0N/A lduba( O7, -1, I0 );
0N/A lduha( I1, I2, 1, I3 );
0N/A lduha( I4, -1, I5 );
0N/A lduwa( I6, I7, 2, L0 );
0N/A lduwa( L1, -1, L2 );
0N/A ldxa( L3, L4, 3, L5 );
0N/A ldxa( L6, -1, L7 );
0N/A ldda( G0, G1, 4, G2 );
0N/A ldda( G3, -1, G4 );
0N/A
0N/A ldstub( G5, G6, G7 );
0N/A ldstub( O0, -1, O1 );
0N/A
0N/A ldstuba( O2, O3, 5, O4 );
0N/A ldstuba( O5, -1, O6 );
0N/A
0N/A and3( I0, L0, O0 );
0N/A and3( G7, -1, O7 );
0N/A andcc( L2, I2, G2 );
0N/A andcc( L4, -1, G4 );
0N/A andn( I5, I6, I7 );
0N/A andn( I6, -1, I7 );
0N/A andncc( I5, I6, I7 );
0N/A andncc( I7, -1, I6 );
0N/A or3( I5, I6, I7 );
0N/A or3( I7, -1, I6 );
0N/A orcc( I5, I6, I7 );
0N/A orcc( I7, -1, I6 );
0N/A orn( I5, I6, I7 );
0N/A orn( I7, -1, I6 );
0N/A orncc( I5, I6, I7 );
0N/A orncc( I7, -1, I6 );
0N/A xor3( I5, I6, I7 );
0N/A xor3( I7, -1, I6 );
0N/A xorcc( I5, I6, I7 );
0N/A xorcc( I7, -1, I6 );
0N/A xnor( I5, I6, I7 );
0N/A xnor( I7, -1, I6 );
0N/A xnorcc( I5, I6, I7 );
0N/A xnorcc( I7, -1, I6 );
0N/A
0N/A membar( Membar_mask_bits(StoreStore | LoadStore | StoreLoad | LoadLoad | Sync | MemIssue | Lookaside ) );
0N/A membar( StoreStore );
0N/A membar( LoadStore );
0N/A membar( StoreLoad );
0N/A membar( LoadLoad );
0N/A membar( Sync );
0N/A membar( MemIssue );
0N/A membar( Lookaside );
0N/A
0N/A fmov( FloatRegisterImpl::S, f_ordered, true, fcc2, F16, F17 );
0N/A fmov( FloatRegisterImpl::D, rc_lz, L5, F18, F20 );
0N/A
0N/A movcc( overflowClear, false, icc, I6, L4 );
0N/A movcc( f_unorderedOrEqual, true, fcc2, (1 << 10) - 1, O0 );
0N/A
0N/A movr( rc_nz, I5, I6, I7 );
0N/A movr( rc_gz, L1, -1, L2 );
0N/A
0N/A mulx( I5, I6, I7 );
0N/A mulx( I7, -1, I6 );
0N/A sdivx( I5, I6, I7 );
0N/A sdivx( I7, -1, I6 );
0N/A udivx( I5, I6, I7 );
0N/A udivx( I7, -1, I6 );
0N/A
0N/A umul( I5, I6, I7 );
0N/A umul( I7, -1, I6 );
0N/A smul( I5, I6, I7 );
0N/A smul( I7, -1, I6 );
0N/A umulcc( I5, I6, I7 );
0N/A umulcc( I7, -1, I6 );
0N/A smulcc( I5, I6, I7 );
0N/A smulcc( I7, -1, I6 );
0N/A
0N/A mulscc( I5, I6, I7 );
0N/A mulscc( I7, -1, I6 );
0N/A
0N/A nop();
0N/A
0N/A
0N/A popc( G0, G1);
0N/A popc( -1, G2);
0N/A
0N/A prefetch( L1, L2, severalReads );
0N/A prefetch( L3, -1, oneRead );
0N/A prefetcha( O3, O2, 6, severalWritesAndPossiblyReads );
0N/A prefetcha( G2, -1, oneWrite );
0N/A
0N/A rett( I7, I7);
0N/A delayed()->nop();
0N/A rett( G0, -1, relocInfo::none);
0N/A delayed()->nop();
0N/A
0N/A save( I5, I6, I7 );
0N/A save( I7, -1, I6 );
0N/A restore( I5, I6, I7 );
0N/A restore( I7, -1, I6 );
0N/A
0N/A saved();
0N/A restored();
0N/A
0N/A sethi( 0xaaaaaaaa, I3, Relocation::spec_simple(relocInfo::none));
0N/A
0N/A sll( I5, I6, I7 );
0N/A sll( I7, 31, I6 );
0N/A srl( I5, I6, I7 );
0N/A srl( I7, 0, I6 );
0N/A sra( I5, I6, I7 );
0N/A sra( I7, 30, I6 );
0N/A sllx( I5, I6, I7 );
0N/A sllx( I7, 63, I6 );
0N/A srlx( I5, I6, I7 );
0N/A srlx( I7, 0, I6 );
0N/A srax( I5, I6, I7 );
0N/A srax( I7, 62, I6 );
0N/A
0N/A sir( -1 );
0N/A
0N/A stbar();
0N/A
0N/A stf( FloatRegisterImpl::Q, F40, G0, I7 );
0N/A stf( FloatRegisterImpl::S, F18, I3, -1 );
0N/A
0N/A stfsr( L1, L2 );
0N/A stfsr( I7, -1 );
0N/A stxfsr( I6, I5 );
0N/A stxfsr( L4, -1 );
0N/A
0N/A stfa( FloatRegisterImpl::D, F22, I6, I7, 7 );
0N/A stfa( FloatRegisterImpl::Q, F44, G0, -1 );
0N/A
0N/A stb( L5, O2, I7 );
0N/A stb( I7, I6, -1 );
0N/A sth( L5, O2, I7 );
0N/A sth( I7, I6, -1 );
0N/A stw( L5, O2, I7 );
0N/A stw( I7, I6, -1 );
0N/A stx( L5, O2, I7 );
0N/A stx( I7, I6, -1 );
0N/A std( L5, O2, I7 );
0N/A std( I7, I6, -1 );
0N/A
0N/A stba( L5, O2, I7, 8 );
0N/A stba( I7, I6, -1 );
0N/A stha( L5, O2, I7, 9 );
0N/A stha( I7, I6, -1 );
0N/A stwa( L5, O2, I7, 0 );
0N/A stwa( I7, I6, -1 );
0N/A stxa( L5, O2, I7, 11 );
0N/A stxa( I7, I6, -1 );
0N/A stda( L5, O2, I7, 12 );
0N/A stda( I7, I6, -1 );
0N/A
0N/A sub( I5, I6, I7 );
0N/A sub( I7, -1, I6 );
0N/A subcc( I5, I6, I7 );
0N/A subcc( I7, -1, I6 );
0N/A subc( I5, I6, I7 );
0N/A subc( I7, -1, I6 );
0N/A subccc( I5, I6, I7 );
0N/A subccc( I7, -1, I6 );
0N/A
0N/A swap( I5, I6, I7 );
0N/A swap( I7, -1, I6 );
0N/A
0N/A swapa( G0, G1, 13, G2 );
0N/A swapa( I7, -1, I6 );
0N/A
0N/A taddcc( I5, I6, I7 );
0N/A taddcc( I7, -1, I6 );
0N/A taddcctv( I5, I6, I7 );
0N/A taddcctv( I7, -1, I6 );
0N/A
0N/A tsubcc( I5, I6, I7 );
0N/A tsubcc( I7, -1, I6 );
0N/A tsubcctv( I5, I6, I7 );
0N/A tsubcctv( I7, -1, I6 );
0N/A
0N/A trap( overflowClear, xcc, G0, G1 );
0N/A trap( lessEqual, icc, I7, 17 );
0N/A
0N/A bind(lbl2);
0N/A bind(lbl3);
0N/A
0N/A code()->decode();
0N/A}
0N/A
0N/A// Generate a bunch 'o stuff unique to V8
0N/Avoid Assembler::test_v8_onlys() {
0N/A Label lbl1;
0N/A
0N/A cb( cp_0or1or2, false, pc() - 4, relocInfo::none);
0N/A delayed()->nop();
0N/A cb( cp_never, true, lbl1);
0N/A delayed()->nop();
0N/A
0N/A cpop1(1, 2, 3, 4);
0N/A cpop2(5, 6, 7, 8);
0N/A
0N/A ldc( I0, I1, 31);
0N/A ldc( I2, -1, 0);
0N/A
0N/A lddc( I4, I4, 30);
0N/A lddc( I6, 0, 1 );
0N/A
0N/A ldcsr( L0, L1, 0);
0N/A ldcsr( L1, (1 << 12) - 1, 17 );
0N/A
0N/A stc( 31, L4, L5);
0N/A stc( 30, L6, -(1 << 12) );
0N/A
0N/A stdc( 0, L7, G0);
0N/A stdc( 1, G1, 0 );
0N/A
0N/A stcsr( 16, G2, G3);
0N/A stcsr( 17, G4, 1 );
0N/A
0N/A stdcq( 4, G5, G6);
0N/A stdcq( 5, G7, -1 );
0N/A
0N/A bind(lbl1);
0N/A
0N/A code()->decode();
0N/A}
0N/A#endif
0N/A
0N/A// Implementation of MacroAssembler
0N/A
0N/Avoid MacroAssembler::null_check(Register reg, int offset) {
0N/A if (needs_explicit_null_check((intptr_t)offset)) {
0N/A // provoke OS NULL exception if reg = NULL by
0N/A // accessing M[reg] w/o changing any registers
0N/A ld_ptr(reg, 0, G0);
0N/A }
0N/A else {
0N/A // nothing to do, (later) access of M[reg + offset]
0N/A // will provoke OS NULL exception if reg = NULL
0N/A }
0N/A}
0N/A
0N/A// Ring buffer jumps
0N/A
0N/A#ifndef PRODUCT
0N/Avoid MacroAssembler::ret( bool trace ) { if (trace) {
0N/A mov(I7, O7); // traceable register
0N/A JMP(O7, 2 * BytesPerInstWord);
0N/A } else {
0N/A jmpl( I7, 2 * BytesPerInstWord, G0 );
0N/A }
0N/A }
0N/A
0N/Avoid MacroAssembler::retl( bool trace ) { if (trace) JMP(O7, 2 * BytesPerInstWord);
0N/A else jmpl( O7, 2 * BytesPerInstWord, G0 ); }
0N/A#endif /* PRODUCT */
0N/A
0N/A
0N/Avoid MacroAssembler::jmp2(Register r1, Register r2, const char* file, int line ) {
0N/A assert_not_delayed();
0N/A // This can only be traceable if r1 & r2 are visible after a window save
0N/A if (TraceJumps) {
0N/A#ifndef PRODUCT
0N/A save_frame(0);
0N/A verify_thread();
0N/A ld(G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()), O0);
0N/A add(G2_thread, in_bytes(JavaThread::jmp_ring_offset()), O1);
0N/A sll(O0, exact_log2(4*sizeof(intptr_t)), O2);
0N/A add(O2, O1, O1);
0N/A
0N/A add(r1->after_save(), r2->after_save(), O2);
0N/A set((intptr_t)file, O3);
0N/A set(line, O4);
0N/A Label L;
0N/A // get nearby pc, store jmp target
0N/A call(L, relocInfo::none); // No relocation for call to pc+0x8
0N/A delayed()->st(O2, O1, 0);
0N/A bind(L);
0N/A
0N/A // store nearby pc
0N/A st(O7, O1, sizeof(intptr_t));
0N/A // store file
0N/A st(O3, O1, 2*sizeof(intptr_t));
0N/A // store line
0N/A st(O4, O1, 3*sizeof(intptr_t));
0N/A add(O0, 1, O0);
0N/A and3(O0, JavaThread::jump_ring_buffer_size - 1, O0);
0N/A st(O0, G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()));
0N/A restore();
0N/A#endif /* PRODUCT */
0N/A }
0N/A jmpl(r1, r2, G0);
0N/A}
0N/Avoid MacroAssembler::jmp(Register r1, int offset, const char* file, int line ) {
0N/A assert_not_delayed();
0N/A // This can only be traceable if r1 is visible after a window save
0N/A if (TraceJumps) {
0N/A#ifndef PRODUCT
0N/A save_frame(0);
0N/A verify_thread();
0N/A ld(G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()), O0);
0N/A add(G2_thread, in_bytes(JavaThread::jmp_ring_offset()), O1);
0N/A sll(O0, exact_log2(4*sizeof(intptr_t)), O2);
0N/A add(O2, O1, O1);
0N/A
0N/A add(r1->after_save(), offset, O2);
0N/A set((intptr_t)file, O3);
0N/A set(line, O4);
0N/A Label L;
0N/A // get nearby pc, store jmp target
0N/A call(L, relocInfo::none); // No relocation for call to pc+0x8
0N/A delayed()->st(O2, O1, 0);
0N/A bind(L);
0N/A
0N/A // store nearby pc
0N/A st(O7, O1, sizeof(intptr_t));
0N/A // store file
0N/A st(O3, O1, 2*sizeof(intptr_t));
0N/A // store line
0N/A st(O4, O1, 3*sizeof(intptr_t));
0N/A add(O0, 1, O0);
0N/A and3(O0, JavaThread::jump_ring_buffer_size - 1, O0);
0N/A st(O0, G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()));
0N/A restore();
0N/A#endif /* PRODUCT */
0N/A }
0N/A jmp(r1, offset);
0N/A}
0N/A
0N/A// This code sequence is relocatable to any address, even on LP64.
1600N/Avoid MacroAssembler::jumpl(const AddressLiteral& addrlit, Register temp, Register d, int offset, const char* file, int line) {
0N/A assert_not_delayed();
0N/A // Force fixed length sethi because NativeJump and NativeFarCall don't handle
0N/A // variable length instruction streams.
727N/A patchable_sethi(addrlit, temp);
727N/A Address a(temp, addrlit.low10() + offset); // Add the offset to the displacement.
0N/A if (TraceJumps) {
0N/A#ifndef PRODUCT
0N/A // Must do the add here so relocation can find the remainder of the
0N/A // value to be relocated.
727N/A add(a.base(), a.disp(), a.base(), addrlit.rspec(offset));
0N/A save_frame(0);
0N/A verify_thread();
0N/A ld(G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()), O0);
0N/A add(G2_thread, in_bytes(JavaThread::jmp_ring_offset()), O1);
0N/A sll(O0, exact_log2(4*sizeof(intptr_t)), O2);
0N/A add(O2, O1, O1);
0N/A
0N/A set((intptr_t)file, O3);
0N/A set(line, O4);
0N/A Label L;
0N/A
0N/A // get nearby pc, store jmp target
0N/A call(L, relocInfo::none); // No relocation for call to pc+0x8
0N/A delayed()->st(a.base()->after_save(), O1, 0);
0N/A bind(L);
0N/A
0N/A // store nearby pc
0N/A st(O7, O1, sizeof(intptr_t));
0N/A // store file
0N/A st(O3, O1, 2*sizeof(intptr_t));
0N/A // store line
0N/A st(O4, O1, 3*sizeof(intptr_t));
0N/A add(O0, 1, O0);
0N/A and3(O0, JavaThread::jump_ring_buffer_size - 1, O0);
0N/A st(O0, G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()));
0N/A restore();
0N/A jmpl(a.base(), G0, d);
0N/A#else
727N/A jmpl(a.base(), a.disp(), d);
0N/A#endif /* PRODUCT */
0N/A } else {
727N/A jmpl(a.base(), a.disp(), d);
0N/A }
0N/A}
0N/A
1600N/Avoid MacroAssembler::jump(const AddressLiteral& addrlit, Register temp, int offset, const char* file, int line) {
727N/A jumpl(addrlit, temp, G0, offset, file, line);
0N/A}
0N/A
0N/A
0N/A// Convert to C varargs format
0N/Avoid MacroAssembler::set_varargs( Argument inArg, Register d ) {
0N/A // spill register-resident args to their memory slots
0N/A // (SPARC calling convention requires callers to have already preallocated these)
0N/A // Note that the inArg might in fact be an outgoing argument,
0N/A // if a leaf routine or stub does some tricky argument shuffling.
0N/A // This routine must work even though one of the saved arguments
0N/A // is in the d register (e.g., set_varargs(Argument(0, false), O0)).
0N/A for (Argument savePtr = inArg;
0N/A savePtr.is_register();
0N/A savePtr = savePtr.successor()) {
0N/A st_ptr(savePtr.as_register(), savePtr.address_in_frame());
0N/A }
0N/A // return the address of the first memory slot
727N/A Address a = inArg.address_in_frame();
727N/A add(a.base(), a.disp(), d);
0N/A}
0N/A
0N/A// Conditional breakpoint (for assertion checks in assembly code)
0N/Avoid MacroAssembler::breakpoint_trap(Condition c, CC cc) {
0N/A trap(c, cc, G0, ST_RESERVED_FOR_USER_0);
0N/A}
0N/A
0N/A// We want to use ST_BREAKPOINT here, but the debugger is confused by it.
0N/Avoid MacroAssembler::breakpoint_trap() {
0N/A trap(ST_RESERVED_FOR_USER_0);
0N/A}
0N/A
0N/A// flush windows (except current) using flushw instruction if avail.
0N/Avoid MacroAssembler::flush_windows() {
0N/A if (VM_Version::v9_instructions_work()) flushw();
0N/A else flush_windows_trap();
0N/A}
0N/A
0N/A// Write serialization page so VM thread can do a pseudo remote membar
0N/A// We use the current thread pointer to calculate a thread specific
0N/A// offset to write to within the page. This minimizes bus traffic
0N/A// due to cache line collision.
0N/Avoid MacroAssembler::serialize_memory(Register thread, Register tmp1, Register tmp2) {
0N/A srl(thread, os::get_serialize_page_shift_count(), tmp2);
0N/A if (Assembler::is_simm13(os::vm_page_size())) {
0N/A and3(tmp2, (os::vm_page_size() - sizeof(int)), tmp2);
0N/A }
0N/A else {
0N/A set((os::vm_page_size() - sizeof(int)), tmp1);
0N/A and3(tmp2, tmp1, tmp2);
0N/A }
727N/A set(os::get_memory_serialize_page(), tmp1);
0N/A st(G0, tmp1, tmp2);
0N/A}
0N/A
0N/A
0N/A
0N/Avoid MacroAssembler::enter() {
0N/A Unimplemented();
0N/A}
0N/A
0N/Avoid MacroAssembler::leave() {
0N/A Unimplemented();
0N/A}
0N/A
0N/Avoid MacroAssembler::mult(Register s1, Register s2, Register d) {
0N/A if(VM_Version::v9_instructions_work()) {
0N/A mulx (s1, s2, d);
0N/A } else {
0N/A smul (s1, s2, d);
0N/A }
0N/A}
0N/A
0N/Avoid MacroAssembler::mult(Register s1, int simm13a, Register d) {
0N/A if(VM_Version::v9_instructions_work()) {
0N/A mulx (s1, simm13a, d);
0N/A } else {
0N/A smul (s1, simm13a, d);
0N/A }
0N/A}
0N/A
0N/A
0N/A#ifdef ASSERT
0N/Avoid MacroAssembler::read_ccr_v8_assert(Register ccr_save) {
0N/A const Register s1 = G3_scratch;
0N/A const Register s2 = G4_scratch;
0N/A Label get_psr_test;
0N/A // Get the condition codes the V8 way.
0N/A read_ccr_trap(s1);
0N/A mov(ccr_save, s2);
0N/A // This is a test of V8 which has icc but not xcc
0N/A // so mask off the xcc bits
0N/A and3(s2, 0xf, s2);
0N/A // Compare condition codes from the V8 and V9 ways.
0N/A subcc(s2, s1, G0);
0N/A br(Assembler::notEqual, true, Assembler::pt, get_psr_test);
0N/A delayed()->breakpoint_trap();
0N/A bind(get_psr_test);
0N/A}
0N/A
0N/Avoid MacroAssembler::write_ccr_v8_assert(Register ccr_save) {
0N/A const Register s1 = G3_scratch;
0N/A const Register s2 = G4_scratch;
0N/A Label set_psr_test;
0N/A // Write out the saved condition codes the V8 way
0N/A write_ccr_trap(ccr_save, s1, s2);
0N/A // Read back the condition codes using the V9 instruction
0N/A rdccr(s1);
0N/A mov(ccr_save, s2);
0N/A // This is a test of V8 which has icc but not xcc
0N/A // so mask off the xcc bits
0N/A and3(s2, 0xf, s2);
0N/A and3(s1, 0xf, s1);
0N/A // Compare the V8 way with the V9 way.
0N/A subcc(s2, s1, G0);
0N/A br(Assembler::notEqual, true, Assembler::pt, set_psr_test);
0N/A delayed()->breakpoint_trap();
0N/A bind(set_psr_test);
0N/A}
0N/A#else
0N/A#define read_ccr_v8_assert(x)
0N/A#define write_ccr_v8_assert(x)
0N/A#endif // ASSERT
0N/A
0N/Avoid MacroAssembler::read_ccr(Register ccr_save) {
0N/A if (VM_Version::v9_instructions_work()) {
0N/A rdccr(ccr_save);
0N/A // Test code sequence used on V8. Do not move above rdccr.
0N/A read_ccr_v8_assert(ccr_save);
0N/A } else {
0N/A read_ccr_trap(ccr_save);
0N/A }
0N/A}
0N/A
0N/Avoid MacroAssembler::write_ccr(Register ccr_save) {
0N/A if (VM_Version::v9_instructions_work()) {
0N/A // Test code sequence used on V8. Do not move below wrccr.
0N/A write_ccr_v8_assert(ccr_save);
0N/A wrccr(ccr_save);
0N/A } else {
0N/A const Register temp_reg1 = G3_scratch;
0N/A const Register temp_reg2 = G4_scratch;
0N/A write_ccr_trap(ccr_save, temp_reg1, temp_reg2);
0N/A }
0N/A}
0N/A
0N/A
0N/A// Calls to C land
0N/A
0N/A#ifdef ASSERT
0N/A// a hook for debugging
0N/Astatic Thread* reinitialize_thread() {
0N/A return ThreadLocalStorage::thread();
0N/A}
0N/A#else
0N/A#define reinitialize_thread ThreadLocalStorage::thread
0N/A#endif
0N/A
0N/A#ifdef ASSERT
0N/Aaddress last_get_thread = NULL;
0N/A#endif
0N/A
0N/A// call this when G2_thread is not known to be valid
0N/Avoid MacroAssembler::get_thread() {
0N/A save_frame(0); // to avoid clobbering O0
0N/A mov(G1, L0); // avoid clobbering G1
0N/A mov(G5_method, L1); // avoid clobbering G5
0N/A mov(G3, L2); // avoid clobbering G3 also
0N/A mov(G4, L5); // avoid clobbering G4
0N/A#ifdef ASSERT
727N/A AddressLiteral last_get_thread_addrlit(&last_get_thread);
727N/A set(last_get_thread_addrlit, L3);
0N/A inc(L4, get_pc(L4) + 2 * BytesPerInstWord); // skip getpc() code + inc + st_ptr to point L4 at call
727N/A st_ptr(L4, L3, 0);
0N/A#endif
0N/A call(CAST_FROM_FN_PTR(address, reinitialize_thread), relocInfo::runtime_call_type);
0N/A delayed()->nop();
0N/A mov(L0, G1);
0N/A mov(L1, G5_method);
0N/A mov(L2, G3);
0N/A mov(L5, G4);
0N/A restore(O0, 0, G2_thread);
0N/A}
0N/A
0N/Astatic Thread* verify_thread_subroutine(Thread* gthread_value) {
0N/A Thread* correct_value = ThreadLocalStorage::thread();
0N/A guarantee(gthread_value == correct_value, "G2_thread value must be the thread");
0N/A return correct_value;
0N/A}
0N/A
0N/Avoid MacroAssembler::verify_thread() {
0N/A if (VerifyThread) {
0N/A // NOTE: this chops off the heads of the 64-bit O registers.
0N/A#ifdef CC_INTERP
0N/A save_frame(0);
0N/A#else
0N/A // make sure G2_thread contains the right value
0N/A save_frame_and_mov(0, Lmethod, Lmethod); // to avoid clobbering O0 (and propagate Lmethod for -Xprof)
0N/A mov(G1, L1); // avoid clobbering G1
0N/A // G2 saved below
0N/A mov(G3, L3); // avoid clobbering G3
0N/A mov(G4, L4); // avoid clobbering G4
0N/A mov(G5_method, L5); // avoid clobbering G5_method
0N/A#endif /* CC_INTERP */
0N/A#if defined(COMPILER2) && !defined(_LP64)
0N/A // Save & restore possible 64-bit Long arguments in G-regs
0N/A srlx(G1,32,L0);
0N/A srlx(G4,32,L6);
0N/A#endif
0N/A call(CAST_FROM_FN_PTR(address,verify_thread_subroutine), relocInfo::runtime_call_type);
0N/A delayed()->mov(G2_thread, O0);
0N/A
0N/A mov(L1, G1); // Restore G1
0N/A // G2 restored below
0N/A mov(L3, G3); // restore G3
0N/A mov(L4, G4); // restore G4
0N/A mov(L5, G5_method); // restore G5_method
0N/A#if defined(COMPILER2) && !defined(_LP64)
0N/A // Save & restore possible 64-bit Long arguments in G-regs
0N/A sllx(L0,32,G2); // Move old high G1 bits high in G2
1909N/A srl(G1, 0,G1); // Clear current high G1 bits
0N/A or3 (G1,G2,G1); // Recover 64-bit G1
0N/A sllx(L6,32,G2); // Move old high G4 bits high in G2
1909N/A srl(G4, 0,G4); // Clear current high G4 bits
0N/A or3 (G4,G2,G4); // Recover 64-bit G4
0N/A#endif
0N/A restore(O0, 0, G2_thread);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::save_thread(const Register thread_cache) {
0N/A verify_thread();
0N/A if (thread_cache->is_valid()) {
0N/A assert(thread_cache->is_local() || thread_cache->is_in(), "bad volatile");
0N/A mov(G2_thread, thread_cache);
0N/A }
0N/A if (VerifyThread) {
0N/A // smash G2_thread, as if the VM were about to anyway
0N/A set(0x67676767, G2_thread);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::restore_thread(const Register thread_cache) {
0N/A if (thread_cache->is_valid()) {
0N/A assert(thread_cache->is_local() || thread_cache->is_in(), "bad volatile");
0N/A mov(thread_cache, G2_thread);
0N/A verify_thread();
0N/A } else {
0N/A // do it the slow way
0N/A get_thread();
0N/A }
0N/A}
0N/A
0N/A
0N/A// %%% maybe get rid of [re]set_last_Java_frame
0N/Avoid MacroAssembler::set_last_Java_frame(Register last_java_sp, Register last_Java_pc) {
0N/A assert_not_delayed();
727N/A Address flags(G2_thread, JavaThread::frame_anchor_offset() +
727N/A JavaFrameAnchor::flags_offset());
727N/A Address pc_addr(G2_thread, JavaThread::last_Java_pc_offset());
0N/A
0N/A // Always set last_Java_pc and flags first because once last_Java_sp is visible
0N/A // has_last_Java_frame is true and users will look at the rest of the fields.
0N/A // (Note: flags should always be zero before we get here so doesn't need to be set.)
0N/A
0N/A#ifdef ASSERT
0N/A // Verify that flags was zeroed on return to Java
0N/A Label PcOk;
0N/A save_frame(0); // to avoid clobbering O0
0N/A ld_ptr(pc_addr, L0);
0N/A tst(L0);
0N/A#ifdef _LP64
0N/A brx(Assembler::zero, false, Assembler::pt, PcOk);
0N/A#else
0N/A br(Assembler::zero, false, Assembler::pt, PcOk);
0N/A#endif // _LP64
0N/A delayed() -> nop();
0N/A stop("last_Java_pc not zeroed before leaving Java");
0N/A bind(PcOk);
0N/A
0N/A // Verify that flags was zeroed on return to Java
0N/A Label FlagsOk;
0N/A ld(flags, L0);
0N/A tst(L0);
0N/A br(Assembler::zero, false, Assembler::pt, FlagsOk);
0N/A delayed() -> restore();
0N/A stop("flags not zeroed before leaving Java");
0N/A bind(FlagsOk);
0N/A#endif /* ASSERT */
0N/A //
0N/A // When returning from calling out from Java mode the frame anchor's last_Java_pc
0N/A // will always be set to NULL. It is set here so that if we are doing a call to
0N/A // native (not VM) that we capture the known pc and don't have to rely on the
0N/A // native call having a standard frame linkage where we can find the pc.
0N/A
0N/A if (last_Java_pc->is_valid()) {
0N/A st_ptr(last_Java_pc, pc_addr);
0N/A }
0N/A
0N/A#ifdef _LP64
0N/A#ifdef ASSERT
0N/A // Make sure that we have an odd stack
0N/A Label StackOk;
0N/A andcc(last_java_sp, 0x01, G0);
0N/A br(Assembler::notZero, false, Assembler::pt, StackOk);
0N/A delayed() -> nop();
0N/A stop("Stack Not Biased in set_last_Java_frame");
0N/A bind(StackOk);
0N/A#endif // ASSERT
0N/A assert( last_java_sp != G4_scratch, "bad register usage in set_last_Java_frame");
0N/A add( last_java_sp, STACK_BIAS, G4_scratch );
727N/A st_ptr(G4_scratch, G2_thread, JavaThread::last_Java_sp_offset());
0N/A#else
727N/A st_ptr(last_java_sp, G2_thread, JavaThread::last_Java_sp_offset());
0N/A#endif // _LP64
0N/A}
0N/A
0N/Avoid MacroAssembler::reset_last_Java_frame(void) {
0N/A assert_not_delayed();
0N/A
727N/A Address sp_addr(G2_thread, JavaThread::last_Java_sp_offset());
727N/A Address pc_addr(G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset());
727N/A Address flags (G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::flags_offset());
0N/A
0N/A#ifdef ASSERT
0N/A // check that it WAS previously set
0N/A#ifdef CC_INTERP
0N/A save_frame(0);
0N/A#else
0N/A save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod to helper frame for -Xprof
0N/A#endif /* CC_INTERP */
0N/A ld_ptr(sp_addr, L0);
0N/A tst(L0);
0N/A breakpoint_trap(Assembler::zero, Assembler::ptr_cc);
0N/A restore();
0N/A#endif // ASSERT
0N/A
0N/A st_ptr(G0, sp_addr);
0N/A // Always return last_Java_pc to zero
0N/A st_ptr(G0, pc_addr);
0N/A // Always null flags after return to Java
0N/A st(G0, flags);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM_base(
0N/A Register oop_result,
0N/A Register thread_cache,
0N/A Register last_java_sp,
0N/A address entry_point,
0N/A int number_of_arguments,
0N/A bool check_exceptions)
0N/A{
0N/A assert_not_delayed();
0N/A
0N/A // determine last_java_sp register
0N/A if (!last_java_sp->is_valid()) {
0N/A last_java_sp = SP;
0N/A }
0N/A // debugging support
0N/A assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
0N/A
0N/A // 64-bit last_java_sp is biased!
0N/A set_last_Java_frame(last_java_sp, noreg);
0N/A if (VerifyThread) mov(G2_thread, O0); // about to be smashed; pass early
0N/A save_thread(thread_cache);
0N/A // do the call
0N/A call(entry_point, relocInfo::runtime_call_type);
0N/A if (!VerifyThread)
0N/A delayed()->mov(G2_thread, O0); // pass thread as first argument
0N/A else
0N/A delayed()->nop(); // (thread already passed)
0N/A restore_thread(thread_cache);
0N/A reset_last_Java_frame();
0N/A
0N/A // check for pending exceptions. use Gtemp as scratch register.
0N/A if (check_exceptions) {
0N/A check_and_forward_exception(Gtemp);
0N/A }
0N/A
0N/A // get oop result if there is one and reset the value in the thread
0N/A if (oop_result->is_valid()) {
0N/A get_vm_result(oop_result);
0N/A }
0N/A}
0N/A
0N/Avoid MacroAssembler::check_and_forward_exception(Register scratch_reg)
0N/A{
0N/A Label L;
0N/A
0N/A check_and_handle_popframe(scratch_reg);
0N/A check_and_handle_earlyret(scratch_reg);
0N/A
727N/A Address exception_addr(G2_thread, Thread::pending_exception_offset());
0N/A ld_ptr(exception_addr, scratch_reg);
0N/A br_null(scratch_reg,false,pt,L);
0N/A delayed()->nop();
0N/A // we use O7 linkage so that forward_exception_entry has the issuing PC
0N/A call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
0N/A delayed()->nop();
0N/A bind(L);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::check_and_handle_popframe(Register scratch_reg) {
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::check_and_handle_earlyret(Register scratch_reg) {
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
0N/A call_VM_base(oop_result, noreg, noreg, entry_point, number_of_arguments, check_exceptions);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions) {
0N/A // O0 is reserved for the thread
0N/A mov(arg_1, O1);
0N/A call_VM(oop_result, entry_point, 1, check_exceptions);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
0N/A // O0 is reserved for the thread
0N/A mov(arg_1, O1);
0N/A mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
0N/A call_VM(oop_result, entry_point, 2, check_exceptions);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
0N/A // O0 is reserved for the thread
0N/A mov(arg_1, O1);
0N/A mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
0N/A mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
0N/A call_VM(oop_result, entry_point, 3, check_exceptions);
0N/A}
0N/A
0N/A
0N/A
0N/A// Note: The following call_VM overloadings are useful when a "save"
0N/A// has already been performed by a stub, and the last Java frame is
0N/A// the previous one. In that case, last_java_sp must be passed as FP
0N/A// instead of SP.
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, int number_of_arguments, bool check_exceptions) {
0N/A call_VM_base(oop_result, noreg, last_java_sp, entry_point, number_of_arguments, check_exceptions);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions) {
0N/A // O0 is reserved for the thread
0N/A mov(arg_1, O1);
0N/A call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
0N/A // O0 is reserved for the thread
0N/A mov(arg_1, O1);
0N/A mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
0N/A call_VM(oop_result, last_java_sp, entry_point, 2, check_exceptions);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
0N/A // O0 is reserved for the thread
0N/A mov(arg_1, O1);
0N/A mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
0N/A mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
0N/A call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
0N/A}
0N/A
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM_leaf_base(Register thread_cache, address entry_point, int number_of_arguments) {
0N/A assert_not_delayed();
0N/A save_thread(thread_cache);
0N/A // do the call
0N/A call(entry_point, relocInfo::runtime_call_type);
0N/A delayed()->nop();
0N/A restore_thread(thread_cache);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, int number_of_arguments) {
0N/A call_VM_leaf_base(thread_cache, entry_point, number_of_arguments);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1) {
0N/A mov(arg_1, O0);
0N/A call_VM_leaf(thread_cache, entry_point, 1);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2) {
0N/A mov(arg_1, O0);
0N/A mov(arg_2, O1); assert(arg_2 != O0, "smashed argument");
0N/A call_VM_leaf(thread_cache, entry_point, 2);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2, Register arg_3) {
0N/A mov(arg_1, O0);
0N/A mov(arg_2, O1); assert(arg_2 != O0, "smashed argument");
0N/A mov(arg_3, O2); assert(arg_3 != O0 && arg_3 != O1, "smashed argument");
0N/A call_VM_leaf(thread_cache, entry_point, 3);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::get_vm_result(Register oop_result) {
0N/A verify_thread();
727N/A Address vm_result_addr(G2_thread, JavaThread::vm_result_offset());
0N/A ld_ptr( vm_result_addr, oop_result);
0N/A st_ptr(G0, vm_result_addr);
0N/A verify_oop(oop_result);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::get_vm_result_2(Register oop_result) {
0N/A verify_thread();
727N/A Address vm_result_addr_2(G2_thread, JavaThread::vm_result_2_offset());
0N/A ld_ptr(vm_result_addr_2, oop_result);
0N/A st_ptr(G0, vm_result_addr_2);
0N/A verify_oop(oop_result);
0N/A}
0N/A
0N/A
0N/A// We require that C code which does not return a value in vm_result will
0N/A// leave it undisturbed.
0N/Avoid MacroAssembler::set_vm_result(Register oop_result) {
0N/A verify_thread();
727N/A Address vm_result_addr(G2_thread, JavaThread::vm_result_offset());
0N/A verify_oop(oop_result);
0N/A
0N/A# ifdef ASSERT
0N/A // Check that we are not overwriting any other oop.
0N/A#ifdef CC_INTERP
0N/A save_frame(0);
0N/A#else
0N/A save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod for -Xprof
0N/A#endif /* CC_INTERP */
0N/A ld_ptr(vm_result_addr, L0);
0N/A tst(L0);
0N/A restore();
0N/A breakpoint_trap(notZero, Assembler::ptr_cc);
0N/A // }
0N/A# endif
0N/A
0N/A st_ptr(oop_result, vm_result_addr);
0N/A}
0N/A
0N/A
342N/Avoid MacroAssembler::card_table_write(jbyte* byte_map_base,
342N/A Register tmp, Register obj) {
0N/A#ifdef _LP64
0N/A srlx(obj, CardTableModRefBS::card_shift, obj);
0N/A#else
0N/A srl(obj, CardTableModRefBS::card_shift, obj);
0N/A#endif
727N/A assert(tmp != obj, "need separate temp reg");
727N/A set((address) byte_map_base, tmp);
727N/A stb(G0, tmp, obj);
0N/A}
0N/A
727N/A
727N/Avoid MacroAssembler::internal_sethi(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) {
0N/A address save_pc;
0N/A int shiftcnt;
0N/A#ifdef _LP64
0N/A# ifdef CHECK_DELAY
727N/A assert_not_delayed((char*) "cannot put two instructions in delay slot");
0N/A# endif
0N/A v9_dep();
0N/A save_pc = pc();
727N/A
727N/A int msb32 = (int) (addrlit.value() >> 32);
727N/A int lsb32 = (int) (addrlit.value());
727N/A
727N/A if (msb32 == 0 && lsb32 >= 0) {
727N/A Assembler::sethi(lsb32, d, addrlit.rspec());
0N/A }
727N/A else if (msb32 == -1) {
727N/A Assembler::sethi(~lsb32, d, addrlit.rspec());
727N/A xor3(d, ~low10(~0), d);
0N/A }
0N/A else {
727N/A Assembler::sethi(msb32, d, addrlit.rspec()); // msb 22-bits
727N/A if (msb32 & 0x3ff) // Any bits?
727N/A or3(d, msb32 & 0x3ff, d); // msb 32-bits are now in lsb 32
727N/A if (lsb32 & 0xFFFFFC00) { // done?
727N/A if ((lsb32 >> 20) & 0xfff) { // Any bits set?
727N/A sllx(d, 12, d); // Make room for next 12 bits
727N/A or3(d, (lsb32 >> 20) & 0xfff, d); // Or in next 12
727N/A shiftcnt = 0; // We already shifted
0N/A }
0N/A else
0N/A shiftcnt = 12;
727N/A if ((lsb32 >> 10) & 0x3ff) {
727N/A sllx(d, shiftcnt + 10, d); // Make room for last 10 bits
727N/A or3(d, (lsb32 >> 10) & 0x3ff, d); // Or in next 10
0N/A shiftcnt = 0;
0N/A }
0N/A else
0N/A shiftcnt = 10;
727N/A sllx(d, shiftcnt + 10, d); // Shift leaving disp field 0'd
0N/A }
0N/A else
727N/A sllx(d, 32, d);
0N/A }
727N/A // Pad out the instruction sequence so it can be patched later.
727N/A if (ForceRelocatable || (addrlit.rtype() != relocInfo::none &&
727N/A addrlit.rtype() != relocInfo::runtime_call_type)) {
727N/A while (pc() < (save_pc + (7 * BytesPerInstWord)))
0N/A nop();
0N/A }
0N/A#else
727N/A Assembler::sethi(addrlit.value(), d, addrlit.rspec());
0N/A#endif
727N/A}
727N/A
727N/A
727N/Avoid MacroAssembler::sethi(const AddressLiteral& addrlit, Register d) {
727N/A internal_sethi(addrlit, d, false);
0N/A}
0N/A
727N/A
727N/Avoid MacroAssembler::patchable_sethi(const AddressLiteral& addrlit, Register d) {
727N/A internal_sethi(addrlit, d, true);
727N/A}
727N/A
727N/A
1964N/Aint MacroAssembler::insts_for_sethi(address a, bool worst_case) {
0N/A#ifdef _LP64
1964N/A if (worst_case) return 7;
1964N/A intptr_t iaddr = (intptr_t) a;
1964N/A int msb32 = (int) (iaddr >> 32);
1964N/A int lsb32 = (int) (iaddr);
1964N/A int count;
1964N/A if (msb32 == 0 && lsb32 >= 0)
1964N/A count = 1;
1964N/A else if (msb32 == -1)
1964N/A count = 2;
0N/A else {
1964N/A count = 2;
1964N/A if (msb32 & 0x3ff)
1964N/A count++;
1964N/A if (lsb32 & 0xFFFFFC00 ) {
1964N/A if ((lsb32 >> 20) & 0xfff) count += 2;
1964N/A if ((lsb32 >> 10) & 0x3ff) count += 2;
0N/A }
0N/A }
1964N/A return count;
0N/A#else
1964N/A return 1;
0N/A#endif
0N/A}
0N/A
1964N/Aint MacroAssembler::worst_case_insts_for_set() {
1964N/A return insts_for_sethi(NULL, true) + 1;
0N/A}
0N/A
727N/A
1964N/A// Keep in sync with MacroAssembler::insts_for_internal_set
727N/Avoid MacroAssembler::internal_set(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) {
727N/A intptr_t value = addrlit.value();
727N/A
727N/A if (!ForceRelocatable && addrlit.rspec().type() == relocInfo::none) {
0N/A // can optimize
727N/A if (-4096 <= value && value <= 4095) {
0N/A or3(G0, value, d); // setsw (this leaves upper 32 bits sign-extended)
0N/A return;
0N/A }
0N/A if (inv_hi22(hi22(value)) == value) {
727N/A sethi(addrlit, d);
0N/A return;
0N/A }
0N/A }
727N/A assert_not_delayed((char*) "cannot put two instructions in delay slot");
727N/A internal_sethi(addrlit, d, ForceRelocatable);
727N/A if (ForceRelocatable || addrlit.rspec().type() != relocInfo::none || addrlit.low10() != 0) {
727N/A add(d, addrlit.low10(), d, addrlit.rspec());
0N/A }
0N/A}
0N/A
1964N/A// Keep in sync with MacroAssembler::internal_set
1964N/Aint MacroAssembler::insts_for_internal_set(intptr_t value) {
1964N/A // can optimize
1964N/A if (-4096 <= value && value <= 4095) {
1964N/A return 1;
1964N/A }
1964N/A if (inv_hi22(hi22(value)) == value) {
1964N/A return insts_for_sethi((address) value);
1964N/A }
1964N/A int count = insts_for_sethi((address) value);
1964N/A AddressLiteral al(value);
1964N/A if (al.low10() != 0) {
1964N/A count++;
1964N/A }
1964N/A return count;
1964N/A}
1964N/A
727N/Avoid MacroAssembler::set(const AddressLiteral& al, Register d) {
727N/A internal_set(al, d, false);
727N/A}
727N/A
727N/Avoid MacroAssembler::set(intptr_t value, Register d) {
727N/A AddressLiteral al(value);
727N/A internal_set(al, d, false);
0N/A}
0N/A
727N/Avoid MacroAssembler::set(address addr, Register d, RelocationHolder const& rspec) {
727N/A AddressLiteral al(addr, rspec);
727N/A internal_set(al, d, false);
727N/A}
727N/A
727N/Avoid MacroAssembler::patchable_set(const AddressLiteral& al, Register d) {
727N/A internal_set(al, d, true);
727N/A}
727N/A
727N/Avoid MacroAssembler::patchable_set(intptr_t value, Register d) {
727N/A AddressLiteral al(value);
727N/A internal_set(al, d, true);
727N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::set64(jlong value, Register d, Register tmp) {
0N/A assert_not_delayed();
0N/A v9_dep();
0N/A
0N/A int hi = (int)(value >> 32);
0N/A int lo = (int)(value & ~0);
0N/A // (Matcher::isSimpleConstant64 knows about the following optimizations.)
0N/A if (Assembler::is_simm13(lo) && value == lo) {
0N/A or3(G0, lo, d);
0N/A } else if (hi == 0) {
0N/A Assembler::sethi(lo, d); // hardware version zero-extends to upper 32
0N/A if (low10(lo) != 0)
0N/A or3(d, low10(lo), d);
0N/A }
0N/A else if (hi == -1) {
0N/A Assembler::sethi(~lo, d); // hardware version zero-extends to upper 32
0N/A xor3(d, low10(lo) ^ ~low10(~0), d);
0N/A }
0N/A else if (lo == 0) {
0N/A if (Assembler::is_simm13(hi)) {
0N/A or3(G0, hi, d);
0N/A } else {
0N/A Assembler::sethi(hi, d); // hardware version zero-extends to upper 32
0N/A if (low10(hi) != 0)
0N/A or3(d, low10(hi), d);
0N/A }
0N/A sllx(d, 32, d);
0N/A }
0N/A else {
0N/A Assembler::sethi(hi, tmp);
0N/A Assembler::sethi(lo, d); // macro assembler version sign-extends
0N/A if (low10(hi) != 0)
0N/A or3 (tmp, low10(hi), tmp);
0N/A if (low10(lo) != 0)
0N/A or3 ( d, low10(lo), d);
0N/A sllx(tmp, 32, tmp);
0N/A or3 (d, tmp, d);
0N/A }
0N/A}
0N/A
1964N/Aint MacroAssembler::insts_for_set64(jlong value) {
1915N/A v9_dep();
1915N/A
1964N/A int hi = (int) (value >> 32);
1964N/A int lo = (int) (value & ~0);
1915N/A int count = 0;
1915N/A
1915N/A // (Matcher::isSimpleConstant64 knows about the following optimizations.)
1915N/A if (Assembler::is_simm13(lo) && value == lo) {
1915N/A count++;
1915N/A } else if (hi == 0) {
1915N/A count++;
1915N/A if (low10(lo) != 0)
1915N/A count++;
1915N/A }
1915N/A else if (hi == -1) {
1915N/A count += 2;
1915N/A }
1915N/A else if (lo == 0) {
1915N/A if (Assembler::is_simm13(hi)) {
1915N/A count++;
1915N/A } else {
1915N/A count++;
1915N/A if (low10(hi) != 0)
1915N/A count++;
1915N/A }
1915N/A count++;
1915N/A }
1915N/A else {
1915N/A count += 2;
1915N/A if (low10(hi) != 0)
1915N/A count++;
1915N/A if (low10(lo) != 0)
1915N/A count++;
1915N/A count += 2;
1915N/A }
1915N/A return count;
1915N/A}
1915N/A
0N/A// compute size in bytes of sparc frame, given
0N/A// number of extraWords
0N/Aint MacroAssembler::total_frame_size_in_bytes(int extraWords) {
0N/A
0N/A int nWords = frame::memory_parameter_word_sp_offset;
0N/A
0N/A nWords += extraWords;
0N/A
0N/A if (nWords & 1) ++nWords; // round up to double-word
0N/A
0N/A return nWords * BytesPerWord;
0N/A}
0N/A
0N/A
0N/A// save_frame: given number of "extra" words in frame,
0N/A// issue approp. save instruction (p 200, v8 manual)
0N/A
0N/Avoid MacroAssembler::save_frame(int extraWords = 0) {
0N/A int delta = -total_frame_size_in_bytes(extraWords);
0N/A if (is_simm13(delta)) {
0N/A save(SP, delta, SP);
0N/A } else {
0N/A set(delta, G3_scratch);
0N/A save(SP, G3_scratch, SP);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::save_frame_c1(int size_in_bytes) {
0N/A if (is_simm13(-size_in_bytes)) {
0N/A save(SP, -size_in_bytes, SP);
0N/A } else {
0N/A set(-size_in_bytes, G3_scratch);
0N/A save(SP, G3_scratch, SP);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::save_frame_and_mov(int extraWords,
0N/A Register s1, Register d1,
0N/A Register s2, Register d2) {
0N/A assert_not_delayed();
0N/A
0N/A // The trick here is to use precisely the same memory word
0N/A // that trap handlers also use to save the register.
0N/A // This word cannot be used for any other purpose, but
0N/A // it works fine to save the register's value, whether or not
0N/A // an interrupt flushes register windows at any given moment!
0N/A Address s1_addr;
0N/A if (s1->is_valid() && (s1->is_in() || s1->is_local())) {
0N/A s1_addr = s1->address_in_saved_window();
0N/A st_ptr(s1, s1_addr);
0N/A }
0N/A
0N/A Address s2_addr;
0N/A if (s2->is_valid() && (s2->is_in() || s2->is_local())) {
0N/A s2_addr = s2->address_in_saved_window();
0N/A st_ptr(s2, s2_addr);
0N/A }
0N/A
0N/A save_frame(extraWords);
0N/A
0N/A if (s1_addr.base() == SP) {
0N/A ld_ptr(s1_addr.after_save(), d1);
0N/A } else if (s1->is_valid()) {
0N/A mov(s1->after_save(), d1);
0N/A }
0N/A
0N/A if (s2_addr.base() == SP) {
0N/A ld_ptr(s2_addr.after_save(), d2);
0N/A } else if (s2->is_valid()) {
0N/A mov(s2->after_save(), d2);
0N/A }
0N/A}
0N/A
0N/A
727N/AAddressLiteral MacroAssembler::allocate_oop_address(jobject obj) {
0N/A assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
0N/A int oop_index = oop_recorder()->allocate_index(obj);
727N/A return AddressLiteral(obj, oop_Relocation::spec(oop_index));
0N/A}
0N/A
0N/A
727N/AAddressLiteral MacroAssembler::constant_oop_address(jobject obj) {
0N/A assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
0N/A int oop_index = oop_recorder()->find_index(obj);
727N/A return AddressLiteral(obj, oop_Relocation::spec(oop_index));
0N/A}
0N/A
164N/Avoid MacroAssembler::set_narrow_oop(jobject obj, Register d) {
164N/A assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
164N/A int oop_index = oop_recorder()->find_index(obj);
164N/A RelocationHolder rspec = oop_Relocation::spec(oop_index);
164N/A
164N/A assert_not_delayed();
164N/A // Relocation with special format (see relocInfo_sparc.hpp).
164N/A relocate(rspec, 1);
164N/A // Assembler::sethi(0x3fffff, d);
164N/A emit_long( op(branch_op) | rd(d) | op2(sethi_op2) | hi22(0x3fffff) );
164N/A // Don't add relocation for 'add'. Do patching during 'sethi' processing.
164N/A add(d, 0x3ff, d);
164N/A
164N/A}
164N/A
0N/A
0N/Avoid MacroAssembler::align(int modulus) {
0N/A while (offset() % modulus != 0) nop();
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::safepoint() {
0N/A relocate(breakpoint_Relocation::spec(breakpoint_Relocation::safepoint));
0N/A}
0N/A
0N/A
0N/Avoid RegistersForDebugging::print(outputStream* s) {
0N/A int j;
0N/A for ( j = 0; j < 8; ++j )
0N/A if ( j != 6 ) s->print_cr("i%d = 0x%.16lx", j, i[j]);
0N/A else s->print_cr( "fp = 0x%.16lx", i[j]);
0N/A s->cr();
0N/A
0N/A for ( j = 0; j < 8; ++j )
0N/A s->print_cr("l%d = 0x%.16lx", j, l[j]);
0N/A s->cr();
0N/A
0N/A for ( j = 0; j < 8; ++j )
0N/A if ( j != 6 ) s->print_cr("o%d = 0x%.16lx", j, o[j]);
0N/A else s->print_cr( "sp = 0x%.16lx", o[j]);
0N/A s->cr();
0N/A
0N/A for ( j = 0; j < 8; ++j )
0N/A s->print_cr("g%d = 0x%.16lx", j, g[j]);
0N/A s->cr();
0N/A
0N/A // print out floats with compression
0N/A for (j = 0; j < 32; ) {
0N/A jfloat val = f[j];
0N/A int last = j;
0N/A for ( ; last+1 < 32; ++last ) {
0N/A char b1[1024], b2[1024];
0N/A sprintf(b1, "%f", val);
0N/A sprintf(b2, "%f", f[last+1]);
0N/A if (strcmp(b1, b2))
0N/A break;
0N/A }
0N/A s->print("f%d", j);
0N/A if ( j != last ) s->print(" - f%d", last);
0N/A s->print(" = %f", val);
0N/A s->fill_to(25);
0N/A s->print_cr(" (0x%x)", val);
0N/A j = last + 1;
0N/A }
0N/A s->cr();
0N/A
0N/A // and doubles (evens only)
0N/A for (j = 0; j < 32; ) {
0N/A jdouble val = d[j];
0N/A int last = j;
0N/A for ( ; last+1 < 32; ++last ) {
0N/A char b1[1024], b2[1024];
0N/A sprintf(b1, "%f", val);
0N/A sprintf(b2, "%f", d[last+1]);
0N/A if (strcmp(b1, b2))
0N/A break;
0N/A }
0N/A s->print("d%d", 2 * j);
0N/A if ( j != last ) s->print(" - d%d", last);
0N/A s->print(" = %f", val);
0N/A s->fill_to(30);
0N/A s->print("(0x%x)", *(int*)&val);
0N/A s->fill_to(42);
0N/A s->print_cr("(0x%x)", *(1 + (int*)&val));
0N/A j = last + 1;
0N/A }
0N/A s->cr();
0N/A}
0N/A
0N/Avoid RegistersForDebugging::save_registers(MacroAssembler* a) {
0N/A a->sub(FP, round_to(sizeof(RegistersForDebugging), sizeof(jdouble)) - STACK_BIAS, O0);
0N/A a->flush_windows();
0N/A int i;
0N/A for (i = 0; i < 8; ++i) {
0N/A a->ld_ptr(as_iRegister(i)->address_in_saved_window().after_save(), L1); a->st_ptr( L1, O0, i_offset(i));
0N/A a->ld_ptr(as_lRegister(i)->address_in_saved_window().after_save(), L1); a->st_ptr( L1, O0, l_offset(i));
0N/A a->st_ptr(as_oRegister(i)->after_save(), O0, o_offset(i));
0N/A a->st_ptr(as_gRegister(i)->after_save(), O0, g_offset(i));
0N/A }
0N/A for (i = 0; i < 32; ++i) {
0N/A a->stf(FloatRegisterImpl::S, as_FloatRegister(i), O0, f_offset(i));
0N/A }
0N/A for (i = 0; i < (VM_Version::v9_instructions_work() ? 64 : 32); i += 2) {
0N/A a->stf(FloatRegisterImpl::D, as_FloatRegister(i), O0, d_offset(i));
0N/A }
0N/A}
0N/A
0N/Avoid RegistersForDebugging::restore_registers(MacroAssembler* a, Register r) {
0N/A for (int i = 1; i < 8; ++i) {
0N/A a->ld_ptr(r, g_offset(i), as_gRegister(i));
0N/A }
0N/A for (int j = 0; j < 32; ++j) {
0N/A a->ldf(FloatRegisterImpl::S, O0, f_offset(j), as_FloatRegister(j));
0N/A }
0N/A for (int k = 0; k < (VM_Version::v9_instructions_work() ? 64 : 32); k += 2) {
0N/A a->ldf(FloatRegisterImpl::D, O0, d_offset(k), as_FloatRegister(k));
0N/A }
0N/A}
0N/A
0N/A
0N/A// pushes double TOS element of FPU stack on CPU stack; pops from FPU stack
0N/Avoid MacroAssembler::push_fTOS() {
0N/A // %%%%%% need to implement this
0N/A}
0N/A
0N/A// pops double TOS element from CPU stack and pushes on FPU stack
0N/Avoid MacroAssembler::pop_fTOS() {
0N/A // %%%%%% need to implement this
0N/A}
0N/A
0N/Avoid MacroAssembler::empty_FPU_stack() {
0N/A // %%%%%% need to implement this
0N/A}
0N/A
0N/Avoid MacroAssembler::_verify_oop(Register reg, const char* msg, const char * file, int line) {
0N/A // plausibility check for oops
0N/A if (!VerifyOops) return;
0N/A
0N/A if (reg == G0) return; // always NULL, which is always an oop
0N/A
342N/A char buffer[64];
342N/A#ifdef COMPILER1
342N/A if (CommentedAssembly) {
342N/A snprintf(buffer, sizeof(buffer), "verify_oop at %d", offset());
342N/A block_comment(buffer);
342N/A }
342N/A#endif
342N/A
342N/A int len = strlen(file) + strlen(msg) + 1 + 4;
0N/A sprintf(buffer, "%d", line);
342N/A len += strlen(buffer);
342N/A sprintf(buffer, " at offset %d ", offset());
342N/A len += strlen(buffer);
0N/A char * real_msg = new char[len];
342N/A sprintf(real_msg, "%s%s(%s:%d)", msg, buffer, file, line);
0N/A
0N/A // Call indirectly to solve generation ordering problem
727N/A AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
0N/A
0N/A // Make some space on stack above the current register window.
0N/A // Enough to hold 8 64-bit registers.
0N/A add(SP,-8*8,SP);
0N/A
0N/A // Save some 64-bit registers; a normal 'save' chops the heads off
0N/A // of 64-bit longs in the 32-bit build.
0N/A stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
0N/A stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
0N/A mov(reg,O0); // Move arg into O0; arg might be in O7 which is about to be crushed
0N/A stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
0N/A
0N/A set((intptr_t)real_msg, O1);
0N/A // Load address to call to into O7
0N/A load_ptr_contents(a, O7);
0N/A // Register call to verify_oop_subroutine
0N/A callr(O7, G0);
0N/A delayed()->nop();
0N/A // recover frame size
0N/A add(SP, 8*8,SP);
0N/A}
0N/A
0N/Avoid MacroAssembler::_verify_oop_addr(Address addr, const char* msg, const char * file, int line) {
0N/A // plausibility check for oops
0N/A if (!VerifyOops) return;
0N/A
0N/A char buffer[64];
0N/A sprintf(buffer, "%d", line);
0N/A int len = strlen(file) + strlen(msg) + 1 + 4 + strlen(buffer);
0N/A sprintf(buffer, " at SP+%d ", addr.disp());
0N/A len += strlen(buffer);
0N/A char * real_msg = new char[len];
0N/A sprintf(real_msg, "%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
0N/A
0N/A // Call indirectly to solve generation ordering problem
727N/A AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
0N/A
0N/A // Make some space on stack above the current register window.
0N/A // Enough to hold 8 64-bit registers.
0N/A add(SP,-8*8,SP);
0N/A
0N/A // Save some 64-bit registers; a normal 'save' chops the heads off
0N/A // of 64-bit longs in the 32-bit build.
0N/A stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
0N/A stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
0N/A ld_ptr(addr.base(), addr.disp() + 8*8, O0); // Load arg into O0; arg might be in O7 which is about to be crushed
0N/A stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
0N/A
0N/A set((intptr_t)real_msg, O1);
0N/A // Load address to call to into O7
0N/A load_ptr_contents(a, O7);
0N/A // Register call to verify_oop_subroutine
0N/A callr(O7, G0);
0N/A delayed()->nop();
0N/A // recover frame size
0N/A add(SP, 8*8,SP);
0N/A}
0N/A
0N/A// side-door communication with signalHandler in os_solaris.cpp
0N/Aaddress MacroAssembler::_verify_oop_implicit_branch[3] = { NULL };
0N/A
0N/A// This macro is expanded just once; it creates shared code. Contract:
0N/A// receives an oop in O0. Must restore O0 & O7 from TLS. Must not smash ANY
0N/A// registers, including flags. May not use a register 'save', as this blows
0N/A// the high bits of the O-regs if they contain Long values. Acts as a 'leaf'
0N/A// call.
0N/Avoid MacroAssembler::verify_oop_subroutine() {
0N/A assert( VM_Version::v9_instructions_work(), "VerifyOops not supported for V8" );
0N/A
0N/A // Leaf call; no frame.
0N/A Label succeed, fail, null_or_fail;
0N/A
0N/A // O0 and O7 were saved already (O0 in O0's TLS home, O7 in O5's TLS home).
0N/A // O0 is now the oop to be checked. O7 is the return address.
0N/A Register O0_obj = O0;
0N/A
0N/A // Save some more registers for temps.
0N/A stx(O2,SP,frame::register_save_words*wordSize+STACK_BIAS+2*8);
0N/A stx(O3,SP,frame::register_save_words*wordSize+STACK_BIAS+3*8);
0N/A stx(O4,SP,frame::register_save_words*wordSize+STACK_BIAS+4*8);
0N/A stx(O5,SP,frame::register_save_words*wordSize+STACK_BIAS+5*8);
0N/A
0N/A // Save flags
0N/A Register O5_save_flags = O5;
0N/A rdccr( O5_save_flags );
0N/A
0N/A { // count number of verifies
0N/A Register O2_adr = O2;
0N/A Register O3_accum = O3;
727N/A inc_counter(StubRoutines::verify_oop_count_addr(), O2_adr, O3_accum);
0N/A }
0N/A
0N/A Register O2_mask = O2;
0N/A Register O3_bits = O3;
0N/A Register O4_temp = O4;
0N/A
0N/A // mark lower end of faulting range
0N/A assert(_verify_oop_implicit_branch[0] == NULL, "set once");
0N/A _verify_oop_implicit_branch[0] = pc();
0N/A
0N/A // We can't check the mark oop because it could be in the process of
0N/A // locking or unlocking while this is running.
0N/A set(Universe::verify_oop_mask (), O2_mask);
0N/A set(Universe::verify_oop_bits (), O3_bits);
0N/A
0N/A // assert((obj & oop_mask) == oop_bits);
0N/A and3(O0_obj, O2_mask, O4_temp);
0N/A cmp(O4_temp, O3_bits);
0N/A brx(notEqual, false, pn, null_or_fail);
0N/A delayed()->nop();
0N/A
0N/A if ((NULL_WORD & Universe::verify_oop_mask()) == Universe::verify_oop_bits()) {
0N/A // the null_or_fail case is useless; must test for null separately
0N/A br_null(O0_obj, false, pn, succeed);
0N/A delayed()->nop();
0N/A }
0N/A
0N/A // Check the klassOop of this object for being in the right area of memory.
0N/A // Cannot do the load in the delay above slot in case O0 is null
113N/A load_klass(O0_obj, O0_obj);
0N/A // assert((klass & klass_mask) == klass_bits);
0N/A if( Universe::verify_klass_mask() != Universe::verify_oop_mask() )
0N/A set(Universe::verify_klass_mask(), O2_mask);
0N/A if( Universe::verify_klass_bits() != Universe::verify_oop_bits() )
0N/A set(Universe::verify_klass_bits(), O3_bits);
0N/A and3(O0_obj, O2_mask, O4_temp);
0N/A cmp(O4_temp, O3_bits);
0N/A brx(notEqual, false, pn, fail);
113N/A delayed()->nop();
0N/A // Check the klass's klass
113N/A load_klass(O0_obj, O0_obj);
0N/A and3(O0_obj, O2_mask, O4_temp);
0N/A cmp(O4_temp, O3_bits);
0N/A brx(notEqual, false, pn, fail);
0N/A delayed()->wrccr( O5_save_flags ); // Restore CCR's
0N/A
0N/A // mark upper end of faulting range
0N/A _verify_oop_implicit_branch[1] = pc();
0N/A
0N/A //-----------------------
0N/A // all tests pass
0N/A bind(succeed);
0N/A
0N/A // Restore prior 64-bit registers
0N/A ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+0*8,O0);
0N/A ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+1*8,O1);
0N/A ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+2*8,O2);
0N/A ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+3*8,O3);
0N/A ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+4*8,O4);
0N/A ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+5*8,O5);
0N/A
0N/A retl(); // Leaf return; restore prior O7 in delay slot
0N/A delayed()->ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+7*8,O7);
0N/A
0N/A //-----------------------
0N/A bind(null_or_fail); // nulls are less common but OK
0N/A br_null(O0_obj, false, pt, succeed);
0N/A delayed()->wrccr( O5_save_flags ); // Restore CCR's
0N/A
0N/A //-----------------------
0N/A // report failure:
0N/A bind(fail);
0N/A _verify_oop_implicit_branch[2] = pc();
0N/A
0N/A wrccr( O5_save_flags ); // Restore CCR's
0N/A
0N/A save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
0N/A
0N/A // stop_subroutine expects message pointer in I1.
0N/A mov(I1, O1);
0N/A
0N/A // Restore prior 64-bit registers
0N/A ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+0*8,I0);
0N/A ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+1*8,I1);
0N/A ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+2*8,I2);
0N/A ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+3*8,I3);
0N/A ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+4*8,I4);
0N/A ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+5*8,I5);
0N/A
0N/A // factor long stop-sequence into subroutine to save space
0N/A assert(StubRoutines::Sparc::stop_subroutine_entry_address(), "hasn't been generated yet");
0N/A
0N/A // call indirectly to solve generation ordering problem
727N/A AddressLiteral al(StubRoutines::Sparc::stop_subroutine_entry_address());
727N/A load_ptr_contents(al, O5);
0N/A jmpl(O5, 0, O7);
0N/A delayed()->nop();
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::stop(const char* msg) {
0N/A // save frame first to get O7 for return address
0N/A // add one word to size in case struct is odd number of words long
0N/A // It must be doubleword-aligned for storing doubles into it.
0N/A
0N/A save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
0N/A
0N/A // stop_subroutine expects message pointer in I1.
0N/A set((intptr_t)msg, O1);
0N/A
0N/A // factor long stop-sequence into subroutine to save space
0N/A assert(StubRoutines::Sparc::stop_subroutine_entry_address(), "hasn't been generated yet");
0N/A
0N/A // call indirectly to solve generation ordering problem
727N/A AddressLiteral a(StubRoutines::Sparc::stop_subroutine_entry_address());
0N/A load_ptr_contents(a, O5);
0N/A jmpl(O5, 0, O7);
0N/A delayed()->nop();
0N/A
0N/A breakpoint_trap(); // make stop actually stop rather than writing
0N/A // unnoticeable results in the output files.
0N/A
0N/A // restore(); done in callee to save space!
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::warn(const char* msg) {
0N/A save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
0N/A RegistersForDebugging::save_registers(this);
0N/A mov(O0, L0);
0N/A set((intptr_t)msg, O0);
0N/A call( CAST_FROM_FN_PTR(address, warning) );
0N/A delayed()->nop();
0N/A// ret();
0N/A// delayed()->restore();
0N/A RegistersForDebugging::restore_registers(this, L0);
0N/A restore();
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::untested(const char* what) {
0N/A // We must be able to turn interactive prompting off
0N/A // in order to run automated test scripts on the VM
0N/A // Use the flag ShowMessageBoxOnError
0N/A
0N/A char* b = new char[1024];
0N/A sprintf(b, "untested: %s", what);
0N/A
0N/A if ( ShowMessageBoxOnError ) stop(b);
0N/A else warn(b);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::stop_subroutine() {
0N/A RegistersForDebugging::save_registers(this);
0N/A
0N/A // for the sake of the debugger, stick a PC on the current frame
0N/A // (this assumes that the caller has performed an extra "save")
0N/A mov(I7, L7);
0N/A add(O7, -7 * BytesPerInt, I7);
0N/A
0N/A save_frame(); // one more save to free up another O7 register
0N/A mov(I0, O1); // addr of reg save area
0N/A
0N/A // We expect pointer to message in I1. Caller must set it up in O1
0N/A mov(I1, O0); // get msg
0N/A call (CAST_FROM_FN_PTR(address, MacroAssembler::debug), relocInfo::runtime_call_type);
0N/A delayed()->nop();
0N/A
0N/A restore();
0N/A
0N/A RegistersForDebugging::restore_registers(this, O0);
0N/A
0N/A save_frame(0);
0N/A call(CAST_FROM_FN_PTR(address,breakpoint));
0N/A delayed()->nop();
0N/A restore();
0N/A
0N/A mov(L7, I7);
0N/A retl();
0N/A delayed()->restore(); // see stop above
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::debug(char* msg, RegistersForDebugging* regs) {
0N/A if ( ShowMessageBoxOnError ) {
0N/A JavaThreadState saved_state = JavaThread::current()->thread_state();
0N/A JavaThread::current()->set_thread_state(_thread_in_vm);
0N/A {
0N/A // In order to get locks work, we need to fake a in_VM state
0N/A ttyLocker ttyl;
0N/A ::tty->print_cr("EXECUTION STOPPED: %s\n", msg);
0N/A if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
0N/A ::tty->print_cr("Interpreter::bytecode_counter = %d", BytecodeCounter::counter_value());
0N/A }
0N/A if (os::message_box(msg, "Execution stopped, print registers?"))
0N/A regs->print(::tty);
0N/A }
0N/A ThreadStateTransition::transition(JavaThread::current(), _thread_in_vm, saved_state);
0N/A }
0N/A else
0N/A ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
0N/A assert(false, "error");
0N/A}
0N/A
0N/A
0N/A#ifndef PRODUCT
0N/Avoid MacroAssembler::test() {
0N/A ResourceMark rm;
0N/A
0N/A CodeBuffer cb("test", 10000, 10000);
0N/A MacroAssembler* a = new MacroAssembler(&cb);
0N/A VM_Version::allow_all();
0N/A a->test_v9();
0N/A a->test_v8_onlys();
0N/A VM_Version::revert();
0N/A
0N/A StubRoutines::Sparc::test_stop_entry()();
0N/A}
0N/A#endif
0N/A
0N/A
0N/Avoid MacroAssembler::calc_mem_param_words(Register Rparam_words, Register Rresult) {
0N/A subcc( Rparam_words, Argument::n_register_parameters, Rresult); // how many mem words?
0N/A Label no_extras;
0N/A br( negative, true, pt, no_extras ); // if neg, clear reg
727N/A delayed()->set(0, Rresult); // annuled, so only if taken
0N/A bind( no_extras );
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::calc_frame_size(Register Rextra_words, Register Rresult) {
0N/A#ifdef _LP64
0N/A add(Rextra_words, frame::memory_parameter_word_sp_offset, Rresult);
0N/A#else
0N/A add(Rextra_words, frame::memory_parameter_word_sp_offset + 1, Rresult);
0N/A#endif
0N/A bclr(1, Rresult);
0N/A sll(Rresult, LogBytesPerWord, Rresult); // Rresult has total frame bytes
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::calc_frame_size_and_save(Register Rextra_words, Register Rresult) {
0N/A calc_frame_size(Rextra_words, Rresult);
0N/A neg(Rresult);
0N/A save(SP, Rresult, SP);
0N/A}
0N/A
0N/A
0N/A// ---------------------------------------------------------
0N/AAssembler::RCondition cond2rcond(Assembler::Condition c) {
0N/A switch (c) {
0N/A /*case zero: */
0N/A case Assembler::equal: return Assembler::rc_z;
0N/A case Assembler::lessEqual: return Assembler::rc_lez;
0N/A case Assembler::less: return Assembler::rc_lz;
0N/A /*case notZero:*/
0N/A case Assembler::notEqual: return Assembler::rc_nz;
0N/A case Assembler::greater: return Assembler::rc_gz;
0N/A case Assembler::greaterEqual: return Assembler::rc_gez;
0N/A }
0N/A ShouldNotReachHere();
0N/A return Assembler::rc_z;
0N/A}
0N/A
0N/A// compares register with zero and branches. NOT FOR USE WITH 64-bit POINTERS
0N/Avoid MacroAssembler::br_zero( Condition c, bool a, Predict p, Register s1, Label& L) {
0N/A tst(s1);
0N/A br (c, a, p, L);
0N/A}
0N/A
0N/A
0N/A// Compares a pointer register with zero and branches on null.
0N/A// Does a test & branch on 32-bit systems and a register-branch on 64-bit.
0N/Avoid MacroAssembler::br_null( Register s1, bool a, Predict p, Label& L ) {
0N/A assert_not_delayed();
0N/A#ifdef _LP64
0N/A bpr( rc_z, a, p, s1, L );
0N/A#else
0N/A tst(s1);
0N/A br ( zero, a, p, L );
0N/A#endif
0N/A}
0N/A
0N/Avoid MacroAssembler::br_notnull( Register s1, bool a, Predict p, Label& L ) {
0N/A assert_not_delayed();
0N/A#ifdef _LP64
0N/A bpr( rc_nz, a, p, s1, L );
0N/A#else
0N/A tst(s1);
0N/A br ( notZero, a, p, L );
0N/A#endif
0N/A}
0N/A
342N/Avoid MacroAssembler::br_on_reg_cond( RCondition rc, bool a, Predict p,
342N/A Register s1, address d,
342N/A relocInfo::relocType rt ) {
342N/A if (VM_Version::v9_instructions_work()) {
342N/A bpr(rc, a, p, s1, d, rt);
342N/A } else {
342N/A tst(s1);
342N/A br(reg_cond_to_cc_cond(rc), a, p, d, rt);
342N/A }
342N/A}
342N/A
342N/Avoid MacroAssembler::br_on_reg_cond( RCondition rc, bool a, Predict p,
342N/A Register s1, Label& L ) {
342N/A if (VM_Version::v9_instructions_work()) {
342N/A bpr(rc, a, p, s1, L);
342N/A } else {
342N/A tst(s1);
342N/A br(reg_cond_to_cc_cond(rc), a, p, L);
342N/A }
342N/A}
342N/A
0N/A
0N/A// instruction sequences factored across compiler & interpreter
0N/A
0N/A
0N/Avoid MacroAssembler::lcmp( Register Ra_hi, Register Ra_low,
0N/A Register Rb_hi, Register Rb_low,
0N/A Register Rresult) {
0N/A
0N/A Label check_low_parts, done;
0N/A
0N/A cmp(Ra_hi, Rb_hi ); // compare hi parts
0N/A br(equal, true, pt, check_low_parts);
0N/A delayed()->cmp(Ra_low, Rb_low); // test low parts
0N/A
0N/A // And, with an unsigned comparison, it does not matter if the numbers
0N/A // are negative or not.
0N/A // E.g., -2 cmp -1: the low parts are 0xfffffffe and 0xffffffff.
0N/A // The second one is bigger (unsignedly).
0N/A
0N/A // Other notes: The first move in each triplet can be unconditional
0N/A // (and therefore probably prefetchable).
0N/A // And the equals case for the high part does not need testing,
0N/A // since that triplet is reached only after finding the high halves differ.
0N/A
0N/A if (VM_Version::v9_instructions_work()) {
0N/A
0N/A mov ( -1, Rresult);
0N/A ba( false, done ); delayed()-> movcc(greater, false, icc, 1, Rresult);
0N/A }
0N/A else {
0N/A br(less, true, pt, done); delayed()-> set(-1, Rresult);
0N/A br(greater, true, pt, done); delayed()-> set( 1, Rresult);
0N/A }
0N/A
0N/A bind( check_low_parts );
0N/A
0N/A if (VM_Version::v9_instructions_work()) {
0N/A mov( -1, Rresult);
0N/A movcc(equal, false, icc, 0, Rresult);
0N/A movcc(greaterUnsigned, false, icc, 1, Rresult);
0N/A }
0N/A else {
0N/A set(-1, Rresult);
0N/A br(equal, true, pt, done); delayed()->set( 0, Rresult);
0N/A br(greaterUnsigned, true, pt, done); delayed()->set( 1, Rresult);
0N/A }
0N/A bind( done );
0N/A}
0N/A
0N/Avoid MacroAssembler::lneg( Register Rhi, Register Rlow ) {
0N/A subcc( G0, Rlow, Rlow );
0N/A subc( G0, Rhi, Rhi );
0N/A}
0N/A
0N/Avoid MacroAssembler::lshl( Register Rin_high, Register Rin_low,
0N/A Register Rcount,
0N/A Register Rout_high, Register Rout_low,
0N/A Register Rtemp ) {
0N/A
0N/A
0N/A Register Ralt_count = Rtemp;
0N/A Register Rxfer_bits = Rtemp;
0N/A
0N/A assert( Ralt_count != Rin_high
0N/A && Ralt_count != Rin_low
0N/A && Ralt_count != Rcount
0N/A && Rxfer_bits != Rin_low
0N/A && Rxfer_bits != Rin_high
0N/A && Rxfer_bits != Rcount
0N/A && Rxfer_bits != Rout_low
0N/A && Rout_low != Rin_high,
0N/A "register alias checks");
0N/A
0N/A Label big_shift, done;
0N/A
0N/A // This code can be optimized to use the 64 bit shifts in V9.
0N/A // Here we use the 32 bit shifts.
0N/A
0N/A and3( Rcount, 0x3f, Rcount); // take least significant 6 bits
0N/A subcc(Rcount, 31, Ralt_count);
0N/A br(greater, true, pn, big_shift);
0N/A delayed()->
0N/A dec(Ralt_count);
0N/A
0N/A // shift < 32 bits, Ralt_count = Rcount-31
0N/A
0N/A // We get the transfer bits by shifting right by 32-count the low
0N/A // register. This is done by shifting right by 31-count and then by one
0N/A // more to take care of the special (rare) case where count is zero
0N/A // (shifting by 32 would not work).
0N/A
0N/A neg( Ralt_count );
0N/A
0N/A // The order of the next two instructions is critical in the case where
0N/A // Rin and Rout are the same and should not be reversed.
0N/A
0N/A srl( Rin_low, Ralt_count, Rxfer_bits ); // shift right by 31-count
0N/A if (Rcount != Rout_low) {
0N/A sll( Rin_low, Rcount, Rout_low ); // low half
0N/A }
0N/A sll( Rin_high, Rcount, Rout_high );
0N/A if (Rcount == Rout_low) {
0N/A sll( Rin_low, Rcount, Rout_low ); // low half
0N/A }
0N/A srl( Rxfer_bits, 1, Rxfer_bits ); // shift right by one more
0N/A ba (false, done);
0N/A delayed()->
0N/A or3( Rout_high, Rxfer_bits, Rout_high); // new hi value: or in shifted old hi part and xfer from low
0N/A
0N/A // shift >= 32 bits, Ralt_count = Rcount-32
0N/A bind(big_shift);
0N/A sll( Rin_low, Ralt_count, Rout_high );
0N/A clr( Rout_low );
0N/A
0N/A bind(done);
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::lshr( Register Rin_high, Register Rin_low,
0N/A Register Rcount,
0N/A Register Rout_high, Register Rout_low,
0N/A Register Rtemp ) {
0N/A
0N/A Register Ralt_count = Rtemp;
0N/A Register Rxfer_bits = Rtemp;
0N/A
0N/A assert( Ralt_count != Rin_high
0N/A && Ralt_count != Rin_low
0N/A && Ralt_count != Rcount
0N/A && Rxfer_bits != Rin_low
0N/A && Rxfer_bits != Rin_high
0N/A && Rxfer_bits != Rcount
0N/A && Rxfer_bits != Rout_high
0N/A && Rout_high != Rin_low,
0N/A "register alias checks");
0N/A
0N/A Label big_shift, done;
0N/A
0N/A // This code can be optimized to use the 64 bit shifts in V9.
0N/A // Here we use the 32 bit shifts.
0N/A
0N/A and3( Rcount, 0x3f, Rcount); // take least significant 6 bits
0N/A subcc(Rcount, 31, Ralt_count);
0N/A br(greater, true, pn, big_shift);
0N/A delayed()->dec(Ralt_count);
0N/A
0N/A // shift < 32 bits, Ralt_count = Rcount-31
0N/A
0N/A // We get the transfer bits by shifting left by 32-count the high
0N/A // register. This is done by shifting left by 31-count and then by one
0N/A // more to take care of the special (rare) case where count is zero
0N/A // (shifting by 32 would not work).
0N/A
0N/A neg( Ralt_count );
0N/A if (Rcount != Rout_low) {
0N/A srl( Rin_low, Rcount, Rout_low );
0N/A }
0N/A
0N/A // The order of the next two instructions is critical in the case where
0N/A // Rin and Rout are the same and should not be reversed.
0N/A
0N/A sll( Rin_high, Ralt_count, Rxfer_bits ); // shift left by 31-count
0N/A sra( Rin_high, Rcount, Rout_high ); // high half
0N/A sll( Rxfer_bits, 1, Rxfer_bits ); // shift left by one more
0N/A if (Rcount == Rout_low) {
0N/A srl( Rin_low, Rcount, Rout_low );
0N/A }
0N/A ba (false, done);
0N/A delayed()->
0N/A or3( Rout_low, Rxfer_bits, Rout_low ); // new low value: or shifted old low part and xfer from high
0N/A
0N/A // shift >= 32 bits, Ralt_count = Rcount-32
0N/A bind(big_shift);
0N/A
0N/A sra( Rin_high, Ralt_count, Rout_low );
0N/A sra( Rin_high, 31, Rout_high ); // sign into hi
0N/A
0N/A bind( done );
0N/A}
0N/A
0N/A
0N/A
0N/Avoid MacroAssembler::lushr( Register Rin_high, Register Rin_low,
0N/A Register Rcount,
0N/A Register Rout_high, Register Rout_low,
0N/A Register Rtemp ) {
0N/A
0N/A Register Ralt_count = Rtemp;
0N/A Register Rxfer_bits = Rtemp;
0N/A
0N/A assert( Ralt_count != Rin_high
0N/A && Ralt_count != Rin_low
0N/A && Ralt_count != Rcount
0N/A && Rxfer_bits != Rin_low
0N/A && Rxfer_bits != Rin_high
0N/A && Rxfer_bits != Rcount
0N/A && Rxfer_bits != Rout_high
0N/A && Rout_high != Rin_low,
0N/A "register alias checks");
0N/A
0N/A Label big_shift, done;
0N/A
0N/A // This code can be optimized to use the 64 bit shifts in V9.
0N/A // Here we use the 32 bit shifts.
0N/A
0N/A and3( Rcount, 0x3f, Rcount); // take least significant 6 bits
0N/A subcc(Rcount, 31, Ralt_count);
0N/A br(greater, true, pn, big_shift);
0N/A delayed()->dec(Ralt_count);
0N/A
0N/A // shift < 32 bits, Ralt_count = Rcount-31
0N/A
0N/A // We get the transfer bits by shifting left by 32-count the high
0N/A // register. This is done by shifting left by 31-count and then by one
0N/A // more to take care of the special (rare) case where count is zero
0N/A // (shifting by 32 would not work).
0N/A
0N/A neg( Ralt_count );
0N/A if (Rcount != Rout_low) {
0N/A srl( Rin_low, Rcount, Rout_low );
0N/A }
0N/A
0N/A // The order of the next two instructions is critical in the case where
0N/A // Rin and Rout are the same and should not be reversed.
0N/A
0N/A sll( Rin_high, Ralt_count, Rxfer_bits ); // shift left by 31-count
0N/A srl( Rin_high, Rcount, Rout_high ); // high half
0N/A sll( Rxfer_bits, 1, Rxfer_bits ); // shift left by one more
0N/A if (Rcount == Rout_low) {
0N/A srl( Rin_low, Rcount, Rout_low );
0N/A }
0N/A ba (false, done);
0N/A delayed()->
0N/A or3( Rout_low, Rxfer_bits, Rout_low ); // new low value: or shifted old low part and xfer from high
0N/A
0N/A // shift >= 32 bits, Ralt_count = Rcount-32
0N/A bind(big_shift);
0N/A
0N/A srl( Rin_high, Ralt_count, Rout_low );
0N/A clr( Rout_high );
0N/A
0N/A bind( done );
0N/A}
0N/A
0N/A#ifdef _LP64
0N/Avoid MacroAssembler::lcmp( Register Ra, Register Rb, Register Rresult) {
0N/A cmp(Ra, Rb);
0N/A mov( -1, Rresult);
0N/A movcc(equal, false, xcc, 0, Rresult);
0N/A movcc(greater, false, xcc, 1, Rresult);
0N/A}
0N/A#endif
0N/A
0N/A
1423N/Avoid MacroAssembler::load_sized_value(Address src, Register dst,
1423N/A size_t size_in_bytes, bool is_signed) {
1423N/A switch (size_in_bytes) {
1423N/A case 8: ldx(src, dst); break;
1423N/A case 4: ld( src, dst); break;
1423N/A case 2: is_signed ? ldsh(src, dst) : lduh(src, dst); break;
1423N/A case 1: is_signed ? ldsb(src, dst) : ldub(src, dst); break;
1423N/A default: ShouldNotReachHere();
1423N/A }
1423N/A}
1423N/A
1423N/A
0N/Avoid MacroAssembler::float_cmp( bool is_float, int unordered_result,
0N/A FloatRegister Fa, FloatRegister Fb,
0N/A Register Rresult) {
0N/A
0N/A fcmp(is_float ? FloatRegisterImpl::S : FloatRegisterImpl::D, fcc0, Fa, Fb);
0N/A
0N/A Condition lt = unordered_result == -1 ? f_unorderedOrLess : f_less;
0N/A Condition eq = f_equal;
0N/A Condition gt = unordered_result == 1 ? f_unorderedOrGreater : f_greater;
0N/A
0N/A if (VM_Version::v9_instructions_work()) {
0N/A
0N/A mov( -1, Rresult );
0N/A movcc( eq, true, fcc0, 0, Rresult );
0N/A movcc( gt, true, fcc0, 1, Rresult );
0N/A
0N/A } else {
0N/A Label done;
0N/A
0N/A set( -1, Rresult );
0N/A //fb(lt, true, pn, done); delayed()->set( -1, Rresult );
0N/A fb( eq, true, pn, done); delayed()->set( 0, Rresult );
0N/A fb( gt, true, pn, done); delayed()->set( 1, Rresult );
0N/A
0N/A bind (done);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::fneg( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d)
0N/A{
0N/A if (VM_Version::v9_instructions_work()) {
0N/A Assembler::fneg(w, s, d);
0N/A } else {
0N/A if (w == FloatRegisterImpl::S) {
0N/A Assembler::fneg(w, s, d);
0N/A } else if (w == FloatRegisterImpl::D) {
0N/A // number() does a sanity check on the alignment.
0N/A assert(((s->encoding(FloatRegisterImpl::D) & 1) == 0) &&
0N/A ((d->encoding(FloatRegisterImpl::D) & 1) == 0), "float register alignment check");
0N/A
0N/A Assembler::fneg(FloatRegisterImpl::S, s, d);
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
0N/A } else {
0N/A assert(w == FloatRegisterImpl::Q, "Invalid float register width");
0N/A
0N/A // number() does a sanity check on the alignment.
0N/A assert(((s->encoding(FloatRegisterImpl::D) & 3) == 0) &&
0N/A ((d->encoding(FloatRegisterImpl::D) & 3) == 0), "float register alignment check");
0N/A
0N/A Assembler::fneg(FloatRegisterImpl::S, s, d);
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor(), d->successor()->successor());
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor()->successor(), d->successor()->successor()->successor());
0N/A }
0N/A }
0N/A}
0N/A
0N/Avoid MacroAssembler::fmov( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d)
0N/A{
0N/A if (VM_Version::v9_instructions_work()) {
0N/A Assembler::fmov(w, s, d);
0N/A } else {
0N/A if (w == FloatRegisterImpl::S) {
0N/A Assembler::fmov(w, s, d);
0N/A } else if (w == FloatRegisterImpl::D) {
0N/A // number() does a sanity check on the alignment.
0N/A assert(((s->encoding(FloatRegisterImpl::D) & 1) == 0) &&
0N/A ((d->encoding(FloatRegisterImpl::D) & 1) == 0), "float register alignment check");
0N/A
0N/A Assembler::fmov(FloatRegisterImpl::S, s, d);
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
0N/A } else {
0N/A assert(w == FloatRegisterImpl::Q, "Invalid float register width");
0N/A
0N/A // number() does a sanity check on the alignment.
0N/A assert(((s->encoding(FloatRegisterImpl::D) & 3) == 0) &&
0N/A ((d->encoding(FloatRegisterImpl::D) & 3) == 0), "float register alignment check");
0N/A
0N/A Assembler::fmov(FloatRegisterImpl::S, s, d);
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor(), d->successor()->successor());
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor()->successor(), d->successor()->successor()->successor());
0N/A }
0N/A }
0N/A}
0N/A
0N/Avoid MacroAssembler::fabs( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d)
0N/A{
0N/A if (VM_Version::v9_instructions_work()) {
0N/A Assembler::fabs(w, s, d);
0N/A } else {
0N/A if (w == FloatRegisterImpl::S) {
0N/A Assembler::fabs(w, s, d);
0N/A } else if (w == FloatRegisterImpl::D) {
0N/A // number() does a sanity check on the alignment.
0N/A assert(((s->encoding(FloatRegisterImpl::D) & 1) == 0) &&
0N/A ((d->encoding(FloatRegisterImpl::D) & 1) == 0), "float register alignment check");
0N/A
0N/A Assembler::fabs(FloatRegisterImpl::S, s, d);
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
0N/A } else {
0N/A assert(w == FloatRegisterImpl::Q, "Invalid float register width");
0N/A
0N/A // number() does a sanity check on the alignment.
0N/A assert(((s->encoding(FloatRegisterImpl::D) & 3) == 0) &&
0N/A ((d->encoding(FloatRegisterImpl::D) & 3) == 0), "float register alignment check");
0N/A
0N/A Assembler::fabs(FloatRegisterImpl::S, s, d);
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor(), d->successor()->successor());
0N/A Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor()->successor(), d->successor()->successor()->successor());
0N/A }
0N/A }
0N/A}
0N/A
0N/Avoid MacroAssembler::save_all_globals_into_locals() {
0N/A mov(G1,L1);
0N/A mov(G2,L2);
0N/A mov(G3,L3);
0N/A mov(G4,L4);
0N/A mov(G5,L5);
0N/A mov(G6,L6);
0N/A mov(G7,L7);
0N/A}
0N/A
0N/Avoid MacroAssembler::restore_globals_from_locals() {
0N/A mov(L1,G1);
0N/A mov(L2,G2);
0N/A mov(L3,G3);
0N/A mov(L4,G4);
0N/A mov(L5,G5);
0N/A mov(L6,G6);
0N/A mov(L7,G7);
0N/A}
0N/A
0N/A// Use for 64 bit operation.
0N/Avoid MacroAssembler::casx_under_lock(Register top_ptr_reg, Register top_reg, Register ptr_reg, address lock_addr, bool use_call_vm)
0N/A{
0N/A // store ptr_reg as the new top value
0N/A#ifdef _LP64
0N/A casx(top_ptr_reg, top_reg, ptr_reg);
0N/A#else
0N/A cas_under_lock(top_ptr_reg, top_reg, ptr_reg, lock_addr, use_call_vm);
0N/A#endif // _LP64
0N/A}
0N/A
0N/A// [RGV] This routine does not handle 64 bit operations.
0N/A// use casx_under_lock() or casx directly!!!
0N/Avoid MacroAssembler::cas_under_lock(Register top_ptr_reg, Register top_reg, Register ptr_reg, address lock_addr, bool use_call_vm)
0N/A{
0N/A // store ptr_reg as the new top value
0N/A if (VM_Version::v9_instructions_work()) {
0N/A cas(top_ptr_reg, top_reg, ptr_reg);
0N/A } else {
0N/A
0N/A // If the register is not an out nor global, it is not visible
0N/A // after the save. Allocate a register for it, save its
0N/A // value in the register save area (the save may not flush
0N/A // registers to the save area).
0N/A
0N/A Register top_ptr_reg_after_save;
0N/A Register top_reg_after_save;
0N/A Register ptr_reg_after_save;
0N/A
0N/A if (top_ptr_reg->is_out() || top_ptr_reg->is_global()) {
0N/A top_ptr_reg_after_save = top_ptr_reg->after_save();
0N/A } else {
0N/A Address reg_save_addr = top_ptr_reg->address_in_saved_window();
0N/A top_ptr_reg_after_save = L0;
0N/A st(top_ptr_reg, reg_save_addr);
0N/A }
0N/A
0N/A if (top_reg->is_out() || top_reg->is_global()) {
0N/A top_reg_after_save = top_reg->after_save();
0N/A } else {
0N/A Address reg_save_addr = top_reg->address_in_saved_window();
0N/A top_reg_after_save = L1;
0N/A st(top_reg, reg_save_addr);
0N/A }
0N/A
0N/A if (ptr_reg->is_out() || ptr_reg->is_global()) {
0N/A ptr_reg_after_save = ptr_reg->after_save();
0N/A } else {
0N/A Address reg_save_addr = ptr_reg->address_in_saved_window();
0N/A ptr_reg_after_save = L2;
0N/A st(ptr_reg, reg_save_addr);
0N/A }
0N/A
0N/A const Register& lock_reg = L3;
0N/A const Register& lock_ptr_reg = L4;
0N/A const Register& value_reg = L5;
0N/A const Register& yield_reg = L6;
0N/A const Register& yieldall_reg = L7;
0N/A
0N/A save_frame();
0N/A
0N/A if (top_ptr_reg_after_save == L0) {
0N/A ld(top_ptr_reg->address_in_saved_window().after_save(), top_ptr_reg_after_save);
0N/A }
0N/A
0N/A if (top_reg_after_save == L1) {
0N/A ld(top_reg->address_in_saved_window().after_save(), top_reg_after_save);
0N/A }
0N/A
0N/A if (ptr_reg_after_save == L2) {
0N/A ld(ptr_reg->address_in_saved_window().after_save(), ptr_reg_after_save);
0N/A }
0N/A
0N/A Label(retry_get_lock);
0N/A Label(not_same);
0N/A Label(dont_yield);
0N/A
0N/A assert(lock_addr, "lock_address should be non null for v8");
0N/A set((intptr_t)lock_addr, lock_ptr_reg);
0N/A // Initialize yield counter
0N/A mov(G0,yield_reg);
0N/A mov(G0, yieldall_reg);
0N/A set(StubRoutines::Sparc::locked, lock_reg);
0N/A
0N/A bind(retry_get_lock);
0N/A cmp(yield_reg, V8AtomicOperationUnderLockSpinCount);
0N/A br(Assembler::less, false, Assembler::pt, dont_yield);
0N/A delayed()->nop();
0N/A
0N/A if(use_call_vm) {
0N/A Untested("Need to verify global reg consistancy");
0N/A call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::yield_all), yieldall_reg);
0N/A } else {
0N/A // Save the regs and make space for a C call
0N/A save(SP, -96, SP);
0N/A save_all_globals_into_locals();
0N/A call(CAST_FROM_FN_PTR(address,os::yield_all));
0N/A delayed()->mov(yieldall_reg, O0);
0N/A restore_globals_from_locals();
0N/A restore();
0N/A }
0N/A
0N/A // reset the counter
0N/A mov(G0,yield_reg);
0N/A add(yieldall_reg, 1, yieldall_reg);
0N/A
0N/A bind(dont_yield);
0N/A // try to get lock
0N/A swap(lock_ptr_reg, 0, lock_reg);
0N/A
0N/A // did we get the lock?
0N/A cmp(lock_reg, StubRoutines::Sparc::unlocked);
0N/A br(Assembler::notEqual, true, Assembler::pn, retry_get_lock);
0N/A delayed()->add(yield_reg,1,yield_reg);
0N/A
0N/A // yes, got lock. do we have the same top?
0N/A ld(top_ptr_reg_after_save, 0, value_reg);
0N/A cmp(value_reg, top_reg_after_save);
0N/A br(Assembler::notEqual, false, Assembler::pn, not_same);
0N/A delayed()->nop();
0N/A
0N/A // yes, same top.
0N/A st(ptr_reg_after_save, top_ptr_reg_after_save, 0);
0N/A membar(Assembler::StoreStore);
0N/A
0N/A bind(not_same);
0N/A mov(value_reg, ptr_reg_after_save);
0N/A st(lock_reg, lock_ptr_reg, 0); // unlock
0N/A
0N/A restore();
0N/A }
0N/A}
0N/A
665N/ARegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
665N/A Register tmp,
665N/A int offset) {
622N/A intptr_t value = *delayed_value_addr;
622N/A if (value != 0)
665N/A return RegisterOrConstant(value + offset);
622N/A
622N/A // load indirectly to solve generation ordering problem
727N/A AddressLiteral a(delayed_value_addr);
622N/A load_ptr_contents(a, tmp);
622N/A
622N/A#ifdef ASSERT
622N/A tst(tmp);
622N/A breakpoint_trap(zero, xcc);
622N/A#endif
622N/A
622N/A if (offset != 0)
622N/A add(tmp, offset, tmp);
622N/A
665N/A return RegisterOrConstant(tmp);
622N/A}
622N/A
622N/A
1423N/ARegisterOrConstant MacroAssembler::regcon_andn_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
1423N/A assert(d.register_or_noreg() != G0, "lost side effect");
1423N/A if ((s2.is_constant() && s2.as_constant() == 0) ||
1423N/A (s2.is_register() && s2.as_register() == G0)) {
1423N/A // Do nothing, just move value.
1423N/A if (s1.is_register()) {
1423N/A if (d.is_constant()) d = temp;
1423N/A mov(s1.as_register(), d.as_register());
1423N/A return d;
1423N/A } else {
1423N/A return s1;
1423N/A }
1423N/A }
1423N/A
1423N/A if (s1.is_register()) {
1423N/A assert_different_registers(s1.as_register(), temp);
1423N/A if (d.is_constant()) d = temp;
1423N/A andn(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
1423N/A return d;
623N/A } else {
1423N/A if (s2.is_register()) {
1423N/A assert_different_registers(s2.as_register(), temp);
1423N/A if (d.is_constant()) d = temp;
1423N/A set(s1.as_constant(), temp);
1423N/A andn(temp, s2.as_register(), d.as_register());
1423N/A return d;
1423N/A } else {
1423N/A intptr_t res = s1.as_constant() & ~s2.as_constant();
1423N/A return res;
1423N/A }
623N/A }
623N/A}
623N/A
1423N/ARegisterOrConstant MacroAssembler::regcon_inc_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
1423N/A assert(d.register_or_noreg() != G0, "lost side effect");
1423N/A if ((s2.is_constant() && s2.as_constant() == 0) ||
1423N/A (s2.is_register() && s2.as_register() == G0)) {
1423N/A // Do nothing, just move value.
1423N/A if (s1.is_register()) {
1423N/A if (d.is_constant()) d = temp;
1423N/A mov(s1.as_register(), d.as_register());
1423N/A return d;
1423N/A } else {
1423N/A return s1;
1423N/A }
1423N/A }
1423N/A
1423N/A if (s1.is_register()) {
1423N/A assert_different_registers(s1.as_register(), temp);
1423N/A if (d.is_constant()) d = temp;
1423N/A add(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
1423N/A return d;
623N/A } else {
1423N/A if (s2.is_register()) {
1423N/A assert_different_registers(s2.as_register(), temp);
1423N/A if (d.is_constant()) d = temp;
1423N/A add(s2.as_register(), ensure_simm13_or_reg(s1, temp), d.as_register());
1423N/A return d;
1423N/A } else {
1423N/A intptr_t res = s1.as_constant() + s2.as_constant();
1423N/A return res;
1423N/A }
1423N/A }
1423N/A}
1423N/A
1423N/ARegisterOrConstant MacroAssembler::regcon_sll_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
1423N/A assert(d.register_or_noreg() != G0, "lost side effect");
1423N/A if (!is_simm13(s2.constant_or_zero()))
1423N/A s2 = (s2.as_constant() & 0xFF);
1423N/A if ((s2.is_constant() && s2.as_constant() == 0) ||
1423N/A (s2.is_register() && s2.as_register() == G0)) {
1423N/A // Do nothing, just move value.
1423N/A if (s1.is_register()) {
1423N/A if (d.is_constant()) d = temp;
1423N/A mov(s1.as_register(), d.as_register());
1423N/A return d;
1423N/A } else {
1423N/A return s1;
1423N/A }
1423N/A }
1423N/A
1423N/A if (s1.is_register()) {
1423N/A assert_different_registers(s1.as_register(), temp);
1423N/A if (d.is_constant()) d = temp;
1423N/A sll_ptr(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
1423N/A return d;
1423N/A } else {
1423N/A if (s2.is_register()) {
1423N/A assert_different_registers(s2.as_register(), temp);
1423N/A if (d.is_constant()) d = temp;
1423N/A set(s1.as_constant(), temp);
1423N/A sll_ptr(temp, s2.as_register(), d.as_register());
1423N/A return d;
1423N/A } else {
1423N/A intptr_t res = s1.as_constant() << s2.as_constant();
1423N/A return res;
1423N/A }
623N/A }
623N/A}
623N/A
623N/A
623N/A// Look up the method for a megamorphic invokeinterface call.
623N/A// The target method is determined by <intf_klass, itable_index>.
623N/A// The receiver klass is in recv_klass.
623N/A// On success, the result will be in method_result, and execution falls through.
623N/A// On failure, execution transfers to the given label.
623N/Avoid MacroAssembler::lookup_interface_method(Register recv_klass,
623N/A Register intf_klass,
665N/A RegisterOrConstant itable_index,
623N/A Register method_result,
623N/A Register scan_temp,
623N/A Register sethi_temp,
623N/A Label& L_no_such_interface) {
623N/A assert_different_registers(recv_klass, intf_klass, method_result, scan_temp);
623N/A assert(itable_index.is_constant() || itable_index.as_register() == method_result,
623N/A "caller must use same register for non-constant itable index as for method");
623N/A
623N/A // Compute start of first itableOffsetEntry (which is at the end of the vtable)
623N/A int vtable_base = instanceKlass::vtable_start_offset() * wordSize;
623N/A int scan_step = itableOffsetEntry::size() * wordSize;
623N/A int vte_size = vtableEntry::size() * wordSize;
623N/A
623N/A lduw(recv_klass, instanceKlass::vtable_length_offset() * wordSize, scan_temp);
623N/A // %%% We should store the aligned, prescaled offset in the klassoop.
623N/A // Then the next several instructions would fold away.
623N/A
623N/A int round_to_unit = ((HeapWordsPerLong > 1) ? BytesPerLong : 0);
623N/A int itb_offset = vtable_base;
623N/A if (round_to_unit != 0) {
623N/A // hoist first instruction of round_to(scan_temp, BytesPerLong):
623N/A itb_offset += round_to_unit - wordSize;
623N/A }
623N/A int itb_scale = exact_log2(vtableEntry::size() * wordSize);
623N/A sll(scan_temp, itb_scale, scan_temp);
623N/A add(scan_temp, itb_offset, scan_temp);
623N/A if (round_to_unit != 0) {
623N/A // Round up to align_object_offset boundary
623N/A // see code for instanceKlass::start_of_itable!
623N/A // Was: round_to(scan_temp, BytesPerLong);
623N/A // Hoisted: add(scan_temp, BytesPerLong-1, scan_temp);
623N/A and3(scan_temp, -round_to_unit, scan_temp);
623N/A }
623N/A add(recv_klass, scan_temp, scan_temp);
623N/A
623N/A // Adjust recv_klass by scaled itable_index, so we can free itable_index.
665N/A RegisterOrConstant itable_offset = itable_index;
1423N/A itable_offset = regcon_sll_ptr(itable_index, exact_log2(itableMethodEntry::size() * wordSize), itable_offset);
1423N/A itable_offset = regcon_inc_ptr(itable_offset, itableMethodEntry::method_offset_in_bytes(), itable_offset);
1006N/A add(recv_klass, ensure_simm13_or_reg(itable_offset, sethi_temp), recv_klass);
623N/A
623N/A // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
623N/A // if (scan->interface() == intf) {
623N/A // result = (klass + scan->offset() + itable_index);
623N/A // }
623N/A // }
623N/A Label search, found_method;
623N/A
623N/A for (int peel = 1; peel >= 0; peel--) {
623N/A // %%%% Could load both offset and interface in one ldx, if they were
623N/A // in the opposite order. This would save a load.
623N/A ld_ptr(scan_temp, itableOffsetEntry::interface_offset_in_bytes(), method_result);
623N/A
623N/A // Check that this entry is non-null. A null entry means that
623N/A // the receiver class doesn't implement the interface, and wasn't the
623N/A // same as when the caller was compiled.
623N/A bpr(Assembler::rc_z, false, Assembler::pn, method_result, L_no_such_interface);
623N/A delayed()->cmp(method_result, intf_klass);
623N/A
623N/A if (peel) {
623N/A brx(Assembler::equal, false, Assembler::pt, found_method);
623N/A } else {
623N/A brx(Assembler::notEqual, false, Assembler::pn, search);
623N/A // (invert the test to fall through to found_method...)
623N/A }
623N/A delayed()->add(scan_temp, scan_step, scan_temp);
623N/A
623N/A if (!peel) break;
623N/A
623N/A bind(search);
623N/A }
623N/A
623N/A bind(found_method);
623N/A
623N/A // Got a hit.
623N/A int ito_offset = itableOffsetEntry::offset_offset_in_bytes();
623N/A // scan_temp[-scan_step] points to the vtable offset we need
623N/A ito_offset -= scan_step;
623N/A lduw(scan_temp, ito_offset, scan_temp);
623N/A ld_ptr(recv_klass, scan_temp, method_result);
623N/A}
623N/A
623N/A
644N/Avoid MacroAssembler::check_klass_subtype(Register sub_klass,
644N/A Register super_klass,
644N/A Register temp_reg,
644N/A Register temp2_reg,
644N/A Label& L_success) {
644N/A Label L_failure, L_pop_to_failure;
644N/A check_klass_subtype_fast_path(sub_klass, super_klass,
644N/A temp_reg, temp2_reg,
644N/A &L_success, &L_failure, NULL);
644N/A Register sub_2 = sub_klass;
644N/A Register sup_2 = super_klass;
644N/A if (!sub_2->is_global()) sub_2 = L0;
644N/A if (!sup_2->is_global()) sup_2 = L1;
644N/A
644N/A save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2);
644N/A check_klass_subtype_slow_path(sub_2, sup_2,
644N/A L2, L3, L4, L5,
644N/A NULL, &L_pop_to_failure);
644N/A
644N/A // on success:
644N/A restore();
644N/A ba(false, L_success);
644N/A delayed()->nop();
644N/A
644N/A // on failure:
644N/A bind(L_pop_to_failure);
644N/A restore();
644N/A bind(L_failure);
644N/A}
644N/A
644N/A
644N/Avoid MacroAssembler::check_klass_subtype_fast_path(Register sub_klass,
644N/A Register super_klass,
644N/A Register temp_reg,
644N/A Register temp2_reg,
644N/A Label* L_success,
644N/A Label* L_failure,
644N/A Label* L_slow_path,
665N/A RegisterOrConstant super_check_offset,
644N/A Register instanceof_hack) {
644N/A int sc_offset = (klassOopDesc::header_size() * HeapWordSize +
644N/A Klass::secondary_super_cache_offset_in_bytes());
644N/A int sco_offset = (klassOopDesc::header_size() * HeapWordSize +
644N/A Klass::super_check_offset_offset_in_bytes());
644N/A
644N/A bool must_load_sco = (super_check_offset.constant_or_zero() == -1);
644N/A bool need_slow_path = (must_load_sco ||
644N/A super_check_offset.constant_or_zero() == sco_offset);
644N/A
644N/A assert_different_registers(sub_klass, super_klass, temp_reg);
644N/A if (super_check_offset.is_register()) {
1423N/A assert_different_registers(sub_klass, super_klass, temp_reg,
644N/A super_check_offset.as_register());
644N/A } else if (must_load_sco) {
644N/A assert(temp2_reg != noreg, "supply either a temp or a register offset");
644N/A }
644N/A
644N/A Label L_fallthrough;
644N/A int label_nulls = 0;
644N/A if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; }
644N/A if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; }
644N/A if (L_slow_path == NULL) { L_slow_path = &L_fallthrough; label_nulls++; }
644N/A assert(label_nulls <= 1 || instanceof_hack != noreg ||
644N/A (L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path),
644N/A "at most one NULL in the batch, usually");
644N/A
644N/A // Support for the instanceof hack, which uses delay slots to
644N/A // set a destination register to zero or one.
644N/A bool do_bool_sets = (instanceof_hack != noreg);
644N/A#define BOOL_SET(bool_value) \
644N/A if (do_bool_sets && bool_value >= 0) \
644N/A set(bool_value, instanceof_hack)
644N/A#define DELAYED_BOOL_SET(bool_value) \
644N/A if (do_bool_sets && bool_value >= 0) \
644N/A delayed()->set(bool_value, instanceof_hack); \
644N/A else delayed()->nop()
644N/A // Hacked ba(), which may only be used just before L_fallthrough.
644N/A#define FINAL_JUMP(label, bool_value) \
644N/A if (&(label) == &L_fallthrough) { \
644N/A BOOL_SET(bool_value); \
644N/A } else { \
644N/A ba((do_bool_sets && bool_value >= 0), label); \
644N/A DELAYED_BOOL_SET(bool_value); \
644N/A }
644N/A
644N/A // If the pointers are equal, we are done (e.g., String[] elements).
644N/A // This self-check enables sharing of secondary supertype arrays among
644N/A // non-primary types such as array-of-interface. Otherwise, each such
644N/A // type would need its own customized SSA.
644N/A // We move this check to the front of the fast path because many
644N/A // type checks are in fact trivially successful in this manner,
644N/A // so we get a nicely predicted branch right at the start of the check.
644N/A cmp(super_klass, sub_klass);
644N/A brx(Assembler::equal, do_bool_sets, Assembler::pn, *L_success);
644N/A DELAYED_BOOL_SET(1);
644N/A
644N/A // Check the supertype display:
644N/A if (must_load_sco) {
644N/A // The super check offset is always positive...
644N/A lduw(super_klass, sco_offset, temp2_reg);
665N/A super_check_offset = RegisterOrConstant(temp2_reg);
1423N/A // super_check_offset is register.
1423N/A assert_different_registers(sub_klass, super_klass, temp_reg, super_check_offset.as_register());
644N/A }
644N/A ld_ptr(sub_klass, super_check_offset, temp_reg);
644N/A cmp(super_klass, temp_reg);
644N/A
644N/A // This check has worked decisively for primary supers.
644N/A // Secondary supers are sought in the super_cache ('super_cache_addr').
644N/A // (Secondary supers are interfaces and very deeply nested subtypes.)
644N/A // This works in the same check above because of a tricky aliasing
644N/A // between the super_cache and the primary super display elements.
644N/A // (The 'super_check_addr' can address either, as the case requires.)
644N/A // Note that the cache is updated below if it does not help us find
644N/A // what we need immediately.
644N/A // So if it was a primary super, we can just fail immediately.
644N/A // Otherwise, it's the slow path for us (no success at this point).
644N/A
644N/A if (super_check_offset.is_register()) {
644N/A brx(Assembler::equal, do_bool_sets, Assembler::pn, *L_success);
644N/A delayed(); if (do_bool_sets) BOOL_SET(1);
644N/A // if !do_bool_sets, sneak the next cmp into the delay slot:
644N/A cmp(super_check_offset.as_register(), sc_offset);
644N/A
644N/A if (L_failure == &L_fallthrough) {
644N/A brx(Assembler::equal, do_bool_sets, Assembler::pt, *L_slow_path);
644N/A delayed()->nop();
644N/A BOOL_SET(0); // fallthrough on failure
644N/A } else {
644N/A brx(Assembler::notEqual, do_bool_sets, Assembler::pn, *L_failure);
644N/A DELAYED_BOOL_SET(0);
644N/A FINAL_JUMP(*L_slow_path, -1); // -1 => vanilla delay slot
644N/A }
644N/A } else if (super_check_offset.as_constant() == sc_offset) {
644N/A // Need a slow path; fast failure is impossible.
644N/A if (L_slow_path == &L_fallthrough) {
644N/A brx(Assembler::equal, do_bool_sets, Assembler::pt, *L_success);
644N/A DELAYED_BOOL_SET(1);
644N/A } else {
644N/A brx(Assembler::notEqual, false, Assembler::pn, *L_slow_path);
644N/A delayed()->nop();
644N/A FINAL_JUMP(*L_success, 1);
644N/A }
644N/A } else {
644N/A // No slow path; it's a fast decision.
644N/A if (L_failure == &L_fallthrough) {
644N/A brx(Assembler::equal, do_bool_sets, Assembler::pt, *L_success);
644N/A DELAYED_BOOL_SET(1);
644N/A BOOL_SET(0);
644N/A } else {
644N/A brx(Assembler::notEqual, do_bool_sets, Assembler::pn, *L_failure);
644N/A DELAYED_BOOL_SET(0);
644N/A FINAL_JUMP(*L_success, 1);
644N/A }
644N/A }
644N/A
644N/A bind(L_fallthrough);
644N/A
644N/A#undef final_jump
644N/A#undef bool_set
644N/A#undef DELAYED_BOOL_SET
644N/A#undef final_jump
644N/A}
644N/A
644N/A
644N/Avoid MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
644N/A Register super_klass,
644N/A Register count_temp,
644N/A Register scan_temp,
644N/A Register scratch_reg,
644N/A Register coop_reg,
644N/A Label* L_success,
644N/A Label* L_failure) {
644N/A assert_different_registers(sub_klass, super_klass,
644N/A count_temp, scan_temp, scratch_reg, coop_reg);
644N/A
644N/A Label L_fallthrough, L_loop;
644N/A int label_nulls = 0;
644N/A if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; }
644N/A if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; }
644N/A assert(label_nulls <= 1, "at most one NULL in the batch");
644N/A
644N/A // a couple of useful fields in sub_klass:
644N/A int ss_offset = (klassOopDesc::header_size() * HeapWordSize +
644N/A Klass::secondary_supers_offset_in_bytes());
644N/A int sc_offset = (klassOopDesc::header_size() * HeapWordSize +
644N/A Klass::secondary_super_cache_offset_in_bytes());
644N/A
644N/A // Do a linear scan of the secondary super-klass chain.
644N/A // This code is rarely used, so simplicity is a virtue here.
644N/A
644N/A#ifndef PRODUCT
644N/A int* pst_counter = &SharedRuntime::_partial_subtype_ctr;
644N/A inc_counter((address) pst_counter, count_temp, scan_temp);
644N/A#endif
644N/A
644N/A // We will consult the secondary-super array.
644N/A ld_ptr(sub_klass, ss_offset, scan_temp);
644N/A
644N/A // Compress superclass if necessary.
644N/A Register search_key = super_klass;
644N/A bool decode_super_klass = false;
644N/A if (UseCompressedOops) {
644N/A if (coop_reg != noreg) {
644N/A encode_heap_oop_not_null(super_klass, coop_reg);
644N/A search_key = coop_reg;
644N/A } else {
644N/A encode_heap_oop_not_null(super_klass);
644N/A decode_super_klass = true; // scarce temps!
644N/A }
644N/A // The superclass is never null; it would be a basic system error if a null
644N/A // pointer were to sneak in here. Note that we have already loaded the
644N/A // Klass::super_check_offset from the super_klass in the fast path,
644N/A // so if there is a null in that register, we are already in the afterlife.
644N/A }
644N/A
644N/A // Load the array length. (Positive movl does right thing on LP64.)
644N/A lduw(scan_temp, arrayOopDesc::length_offset_in_bytes(), count_temp);
644N/A
644N/A // Check for empty secondary super list
644N/A tst(count_temp);
644N/A
644N/A // Top of search loop
644N/A bind(L_loop);
644N/A br(Assembler::equal, false, Assembler::pn, *L_failure);
644N/A delayed()->add(scan_temp, heapOopSize, scan_temp);
644N/A assert(heapOopSize != 0, "heapOopSize should be initialized");
644N/A
644N/A // Skip the array header in all array accesses.
644N/A int elem_offset = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
644N/A elem_offset -= heapOopSize; // the scan pointer was pre-incremented also
644N/A
644N/A // Load next super to check
644N/A if (UseCompressedOops) {
644N/A // Don't use load_heap_oop; we don't want to decode the element.
644N/A lduw( scan_temp, elem_offset, scratch_reg );
644N/A } else {
644N/A ld_ptr( scan_temp, elem_offset, scratch_reg );
644N/A }
644N/A
644N/A // Look for Rsuper_klass on Rsub_klass's secondary super-class-overflow list
644N/A cmp(scratch_reg, search_key);
644N/A
644N/A // A miss means we are NOT a subtype and need to keep looping
644N/A brx(Assembler::notEqual, false, Assembler::pn, L_loop);
644N/A delayed()->deccc(count_temp); // decrement trip counter in delay slot
644N/A
644N/A // Falling out the bottom means we found a hit; we ARE a subtype
644N/A if (decode_super_klass) decode_heap_oop(super_klass);
644N/A
644N/A // Success. Cache the super we found and proceed in triumph.
644N/A st_ptr(super_klass, sub_klass, sc_offset);
644N/A
644N/A if (L_success != &L_fallthrough) {
644N/A ba(false, *L_success);
644N/A delayed()->nop();
644N/A }
644N/A
644N/A bind(L_fallthrough);
644N/A}
644N/A
644N/A
710N/Avoid MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
710N/A Register temp_reg,
710N/A Label& wrong_method_type) {
710N/A assert_different_registers(mtype_reg, mh_reg, temp_reg);
710N/A // compare method type against that of the receiver
710N/A RegisterOrConstant mhtype_offset = delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg);
1766N/A load_heap_oop(mh_reg, mhtype_offset, temp_reg);
710N/A cmp(temp_reg, mtype_reg);
710N/A br(Assembler::notEqual, false, Assembler::pn, wrong_method_type);
710N/A delayed()->nop();
710N/A}
710N/A
710N/A
1423N/A// A method handle has a "vmslots" field which gives the size of its
1423N/A// argument list in JVM stack slots. This field is either located directly
1423N/A// in every method handle, or else is indirectly accessed through the
1423N/A// method handle's MethodType. This macro hides the distinction.
1423N/Avoid MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register mh_reg,
1423N/A Register temp_reg) {
1423N/A assert_different_registers(vmslots_reg, mh_reg, temp_reg);
1423N/A // load mh.type.form.vmslots
1423N/A if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) {
1423N/A // hoist vmslots into every mh to avoid dependent load chain
1766N/A ld( Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
1423N/A } else {
1423N/A Register temp2_reg = vmslots_reg;
1766N/A load_heap_oop(Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)), temp2_reg);
1766N/A load_heap_oop(Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)), temp2_reg);
1766N/A ld( Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
1423N/A }
1423N/A}
1423N/A
1423N/A
1423N/Avoid MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_reg, bool emit_delayed_nop) {
710N/A assert(mh_reg == G3_method_handle, "caller must put MH object in G3");
710N/A assert_different_registers(mh_reg, temp_reg);
710N/A
710N/A // pick out the interpreted side of the handler
1766N/A // NOTE: vmentry is not an oop!
710N/A ld_ptr(mh_reg, delayed_value(java_dyn_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg);
710N/A
710N/A // off we go...
710N/A ld_ptr(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes(), temp_reg);
710N/A jmp(temp_reg, 0);
710N/A
710N/A // for the various stubs which take control at this point,
710N/A // see MethodHandles::generate_method_handle_stub
710N/A
1423N/A // Some callers can fill the delay slot.
1423N/A if (emit_delayed_nop) {
1423N/A delayed()->nop();
1423N/A }
710N/A}
710N/A
1423N/A
710N/ARegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
710N/A int extra_slot_offset) {
710N/A // cf. TemplateTable::prepare_invoke(), if (load_receiver).
1426N/A int stackElementSize = Interpreter::stackElementSize;
1423N/A int offset = extra_slot_offset * stackElementSize;
710N/A if (arg_slot.is_constant()) {
710N/A offset += arg_slot.as_constant() * stackElementSize;
710N/A return offset;
710N/A } else {
710N/A Register temp = arg_slot.as_register();
710N/A sll_ptr(temp, exact_log2(stackElementSize), temp);
710N/A if (offset != 0)
710N/A add(temp, offset, temp);
710N/A return temp;
710N/A }
710N/A}
710N/A
710N/A
1423N/AAddress MacroAssembler::argument_address(RegisterOrConstant arg_slot,
1423N/A int extra_slot_offset) {
1423N/A return Address(Gargs, argument_offset(arg_slot, extra_slot_offset));
1423N/A}
1423N/A
710N/A
420N/Avoid MacroAssembler::biased_locking_enter(Register obj_reg, Register mark_reg,
420N/A Register temp_reg,
0N/A Label& done, Label* slow_case,
0N/A BiasedLockingCounters* counters) {
0N/A assert(UseBiasedLocking, "why call this otherwise?");
0N/A
0N/A if (PrintBiasedLockingStatistics) {
0N/A assert_different_registers(obj_reg, mark_reg, temp_reg, O7);
0N/A if (counters == NULL)
0N/A counters = BiasedLocking::counters();
0N/A }
0N/A
0N/A Label cas_label;
0N/A
0N/A // Biased locking
0N/A // See whether the lock is currently biased toward our thread and
0N/A // whether the epoch is still valid
0N/A // Note that the runtime guarantees sufficient alignment of JavaThread
0N/A // pointers to allow age to be placed into low bits
0N/A assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
0N/A and3(mark_reg, markOopDesc::biased_lock_mask_in_place, temp_reg);
0N/A cmp(temp_reg, markOopDesc::biased_lock_pattern);
0N/A brx(Assembler::notEqual, false, Assembler::pn, cas_label);
113N/A delayed()->nop();
113N/A
113N/A load_klass(obj_reg, temp_reg);
727N/A ld_ptr(Address(temp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()), temp_reg);
0N/A or3(G2_thread, temp_reg, temp_reg);
0N/A xor3(mark_reg, temp_reg, temp_reg);
0N/A andcc(temp_reg, ~((int) markOopDesc::age_mask_in_place), temp_reg);
0N/A if (counters != NULL) {
0N/A cond_inc(Assembler::equal, (address) counters->biased_lock_entry_count_addr(), mark_reg, temp_reg);
0N/A // Reload mark_reg as we may need it later
727N/A ld_ptr(Address(obj_reg, oopDesc::mark_offset_in_bytes()), mark_reg);
0N/A }
0N/A brx(Assembler::equal, true, Assembler::pt, done);
0N/A delayed()->nop();
0N/A
0N/A Label try_revoke_bias;
0N/A Label try_rebias;
727N/A Address mark_addr = Address(obj_reg, oopDesc::mark_offset_in_bytes());
0N/A assert(mark_addr.disp() == 0, "cas must take a zero displacement");
0N/A
0N/A // At this point we know that the header has the bias pattern and
0N/A // that we are not the bias owner in the current epoch. We need to
0N/A // figure out more details about the state of the header in order to
0N/A // know what operations can be legally performed on the object's
0N/A // header.
0N/A
0N/A // If the low three bits in the xor result aren't clear, that means
0N/A // the prototype header is no longer biased and we have to revoke
0N/A // the bias on this object.
0N/A btst(markOopDesc::biased_lock_mask_in_place, temp_reg);
0N/A brx(Assembler::notZero, false, Assembler::pn, try_revoke_bias);
0N/A
0N/A // Biasing is still enabled for this data type. See whether the
0N/A // epoch of the current bias is still valid, meaning that the epoch
0N/A // bits of the mark word are equal to the epoch bits of the
0N/A // prototype header. (Note that the prototype header's epoch bits
0N/A // only change at a safepoint.) If not, attempt to rebias the object
0N/A // toward the current thread. Note that we must be absolutely sure
0N/A // that the current epoch is invalid in order to do this because
0N/A // otherwise the manipulations it performs on the mark word are
0N/A // illegal.
0N/A delayed()->btst(markOopDesc::epoch_mask_in_place, temp_reg);
0N/A brx(Assembler::notZero, false, Assembler::pn, try_rebias);
0N/A
0N/A // The epoch of the current bias is still valid but we know nothing
0N/A // about the owner; it might be set or it might be clear. Try to
0N/A // acquire the bias of the object using an atomic operation. If this
0N/A // fails we will go in to the runtime to revoke the object's bias.
0N/A // Note that we first construct the presumed unbiased header so we
0N/A // don't accidentally blow away another thread's valid bias.
0N/A delayed()->and3(mark_reg,
0N/A markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place,
0N/A mark_reg);
0N/A or3(G2_thread, mark_reg, temp_reg);
420N/A casn(mark_addr.base(), mark_reg, temp_reg);
0N/A // If the biasing toward our thread failed, this means that
0N/A // another thread succeeded in biasing it toward itself and we
0N/A // need to revoke that bias. The revocation will occur in the
0N/A // interpreter runtime in the slow case.
0N/A cmp(mark_reg, temp_reg);
0N/A if (counters != NULL) {
0N/A cond_inc(Assembler::zero, (address) counters->anonymously_biased_lock_entry_count_addr(), mark_reg, temp_reg);
0N/A }
0N/A if (slow_case != NULL) {
0N/A brx(Assembler::notEqual, true, Assembler::pn, *slow_case);
0N/A delayed()->nop();
0N/A }
0N/A br(Assembler::always, false, Assembler::pt, done);
0N/A delayed()->nop();
0N/A
0N/A bind(try_rebias);
0N/A // At this point we know the epoch has expired, meaning that the
0N/A // current "bias owner", if any, is actually invalid. Under these
0N/A // circumstances _only_, we are allowed to use the current header's
0N/A // value as the comparison value when doing the cas to acquire the
0N/A // bias in the current epoch. In other words, we allow transfer of
0N/A // the bias from one thread to another directly in this situation.
0N/A //
0N/A // FIXME: due to a lack of registers we currently blow away the age
0N/A // bits in this situation. Should attempt to preserve them.
113N/A load_klass(obj_reg, temp_reg);
727N/A ld_ptr(Address(temp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()), temp_reg);
0N/A or3(G2_thread, temp_reg, temp_reg);
420N/A casn(mark_addr.base(), mark_reg, temp_reg);
0N/A // If the biasing toward our thread failed, this means that
0N/A // another thread succeeded in biasing it toward itself and we
0N/A // need to revoke that bias. The revocation will occur in the
0N/A // interpreter runtime in the slow case.
0N/A cmp(mark_reg, temp_reg);
0N/A if (counters != NULL) {
0N/A cond_inc(Assembler::zero, (address) counters->rebiased_lock_entry_count_addr(), mark_reg, temp_reg);
0N/A }
0N/A if (slow_case != NULL) {
0N/A brx(Assembler::notEqual, true, Assembler::pn, *slow_case);
0N/A delayed()->nop();
0N/A }
0N/A br(Assembler::always, false, Assembler::pt, done);
0N/A delayed()->nop();
0N/A
0N/A bind(try_revoke_bias);
0N/A // The prototype mark in the klass doesn't have the bias bit set any
0N/A // more, indicating that objects of this data type are not supposed
0N/A // to be biased any more. We are going to try to reset the mark of
0N/A // this object to the prototype value and fall through to the
0N/A // CAS-based locking scheme. Note that if our CAS fails, it means
0N/A // that another thread raced us for the privilege of revoking the
0N/A // bias of this particular object, so it's okay to continue in the
0N/A // normal locking code.
0N/A //
0N/A // FIXME: due to a lack of registers we currently blow away the age
0N/A // bits in this situation. Should attempt to preserve them.
113N/A load_klass(obj_reg, temp_reg);
727N/A ld_ptr(Address(temp_reg, Klass::prototype_header_offset_in_bytes() + klassOopDesc::klass_part_offset_in_bytes()), temp_reg);
420N/A casn(mark_addr.base(), mark_reg, temp_reg);
0N/A // Fall through to the normal CAS-based lock, because no matter what
0N/A // the result of the above CAS, some thread must have succeeded in
0N/A // removing the bias bit from the object's header.
0N/A if (counters != NULL) {
0N/A cmp(mark_reg, temp_reg);
0N/A cond_inc(Assembler::zero, (address) counters->revoked_lock_entry_count_addr(), mark_reg, temp_reg);
0N/A }
0N/A
0N/A bind(cas_label);
0N/A}
0N/A
0N/Avoid MacroAssembler::biased_locking_exit (Address mark_addr, Register temp_reg, Label& done,
0N/A bool allow_delay_slot_filling) {
0N/A // Check for biased locking unlock case, which is a no-op
0N/A // Note: we do not have to check the thread ID for two reasons.
0N/A // First, the interpreter checks for IllegalMonitorStateException at
0N/A // a higher level. Second, if the bias was revoked while we held the
0N/A // lock, the object could not be rebiased toward another thread, so
0N/A // the bias bit would be clear.
0N/A ld_ptr(mark_addr, temp_reg);
0N/A and3(temp_reg, markOopDesc::biased_lock_mask_in_place, temp_reg);
0N/A cmp(temp_reg, markOopDesc::biased_lock_pattern);
0N/A brx(Assembler::equal, allow_delay_slot_filling, Assembler::pt, done);
0N/A delayed();
0N/A if (!allow_delay_slot_filling) {
0N/A nop();
0N/A }
0N/A}
0N/A
0N/A
0N/A// CASN -- 32-64 bit switch hitter similar to the synthetic CASN provided by
0N/A// Solaris/SPARC's "as". Another apt name would be cas_ptr()
0N/A
0N/Avoid MacroAssembler::casn (Register addr_reg, Register cmp_reg, Register set_reg ) {
0N/A casx_under_lock (addr_reg, cmp_reg, set_reg, (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr()) ;
0N/A}
0N/A
0N/A
0N/A
0N/A// compiler_lock_object() and compiler_unlock_object() are direct transliterations
0N/A// of i486.ad fast_lock() and fast_unlock(). See those methods for detailed comments.
0N/A// The code could be tightened up considerably.
0N/A//
0N/A// box->dhw disposition - post-conditions at DONE_LABEL.
0N/A// - Successful inflated lock: box->dhw != 0.
0N/A// Any non-zero value suffices.
0N/A// Consider G2_thread, rsp, boxReg, or unused_mark()
0N/A// - Successful Stack-lock: box->dhw == mark.
0N/A// box->dhw must contain the displaced mark word value
0N/A// - Failure -- icc.ZFlag == 0 and box->dhw is undefined.
0N/A// The slow-path fast_enter() and slow_enter() operators
0N/A// are responsible for setting box->dhw = NonZero (typically ::unused_mark).
0N/A// - Biased: box->dhw is undefined
0N/A//
0N/A// SPARC refworkload performance - specifically jetstream and scimark - are
0N/A// extremely sensitive to the size of the code emitted by compiler_lock_object
0N/A// and compiler_unlock_object. Critically, the key factor is code size, not path
0N/A// length. (Simply experiments to pad CLO with unexecuted NOPs demonstrte the
0N/A// effect).
0N/A
0N/A
420N/Avoid MacroAssembler::compiler_lock_object(Register Roop, Register Rmark,
420N/A Register Rbox, Register Rscratch,
420N/A BiasedLockingCounters* counters,
420N/A bool try_bias) {
727N/A Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
0N/A
0N/A verify_oop(Roop);
0N/A Label done ;
0N/A
0N/A if (counters != NULL) {
0N/A inc_counter((address) counters->total_entry_count_addr(), Rmark, Rscratch);
0N/A }
0N/A
0N/A if (EmitSync & 1) {
0N/A mov (3, Rscratch) ;
0N/A st_ptr (Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A cmp (SP, G0) ;
0N/A return ;
0N/A }
0N/A
0N/A if (EmitSync & 2) {
0N/A
0N/A // Fetch object's markword
0N/A ld_ptr(mark_addr, Rmark);
0N/A
420N/A if (try_bias) {
0N/A biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
0N/A }
0N/A
0N/A // Save Rbox in Rscratch to be used for the cas operation
0N/A mov(Rbox, Rscratch);
0N/A
0N/A // set Rmark to markOop | markOopDesc::unlocked_value
0N/A or3(Rmark, markOopDesc::unlocked_value, Rmark);
0N/A
0N/A // Initialize the box. (Must happen before we update the object mark!)
0N/A st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A
0N/A // compare object markOop with Rmark and if equal exchange Rscratch with object markOop
0N/A assert(mark_addr.disp() == 0, "cas must take a zero displacement");
0N/A casx_under_lock(mark_addr.base(), Rmark, Rscratch,
0N/A (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr());
0N/A
0N/A // if compare/exchange succeeded we found an unlocked object and we now have locked it
0N/A // hence we are done
0N/A cmp(Rmark, Rscratch);
0N/A#ifdef _LP64
0N/A sub(Rscratch, STACK_BIAS, Rscratch);
0N/A#endif
0N/A brx(Assembler::equal, false, Assembler::pt, done);
0N/A delayed()->sub(Rscratch, SP, Rscratch); //pull next instruction into delay slot
0N/A
0N/A // we did not find an unlocked object so see if this is a recursive case
0N/A // sub(Rscratch, SP, Rscratch);
0N/A assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
0N/A andcc(Rscratch, 0xfffff003, Rscratch);
0N/A st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A bind (done) ;
0N/A return ;
0N/A }
0N/A
0N/A Label Egress ;
0N/A
0N/A if (EmitSync & 256) {
0N/A Label IsInflated ;
0N/A
0N/A ld_ptr (mark_addr, Rmark); // fetch obj->mark
0N/A // Triage: biased, stack-locked, neutral, inflated
420N/A if (try_bias) {
0N/A biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
0N/A // Invariant: if control reaches this point in the emitted stream
0N/A // then Rmark has not been modified.
0N/A }
0N/A
0N/A // Store mark into displaced mark field in the on-stack basic-lock "box"
0N/A // Critically, this must happen before the CAS
0N/A // Maximize the ST-CAS distance to minimize the ST-before-CAS penalty.
0N/A st_ptr (Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A andcc (Rmark, 2, G0) ;
0N/A brx (Assembler::notZero, false, Assembler::pn, IsInflated) ;
0N/A delayed() ->
0N/A
0N/A // Try stack-lock acquisition.
0N/A // Beware: the 1st instruction is in a delay slot
0N/A mov (Rbox, Rscratch);
0N/A or3 (Rmark, markOopDesc::unlocked_value, Rmark);
0N/A assert (mark_addr.disp() == 0, "cas must take a zero displacement");
0N/A casn (mark_addr.base(), Rmark, Rscratch) ;
0N/A cmp (Rmark, Rscratch);
0N/A brx (Assembler::equal, false, Assembler::pt, done);
0N/A delayed()->sub(Rscratch, SP, Rscratch);
0N/A
0N/A // Stack-lock attempt failed - check for recursive stack-lock.
0N/A // See the comments below about how we might remove this case.
0N/A#ifdef _LP64
0N/A sub (Rscratch, STACK_BIAS, Rscratch);
0N/A#endif
0N/A assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
0N/A andcc (Rscratch, 0xfffff003, Rscratch);
0N/A br (Assembler::always, false, Assembler::pt, done) ;
0N/A delayed()-> st_ptr (Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A
0N/A bind (IsInflated) ;
0N/A if (EmitSync & 64) {
0N/A // If m->owner != null goto IsLocked
0N/A // Pessimistic form: Test-and-CAS vs CAS
0N/A // The optimistic form avoids RTS->RTO cache line upgrades.
727N/A ld_ptr (Rmark, ObjectMonitor::owner_offset_in_bytes() - 2, Rscratch);
0N/A andcc (Rscratch, Rscratch, G0) ;
0N/A brx (Assembler::notZero, false, Assembler::pn, done) ;
0N/A delayed()->nop() ;
0N/A // m->owner == null : it's unlocked.
0N/A }
0N/A
0N/A // Try to CAS m->owner from null to Self
0N/A // Invariant: if we acquire the lock then _recursions should be 0.
0N/A add (Rmark, ObjectMonitor::owner_offset_in_bytes()-2, Rmark) ;
0N/A mov (G2_thread, Rscratch) ;
0N/A casn (Rmark, G0, Rscratch) ;
0N/A cmp (Rscratch, G0) ;
0N/A // Intentional fall-through into done
0N/A } else {
0N/A // Aggressively avoid the Store-before-CAS penalty
0N/A // Defer the store into box->dhw until after the CAS
0N/A Label IsInflated, Recursive ;
0N/A
0N/A// Anticipate CAS -- Avoid RTS->RTO upgrade
0N/A// prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads) ;
0N/A
0N/A ld_ptr (mark_addr, Rmark); // fetch obj->mark
0N/A // Triage: biased, stack-locked, neutral, inflated
0N/A
420N/A if (try_bias) {
0N/A biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
0N/A // Invariant: if control reaches this point in the emitted stream
0N/A // then Rmark has not been modified.
0N/A }
0N/A andcc (Rmark, 2, G0) ;
0N/A brx (Assembler::notZero, false, Assembler::pn, IsInflated) ;
0N/A delayed()-> // Beware - dangling delay-slot
0N/A
0N/A // Try stack-lock acquisition.
0N/A // Transiently install BUSY (0) encoding in the mark word.
0N/A // if the CAS of 0 into the mark was successful then we execute:
0N/A // ST box->dhw = mark -- save fetched mark in on-stack basiclock box
0N/A // ST obj->mark = box -- overwrite transient 0 value
0N/A // This presumes TSO, of course.
0N/A
0N/A mov (0, Rscratch) ;
0N/A or3 (Rmark, markOopDesc::unlocked_value, Rmark);
0N/A assert (mark_addr.disp() == 0, "cas must take a zero displacement");
0N/A casn (mark_addr.base(), Rmark, Rscratch) ;
0N/A// prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads) ;
0N/A cmp (Rscratch, Rmark) ;
0N/A brx (Assembler::notZero, false, Assembler::pn, Recursive) ;
0N/A delayed() ->
0N/A st_ptr (Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A if (counters != NULL) {
0N/A cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
0N/A }
0N/A br (Assembler::always, false, Assembler::pt, done);
0N/A delayed() ->
0N/A st_ptr (Rbox, mark_addr) ;
0N/A
0N/A bind (Recursive) ;
0N/A // Stack-lock attempt failed - check for recursive stack-lock.
0N/A // Tests show that we can remove the recursive case with no impact
0N/A // on refworkload 0.83. If we need to reduce the size of the code
0N/A // emitted by compiler_lock_object() the recursive case is perfect
0N/A // candidate.
0N/A //
0N/A // A more extreme idea is to always inflate on stack-lock recursion.
0N/A // This lets us eliminate the recursive checks in compiler_lock_object
0N/A // and compiler_unlock_object and the (box->dhw == 0) encoding.
0N/A // A brief experiment - requiring changes to synchronizer.cpp, interpreter,
0N/A // and showed a performance *increase*. In the same experiment I eliminated
0N/A // the fast-path stack-lock code from the interpreter and always passed
0N/A // control to the "slow" operators in synchronizer.cpp.
0N/A
0N/A // RScratch contains the fetched obj->mark value from the failed CASN.
0N/A#ifdef _LP64
0N/A sub (Rscratch, STACK_BIAS, Rscratch);
0N/A#endif
0N/A sub(Rscratch, SP, Rscratch);
0N/A assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
0N/A andcc (Rscratch, 0xfffff003, Rscratch);
0N/A if (counters != NULL) {
0N/A // Accounting needs the Rscratch register
0N/A st_ptr (Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
0N/A br (Assembler::always, false, Assembler::pt, done) ;
0N/A delayed()->nop() ;
0N/A } else {
0N/A br (Assembler::always, false, Assembler::pt, done) ;
0N/A delayed()-> st_ptr (Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A }
0N/A
0N/A bind (IsInflated) ;
0N/A if (EmitSync & 64) {
0N/A // If m->owner != null goto IsLocked
0N/A // Test-and-CAS vs CAS
0N/A // Pessimistic form avoids futile (doomed) CAS attempts
0N/A // The optimistic form avoids RTS->RTO cache line upgrades.
727N/A ld_ptr (Rmark, ObjectMonitor::owner_offset_in_bytes() - 2, Rscratch);
0N/A andcc (Rscratch, Rscratch, G0) ;
0N/A brx (Assembler::notZero, false, Assembler::pn, done) ;
0N/A delayed()->nop() ;
0N/A // m->owner == null : it's unlocked.
0N/A }
0N/A
0N/A // Try to CAS m->owner from null to Self
0N/A // Invariant: if we acquire the lock then _recursions should be 0.
0N/A add (Rmark, ObjectMonitor::owner_offset_in_bytes()-2, Rmark) ;
0N/A mov (G2_thread, Rscratch) ;
0N/A casn (Rmark, G0, Rscratch) ;
0N/A cmp (Rscratch, G0) ;
0N/A // ST box->displaced_header = NonZero.
0N/A // Any non-zero value suffices:
0N/A // unused_mark(), G2_thread, RBox, RScratch, rsp, etc.
0N/A st_ptr (Rbox, Rbox, BasicLock::displaced_header_offset_in_bytes());
0N/A // Intentional fall-through into done
0N/A }
0N/A
0N/A bind (done) ;
0N/A}
0N/A
420N/Avoid MacroAssembler::compiler_unlock_object(Register Roop, Register Rmark,
420N/A Register Rbox, Register Rscratch,
420N/A bool try_bias) {
727N/A Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
0N/A
0N/A Label done ;
0N/A
0N/A if (EmitSync & 4) {
0N/A cmp (SP, G0) ;
0N/A return ;
0N/A }
0N/A
0N/A if (EmitSync & 8) {
420N/A if (try_bias) {
0N/A biased_locking_exit(mark_addr, Rscratch, done);
0N/A }
0N/A
0N/A // Test first if it is a fast recursive unlock
0N/A ld_ptr(Rbox, BasicLock::displaced_header_offset_in_bytes(), Rmark);
0N/A cmp(Rmark, G0);
0N/A brx(Assembler::equal, false, Assembler::pt, done);
0N/A delayed()->nop();
0N/A
0N/A // Check if it is still a light weight lock, this is is true if we see
0N/A // the stack address of the basicLock in the markOop of the object
0N/A assert(mark_addr.disp() == 0, "cas must take a zero displacement");
0N/A casx_under_lock(mark_addr.base(), Rbox, Rmark,
0N/A (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr());
0N/A br (Assembler::always, false, Assembler::pt, done);
0N/A delayed()->cmp(Rbox, Rmark);
0N/A bind (done) ;
0N/A return ;
0N/A }
0N/A
0N/A // Beware ... If the aggregate size of the code emitted by CLO and CUO is
0N/A // is too large performance rolls abruptly off a cliff.
0N/A // This could be related to inlining policies, code cache management, or
0N/A // I$ effects.
0N/A Label LStacked ;
0N/A
420N/A if (try_bias) {
0N/A // TODO: eliminate redundant LDs of obj->mark
0N/A biased_locking_exit(mark_addr, Rscratch, done);
0N/A }
0N/A
0N/A ld_ptr (Roop, oopDesc::mark_offset_in_bytes(), Rmark) ;
0N/A ld_ptr (Rbox, BasicLock::displaced_header_offset_in_bytes(), Rscratch);
0N/A andcc (Rscratch, Rscratch, G0);
0N/A brx (Assembler::zero, false, Assembler::pn, done);
0N/A delayed()-> nop() ; // consider: relocate fetch of mark, above, into this DS
0N/A andcc (Rmark, 2, G0) ;
0N/A brx (Assembler::zero, false, Assembler::pt, LStacked) ;
0N/A delayed()-> nop() ;
0N/A
0N/A // It's inflated
0N/A // Conceptually we need a #loadstore|#storestore "release" MEMBAR before
0N/A // the ST of 0 into _owner which releases the lock. This prevents loads
0N/A // and stores within the critical section from reordering (floating)
0N/A // past the store that releases the lock. But TSO is a strong memory model
0N/A // and that particular flavor of barrier is a noop, so we can safely elide it.
0N/A // Note that we use 1-0 locking by default for the inflated case. We
0N/A // close the resultant (and rare) race by having contented threads in
0N/A // monitorenter periodically poll _owner.
727N/A ld_ptr (Rmark, ObjectMonitor::owner_offset_in_bytes() - 2, Rscratch);
727N/A ld_ptr (Rmark, ObjectMonitor::recursions_offset_in_bytes() - 2, Rbox);
0N/A xor3 (Rscratch, G2_thread, Rscratch) ;
0N/A orcc (Rbox, Rscratch, Rbox) ;
0N/A brx (Assembler::notZero, false, Assembler::pn, done) ;
0N/A delayed()->
727N/A ld_ptr (Rmark, ObjectMonitor::EntryList_offset_in_bytes() - 2, Rscratch);
727N/A ld_ptr (Rmark, ObjectMonitor::cxq_offset_in_bytes() - 2, Rbox);
0N/A orcc (Rbox, Rscratch, G0) ;
0N/A if (EmitSync & 65536) {
0N/A Label LSucc ;
0N/A brx (Assembler::notZero, false, Assembler::pn, LSucc) ;
0N/A delayed()->nop() ;
0N/A br (Assembler::always, false, Assembler::pt, done) ;
0N/A delayed()->
727N/A st_ptr (G0, Rmark, ObjectMonitor::owner_offset_in_bytes() - 2);
0N/A
0N/A bind (LSucc) ;
727N/A st_ptr (G0, Rmark, ObjectMonitor::owner_offset_in_bytes() - 2);
0N/A if (os::is_MP()) { membar (StoreLoad) ; }
727N/A ld_ptr (Rmark, ObjectMonitor::succ_offset_in_bytes() - 2, Rscratch);
0N/A andcc (Rscratch, Rscratch, G0) ;
0N/A brx (Assembler::notZero, false, Assembler::pt, done) ;
0N/A delayed()-> andcc (G0, G0, G0) ;
0N/A add (Rmark, ObjectMonitor::owner_offset_in_bytes()-2, Rmark) ;
0N/A mov (G2_thread, Rscratch) ;
0N/A casn (Rmark, G0, Rscratch) ;
0N/A cmp (Rscratch, G0) ;
0N/A // invert icc.zf and goto done
0N/A brx (Assembler::notZero, false, Assembler::pt, done) ;
0N/A delayed() -> cmp (G0, G0) ;
0N/A br (Assembler::always, false, Assembler::pt, done);
0N/A delayed() -> cmp (G0, 1) ;
0N/A } else {
0N/A brx (Assembler::notZero, false, Assembler::pn, done) ;
0N/A delayed()->nop() ;
0N/A br (Assembler::always, false, Assembler::pt, done) ;
0N/A delayed()->
727N/A st_ptr (G0, Rmark, ObjectMonitor::owner_offset_in_bytes() - 2);
0N/A }
0N/A
0N/A bind (LStacked) ;
0N/A // Consider: we could replace the expensive CAS in the exit
0N/A // path with a simple ST of the displaced mark value fetched from
0N/A // the on-stack basiclock box. That admits a race where a thread T2
0N/A // in the slow lock path -- inflating with monitor M -- could race a
0N/A // thread T1 in the fast unlock path, resulting in a missed wakeup for T2.
0N/A // More precisely T1 in the stack-lock unlock path could "stomp" the
0N/A // inflated mark value M installed by T2, resulting in an orphan
0N/A // object monitor M and T2 becoming stranded. We can remedy that situation
0N/A // by having T2 periodically poll the object's mark word using timed wait
0N/A // operations. If T2 discovers that a stomp has occurred it vacates
0N/A // the monitor M and wakes any other threads stranded on the now-orphan M.
0N/A // In addition the monitor scavenger, which performs deflation,
0N/A // would also need to check for orpan monitors and stranded threads.
0N/A //
0N/A // Finally, inflation is also used when T2 needs to assign a hashCode
0N/A // to O and O is stack-locked by T1. The "stomp" race could cause
0N/A // an assigned hashCode value to be lost. We can avoid that condition
0N/A // and provide the necessary hashCode stability invariants by ensuring
0N/A // that hashCode generation is idempotent between copying GCs.
0N/A // For example we could compute the hashCode of an object O as
0N/A // O's heap address XOR some high quality RNG value that is refreshed
0N/A // at GC-time. The monitor scavenger would install the hashCode
0N/A // found in any orphan monitors. Again, the mechanism admits a
0N/A // lost-update "stomp" WAW race but detects and recovers as needed.
0N/A //
0N/A // A prototype implementation showed excellent results, although
0N/A // the scavenger and timeout code was rather involved.
0N/A
0N/A casn (mark_addr.base(), Rbox, Rscratch) ;
0N/A cmp (Rbox, Rscratch);
0N/A // Intentional fall through into done ...
0N/A
0N/A bind (done) ;
0N/A}
0N/A
0N/A
0N/A
0N/Avoid MacroAssembler::print_CPU_state() {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/Avoid MacroAssembler::verify_FPU(int stack_depth, const char* s) {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/Avoid MacroAssembler::push_IU_state() {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::pop_IU_state() {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::push_FPU_state() {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::pop_FPU_state() {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::push_CPU_state() {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::pop_CPU_state() {
0N/A // %%%%% need to implement this
0N/A}
0N/A
0N/A
0N/A
0N/Avoid MacroAssembler::verify_tlab() {
0N/A#ifdef ASSERT
0N/A if (UseTLAB && VerifyOops) {
0N/A Label next, next2, ok;
0N/A Register t1 = L0;
0N/A Register t2 = L1;
0N/A Register t3 = L2;
0N/A
0N/A save_frame(0);
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2);
0N/A or3(t1, t2, t3);
0N/A cmp(t1, t2);
0N/A br(Assembler::greaterEqual, false, Assembler::pn, next);
0N/A delayed()->nop();
0N/A stop("assert(top >= start)");
0N/A should_not_reach_here();
0N/A
0N/A bind(next);
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t2);
0N/A or3(t3, t2, t3);
0N/A cmp(t1, t2);
0N/A br(Assembler::lessEqual, false, Assembler::pn, next2);
0N/A delayed()->nop();
0N/A stop("assert(top <= end)");
0N/A should_not_reach_here();
0N/A
0N/A bind(next2);
0N/A and3(t3, MinObjAlignmentInBytesMask, t3);
0N/A cmp(t3, 0);
0N/A br(Assembler::lessEqual, false, Assembler::pn, ok);
0N/A delayed()->nop();
0N/A stop("assert(aligned)");
0N/A should_not_reach_here();
0N/A
0N/A bind(ok);
0N/A restore();
0N/A }
0N/A#endif
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::eden_allocate(
0N/A Register obj, // result: pointer to object after successful allocation
0N/A Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
0N/A int con_size_in_bytes, // object size in bytes if known at compile time
0N/A Register t1, // temp register
0N/A Register t2, // temp register
0N/A Label& slow_case // continuation point if fast allocation fails
0N/A){
0N/A // make sure arguments make sense
0N/A assert_different_registers(obj, var_size_in_bytes, t1, t2);
0N/A assert(0 <= con_size_in_bytes && Assembler::is_simm13(con_size_in_bytes), "illegal object size");
0N/A assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
0N/A
342N/A if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
342N/A // No allocation in the shared eden.
342N/A br(Assembler::always, false, Assembler::pt, slow_case);
0N/A delayed()->nop();
342N/A } else {
342N/A // get eden boundaries
342N/A // note: we need both top & top_addr!
342N/A const Register top_addr = t1;
342N/A const Register end = t2;
342N/A
342N/A CollectedHeap* ch = Universe::heap();
342N/A set((intx)ch->top_addr(), top_addr);
342N/A intx delta = (intx)ch->end_addr() - (intx)ch->top_addr();
342N/A ld_ptr(top_addr, delta, end);
342N/A ld_ptr(top_addr, 0, obj);
342N/A
342N/A // try to allocate
342N/A Label retry;
342N/A bind(retry);
342N/A#ifdef ASSERT
342N/A // make sure eden top is properly aligned
342N/A {
342N/A Label L;
342N/A btst(MinObjAlignmentInBytesMask, obj);
342N/A br(Assembler::zero, false, Assembler::pt, L);
342N/A delayed()->nop();
342N/A stop("eden top is not properly aligned");
342N/A bind(L);
342N/A }
0N/A#endif // ASSERT
342N/A const Register free = end;
342N/A sub(end, obj, free); // compute amount of free space
342N/A if (var_size_in_bytes->is_valid()) {
342N/A // size is unknown at compile time
342N/A cmp(free, var_size_in_bytes);
342N/A br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
342N/A delayed()->add(obj, var_size_in_bytes, end);
342N/A } else {
342N/A // size is known at compile time
342N/A cmp(free, con_size_in_bytes);
342N/A br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
342N/A delayed()->add(obj, con_size_in_bytes, end);
342N/A }
342N/A // Compare obj with the value at top_addr; if still equal, swap the value of
342N/A // end with the value at top_addr. If not equal, read the value at top_addr
342N/A // into end.
342N/A casx_under_lock(top_addr, obj, end, (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr());
342N/A // if someone beat us on the allocation, try again, otherwise continue
342N/A cmp(obj, end);
342N/A brx(Assembler::notEqual, false, Assembler::pn, retry);
342N/A delayed()->mov(end, obj); // nop if successfull since obj == end
0N/A
0N/A#ifdef ASSERT
342N/A // make sure eden top is properly aligned
342N/A {
342N/A Label L;
342N/A const Register top_addr = t1;
342N/A
342N/A set((intx)ch->top_addr(), top_addr);
342N/A ld_ptr(top_addr, 0, top_addr);
342N/A btst(MinObjAlignmentInBytesMask, top_addr);
342N/A br(Assembler::zero, false, Assembler::pt, L);
342N/A delayed()->nop();
342N/A stop("eden top is not properly aligned");
342N/A bind(L);
342N/A }
342N/A#endif // ASSERT
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::tlab_allocate(
0N/A Register obj, // result: pointer to object after successful allocation
0N/A Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
0N/A int con_size_in_bytes, // object size in bytes if known at compile time
0N/A Register t1, // temp register
0N/A Label& slow_case // continuation point if fast allocation fails
0N/A){
0N/A // make sure arguments make sense
0N/A assert_different_registers(obj, var_size_in_bytes, t1);
0N/A assert(0 <= con_size_in_bytes && is_simm13(con_size_in_bytes), "illegal object size");
0N/A assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
0N/A
0N/A const Register free = t1;
0N/A
0N/A verify_tlab();
0N/A
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), obj);
0N/A
0N/A // calculate amount of free space
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), free);
0N/A sub(free, obj, free);
0N/A
0N/A Label done;
0N/A if (var_size_in_bytes == noreg) {
0N/A cmp(free, con_size_in_bytes);
0N/A } else {
0N/A cmp(free, var_size_in_bytes);
0N/A }
0N/A br(Assembler::less, false, Assembler::pn, slow_case);
0N/A // calculate the new top pointer
0N/A if (var_size_in_bytes == noreg) {
0N/A delayed()->add(obj, con_size_in_bytes, free);
0N/A } else {
0N/A delayed()->add(obj, var_size_in_bytes, free);
0N/A }
0N/A
0N/A bind(done);
0N/A
0N/A#ifdef ASSERT
0N/A // make sure new free pointer is properly aligned
0N/A {
0N/A Label L;
0N/A btst(MinObjAlignmentInBytesMask, free);
0N/A br(Assembler::zero, false, Assembler::pt, L);
0N/A delayed()->nop();
0N/A stop("updated TLAB free is not properly aligned");
0N/A bind(L);
0N/A }
0N/A#endif // ASSERT
0N/A
0N/A // update the tlab top pointer
0N/A st_ptr(free, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
0N/A verify_tlab();
0N/A}
0N/A
0N/A
0N/Avoid MacroAssembler::tlab_refill(Label& retry, Label& try_eden, Label& slow_case) {
0N/A Register top = O0;
0N/A Register t1 = G1;
0N/A Register t2 = G3;
0N/A Register t3 = O1;
0N/A assert_different_registers(top, t1, t2, t3, G4, G5 /* preserve G4 and G5 */);
0N/A Label do_refill, discard_tlab;
0N/A
0N/A if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
0N/A // No allocation in the shared eden.
0N/A br(Assembler::always, false, Assembler::pt, slow_case);
0N/A delayed()->nop();
0N/A }
0N/A
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), top);
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t1);
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), t2);
0N/A
0N/A // calculate amount of free space
0N/A sub(t1, top, t1);
0N/A srl_ptr(t1, LogHeapWordSize, t1);
0N/A
0N/A // Retain tlab and allocate object in shared space if
0N/A // the amount free in the tlab is too large to discard.
0N/A cmp(t1, t2);
0N/A brx(Assembler::lessEqual, false, Assembler::pt, discard_tlab);
0N/A
0N/A // increment waste limit to prevent getting stuck on this slow path
0N/A delayed()->add(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment(), t2);
0N/A st_ptr(t2, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
0N/A if (TLABStats) {
0N/A // increment number of slow_allocations
0N/A ld(G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()), t2);
0N/A add(t2, 1, t2);
0N/A stw(t2, G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()));
0N/A }
0N/A br(Assembler::always, false, Assembler::pt, try_eden);
0N/A delayed()->nop();
0N/A
0N/A bind(discard_tlab);
0N/A if (TLABStats) {
0N/A // increment number of refills
0N/A ld(G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()), t2);
0N/A add(t2, 1, t2);
0N/A stw(t2, G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()));
0N/A // accumulate wastage
0N/A ld(G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()), t2);
0N/A add(t2, t1, t2);
0N/A stw(t2, G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()));
0N/A }
0N/A
0N/A // if tlab is currently allocated (top or end != null) then
0N/A // fill [top, end + alignment_reserve) with array object
0N/A br_null(top, false, Assembler::pn, do_refill);
0N/A delayed()->nop();
0N/A
0N/A set((intptr_t)markOopDesc::prototype()->copy_set_hash(0x2), t2);
0N/A st_ptr(t2, top, oopDesc::mark_offset_in_bytes()); // set up the mark word
0N/A // set klass to intArrayKlass
0N/A sub(t1, typeArrayOopDesc::header_size(T_INT), t1);
0N/A add(t1, ThreadLocalAllocBuffer::alignment_reserve(), t1);
0N/A sll_ptr(t1, log2_intptr(HeapWordSize/sizeof(jint)), t1);
0N/A st(t1, top, arrayOopDesc::length_offset_in_bytes());
167N/A set((intptr_t)Universe::intArrayKlassObj_addr(), t2);
167N/A ld_ptr(t2, 0, t2);
167N/A // store klass last. concurrent gcs assumes klass length is valid if
167N/A // klass field is not null.
167N/A store_klass(t2, top);
0N/A verify_oop(top);
0N/A
0N/A // refill the tlab with an eden allocation
0N/A bind(do_refill);
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t1);
0N/A sll_ptr(t1, LogHeapWordSize, t1);
0N/A // add object_size ??
0N/A eden_allocate(top, t1, 0, t2, t3, slow_case);
0N/A
0N/A st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_start_offset()));
0N/A st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
0N/A#ifdef ASSERT
0N/A // check that tlab_size (t1) is still valid
0N/A {
0N/A Label ok;
0N/A ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t2);
0N/A sll_ptr(t2, LogHeapWordSize, t2);
0N/A cmp(t1, t2);
0N/A br(Assembler::equal, false, Assembler::pt, ok);
0N/A delayed()->nop();
0N/A stop("assert(t1 == tlab_size)");
0N/A should_not_reach_here();
0N/A
0N/A bind(ok);
0N/A }
0N/A#endif // ASSERT
0N/A add(top, t1, top); // t1 is tlab_size
0N/A sub(top, ThreadLocalAllocBuffer::alignment_reserve_in_bytes(), top);
0N/A st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_end_offset()));
0N/A verify_tlab();
0N/A br(Assembler::always, false, Assembler::pt, retry);
0N/A delayed()->nop();
0N/A}
0N/A
0N/AAssembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
0N/A switch (cond) {
0N/A // Note some conditions are synonyms for others
0N/A case Assembler::never: return Assembler::always;
0N/A case Assembler::zero: return Assembler::notZero;
0N/A case Assembler::lessEqual: return Assembler::greater;
0N/A case Assembler::less: return Assembler::greaterEqual;
0N/A case Assembler::lessEqualUnsigned: return Assembler::greaterUnsigned;
0N/A case Assembler::lessUnsigned: return Assembler::greaterEqualUnsigned;
0N/A case Assembler::negative: return Assembler::positive;
0N/A case Assembler::overflowSet: return Assembler::overflowClear;
0N/A case Assembler::always: return Assembler::never;
0N/A case Assembler::notZero: return Assembler::zero;
0N/A case Assembler::greater: return Assembler::lessEqual;
0N/A case Assembler::greaterEqual: return Assembler::less;
0N/A case Assembler::greaterUnsigned: return Assembler::lessEqualUnsigned;
0N/A case Assembler::greaterEqualUnsigned: return Assembler::lessUnsigned;
0N/A case Assembler::positive: return Assembler::negative;
0N/A case Assembler::overflowClear: return Assembler::overflowSet;
0N/A }
0N/A
0N/A ShouldNotReachHere(); return Assembler::overflowClear;
0N/A}
0N/A
0N/Avoid MacroAssembler::cond_inc(Assembler::Condition cond, address counter_ptr,
0N/A Register Rtmp1, Register Rtmp2 /*, Register Rtmp3, Register Rtmp4 */) {
0N/A Condition negated_cond = negate_condition(cond);
0N/A Label L;
0N/A brx(negated_cond, false, Assembler::pt, L);
0N/A delayed()->nop();
0N/A inc_counter(counter_ptr, Rtmp1, Rtmp2);
0N/A bind(L);
0N/A}
0N/A
727N/Avoid MacroAssembler::inc_counter(address counter_addr, Register Rtmp1, Register Rtmp2) {
727N/A AddressLiteral addrlit(counter_addr);
727N/A sethi(addrlit, Rtmp1); // Move hi22 bits into temporary register.
727N/A Address addr(Rtmp1, addrlit.low10()); // Build an address with low10 bits.
727N/A ld(addr, Rtmp2);
0N/A inc(Rtmp2);
727N/A st(Rtmp2, addr);
727N/A}
727N/A
727N/Avoid MacroAssembler::inc_counter(int* counter_addr, Register Rtmp1, Register Rtmp2) {
727N/A inc_counter((address) counter_addr, Rtmp1, Rtmp2);
0N/A}
0N/A
0N/ASkipIfEqual::SkipIfEqual(
0N/A MacroAssembler* masm, Register temp, const bool* flag_addr,
0N/A Assembler::Condition condition) {
0N/A _masm = masm;
727N/A AddressLiteral flag(flag_addr);
727N/A _masm->sethi(flag, temp);
727N/A _masm->ldub(temp, flag.low10(), temp);
0N/A _masm->tst(temp);
0N/A _masm->br(condition, false, Assembler::pt, _label);
0N/A _masm->delayed()->nop();
0N/A}
0N/A
0N/ASkipIfEqual::~SkipIfEqual() {
0N/A _masm->bind(_label);
0N/A}
0N/A
0N/A
0N/A// Writes to stack successive pages until offset reached to check for
0N/A// stack overflow + shadow pages. This clobbers tsp and scratch.
0N/Avoid MacroAssembler::bang_stack_size(Register Rsize, Register Rtsp,
0N/A Register Rscratch) {
0N/A // Use stack pointer in temp stack pointer
0N/A mov(SP, Rtsp);
0N/A
0N/A // Bang stack for total size given plus stack shadow page size.
0N/A // Bang one page at a time because a large size can overflow yellow and
0N/A // red zones (the bang will fail but stack overflow handling can't tell that
0N/A // it was a stack overflow bang vs a regular segv).
0N/A int offset = os::vm_page_size();
0N/A Register Roffset = Rscratch;
0N/A
0N/A Label loop;
0N/A bind(loop);
0N/A set((-offset)+STACK_BIAS, Rscratch);
0N/A st(G0, Rtsp, Rscratch);
0N/A set(offset, Roffset);
0N/A sub(Rsize, Roffset, Rsize);
0N/A cmp(Rsize, G0);
0N/A br(Assembler::greater, false, Assembler::pn, loop);
0N/A delayed()->sub(Rtsp, Roffset, Rtsp);
0N/A
0N/A // Bang down shadow pages too.
0N/A // The -1 because we already subtracted 1 page.
0N/A for (int i = 0; i< StackShadowPages-1; i++) {
0N/A set((-i*offset)+STACK_BIAS, Rscratch);
0N/A st(G0, Rtsp, Rscratch);
0N/A }
0N/A}
113N/A
342N/A///////////////////////////////////////////////////////////////////////////////////
342N/A#ifndef SERIALGC
342N/A
342N/Astatic uint num_stores = 0;
342N/Astatic uint num_null_pre_stores = 0;
342N/A
342N/Astatic void count_null_pre_vals(void* pre_val) {
342N/A num_stores++;
342N/A if (pre_val == NULL) num_null_pre_stores++;
342N/A if ((num_stores % 1000000) == 0) {
342N/A tty->print_cr(UINT32_FORMAT " stores, " UINT32_FORMAT " (%5.2f%%) with null pre-vals.",
342N/A num_stores, num_null_pre_stores,
342N/A 100.0*(float)num_null_pre_stores/(float)num_stores);
342N/A }
342N/A}
342N/A
342N/Astatic address satb_log_enqueue_with_frame = 0;
342N/Astatic u_char* satb_log_enqueue_with_frame_end = 0;
342N/A
342N/Astatic address satb_log_enqueue_frameless = 0;
342N/Astatic u_char* satb_log_enqueue_frameless_end = 0;
342N/A
342N/Astatic int EnqueueCodeSize = 128 DEBUG_ONLY( + 256); // Instructions?
342N/A
342N/A// The calls to this don't work. We'd need to do a fair amount of work to
342N/A// make it work.
342N/Astatic void check_index(int ind) {
342N/A assert(0 <= ind && ind <= 64*K && ((ind % oopSize) == 0),
1409N/A "Invariants.");
342N/A}
342N/A
342N/Astatic void generate_satb_log_enqueue(bool with_frame) {
342N/A BufferBlob* bb = BufferBlob::create("enqueue_with_frame", EnqueueCodeSize);
1668N/A CodeBuffer buf(bb);
342N/A MacroAssembler masm(&buf);
342N/A address start = masm.pc();
342N/A Register pre_val;
342N/A
342N/A Label refill, restart;
342N/A if (with_frame) {
342N/A masm.save_frame(0);
342N/A pre_val = I0; // Was O0 before the save.
342N/A } else {
342N/A pre_val = O0;
342N/A }
342N/A int satb_q_index_byte_offset =
342N/A in_bytes(JavaThread::satb_mark_queue_offset() +
342N/A PtrQueue::byte_offset_of_index());
342N/A int satb_q_buf_byte_offset =
342N/A in_bytes(JavaThread::satb_mark_queue_offset() +
342N/A PtrQueue::byte_offset_of_buf());
342N/A assert(in_bytes(PtrQueue::byte_width_of_index()) == sizeof(intptr_t) &&
342N/A in_bytes(PtrQueue::byte_width_of_buf()) == sizeof(intptr_t),
342N/A "check sizes in assembly below");
342N/A
342N/A masm.bind(restart);
342N/A masm.ld_ptr(G2_thread, satb_q_index_byte_offset, L0);
342N/A
342N/A masm.br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pn, L0, refill);
342N/A // If the branch is taken, no harm in executing this in the delay slot.
342N/A masm.delayed()->ld_ptr(G2_thread, satb_q_buf_byte_offset, L1);
342N/A masm.sub(L0, oopSize, L0);
342N/A
342N/A masm.st_ptr(pre_val, L1, L0); // [_buf + index] := I0
342N/A if (!with_frame) {
342N/A // Use return-from-leaf
342N/A masm.retl();
342N/A masm.delayed()->st_ptr(L0, G2_thread, satb_q_index_byte_offset);
342N/A } else {
342N/A // Not delayed.
342N/A masm.st_ptr(L0, G2_thread, satb_q_index_byte_offset);
342N/A }
342N/A if (with_frame) {
342N/A masm.ret();
342N/A masm.delayed()->restore();
342N/A }
342N/A masm.bind(refill);
342N/A
342N/A address handle_zero =
342N/A CAST_FROM_FN_PTR(address,
342N/A &SATBMarkQueueSet::handle_zero_index_for_thread);
342N/A // This should be rare enough that we can afford to save all the
342N/A // scratch registers that the calling context might be using.
342N/A masm.mov(G1_scratch, L0);
342N/A masm.mov(G3_scratch, L1);
342N/A masm.mov(G4, L2);
342N/A // We need the value of O0 above (for the write into the buffer), so we
342N/A // save and restore it.
342N/A masm.mov(O0, L3);
342N/A // Since the call will overwrite O7, we save and restore that, as well.
342N/A masm.mov(O7, L4);
342N/A masm.call_VM_leaf(L5, handle_zero, G2_thread);
342N/A masm.mov(L0, G1_scratch);
342N/A masm.mov(L1, G3_scratch);
342N/A masm.mov(L2, G4);
342N/A masm.mov(L3, O0);
342N/A masm.br(Assembler::always, /*annul*/false, Assembler::pt, restart);
342N/A masm.delayed()->mov(L4, O7);
342N/A
342N/A if (with_frame) {
342N/A satb_log_enqueue_with_frame = start;
342N/A satb_log_enqueue_with_frame_end = masm.pc();
342N/A } else {
342N/A satb_log_enqueue_frameless = start;
342N/A satb_log_enqueue_frameless_end = masm.pc();
342N/A }
342N/A}
342N/A
342N/Astatic inline void generate_satb_log_enqueue_if_necessary(bool with_frame) {
342N/A if (with_frame) {
342N/A if (satb_log_enqueue_with_frame == 0) {
342N/A generate_satb_log_enqueue(with_frame);
342N/A assert(satb_log_enqueue_with_frame != 0, "postcondition.");
342N/A if (G1SATBPrintStubs) {
342N/A tty->print_cr("Generated with-frame satb enqueue:");
342N/A Disassembler::decode((u_char*)satb_log_enqueue_with_frame,
342N/A satb_log_enqueue_with_frame_end,
342N/A tty);
342N/A }
342N/A }
342N/A } else {
342N/A if (satb_log_enqueue_frameless == 0) {
342N/A generate_satb_log_enqueue(with_frame);
342N/A assert(satb_log_enqueue_frameless != 0, "postcondition.");
342N/A if (G1SATBPrintStubs) {
342N/A tty->print_cr("Generated frameless satb enqueue:");
342N/A Disassembler::decode((u_char*)satb_log_enqueue_frameless,
342N/A satb_log_enqueue_frameless_end,
342N/A tty);
342N/A }
342N/A }
342N/A }
342N/A}
342N/A
342N/Avoid MacroAssembler::g1_write_barrier_pre(Register obj, Register index, int offset, Register tmp, bool preserve_o_regs) {
342N/A assert(offset == 0 || index == noreg, "choose one");
342N/A
342N/A if (G1DisablePreBarrier) return;
342N/A // satb_log_barrier(tmp, obj, offset, preserve_o_regs);
342N/A Label filtered;
342N/A // satb_log_barrier_work0(tmp, filtered);
342N/A if (in_bytes(PtrQueue::byte_width_of_active()) == 4) {
342N/A ld(G2,
342N/A in_bytes(JavaThread::satb_mark_queue_offset() +
342N/A PtrQueue::byte_offset_of_active()),
342N/A tmp);
342N/A } else {
342N/A guarantee(in_bytes(PtrQueue::byte_width_of_active()) == 1,
342N/A "Assumption");
342N/A ldsb(G2,
342N/A in_bytes(JavaThread::satb_mark_queue_offset() +
342N/A PtrQueue::byte_offset_of_active()),
342N/A tmp);
342N/A }
845N/A
342N/A // Check on whether to annul.
342N/A br_on_reg_cond(rc_z, /*annul*/false, Assembler::pt, tmp, filtered);
342N/A delayed() -> nop();
342N/A
342N/A // satb_log_barrier_work1(tmp, offset);
342N/A if (index == noreg) {
342N/A if (Assembler::is_simm13(offset)) {
845N/A load_heap_oop(obj, offset, tmp);
342N/A } else {
342N/A set(offset, tmp);
845N/A load_heap_oop(obj, tmp, tmp);
342N/A }
342N/A } else {
845N/A load_heap_oop(obj, index, tmp);
342N/A }
342N/A
342N/A // satb_log_barrier_work2(obj, tmp, offset);
342N/A
342N/A // satb_log_barrier_work3(tmp, filtered, preserve_o_regs);
342N/A
342N/A const Register pre_val = tmp;
342N/A
342N/A if (G1SATBBarrierPrintNullPreVals) {
342N/A save_frame(0);
342N/A mov(pre_val, O0);
342N/A // Save G-regs that target may use.
342N/A mov(G1, L1);
342N/A mov(G2, L2);
342N/A mov(G3, L3);
342N/A mov(G4, L4);
342N/A mov(G5, L5);
342N/A call(CAST_FROM_FN_PTR(address, &count_null_pre_vals));
342N/A delayed()->nop();
342N/A // Restore G-regs that target may have used.
342N/A mov(L1, G1);
342N/A mov(L2, G2);
342N/A mov(L3, G3);
342N/A mov(L4, G4);
342N/A mov(L5, G5);
342N/A restore(G0, G0, G0);
342N/A }
342N/A
342N/A // Check on whether to annul.
342N/A br_on_reg_cond(rc_z, /*annul*/false, Assembler::pt, pre_val, filtered);
342N/A delayed() -> nop();
342N/A
342N/A // OK, it's not filtered, so we'll need to call enqueue. In the normal
342N/A // case, pre_val will be a scratch G-reg, but there's some cases in which
342N/A // it's an O-reg. In the first case, do a normal call. In the latter,
342N/A // do a save here and call the frameless version.
342N/A
342N/A guarantee(pre_val->is_global() || pre_val->is_out(),
342N/A "Or we need to think harder.");
342N/A if (pre_val->is_global() && !preserve_o_regs) {
342N/A generate_satb_log_enqueue_if_necessary(true); // with frame.
342N/A call(satb_log_enqueue_with_frame);
342N/A delayed()->mov(pre_val, O0);
342N/A } else {
342N/A generate_satb_log_enqueue_if_necessary(false); // with frameless.
342N/A save_frame(0);
342N/A call(satb_log_enqueue_frameless);
342N/A delayed()->mov(pre_val->after_save(), O0);
342N/A restore();
342N/A }
342N/A
342N/A bind(filtered);
342N/A}
342N/A
342N/Astatic jint num_ct_writes = 0;
342N/Astatic jint num_ct_writes_filtered_in_hr = 0;
342N/Astatic jint num_ct_writes_filtered_null = 0;
342N/Astatic G1CollectedHeap* g1 = NULL;
342N/A
342N/Astatic Thread* count_ct_writes(void* filter_val, void* new_val) {
342N/A Atomic::inc(&num_ct_writes);
342N/A if (filter_val == NULL) {
342N/A Atomic::inc(&num_ct_writes_filtered_in_hr);
342N/A } else if (new_val == NULL) {
342N/A Atomic::inc(&num_ct_writes_filtered_null);
342N/A } else {
342N/A if (g1 == NULL) {
342N/A g1 = G1CollectedHeap::heap();
342N/A }
342N/A }
342N/A if ((num_ct_writes % 1000000) == 0) {
342N/A jint num_ct_writes_filtered =
342N/A num_ct_writes_filtered_in_hr +
677N/A num_ct_writes_filtered_null;
342N/A
342N/A tty->print_cr("%d potential CT writes: %5.2f%% filtered\n"
677N/A " (%5.2f%% intra-HR, %5.2f%% null).",
342N/A num_ct_writes,
342N/A 100.0*(float)num_ct_writes_filtered/(float)num_ct_writes,
342N/A 100.0*(float)num_ct_writes_filtered_in_hr/
342N/A (float)num_ct_writes,
342N/A 100.0*(float)num_ct_writes_filtered_null/
342N/A (float)num_ct_writes);
342N/A }
342N/A return Thread::current();
342N/A}
342N/A
342N/Astatic address dirty_card_log_enqueue = 0;
342N/Astatic u_char* dirty_card_log_enqueue_end = 0;
342N/A
342N/A// This gets to assume that o0 contains the object address.
342N/Astatic void generate_dirty_card_log_enqueue(jbyte* byte_map_base) {
342N/A BufferBlob* bb = BufferBlob::create("dirty_card_enqueue", EnqueueCodeSize*2);
1668N/A CodeBuffer buf(bb);
342N/A MacroAssembler masm(&buf);
342N/A address start = masm.pc();
342N/A
342N/A Label not_already_dirty, restart, refill;
342N/A
342N/A#ifdef _LP64
342N/A masm.srlx(O0, CardTableModRefBS::card_shift, O0);
342N/A#else
342N/A masm.srl(O0, CardTableModRefBS::card_shift, O0);
342N/A#endif
727N/A AddressLiteral addrlit(byte_map_base);
727N/A masm.set(addrlit, O1); // O1 := <card table base>
342N/A masm.ldub(O0, O1, O2); // O2 := [O0 + O1]
342N/A
342N/A masm.br_on_reg_cond(Assembler::rc_nz, /*annul*/false, Assembler::pt,
342N/A O2, not_already_dirty);
342N/A // Get O1 + O2 into a reg by itself -- useful in the take-the-branch
342N/A // case, harmless if not.
342N/A masm.delayed()->add(O0, O1, O3);
342N/A
342N/A // We didn't take the branch, so we're already dirty: return.
342N/A // Use return-from-leaf
342N/A masm.retl();
342N/A masm.delayed()->nop();
342N/A
342N/A // Not dirty.
342N/A masm.bind(not_already_dirty);
342N/A // First, dirty it.
342N/A masm.stb(G0, O3, G0); // [cardPtr] := 0 (i.e., dirty).
342N/A int dirty_card_q_index_byte_offset =
342N/A in_bytes(JavaThread::dirty_card_queue_offset() +
342N/A PtrQueue::byte_offset_of_index());
342N/A int dirty_card_q_buf_byte_offset =
342N/A in_bytes(JavaThread::dirty_card_queue_offset() +
342N/A PtrQueue::byte_offset_of_buf());
342N/A masm.bind(restart);
342N/A masm.ld_ptr(G2_thread, dirty_card_q_index_byte_offset, L0);
342N/A
342N/A masm.br_on_reg_cond(Assembler::rc_z, /*annul*/false, Assembler::pn,
342N/A L0, refill);
342N/A // If the branch is taken, no harm in executing this in the delay slot.
342N/A masm.delayed()->ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, L1);
342N/A masm.sub(L0, oopSize, L0);
342N/A
342N/A masm.st_ptr(O3, L1, L0); // [_buf + index] := I0
342N/A // Use return-from-leaf
342N/A masm.retl();
342N/A masm.delayed()->st_ptr(L0, G2_thread, dirty_card_q_index_byte_offset);
342N/A
342N/A masm.bind(refill);
342N/A address handle_zero =
342N/A CAST_FROM_FN_PTR(address,
342N/A &DirtyCardQueueSet::handle_zero_index_for_thread);
342N/A // This should be rare enough that we can afford to save all the
342N/A // scratch registers that the calling context might be using.
342N/A masm.mov(G1_scratch, L3);
342N/A masm.mov(G3_scratch, L5);
342N/A // We need the value of O3 above (for the write into the buffer), so we
342N/A // save and restore it.
342N/A masm.mov(O3, L6);
342N/A // Since the call will overwrite O7, we save and restore that, as well.
342N/A masm.mov(O7, L4);
342N/A
342N/A masm.call_VM_leaf(L7_thread_cache, handle_zero, G2_thread);
342N/A masm.mov(L3, G1_scratch);
342N/A masm.mov(L5, G3_scratch);
342N/A masm.mov(L6, O3);
342N/A masm.br(Assembler::always, /*annul*/false, Assembler::pt, restart);
342N/A masm.delayed()->mov(L4, O7);
342N/A
342N/A dirty_card_log_enqueue = start;
342N/A dirty_card_log_enqueue_end = masm.pc();
342N/A // XXX Should have a guarantee here about not going off the end!
342N/A // Does it already do so? Do an experiment...
342N/A}
342N/A
342N/Astatic inline void
342N/Agenerate_dirty_card_log_enqueue_if_necessary(jbyte* byte_map_base) {
342N/A if (dirty_card_log_enqueue == 0) {
342N/A generate_dirty_card_log_enqueue(byte_map_base);
342N/A assert(dirty_card_log_enqueue != 0, "postcondition.");
342N/A if (G1SATBPrintStubs) {
342N/A tty->print_cr("Generated dirty_card enqueue:");
342N/A Disassembler::decode((u_char*)dirty_card_log_enqueue,
342N/A dirty_card_log_enqueue_end,
342N/A tty);
342N/A }
342N/A }
342N/A}
342N/A
342N/A
342N/Avoid MacroAssembler::g1_write_barrier_post(Register store_addr, Register new_val, Register tmp) {
342N/A
342N/A Label filtered;
342N/A MacroAssembler* post_filter_masm = this;
342N/A
342N/A if (new_val == G0) return;
342N/A if (G1DisablePostBarrier) return;
342N/A
342N/A G1SATBCardTableModRefBS* bs = (G1SATBCardTableModRefBS*) Universe::heap()->barrier_set();
342N/A assert(bs->kind() == BarrierSet::G1SATBCT ||
342N/A bs->kind() == BarrierSet::G1SATBCTLogging, "wrong barrier");
342N/A if (G1RSBarrierRegionFilter) {
342N/A xor3(store_addr, new_val, tmp);
342N/A#ifdef _LP64
342N/A srlx(tmp, HeapRegion::LogOfHRGrainBytes, tmp);
342N/A#else
342N/A srl(tmp, HeapRegion::LogOfHRGrainBytes, tmp);
342N/A#endif
342N/A if (G1PrintCTFilterStats) {
342N/A guarantee(tmp->is_global(), "Or stats won't work...");
342N/A // This is a sleazy hack: I'm temporarily hijacking G2, which I
342N/A // promise to restore.
342N/A mov(new_val, G2);
342N/A save_frame(0);
342N/A mov(tmp, O0);
342N/A mov(G2, O1);
342N/A // Save G-regs that target may use.
342N/A mov(G1, L1);
342N/A mov(G2, L2);
342N/A mov(G3, L3);
342N/A mov(G4, L4);
342N/A mov(G5, L5);
342N/A call(CAST_FROM_FN_PTR(address, &count_ct_writes));
342N/A delayed()->nop();
342N/A mov(O0, G2);
342N/A // Restore G-regs that target may have used.
342N/A mov(L1, G1);
342N/A mov(L3, G3);
342N/A mov(L4, G4);
342N/A mov(L5, G5);
342N/A restore(G0, G0, G0);
342N/A }
342N/A // XXX Should I predict this taken or not? Does it mattern?
342N/A br_on_reg_cond(rc_z, /*annul*/false, Assembler::pt, tmp, filtered);
342N/A delayed()->nop();
342N/A }
342N/A
794N/A // If the "store_addr" register is an "in" or "local" register, move it to
794N/A // a scratch reg so we can pass it as an argument.
794N/A bool use_scr = !(store_addr->is_global() || store_addr->is_out());
794N/A // Pick a scratch register different from "tmp".
794N/A Register scr = (tmp == G1_scratch ? G3_scratch : G1_scratch);
794N/A // Make sure we use up the delay slot!
794N/A if (use_scr) {
794N/A post_filter_masm->mov(store_addr, scr);
342N/A } else {
794N/A post_filter_masm->nop();
342N/A }
794N/A generate_dirty_card_log_enqueue_if_necessary(bs->byte_map_base);
794N/A save_frame(0);
794N/A call(dirty_card_log_enqueue);
794N/A if (use_scr) {
794N/A delayed()->mov(scr, O0);
794N/A } else {
794N/A delayed()->mov(store_addr->after_save(), O0);
794N/A }
794N/A restore();
342N/A
342N/A bind(filtered);
342N/A
342N/A}
342N/A
342N/A#endif // SERIALGC
342N/A///////////////////////////////////////////////////////////////////////////////////
342N/A
342N/Avoid MacroAssembler::card_write_barrier_post(Register store_addr, Register new_val, Register tmp) {
342N/A // If we're writing constant NULL, we can skip the write barrier.
342N/A if (new_val == G0) return;
342N/A CardTableModRefBS* bs = (CardTableModRefBS*) Universe::heap()->barrier_set();
342N/A assert(bs->kind() == BarrierSet::CardTableModRef ||
342N/A bs->kind() == BarrierSet::CardTableExtension, "wrong barrier");
342N/A card_table_write(bs->byte_map_base, tmp, store_addr);
342N/A}
342N/A
164N/Avoid MacroAssembler::load_klass(Register src_oop, Register klass) {
113N/A // The number of bytes in this code is used by
113N/A // MachCallDynamicJavaNode::ret_addr_offset()
113N/A // if this changes, change that.
113N/A if (UseCompressedOops) {
164N/A lduw(src_oop, oopDesc::klass_offset_in_bytes(), klass);
164N/A decode_heap_oop_not_null(klass);
113N/A } else {
164N/A ld_ptr(src_oop, oopDesc::klass_offset_in_bytes(), klass);
113N/A }
113N/A}
113N/A
164N/Avoid MacroAssembler::store_klass(Register klass, Register dst_oop) {
113N/A if (UseCompressedOops) {
164N/A assert(dst_oop != klass, "not enough registers");
164N/A encode_heap_oop_not_null(klass);
167N/A st(klass, dst_oop, oopDesc::klass_offset_in_bytes());
113N/A } else {
164N/A st_ptr(klass, dst_oop, oopDesc::klass_offset_in_bytes());
113N/A }
113N/A}
113N/A
167N/Avoid MacroAssembler::store_klass_gap(Register s, Register d) {
167N/A if (UseCompressedOops) {
167N/A assert(s != d, "not enough registers");
167N/A st(s, d, oopDesc::klass_gap_offset_in_bytes());
113N/A }
113N/A}
113N/A
727N/Avoid MacroAssembler::load_heap_oop(const Address& s, Register d) {
113N/A if (UseCompressedOops) {
727N/A lduw(s, d);
113N/A decode_heap_oop(d);
113N/A } else {
727N/A ld_ptr(s, d);
113N/A }
113N/A}
113N/A
113N/Avoid MacroAssembler::load_heap_oop(Register s1, Register s2, Register d) {
113N/A if (UseCompressedOops) {
113N/A lduw(s1, s2, d);
113N/A decode_heap_oop(d, d);
113N/A } else {
113N/A ld_ptr(s1, s2, d);
113N/A }
113N/A}
113N/A
113N/Avoid MacroAssembler::load_heap_oop(Register s1, int simm13a, Register d) {
113N/A if (UseCompressedOops) {
113N/A lduw(s1, simm13a, d);
113N/A decode_heap_oop(d, d);
113N/A } else {
113N/A ld_ptr(s1, simm13a, d);
113N/A }
113N/A}
113N/A
1766N/Avoid MacroAssembler::load_heap_oop(Register s1, RegisterOrConstant s2, Register d) {
1766N/A if (s2.is_constant()) load_heap_oop(s1, s2.as_constant(), d);
1766N/A else load_heap_oop(s1, s2.as_register(), d);
1766N/A}
1766N/A
113N/Avoid MacroAssembler::store_heap_oop(Register d, Register s1, Register s2) {
113N/A if (UseCompressedOops) {
113N/A assert(s1 != d && s2 != d, "not enough registers");
113N/A encode_heap_oop(d);
113N/A st(d, s1, s2);
113N/A } else {
113N/A st_ptr(d, s1, s2);
113N/A }
113N/A}
113N/A
113N/Avoid MacroAssembler::store_heap_oop(Register d, Register s1, int simm13a) {
113N/A if (UseCompressedOops) {
113N/A assert(s1 != d, "not enough registers");
113N/A encode_heap_oop(d);
113N/A st(d, s1, simm13a);
113N/A } else {
113N/A st_ptr(d, s1, simm13a);
113N/A }
113N/A}
113N/A
113N/Avoid MacroAssembler::store_heap_oop(Register d, const Address& a, int offset) {
113N/A if (UseCompressedOops) {
113N/A assert(a.base() != d, "not enough registers");
113N/A encode_heap_oop(d);
113N/A st(d, a, offset);
113N/A } else {
113N/A st_ptr(d, a, offset);
113N/A }
113N/A}
113N/A
113N/A
113N/Avoid MacroAssembler::encode_heap_oop(Register src, Register dst) {
113N/A assert (UseCompressedOops, "must be compressed");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
178N/A verify_oop(src);
642N/A if (Universe::narrow_oop_base() == NULL) {
642N/A srlx(src, LogMinObjAlignmentInBytes, dst);
642N/A return;
642N/A }
113N/A Label done;
113N/A if (src == dst) {
113N/A // optimize for frequent case src == dst
113N/A bpr(rc_nz, true, Assembler::pt, src, done);
113N/A delayed() -> sub(src, G6_heapbase, dst); // annuled if not taken
113N/A bind(done);
113N/A srlx(src, LogMinObjAlignmentInBytes, dst);
113N/A } else {
113N/A bpr(rc_z, false, Assembler::pn, src, done);
113N/A delayed() -> mov(G0, dst);
113N/A // could be moved before branch, and annulate delay,
113N/A // but may add some unneeded work decoding null
113N/A sub(src, G6_heapbase, dst);
113N/A srlx(dst, LogMinObjAlignmentInBytes, dst);
113N/A bind(done);
113N/A }
113N/A}
113N/A
113N/A
113N/Avoid MacroAssembler::encode_heap_oop_not_null(Register r) {
113N/A assert (UseCompressedOops, "must be compressed");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
178N/A verify_oop(r);
642N/A if (Universe::narrow_oop_base() != NULL)
642N/A sub(r, G6_heapbase, r);
113N/A srlx(r, LogMinObjAlignmentInBytes, r);
113N/A}
113N/A
124N/Avoid MacroAssembler::encode_heap_oop_not_null(Register src, Register dst) {
124N/A assert (UseCompressedOops, "must be compressed");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
178N/A verify_oop(src);
642N/A if (Universe::narrow_oop_base() == NULL) {
642N/A srlx(src, LogMinObjAlignmentInBytes, dst);
642N/A } else {
642N/A sub(src, G6_heapbase, dst);
642N/A srlx(dst, LogMinObjAlignmentInBytes, dst);
642N/A }
124N/A}
124N/A
113N/A// Same algorithm as oops.inline.hpp decode_heap_oop.
113N/Avoid MacroAssembler::decode_heap_oop(Register src, Register dst) {
113N/A assert (UseCompressedOops, "must be compressed");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
113N/A sllx(src, LogMinObjAlignmentInBytes, dst);
642N/A if (Universe::narrow_oop_base() != NULL) {
642N/A Label done;
642N/A bpr(rc_nz, true, Assembler::pt, dst, done);
642N/A delayed() -> add(dst, G6_heapbase, dst); // annuled if not taken
642N/A bind(done);
642N/A }
178N/A verify_oop(dst);
113N/A}
113N/A
113N/Avoid MacroAssembler::decode_heap_oop_not_null(Register r) {
113N/A // Do not add assert code to this unless you change vtableStubs_sparc.cpp
113N/A // pd_code_size_limit.
178N/A // Also do not verify_oop as this is called by verify_oop.
113N/A assert (UseCompressedOops, "must be compressed");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
113N/A sllx(r, LogMinObjAlignmentInBytes, r);
642N/A if (Universe::narrow_oop_base() != NULL)
642N/A add(r, G6_heapbase, r);
113N/A}
113N/A
124N/Avoid MacroAssembler::decode_heap_oop_not_null(Register src, Register dst) {
124N/A // Do not add assert code to this unless you change vtableStubs_sparc.cpp
124N/A // pd_code_size_limit.
178N/A // Also do not verify_oop as this is called by verify_oop.
124N/A assert (UseCompressedOops, "must be compressed");
642N/A assert (Universe::heap() != NULL, "java heap should be initialized");
642N/A assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
124N/A sllx(src, LogMinObjAlignmentInBytes, dst);
642N/A if (Universe::narrow_oop_base() != NULL)
642N/A add(dst, G6_heapbase, dst);
124N/A}
124N/A
113N/Avoid MacroAssembler::reinit_heapbase() {
113N/A if (UseCompressedOops) {
113N/A // call indirectly to solve generation ordering problem
727N/A AddressLiteral base(Universe::narrow_oop_base_addr());
113N/A load_ptr_contents(base, G6_heapbase);
113N/A }
113N/A}
986N/A
986N/A// Compare char[] arrays aligned to 4 bytes.
986N/Avoid MacroAssembler::char_arrays_equals(Register ary1, Register ary2,
986N/A Register limit, Register result,
986N/A Register chr1, Register chr2, Label& Ldone) {
986N/A Label Lvector, Lloop;
986N/A assert(chr1 == result, "should be the same");
986N/A
986N/A // Note: limit contains number of bytes (2*char_elements) != 0.
986N/A andcc(limit, 0x2, chr1); // trailing character ?
986N/A br(Assembler::zero, false, Assembler::pt, Lvector);
986N/A delayed()->nop();
986N/A
986N/A // compare the trailing char
986N/A sub(limit, sizeof(jchar), limit);
986N/A lduh(ary1, limit, chr1);
986N/A lduh(ary2, limit, chr2);
986N/A cmp(chr1, chr2);
986N/A br(Assembler::notEqual, true, Assembler::pt, Ldone);
986N/A delayed()->mov(G0, result); // not equal
986N/A
986N/A // only one char ?
986N/A br_on_reg_cond(rc_z, true, Assembler::pn, limit, Ldone);
986N/A delayed()->add(G0, 1, result); // zero-length arrays are equal
986N/A
986N/A // word by word compare, dont't need alignment check
986N/A bind(Lvector);
986N/A // Shift ary1 and ary2 to the end of the arrays, negate limit
986N/A add(ary1, limit, ary1);
986N/A add(ary2, limit, ary2);
986N/A neg(limit, limit);
986N/A
986N/A lduw(ary1, limit, chr1);
986N/A bind(Lloop);
986N/A lduw(ary2, limit, chr2);
986N/A cmp(chr1, chr2);
986N/A br(Assembler::notEqual, true, Assembler::pt, Ldone);
986N/A delayed()->mov(G0, result); // not equal
986N/A inccc(limit, 2*sizeof(jchar));
986N/A // annul LDUW if branch is not taken to prevent access past end of array
986N/A br(Assembler::notZero, true, Assembler::pt, Lloop);
986N/A delayed()->lduw(ary1, limit, chr1); // hoisted
986N/A
986N/A // Caller should set it:
986N/A // add(G0, 1, result); // equals
986N/A}
986N/A