< prev index next >

src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp

Print this page

1229   }
1230 
1231   if (use_R29) {
1232     __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); // reinit
1233   }
1234 
1235   if (patch != nullptr) {
1236     patching_epilog(patch, patch_code, src, info);
1237   }
1238 
1239   if (info != nullptr && !needs_explicit_null_check) {
1240     add_debug_info_for_null_check(offset, info);
1241   }
1242 }
1243 
1244 
1245 void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) {
1246   const Register return_pc = R31;  // Must survive C-call to enable_stack_reserved_zone().
1247   const Register temp      = R12;
1248 


1249   // Pop the stack before the safepoint code.
1250   int frame_size = initial_frame_size_in_bytes();
1251   if (Assembler::is_simm(frame_size, 16)) {
1252     __ addi(R1_SP, R1_SP, frame_size);
1253   } else {
1254     __ pop_frame();
1255   }
1256 
1257   // Restore return pc relative to callers' sp.
1258   __ ld(return_pc, _abi0(lr), R1_SP);
1259   // Move return pc to LR.
1260   __ mtlr(return_pc);
1261 
1262   if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
1263     __ reserved_stack_check(return_pc);
1264   }
1265 
1266   // We need to mark the code position where the load from the safepoint
1267   // polling page was emitted as relocInfo::poll_return_type here.
1268   if (!UseSIGTRAP) {

1744   //__ load_const(exceptionPC->as_register(), pc_for_athrow, R0);
1745   __ calculate_address_from_global_toc(exceptionPC->as_register(), pc_for_athrow, true, true, /*add_relocation*/ true);
1746   add_call_info(pc_for_athrow_offset, info); // for exception handler
1747 
1748   address stub = Runtime1::entry_for(compilation()->has_fpu_code() ? StubId::c1_handle_exception_id
1749                                                                    : StubId::c1_handle_exception_nofpu_id);
1750   //__ load_const_optimized(R0, stub);
1751   __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
1752   __ mtctr(R0);
1753   __ bctr();
1754 }
1755 
1756 
1757 void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
1758   // Note: Not used with EnableDebuggingOnDemand.
1759   assert(exceptionOop->as_register() == R3, "should match");
1760   __ b(_unwind_handler_entry);
1761 }
1762 
1763 














1764 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
1765   Register src = op->src()->as_register();
1766   Register dst = op->dst()->as_register();
1767   Register src_pos = op->src_pos()->as_register();
1768   Register dst_pos = op->dst_pos()->as_register();
1769   Register length  = op->length()->as_register();
1770   Register tmp = op->tmp()->as_register();
1771   Register tmp2 = R0;
1772 
1773   int flags = op->flags();
1774   ciArrayKlass* default_type = op->expected_type();
1775   BasicType basic_type = (default_type != nullptr) ? default_type->element_type()->basic_type() : T_ILLEGAL;
1776   if (basic_type == T_ARRAY) basic_type = T_OBJECT;
1777 
1778   // Set up the arraycopy stub information.
1779   ArrayCopyStub* stub = op->stub();
1780 






1781   // Always do stub if no type information is available. It's ok if
1782   // the known type isn't loaded since the code sanity checks
1783   // in debug mode and the type isn't required when we know the exact type
1784   // also check that the type is an array type.
1785   if (default_type == nullptr) {
1786     assert(src->is_nonvolatile() && src_pos->is_nonvolatile() && dst->is_nonvolatile() && dst_pos->is_nonvolatile() &&
1787            length->is_nonvolatile(), "must preserve");
1788     address copyfunc_addr = StubRoutines::generic_arraycopy();
1789     assert(copyfunc_addr != nullptr, "generic arraycopy stub required");
1790 
1791     // 3 parms are int. Convert to long.
1792     __ mr(R3_ARG1, src);
1793     __ extsw(R4_ARG2, src_pos);
1794     __ mr(R5_ARG3, dst);
1795     __ extsw(R6_ARG4, dst_pos);
1796     __ extsw(R7_ARG5, length);
1797 
1798 #ifndef PRODUCT
1799     if (PrintC1Statistics) {
1800       address counter = (address)&Runtime1::_generic_arraycopystub_cnt;
1801       int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
1802       __ lwz(R11_scratch1, simm16_offs, tmp);
1803       __ addi(R11_scratch1, R11_scratch1, 1);
1804       __ stw(R11_scratch1, simm16_offs, tmp);
1805     }
1806 #endif
1807     __ call_c(copyfunc_addr, relocInfo::runtime_call_type);
1808 
1809     __ nand(tmp, R3_RET, R3_RET);
1810     __ subf(length, tmp, length);
1811     __ add(src_pos, tmp, src_pos);
1812     __ add(dst_pos, tmp, dst_pos);
1813 
1814     __ cmpwi(CR0, R3_RET, 0);
1815     __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::less), *stub->entry());
1816     __ bind(*stub->continuation());
1817     return;
1818   }
1819 








