1.1 --- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Jan 14 12:44:12 2014 +0100 1.2 +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Jan 14 14:51:47 2014 +0100 1.3 @@ -1315,7 +1315,7 @@ 1.4 } 1.5 1.6 Address LIR_Assembler::as_Address(LIR_Address* addr) { 1.7 - Register reg = addr->base()->as_register(); 1.8 + Register reg = addr->base()->as_pointer_register(); 1.9 LIR_Opr index = addr->index(); 1.10 if (index->is_illegal()) { 1.11 return Address(reg, addr->disp()); 1.12 @@ -3101,7 +3101,145 @@ 1.13 } 1.14 1.15 void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) { 1.16 - fatal("Type profiling not implemented on this platform"); 1.17 + Register obj = op->obj()->as_register(); 1.18 + Register tmp1 = op->tmp()->as_pointer_register(); 1.19 + Register tmp2 = G1; 1.20 + Address mdo_addr = as_Address(op->mdp()->as_address_ptr()); 1.21 + ciKlass* exact_klass = op->exact_klass(); 1.22 + intptr_t current_klass = op->current_klass(); 1.23 + bool not_null = op->not_null(); 1.24 + bool no_conflict = op->no_conflict(); 1.25 + 1.26 + Label update, next, none; 1.27 + 1.28 + bool do_null = !not_null; 1.29 + bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass; 1.30 + bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set; 1.31 + 1.32 + assert(do_null || do_update, "why are we here?"); 1.33 + assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?"); 1.34 + 1.35 + __ verify_oop(obj); 1.36 + 1.37 + if (tmp1 != obj) { 1.38 + __ mov(obj, tmp1); 1.39 + } 1.40 + if (do_null) { 1.41 + __ br_notnull_short(tmp1, Assembler::pt, update); 1.42 + if (!TypeEntries::was_null_seen(current_klass)) { 1.43 + __ ld_ptr(mdo_addr, tmp1); 1.44 + __ or3(tmp1, TypeEntries::null_seen, tmp1); 1.45 + __ st_ptr(tmp1, mdo_addr); 1.46 + } 1.47 + if (do_update) { 1.48 + __ ba(next); 1.49 + __ delayed()->nop(); 1.50 + } 1.51 +#ifdef ASSERT 1.52 + } else { 1.53 + __ br_notnull_short(tmp1, Assembler::pt, update); 1.54 + __ stop("unexpect null obj"); 1.55 +#endif 1.56 + } 1.57 + 1.58 + __ bind(update); 1.59 + 1.60 + if (do_update) { 1.61 +#ifdef ASSERT 1.62 + if (exact_klass != NULL) { 1.63 + Label ok; 1.64 + __ load_klass(tmp1, tmp1); 1.65 + metadata2reg(exact_klass->constant_encoding(), tmp2); 1.66 + __ cmp_and_br_short(tmp1, tmp2, Assembler::equal, Assembler::pt, ok); 1.67 + __ stop("exact klass and actual klass differ"); 1.68 + __ bind(ok); 1.69 + } 1.70 +#endif 1.71 + 1.72 + Label do_update; 1.73 + __ ld_ptr(mdo_addr, tmp2); 1.74 + 1.75 + if (!no_conflict) { 1.76 + if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) { 1.77 + if (exact_klass != NULL) { 1.78 + metadata2reg(exact_klass->constant_encoding(), tmp1); 1.79 + } else { 1.80 + __ load_klass(tmp1, tmp1); 1.81 + } 1.82 + 1.83 + __ xor3(tmp1, tmp2, tmp1); 1.84 + __ btst(TypeEntries::type_klass_mask, tmp1); 1.85 + // klass seen before, nothing to do. The unknown bit may have been 1.86 + // set already but no need to check. 1.87 + __ brx(Assembler::zero, false, Assembler::pt, next); 1.88 + __ delayed()-> 1.89 + 1.90 + btst(TypeEntries::type_unknown, tmp1); 1.91 + // already unknown. Nothing to do anymore. 1.92 + __ brx(Assembler::notZero, false, Assembler::pt, next); 1.93 + 1.94 + if (TypeEntries::is_type_none(current_klass)) { 1.95 + __ delayed()->btst(TypeEntries::type_mask, tmp2); 1.96 + __ brx(Assembler::zero, true, Assembler::pt, do_update); 1.97 + // first time here. Set profile type. 1.98 + __ delayed()->or3(tmp2, tmp1, tmp2); 1.99 + } else { 1.100 + __ delayed()->nop(); 1.101 + } 1.102 + } else { 1.103 + assert(ciTypeEntries::valid_ciklass(current_klass) != NULL && 1.104 + ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only"); 1.105 + 1.106 + __ btst(TypeEntries::type_unknown, tmp2); 1.107 + // already unknown. Nothing to do anymore. 1.108 + __ brx(Assembler::notZero, false, Assembler::pt, next); 1.109 + __ delayed()->nop(); 1.110 + } 1.111 + 1.112 + // different than before. Cannot keep accurate profile. 1.113 + __ or3(tmp2, TypeEntries::type_unknown, tmp2); 1.114 + } else { 1.115 + // There's a single possible klass at this profile point 1.116 + assert(exact_klass != NULL, "should be"); 1.117 + if (TypeEntries::is_type_none(current_klass)) { 1.118 + metadata2reg(exact_klass->constant_encoding(), tmp1); 1.119 + __ xor3(tmp1, tmp2, tmp1); 1.120 + __ btst(TypeEntries::type_klass_mask, tmp1); 1.121 + __ brx(Assembler::zero, false, Assembler::pt, next); 1.122 +#ifdef ASSERT 1.123 + 1.124 + { 1.125 + Label ok; 1.126 + __ delayed()->btst(TypeEntries::type_mask, tmp2); 1.127 + __ brx(Assembler::zero, true, Assembler::pt, ok); 1.128 + __ delayed()->nop(); 1.129 + 1.130 + __ stop("unexpected profiling mismatch"); 1.131 + __ bind(ok); 1.132 + } 1.133 + // first time here. Set profile type. 1.134 + __ or3(tmp2, tmp1, tmp2); 1.135 +#else 1.136 + // first time here. Set profile type. 1.137 + __ delayed()->or3(tmp2, tmp1, tmp2); 1.138 +#endif 1.139 + 1.140 + } else { 1.141 + assert(ciTypeEntries::valid_ciklass(current_klass) != NULL && 1.142 + ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent"); 1.143 + 1.144 + // already unknown. Nothing to do anymore. 1.145 + __ btst(TypeEntries::type_unknown, tmp2); 1.146 + __ brx(Assembler::notZero, false, Assembler::pt, next); 1.147 + __ delayed()->or3(tmp2, TypeEntries::type_unknown, tmp2); 1.148 + } 1.149 + } 1.150 + 1.151 + __ bind(do_update); 1.152 + __ st_ptr(tmp2, mdo_addr); 1.153 + 1.154 + __ bind(next); 1.155 + } 1.156 } 1.157 1.158 void LIR_Assembler::align_backward_branch_target() { 1.159 @@ -3321,9 +3459,14 @@ 1.160 1.161 void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest) { 1.162 LIR_Address* addr = addr_opr->as_address_ptr(); 1.163 - assert(addr->index()->is_illegal() && addr->scale() == LIR_Address::times_1 && Assembler::is_simm13(addr->disp()), "can't handle complex addresses yet"); 1.164 - 1.165 - __ add(addr->base()->as_pointer_register(), addr->disp(), dest->as_pointer_register()); 1.166 + assert(addr->index()->is_illegal() && addr->scale() == LIR_Address::times_1, "can't handle complex addresses yet"); 1.167 + 1.168 + if (Assembler::is_simm13(addr->disp())) { 1.169 + __ add(addr->base()->as_pointer_register(), addr->disp(), dest->as_pointer_register()); 1.170 + } else { 1.171 + __ set(addr->disp(), G3_scratch); 1.172 + __ add(addr->base()->as_pointer_register(), G3_scratch, dest->as_pointer_register()); 1.173 + } 1.174 } 1.175 1.176