1.1 --- a/src/cpu/mips/vm/c1_LIRGenerator_mips.cpp Sat Jan 06 16:30:58 2018 +0800 1.2 +++ b/src/cpu/mips/vm/c1_LIRGenerator_mips.cpp Thu May 24 19:49:50 2018 +0800 1.3 @@ -235,47 +235,57 @@ 1.4 } 1.5 } 1.6 1.7 -LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr,BasicType type, bool needs_card_mark) { 1.8 - int offset_in_bytes = arrayOopDesc::base_offset_in_bytes(type); 1.9 +LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, 1.10 + BasicType type, bool needs_card_mark) { 1.11 + int elem_size = type2aelembytes(type); 1.12 + int shift = exact_log2(elem_size); 1.13 1.14 - LIR_Address* addr; 1.15 + LIR_Opr base_opr; 1.16 + int offset = arrayOopDesc::base_offset_in_bytes(type); 1.17 + 1.18 if (index_opr->is_constant()) { 1.19 - int elem_size = _type2aelembytes[type]; 1.20 - addr = new LIR_Address(array_opr, 1.21 - offset_in_bytes + index_opr->as_jint() * elem_size, type); 1.22 - } else if( index_opr->is_register()){ 1.23 + int i = index_opr->as_constant_ptr()->as_jint(); 1.24 + int array_offset = i * elem_size; 1.25 + if (Assembler::is_simm16(array_offset + offset)) { 1.26 + base_opr = array_opr; 1.27 + offset = array_offset + offset; 1.28 + } else { 1.29 + base_opr = new_pointer_register(); 1.30 + if (Assembler::is_simm16(array_offset)) { 1.31 + __ add(array_opr, LIR_OprFact::intptrConst(array_offset), base_opr); 1.32 + } else { 1.33 + __ move(LIR_OprFact::intptrConst(array_offset), base_opr); 1.34 + __ add(base_opr, array_opr, base_opr); 1.35 + } 1.36 + } 1.37 + } else { 1.38 #ifdef _LP64 1.39 - LIR_Opr tmp = new_register(T_LONG); 1.40 -#else 1.41 - LIR_Opr tmp = new_register(T_INT); 1.42 + if (index_opr->type() == T_INT) { 1.43 + LIR_Opr tmp = new_register(T_LONG); 1.44 + __ convert(Bytecodes::_i2l, index_opr, tmp); 1.45 + index_opr = tmp; 1.46 + } 1.47 #endif 1.48 - __ move(index_opr, tmp); 1.49 - __ shift_left(tmp, LIR_Address::scale(type),tmp); 1.50 - __ add(tmp, array_opr, tmp); 1.51 - addr = new LIR_Address(tmp, offset_in_bytes,type); 1.52 1.53 + base_opr = new_pointer_register(); 1.54 + assert (index_opr->is_register(), "Must be register"); 1.55 + if (shift > 0) { 1.56 + __ shift_left(index_opr, shift, base_opr); 1.57 + __ add(base_opr, array_opr, base_opr); 1.58 + } else { 1.59 + __ add(index_opr, array_opr, base_opr); 1.60 + } 1.61 } 1.62 - else{ 1.63 - addr = new LIR_Address(array_opr, 1.64 - offset_in_bytes, type); 1.65 - } 1.66 - 1.67 if (needs_card_mark) { 1.68 // This store will need a precise card mark, so go ahead and 1.69 // compute the full adddres instead of computing once for the 1.70 // store and again for the card mark. 1.71 -#ifdef _LP64 1.72 - LIR_Opr tmp = new_register(T_ADDRESS); 1.73 -#else 1.74 - LIR_Opr tmp = new_register(T_INT); 1.75 -#endif 1.76 - __ leal(LIR_OprFact::address(addr), tmp); 1.77 - return new LIR_Address(tmp, 0, type); 1.78 + LIR_Opr ptr = new_pointer_register(); 1.79 + __ add(base_opr, LIR_OprFact::intptrConst(offset), ptr); 1.80 + return new LIR_Address(ptr, type); 1.81 } else { 1.82 - return addr; 1.83 + return new LIR_Address(base_opr, offset, type); 1.84 } 1.85 - 1.86 - 1.87 } 1.88 1.89 1.90 @@ -292,21 +302,29 @@ 1.91 } 1.92 1.93 void LIRGenerator::increment_counter(address counter, BasicType type, int step) { 1.94 - LIR_Opr temp = new_register(T_INT); 1.95 +#ifdef _LP64 1.96 + LIR_Opr pointer = new_register(T_LONG); 1.97 +#else 1.98 LIR_Opr pointer = new_register(T_INT); 1.99 -#ifndef _LP64 1.100 - __ move(LIR_OprFact::intConst((int)counter), pointer); 1.101 -#else 1.102 - __ move(LIR_OprFact::longConst((long)counter), pointer); 1.103 #endif 1.104 - LIR_Opr addr = (LIR_Opr)new LIR_Address(pointer, type); 1.105 - LIR_Opr c = LIR_OprFact::intConst((int)step); 1.106 - __ add(addr, c, addr); 1.107 + __ move(LIR_OprFact::intptrConst(counter), pointer); 1.108 + LIR_Address* addr = new LIR_Address(pointer, type); 1.109 + increment_counter(addr, step); 1.110 } 1.111 1.112 +//void LIRGenerator::increment_counter(address counter, BasicType type, int step) { 1.113 +// LIR_Opr pointer = new_register(T_LONG); 1.114 +// __ move(LIR_OprFact::longConst((long)counter), pointer); 1.115 +// LIR_Opr addr = (LIR_Opr)new LIR_Address(pointer, type); 1.116 +// LIR_Opr c = LIR_OprFact::intConst((int)step); 1.117 +// __ add(addr, c, addr); 1.118 +//} 1.119 1.120 void LIRGenerator::increment_counter(LIR_Address* addr, int step) { 1.121 - Unimplemented(); 1.122 + LIR_Opr temp = new_register(addr->type()); 1.123 + __ move(addr, temp); 1.124 + __ add(temp, load_immediate(step, addr->type()), temp); 1.125 + __ move(temp, addr); 1.126 } 1.127 1.128 1.129 @@ -526,33 +544,14 @@ 1.130 default: 1.131 ShouldNotReachHere(); 1.132 } 1.133 + 1.134 // order of arguments to runtime call is reversed. 1.135 LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL); 1.136 set_result(x, result); 1.137 break; 1.138 } 1.139 - /* _ladd, _lsub is delete in sharedRuntime.hpp 1.140 case Bytecodes::_ladd: 1.141 - case Bytecodes::_lsub: { 1.142 - address entry; 1.143 - switch (x->op()) { 1.144 - case Bytecodes::_ladd: 1.145 - entry = CAST_FROM_FN_PTR(address, SharedRuntime::ladd); 1.146 - break; // check if dividend is 0 is done elsewhere 1.147 - case Bytecodes::_lsub: 1.148 - entry = CAST_FROM_FN_PTR(address, SharedRuntime::lsub); 1.149 - break; // check if dividend is 0 is done elsewhere 1.150 - default: 1.151 - ShouldNotReachHere(); 1.152 - } 1.153 - 1.154 - // order of arguments to runtime call is reversed. 1.155 - LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL); 1.156 - set_result(x, result); 1.157 - break; 1.158 - }*/ 1.159 - 1.160 -/* { 1.161 + case Bytecodes::_lsub: { 1.162 LIRItem left(x->x(), this); 1.163 LIRItem right(x->y(), this); 1.164 left.load_item(); 1.165 @@ -562,8 +561,8 @@ 1.166 arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL); 1.167 break; 1.168 } 1.169 -*/ 1.170 - default: ShouldNotReachHere(); 1.171 + default: 1.172 + ShouldNotReachHere(); 1.173 } 1.174 } 1.175 1.176 @@ -620,31 +619,6 @@ 1.177 1.178 // _ishl, _lshl, _ishr, _lshr, _iushr, _lushr 1.179 void LIRGenerator::do_ShiftOp(ShiftOp* x) { 1.180 - if(x->op() == Bytecodes::_lshl 1.181 - || x->op() == Bytecodes::_lshr 1.182 - || x->op() == Bytecodes::_lushr) { 1.183 - address entry; 1.184 - /* lushr, lshr, lshl, is delete in ShredRuntime.hpp 1.185 - switch (x->op()) { 1.186 - case Bytecodes::_lshl: 1.187 - entry = CAST_FROM_FN_PTR(address, SharedRuntime::lshl); 1.188 - break; // check if dividend is 0 is done elsewhere 1.189 - case Bytecodes::_lshr: 1.190 - entry = CAST_FROM_FN_PTR(address, SharedRuntime::lshr); 1.191 - break; // check if dividend is 0 is done elsewhere 1.192 - case Bytecodes::_lushr: 1.193 - entry = CAST_FROM_FN_PTR(address, SharedRuntime::lushr); 1.194 - break; 1.195 - default: 1.196 - ShouldNotReachHere(); 1.197 - } 1.198 - */ 1.199 - // order of arguments to runtime call is reversed. 1.200 - LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL); 1.201 - set_result(x, result); 1.202 - return; 1.203 - } 1.204 - 1.205 // count must always be in rcx 1.206 LIRItem value(x->x(), this); 1.207 LIRItem count(x->y(), this); 1.208 @@ -881,7 +855,6 @@ 1.209 } 1.210 1.211 void LIRGenerator::do_update_CRC32(Intrinsic* x) { // Fu: 20130832 1.212 - tty->print_cr("LIRGenerator::do_update_CRC32 unimplemented yet !"); 1.213 Unimplemented(); 1.214 } 1.215 1.216 @@ -962,7 +935,8 @@ 1.217 fixed_result = true; 1.218 round_result = false; 1.219 needs_stub = false; break; 1.220 - default: ShouldNotReachHere(); 1.221 + default: 1.222 + ShouldNotReachHere(); 1.223 } 1.224 1.225 LIRItem value(x->value(), this); 1.226 @@ -1015,15 +989,13 @@ 1.227 // LIR_Opr tmp3 = new_register(T_INT); 1.228 // LIR_Opr tmp4 = new_register(T_INT); 1.229 #ifndef _LP64 1.230 - LIR_Opr klass_reg = FrameMap::_t4_oop_opr; 1.231 + LIR_Opr klass_reg = FrameMap::_t4_metadata_opr; 1.232 #else 1.233 - LIR_Opr klass_reg = FrameMap::_a4_oop_opr; 1.234 + LIR_Opr klass_reg = FrameMap::_a4_metadata_opr; 1.235 #endif 1.236 -// new_instance(reg, x->klass(), FrameMap::_t0_oop_opr, FrameMap::_t1_oop_opr,FrameMap::_t2_oop_opr, LIR_OprFact::illegalOpr, klass_reg, info); 1.237 - guarantee(false, "not implemented yet."); 1.238 -/* 1.239 new_instance(reg, 1.240 x->klass(), 1.241 + x->is_unresolved(), 1.242 FrameMap::_t0_oop_opr, 1.243 FrameMap::_t1_oop_opr, 1.244 FrameMap::_t2_oop_opr, 1.245 @@ -1037,7 +1009,6 @@ 1.246 #endif 1.247 klass_reg, 1.248 info); 1.249 -*/ 1.250 LIR_Opr result = rlock_result(x); 1.251 __ move(reg, result); 1.252 } 1.253 @@ -1060,7 +1031,7 @@ 1.254 #else 1.255 LIR_Opr tmp4 = FrameMap::_a5_oop_opr; 1.256 LIR_Opr tmp5 = FrameMap::_a6_oop_opr; 1.257 - LIR_Opr klass_reg = FrameMap::_a4_oop_opr; 1.258 + LIR_Opr klass_reg = FrameMap::_a4_metadata_opr; 1.259 #endif 1.260 LIR_Opr len = length.result(); 1.261 BasicType elem_type = x->elt_type(); 1.262 @@ -1097,7 +1068,7 @@ 1.263 #else 1.264 LIR_Opr tmp4 = FrameMap::_a5_oop_opr; 1.265 LIR_Opr tmp5 = FrameMap::_a6_oop_opr; 1.266 - LIR_Opr klass_reg = FrameMap::_a4_oop_opr; 1.267 + LIR_Opr klass_reg = FrameMap::_a4_metadata_opr; 1.268 #endif 1.269 1.270 length.load_item_force(FrameMap::_t2_opr); 1.271 @@ -1145,8 +1116,8 @@ 1.272 store_stack_parameter(size->result(), in_ByteSize(i*4)); 1.273 } 1.274 1.275 - LIR_Opr reg = result_register_for(x->type()); 1.276 - klass2reg_with_patching(reg, x->klass(), patching_info); 1.277 + LIR_Opr klass_reg = FrameMap::_v0_metadata_opr; 1.278 + klass2reg_with_patching(klass_reg, x->klass(), patching_info); 1.279 1.280 // LIR_Opr rank = FrameMap::ebx_opr; 1.281 LIR_Opr rank = FrameMap::_t2_opr; 1.282 @@ -1155,12 +1126,14 @@ 1.283 LIR_Opr varargs = FrameMap::_t0_opr; 1.284 __ move(FrameMap::_sp_opr, varargs); 1.285 LIR_OprList* args = new LIR_OprList(3); 1.286 - args->append(reg); 1.287 + args->append(klass_reg); 1.288 args->append(rank); 1.289 args->append(varargs); 1.290 + LIR_Opr reg = result_register_for(x->type()); 1.291 __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), 1.292 LIR_OprFact::illegalOpr, 1.293 reg, args, info); 1.294 + 1.295 LIR_Opr result = rlock_result(x); 1.296 __ move(reg, result); 1.297 }