1820   assert(default_type != nullptr && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
1821   Label cont, slow, copyfunc;
1822 
1823   bool simple_check_flag_set = flags & (LIR_OpArrayCopy::src_null_check |
1824                                         LIR_OpArrayCopy::dst_null_check |
1825                                         LIR_OpArrayCopy::src_pos_positive_check |
1826                                         LIR_OpArrayCopy::dst_pos_positive_check |
1827                                         LIR_OpArrayCopy::length_positive_check);
1828 
1829   // Use only one conditional branch for simple checks.
1830   if (simple_check_flag_set) {
1831     ConditionRegister combined_check = CR1, tmp_check = CR1;
1832 
1833     // Make sure src and dst are non-null.
1834     if (flags & LIR_OpArrayCopy::src_null_check) {
1835       __ cmpdi(combined_check, src, 0);
1836       tmp_check = CR0;
1837     }
1838 
1839     if (flags & LIR_OpArrayCopy::dst_null_check) {

2294     __ bind(not_null);
2295 
2296     Register recv = klass_RInfo;
2297     __ load_klass(recv, obj);
2298     type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2299   } else {
2300     __ cmpdi(CR0, obj, 0);
2301     __ beq(CR0, *obj_is_null);
2302   }
2303 
2304   // get object class
2305   __ load_klass(klass_RInfo, obj);
2306 
2307   if (k->is_loaded()) {
2308     metadata2reg(k->constant_encoding(), k_RInfo);
2309   } else {
2310     klass2reg_with_patching(k_RInfo, op->info_for_patch());
2311   }
2312 
2313   if (op->fast_check()) {

2314     assert_different_registers(klass_RInfo, k_RInfo);
2315     __ cmpd(CR0, k_RInfo, klass_RInfo);
2316     __ beq(CR0, *success);
2317     // Fall through to failure case.
2318   } else {
2319     bool need_slow_path = true;
2320     if (k->is_loaded()) {
2321       if ((int) k->super_check_offset() != in_bytes(Klass::secondary_super_cache_offset())) {
2322         need_slow_path = false;
2323       }
2324       // Perform the fast part of the checking logic.
2325       __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, (need_slow_path ? success : nullptr),
2326                                        failure, nullptr, RegisterOrConstant(k->super_check_offset()));
2327     } else {
2328       // Perform the fast part of the checking logic.
2329       __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, success, failure);
2330     }
2331     if (!need_slow_path) {
2332       __ b(*success);
2333     } else {

2363     Register array = op->array()->as_register();
2364     Register k_RInfo = op->tmp1()->as_register();
2365     Register klass_RInfo = op->tmp2()->as_register();
2366     Register Rtmp1 = op->tmp3()->as_register();
2367     bool should_profile = op->should_profile();
2368 
2369     __ verify_oop(value, FILE_AND_LINE);
2370     CodeStub* stub = op->stub();
2371     // Check if it needs to be profiled.
2372     ciMethodData* md = nullptr;
2373     ciProfileData* data = nullptr;
2374     int mdo_offset_bias = 0;
2375     if (should_profile) {
2376       ciMethod* method = op->profiled_method();
2377       assert(method != nullptr, "Should have method");
2378       setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
2379     }
2380 
2381     Label done;
2382 
2383     if (should_profile) {
2384       Label not_null;
2385       Register mdo      = k_RInfo;
2386       Register data_val = Rtmp1;
2387       metadata2reg(md->constant_encoding(), mdo);
2388       __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
2389       __ cmpdi(CR0, value, 0);
2390       __ bne(CR0, not_null);
2391       __ lbz(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2392       __ ori(data_val, data_val, BitData::null_seen_byte_constant());
2393       __ stb(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2394       __ b(done);
2395       __ bind(not_null);
2396 
2397       Register recv = klass_RInfo;
2398       __ load_klass(recv, value);
2399       type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2400     } else {
2401       __ cmpdi(CR0, value, 0);
2402       __ beq(CR0, done);


2403     }
2404     if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
2405       explicit_null_check(array, op->info_for_exception());
2406     } else {
2407       add_debug_info_for_null_check_here(op->info_for_exception());
2408     }
2409     __ load_klass(k_RInfo, array);
2410     __ load_klass(klass_RInfo, value);
2411 
2412     Label failure;
2413 
2414     // Get instance klass.
2415     __ ld(k_RInfo, in_bytes(ObjArrayKlass::element_klass_offset()), k_RInfo);
2416     // Perform the fast part of the checking logic.
2417     __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, &done, &failure, nullptr);
2418 
2419     // Call out-of-line instance of __ check_klass_subtype_slow_path(...):
2420     const address slow_path = Runtime1::entry_for(StubId::c1_slow_subtype_check_id);
2421     //__ load_const_optimized(R0, slow_path);
2422     __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(slow_path));

3006                ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
3007 
3008         // Already unknown. Nothing to do anymore.
3009         __ andi_(R0, tmp, TypeEntries::type_unknown);
3010         __ bne(CR0, Lnext);
3011 
3012         // Different than before. Cannot keep accurate profile.
3013         __ ori(R0, tmp, TypeEntries::type_unknown);
3014       }
3015     }
3016 
3017     __ bind(Ldo_update);
3018     __ std(R0, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
3019 
3020     __ bind(Lnext);
3021     if (klass_reg_used) { __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); } // reinit
3022   }
3023   __ bind(Ldone);
3024 }
3025 



















3026 
3027 void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
3028   assert(op->crc()->is_single_cpu(), "crc must be register");
3029   assert(op->val()->is_single_cpu(), "byte value must be register");
3030   assert(op->result_opr()->is_single_cpu(), "result must be register");
3031   Register crc = op->crc()->as_register();
3032   Register val = op->val()->as_register();
3033   Register res = op->result_opr()->as_register();
3034 
3035   assert_different_registers(val, crc, res);
3036 
3037   __ load_const_optimized(res, StubRoutines::crc_table_addr(), R0);
3038   __ kernel_crc32_singleByteReg(crc, val, res, true);
3039   __ mr(res, crc);
3040 }
3041 





































































































3042 #undef __

1229   }
1230 
1231   if (use_R29) {
1232     __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); // reinit
1233   }
1234 
1235   if (patch != nullptr) {
1236     patching_epilog(patch, patch_code, src, info);
1237   }
1238 
1239   if (info != nullptr && !needs_explicit_null_check) {
1240     add_debug_info_for_null_check(offset, info);
1241   }
1242 }
1243 
1244 
1245 void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) {
1246   const Register return_pc = R31;  // Must survive C-call to enable_stack_reserved_zone().
1247   const Register temp      = R12;
1248 
1249   assert(!InlineTypeReturnedAsFields, "unimplemented");
1250 
1251   // Pop the stack before the safepoint code.
1252   int frame_size = initial_frame_size_in_bytes();
1253   if (Assembler::is_simm(frame_size, 16)) {
1254     __ addi(R1_SP, R1_SP, frame_size);
1255   } else {
1256     __ pop_frame();
1257   }
1258 
1259   // Restore return pc relative to callers' sp.
1260   __ ld(return_pc, _abi0(lr), R1_SP);
1261   // Move return pc to LR.
1262   __ mtlr(return_pc);
1263 
1264   if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
1265     __ reserved_stack_check(return_pc);
1266   }
1267 
1268   // We need to mark the code position where the load from the safepoint
1269   // polling page was emitted as relocInfo::poll_return_type here.
1270   if (!UseSIGTRAP) {

1746   //__ load_const(exceptionPC->as_register(), pc_for_athrow, R0);
1747   __ calculate_address_from_global_toc(exceptionPC->as_register(), pc_for_athrow, true, true, /*add_relocation*/ true);
1748   add_call_info(pc_for_athrow_offset, info); // for exception handler
1749 
1750   address stub = Runtime1::entry_for(compilation()->has_fpu_code() ? StubId::c1_handle_exception_id
1751                                                                    : StubId::c1_handle_exception_nofpu_id);
1752   //__ load_const_optimized(R0, stub);
1753   __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
1754   __ mtctr(R0);
1755   __ bctr();
1756 }
1757 
1758 
1759 void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
1760   // Note: Not used with EnableDebuggingOnDemand.
1761   assert(exceptionOop->as_register() == R3, "should match");
1762   __ b(_unwind_handler_entry);
1763 }
1764 
1765 
1766 void LIR_Assembler::arraycopy_inlinetype_check(Register obj, Register tmp, CodeStub* slow_path, bool is_dest, bool null_check) {
1767   if (null_check) {
1768     __ cmpdi(CR0, obj, 0);
1769     __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::equal), *slow_path->entry());
1770   }
1771   if (is_dest) {
1772     __ test_null_free_array_oop(obj, tmp, *slow_path->entry(), true);
1773     __ test_flat_array_oop(obj, tmp, *slow_path->entry(), true);
1774   } else {
1775     __ test_flat_array_oop(obj, tmp, *slow_path->entry(), true);
1776   }
1777 }
1778 
1779 
1780 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
1781   Register src = op->src()->as_register();
1782   Register dst = op->dst()->as_register();
1783   Register src_pos = op->src_pos()->as_register();
1784   Register dst_pos = op->dst_pos()->as_register();
1785   Register length  = op->length()->as_register();
1786   Register tmp = op->tmp()->as_register();
1787   Register tmp2 = R0;
1788 
1789   int flags = op->flags();
1790   ciArrayKlass* default_type = op->expected_type();
1791   BasicType basic_type = (default_type != nullptr) ? default_type->element_type()->basic_type() : T_ILLEGAL;
1792   if (basic_type == T_ARRAY) basic_type = T_OBJECT;
1793 
1794   // Set up the arraycopy stub information.
1795   ArrayCopyStub* stub = op->stub();
1796 
1797   if (flags & LIR_OpArrayCopy::always_slow_path) {
1798     __ b(*stub->entry());
1799     __ bind(*stub->continuation());
1800     return;
1801   }
1802 
1803   // Always do stub if no type information is available. It's ok if
1804   // the known type isn't loaded since the code sanity checks
1805   // in debug mode and the type isn't required when we know the exact type
1806   // also check that the type is an array type.
1807   if (default_type == nullptr) {
1808     assert(src->is_nonvolatile() && src_pos->is_nonvolatile() && dst->is_nonvolatile() && dst_pos->is_nonvolatile() &&
1809            length->is_nonvolatile(), "must preserve");
1810     address copyfunc_addr = StubRoutines::generic_arraycopy();
1811     assert(copyfunc_addr != nullptr, "generic arraycopy stub required");
1812 
1813     // 3 parms are int. Convert to long.
1814     __ mr(R3_ARG1, src);
1815     __ extsw(R4_ARG2, src_pos);
1816     __ mr(R5_ARG3, dst);
1817     __ extsw(R6_ARG4, dst_pos);
1818     __ extsw(R7_ARG5, length);
1819 
1820 #ifndef PRODUCT
1821     if (PrintC1Statistics) {
1822       address counter = (address)&Runtime1::_generic_arraycopystub_cnt;
1823       int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
1824       __ lwz(R11_scratch1, simm16_offs, tmp);
1825       __ addi(R11_scratch1, R11_scratch1, 1);
1826       __ stw(R11_scratch1, simm16_offs, tmp);
1827     }
1828 #endif
1829     __ call_c(copyfunc_addr, relocInfo::runtime_call_type);
1830 
1831     __ nand(tmp, R3_RET, R3_RET);
1832     __ subf(length, tmp, length);
1833     __ add(src_pos, tmp, src_pos);
1834     __ add(dst_pos, tmp, dst_pos);
1835 
1836     __ cmpwi(CR0, R3_RET, 0);
1837     __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::less), *stub->entry());
1838     __ bind(*stub->continuation());
1839     return;
1840   }
1841 
1842   // Handle inline type arrays
1843   if (flags & LIR_OpArrayCopy::src_inlinetype_check) {
1844     arraycopy_inlinetype_check(src, tmp, stub, false, (flags & LIR_OpArrayCopy::src_null_check));
1845   }
1846   if (flags & LIR_OpArrayCopy::dst_inlinetype_check) {
1847     arraycopy_inlinetype_check(dst, tmp, stub, true, (flags & LIR_OpArrayCopy::dst_null_check));
1848   }
1849 
1850   assert(default_type != nullptr && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
1851   Label cont, slow, copyfunc;
1852 
1853   bool simple_check_flag_set = flags & (LIR_OpArrayCopy::src_null_check |
1854                                         LIR_OpArrayCopy::dst_null_check |
1855                                         LIR_OpArrayCopy::src_pos_positive_check |
1856                                         LIR_OpArrayCopy::dst_pos_positive_check |
1857                                         LIR_OpArrayCopy::length_positive_check);
1858 
1859   // Use only one conditional branch for simple checks.
1860   if (simple_check_flag_set) {
1861     ConditionRegister combined_check = CR1, tmp_check = CR1;
1862 
1863     // Make sure src and dst are non-null.
1864     if (flags & LIR_OpArrayCopy::src_null_check) {
1865       __ cmpdi(combined_check, src, 0);
1866       tmp_check = CR0;
1867     }
1868 
1869     if (flags & LIR_OpArrayCopy::dst_null_check) {

2324     __ bind(not_null);
2325 
2326     Register recv = klass_RInfo;
2327     __ load_klass(recv, obj);
2328     type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2329   } else {
2330     __ cmpdi(CR0, obj, 0);
2331     __ beq(CR0, *obj_is_null);
2332   }
2333 
2334   // get object class
2335   __ load_klass(klass_RInfo, obj);
2336 
2337   if (k->is_loaded()) {
2338     metadata2reg(k->constant_encoding(), k_RInfo);
2339   } else {
2340     klass2reg_with_patching(k_RInfo, op->info_for_patch());
2341   }
2342 
2343   if (op->fast_check()) {
2344     assert(!k->is_loaded() || !k->is_obj_array_klass(), "Use refined array for a direct pointer comparison");
2345     assert_different_registers(klass_RInfo, k_RInfo);
2346     __ cmpd(CR0, k_RInfo, klass_RInfo);
2347     __ beq(CR0, *success);
2348     // Fall through to failure case.
2349   } else {
2350     bool need_slow_path = true;
2351     if (k->is_loaded()) {
2352       if ((int) k->super_check_offset() != in_bytes(Klass::secondary_super_cache_offset())) {
2353         need_slow_path = false;
2354       }
2355       // Perform the fast part of the checking logic.
2356       __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, (need_slow_path ? success : nullptr),
2357                                        failure, nullptr, RegisterOrConstant(k->super_check_offset()));
2358     } else {
2359       // Perform the fast part of the checking logic.
2360       __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, success, failure);
2361     }
2362     if (!need_slow_path) {
2363       __ b(*success);
2364     } else {

2394     Register array = op->array()->as_register();
2395     Register k_RInfo = op->tmp1()->as_register();
2396     Register klass_RInfo = op->tmp2()->as_register();
2397     Register Rtmp1 = op->tmp3()->as_register();
2398     bool should_profile = op->should_profile();
2399 
2400     __ verify_oop(value, FILE_AND_LINE);
2401     CodeStub* stub = op->stub();
2402     // Check if it needs to be profiled.
2403     ciMethodData* md = nullptr;
2404     ciProfileData* data = nullptr;
2405     int mdo_offset_bias = 0;
2406     if (should_profile) {
2407       ciMethod* method = op->profiled_method();
2408       assert(method != nullptr, "Should have method");
2409       setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
2410     }
2411 
2412     Label done;
2413 
2414     if (op->need_null_check()) {
2415       if (should_profile) {
2416         Label not_null;
2417         Register mdo      = k_RInfo;
2418         Register data_val = Rtmp1;
2419         metadata2reg(md->constant_encoding(), mdo);
2420         __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
2421         __ cmpdi(CR0, value, 0);
2422         __ bne(CR0, not_null);
2423         __ lbz(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2424         __ ori(data_val, data_val, BitData::null_seen_byte_constant());
2425         __ stb(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2426         __ b(done);
2427         __ bind(not_null);
2428 
2429         Register recv = klass_RInfo;
2430         __ load_klass(recv, value);
2431         type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2432       } else {
2433         __ cmpdi(CR0, value, 0);
2434         __ beq(CR0, done);
2435       }
2436     }
2437     if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
2438       explicit_null_check(array, op->info_for_exception());
2439     } else {
2440       add_debug_info_for_null_check_here(op->info_for_exception());
2441     }
2442     __ load_klass(k_RInfo, array);
2443     __ load_klass(klass_RInfo, value);
2444 
2445     Label failure;
2446 
2447     // Get instance klass.
2448     __ ld(k_RInfo, in_bytes(ObjArrayKlass::element_klass_offset()), k_RInfo);
2449     // Perform the fast part of the checking logic.
2450     __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, &done, &failure, nullptr);
2451 
2452     // Call out-of-line instance of __ check_klass_subtype_slow_path(...):
2453     const address slow_path = Runtime1::entry_for(StubId::c1_slow_subtype_check_id);
2454     //__ load_const_optimized(R0, slow_path);
2455     __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(slow_path));

3039                ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
3040 
3041         // Already unknown. Nothing to do anymore.
3042         __ andi_(R0, tmp, TypeEntries::type_unknown);
3043         __ bne(CR0, Lnext);
3044 
3045         // Different than before. Cannot keep accurate profile.
3046         __ ori(R0, tmp, TypeEntries::type_unknown);
3047       }
3048     }
3049 
3050     __ bind(Ldo_update);
3051     __ std(R0, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
3052 
3053     __ bind(Lnext);
3054     if (klass_reg_used) { __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); } // reinit
3055   }
3056   __ bind(Ldone);
3057 }
3058 
3059 void LIR_Assembler::emit_profile_inline_type(LIR_OpProfileInlineType* op) {
3060   Register obj = op->obj()->as_register();
3061   //Register tmp = op->tmp()->as_pointer_register(); not needed!
3062   LIR_Address* mdo_addr = op->mdp()->as_address_ptr();
3063   assert(!mdo_addr->index()->is_valid(), "index unsupported");
3064   Register mdo_base = mdo_addr->base()->as_pointer_register();
3065   int mdo_offs = mdo_addr->disp();
3066   bool not_null = op->not_null();
3067   int flag = op->flag();
3068 
3069   Label not_inline_type;
3070   __ test_oop_is_not_inline_type(obj, not_inline_type, !not_null);
3071 
3072   __ lbz(R0, mdo_offs, mdo_base);
3073   __ ori(R0, R0, flag);
3074   __ stb(R0, mdo_offs, mdo_base);
3075 
3076   __ bind(not_inline_type);
3077 }
3078 
3079 void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
3080   assert(op->crc()->is_single_cpu(), "crc must be register");
3081   assert(op->val()->is_single_cpu(), "byte value must be register");
3082   assert(op->result_opr()->is_single_cpu(), "result must be register");
3083   Register crc = op->crc()->as_register();
3084   Register val = op->val()->as_register();
3085   Register res = op->result_opr()->as_register();
3086 
3087   assert_different_registers(val, crc, res);
3088 
3089   __ load_const_optimized(res, StubRoutines::crc_table_addr(), R0);
3090   __ kernel_crc32_singleByteReg(crc, val, res, true);
3091   __ mr(res, crc);
3092 }
3093 
3094 // Valhalla support
3095 
3096 void LIR_Assembler::check_orig_pc() {
3097   Address address_for_orig_pc_addr = frame_map()->address_for_orig_pc_addr();
3098   __ ld(R0, address_for_orig_pc_addr);
3099   __ cmpdi(BOOL_RESULT, R0, (u1)NULL_WORD);
3100 }
3101 
3102 int LIR_Assembler::store_inline_type_fields_to_buf(ciInlineKlass* vk) {
3103   return (__ store_inline_type_fields_to_buf(vk, false));
3104 }
3105 
3106 void LIR_Assembler::emit_opFlattenedArrayCheck(LIR_OpFlattenedArrayCheck* op) {
3107   // We are loading/storing from/to an array that *may* be a flat array (the
3108   // declared type is Object[], abstract[], interface[] or VT.ref[]).
3109   // If this array is a flat array, take the slow path.
3110   __ test_flat_array_oop(op->array()->as_register(), op->tmp()->as_register(), *op->stub()->entry(), true);
3111 }
3112 
3113 void LIR_Assembler::emit_opNullFreeArrayCheck(LIR_OpNullFreeArrayCheck* op) {
3114   // We are storing into an array that *may* be null-free (the declared type is
3115   // Object[], abstract[], interface[] or VT.ref[]).
3116   Label test_mark_word;
3117   Register tmp = op->tmp()->as_register();
3118   __ ld(tmp, oopDesc::mark_offset_in_bytes(), op->array()->as_register());
3119   __ andi_(R0, tmp, markWord::unlocked_value);
3120   __ bne(CR0, test_mark_word);
3121   __ load_prototype_header(tmp, op->array()->as_register());
3122   __ bind(test_mark_word);
3123   __ andi(R0, tmp, markWord::null_free_array_bit_in_place);
3124   __ cmpwi(BOOL_RESULT, R0, 0);
3125 }
3126 
3127 void LIR_Assembler::emit_opSubstitutabilityCheck(LIR_OpSubstitutabilityCheck* op) {
3128   Label L_oops_equal;
3129   Label L_oops_not_equal;
3130   Label L_end;
3131 
3132   Register left  = op->left()->as_register();
3133   Register right = op->right()->as_register();
3134 
3135   __ cmpd(CR0, left, right);
3136   __ beq(CR0, L_oops_equal);
3137 
3138   // (1) Null check -- if one of the operands is null, the other must not be null (because
3139   //     the two references are not equal), so they are not substitutable,
3140   __ cmpdi(CR0, left, 0);
3141   __ cmpdi(CR1, right, 0);
3142   __ cror(CR0, Assembler::equal, CR1, Assembler::equal);
3143   __ beq(CR0, L_oops_not_equal);
3144 
3145   ciKlass* left_klass = op->left_klass();
3146   ciKlass* right_klass = op->right_klass();
3147 
3148   // (2) Inline type check -- if either of the operands is not an inline type,
3149   //     they are not substitutable. We do this only if we are not sure that the
3150   //     operands are inline type
3151   if ((left_klass == nullptr || right_klass == nullptr) ||// The klass is still unloaded, or came from a Phi node.
3152       !left_klass->is_inlinetype() || !right_klass->is_inlinetype()) {
3153     Register tmp = op->tmp1()->as_register();
3154     __ ld(tmp, oopDesc::mark_offset_in_bytes(), left);
3155     __ ld(R0, oopDesc::mark_offset_in_bytes(), right);
3156     __ andi(tmp, tmp, (intptr_t)markWord::inline_type_pattern);
3157     __ andr(tmp, tmp, R0);
3158     __ cmpdi(CR0, tmp, (intptr_t)markWord::inline_type_pattern);
3159     __ bne(CR0, L_oops_not_equal);
3160   }
3161 
3162   // (3) Same klass check: if the operands are of different klasses, they are not substitutable.
3163   if (left_klass != nullptr && left_klass->is_inlinetype() && left_klass == right_klass) {
3164     // No need to load klass -- the operands are statically known to be the same inline klass.
3165     __ b(*op->stub()->entry());
3166   } else {
3167     Register tmp1 = op->tmp1()->as_register();
3168     Register tmp2 = op->tmp2()->as_register();
3169     if (left == right) { // same operand, so clearly the same klasses, let's save the check
3170       __ b(*op->stub()->entry());  //  -> do slow check
3171     } else {
3172       __ cmp_klasses_from_objects(CR0, left, right, tmp1, tmp2);
3173       __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::equal),
3174                           *op->stub()->entry()); // same klass -> do slow check
3175     }
3176     // fall through to L_oops_not_equal
3177   }
3178 
3179   __ bind(L_oops_not_equal);
3180   load_to_reg(this, op->not_equal_result(), op->result_opr());
3181   __ b(L_end);
3182 
3183   // We've returned from the stub. R3_RET (stub's _scratch_reg) contains 0x0 IFF the two
3184   // operands are not substitutable. (Don't compare against 0x1 in case the
3185   // C compiler is naughty)
3186   __ bind(*op->stub()->continuation());
3187   __ cmpdi(CR0, R3_RET, 0);
3188   __ beq(CR0, L_oops_not_equal);
3189 
3190   __ bind(L_oops_equal);
3191   load_to_reg(this, op->equal_result(), op->result_opr()); // (call_stub() != 0x0) -> equal
3192   // fall-through
3193   __ bind(L_end);
3194 }
3195 #undef __
< prev index next >