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) {
1758 //__ load_const(exceptionPC->as_register(), pc_for_athrow, R0);
1759 __ calculate_address_from_global_toc(exceptionPC->as_register(), pc_for_athrow, true, true, /*add_relocation*/ true);
1760 add_call_info(pc_for_athrow_offset, info); // for exception handler
1761
1762 address stub = Runtime1::entry_for(compilation()->has_fpu_code() ? StubId::c1_handle_exception_id
1763 : StubId::c1_handle_exception_nofpu_id);
1764 //__ load_const_optimized(R0, stub);
1765 __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
1766 __ mtctr(R0);
1767 __ bctr();
1768 }
1769
1770
1771 void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
1772 // Note: Not used with EnableDebuggingOnDemand.
1773 assert(exceptionOop->as_register() == R3, "should match");
1774 __ b(_unwind_handler_entry);
1775 }
1776
1777
1778 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
1779 Register src = op->src()->as_register();
1780 Register dst = op->dst()->as_register();
1781 Register src_pos = op->src_pos()->as_register();
1782 Register dst_pos = op->dst_pos()->as_register();
1783 Register length = op->length()->as_register();
1784 Register tmp = op->tmp()->as_register();
1785 Register tmp2 = R0;
1786
1787 int flags = op->flags();
1788 ciArrayKlass* default_type = op->expected_type();
1789 BasicType basic_type = (default_type != nullptr) ? default_type->element_type()->basic_type() : T_ILLEGAL;
1790 if (basic_type == T_ARRAY) basic_type = T_OBJECT;
1791
1792 // Set up the arraycopy stub information.
1793 ArrayCopyStub* stub = op->stub();
1794
1795 // Always do stub if no type information is available. It's ok if
1796 // the known type isn't loaded since the code sanity checks
1797 // in debug mode and the type isn't required when we know the exact type
1798 // also check that the type is an array type.
1799 if (default_type == nullptr) {
1800 assert(src->is_nonvolatile() && src_pos->is_nonvolatile() && dst->is_nonvolatile() && dst_pos->is_nonvolatile() &&
1801 length->is_nonvolatile(), "must preserve");
1802 address copyfunc_addr = StubRoutines::generic_arraycopy();
1803 assert(copyfunc_addr != nullptr, "generic arraycopy stub required");
1804
1805 // 3 parms are int. Convert to long.
1806 __ mr(R3_ARG1, src);
1807 __ extsw(R4_ARG2, src_pos);
1808 __ mr(R5_ARG3, dst);
1809 __ extsw(R6_ARG4, dst_pos);
1810 __ extsw(R7_ARG5, length);
1811
1812 #ifndef PRODUCT
1813 if (PrintC1Statistics) {
1814 address counter = (address)&Runtime1::_generic_arraycopystub_cnt;
1815 int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
1816 __ lwz(R11_scratch1, simm16_offs, tmp);
1817 __ addi(R11_scratch1, R11_scratch1, 1);
1818 __ stw(R11_scratch1, simm16_offs, tmp);
1819 }
1820 #endif
1821 __ call_c(copyfunc_addr, relocInfo::runtime_call_type);
1822
1823 __ nand(tmp, R3_RET, R3_RET);
1824 __ subf(length, tmp, length);
1825 __ add(src_pos, tmp, src_pos);
1826 __ add(dst_pos, tmp, dst_pos);
1827
1828 __ cmpwi(CR0, R3_RET, 0);
1829 __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::less), *stub->entry());
1830 __ bind(*stub->continuation());
1831 return;
1832 }
1833
1834 assert(default_type != nullptr && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
1835 Label cont, slow, copyfunc;
1836
1837 bool simple_check_flag_set = flags & (LIR_OpArrayCopy::src_null_check |
1838 LIR_OpArrayCopy::dst_null_check |
1839 LIR_OpArrayCopy::src_pos_positive_check |
1840 LIR_OpArrayCopy::dst_pos_positive_check |
1841 LIR_OpArrayCopy::length_positive_check);
1842
1843 // Use only one conditional branch for simple checks.
1844 if (simple_check_flag_set) {
1845 ConditionRegister combined_check = CR1, tmp_check = CR1;
1846
1847 // Make sure src and dst are non-null.
1848 if (flags & LIR_OpArrayCopy::src_null_check) {
1849 __ cmpdi(combined_check, src, 0);
1850 tmp_check = CR0;
1851 }
1852
1853 if (flags & LIR_OpArrayCopy::dst_null_check) {
2308 __ bind(not_null);
2309
2310 Register recv = klass_RInfo;
2311 __ load_klass(recv, obj);
2312 type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2313 } else {
2314 __ cmpdi(CR0, obj, 0);
2315 __ beq(CR0, *obj_is_null);
2316 }
2317
2318 // get object class
2319 __ load_klass(klass_RInfo, obj);
2320
2321 if (k->is_loaded()) {
2322 metadata2reg(k->constant_encoding(), k_RInfo);
2323 } else {
2324 klass2reg_with_patching(k_RInfo, op->info_for_patch());
2325 }
2326
2327 if (op->fast_check()) {
2328 assert_different_registers(klass_RInfo, k_RInfo);
2329 __ cmpd(CR0, k_RInfo, klass_RInfo);
2330 __ beq(CR0, *success);
2331 // Fall through to failure case.
2332 } else {
2333 bool need_slow_path = true;
2334 if (k->is_loaded()) {
2335 if ((int) k->super_check_offset() != in_bytes(Klass::secondary_super_cache_offset())) {
2336 need_slow_path = false;
2337 }
2338 // Perform the fast part of the checking logic.
2339 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, (need_slow_path ? success : nullptr),
2340 failure, nullptr, RegisterOrConstant(k->super_check_offset()));
2341 } else {
2342 // Perform the fast part of the checking logic.
2343 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, success, failure);
2344 }
2345 if (!need_slow_path) {
2346 __ b(*success);
2347 } else {
2377 Register array = op->array()->as_register();
2378 Register k_RInfo = op->tmp1()->as_register();
2379 Register klass_RInfo = op->tmp2()->as_register();
2380 Register Rtmp1 = op->tmp3()->as_register();
2381 bool should_profile = op->should_profile();
2382
2383 __ verify_oop(value, FILE_AND_LINE);
2384 CodeStub* stub = op->stub();
2385 // Check if it needs to be profiled.
2386 ciMethodData* md = nullptr;
2387 ciProfileData* data = nullptr;
2388 int mdo_offset_bias = 0;
2389 if (should_profile) {
2390 ciMethod* method = op->profiled_method();
2391 assert(method != nullptr, "Should have method");
2392 setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
2393 }
2394
2395 Label done;
2396
2397 if (should_profile) {
2398 Label not_null;
2399 Register mdo = k_RInfo;
2400 Register data_val = Rtmp1;
2401 metadata2reg(md->constant_encoding(), mdo);
2402 __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
2403 __ cmpdi(CR0, value, 0);
2404 __ bne(CR0, not_null);
2405 __ lbz(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2406 __ ori(data_val, data_val, BitData::null_seen_byte_constant());
2407 __ stb(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2408 __ b(done);
2409 __ bind(not_null);
2410
2411 Register recv = klass_RInfo;
2412 __ load_klass(recv, value);
2413 type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2414 } else {
2415 __ cmpdi(CR0, value, 0);
2416 __ beq(CR0, done);
2417 }
2418 if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
2419 explicit_null_check(array, op->info_for_exception());
2420 } else {
2421 add_debug_info_for_null_check_here(op->info_for_exception());
2422 }
2423 __ load_klass(k_RInfo, array);
2424 __ load_klass(klass_RInfo, value);
2425
2426 Label failure;
2427
2428 // Get instance klass.
2429 __ ld(k_RInfo, in_bytes(ObjArrayKlass::element_klass_offset()), k_RInfo);
2430 // Perform the fast part of the checking logic.
2431 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, &done, &failure, nullptr);
2432
2433 // Call out-of-line instance of __ check_klass_subtype_slow_path(...):
2434 const address slow_path = Runtime1::entry_for(StubId::c1_slow_subtype_check_id);
2435 //__ load_const_optimized(R0, slow_path);
2436 __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(slow_path));
3020 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
3021
3022 // Already unknown. Nothing to do anymore.
3023 __ andi_(R0, tmp, TypeEntries::type_unknown);
3024 __ bne(CR0, Lnext);
3025
3026 // Different than before. Cannot keep accurate profile.
3027 __ ori(R0, tmp, TypeEntries::type_unknown);
3028 }
3029 }
3030
3031 __ bind(Ldo_update);
3032 __ std(R0, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
3033
3034 __ bind(Lnext);
3035 if (klass_reg_used) { __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); } // reinit
3036 }
3037 __ bind(Ldone);
3038 }
3039
3040
3041 void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
3042 assert(op->crc()->is_single_cpu(), "crc must be register");
3043 assert(op->val()->is_single_cpu(), "byte value must be register");
3044 assert(op->result_opr()->is_single_cpu(), "result must be register");
3045 Register crc = op->crc()->as_register();
3046 Register val = op->val()->as_register();
3047 Register res = op->result_opr()->as_register();
3048
3049 assert_different_registers(val, crc, res);
3050
3051 __ load_const_optimized(res, StubRoutines::crc_table_addr(), R0);
3052 __ kernel_crc32_singleByteReg(crc, val, res, true);
3053 __ mr(res, crc);
3054 }
3055
3056 #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) {
1760 //__ load_const(exceptionPC->as_register(), pc_for_athrow, R0);
1761 __ calculate_address_from_global_toc(exceptionPC->as_register(), pc_for_athrow, true, true, /*add_relocation*/ true);
1762 add_call_info(pc_for_athrow_offset, info); // for exception handler
1763
1764 address stub = Runtime1::entry_for(compilation()->has_fpu_code() ? StubId::c1_handle_exception_id
1765 : StubId::c1_handle_exception_nofpu_id);
1766 //__ load_const_optimized(R0, stub);
1767 __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
1768 __ mtctr(R0);
1769 __ bctr();
1770 }
1771
1772
1773 void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
1774 // Note: Not used with EnableDebuggingOnDemand.
1775 assert(exceptionOop->as_register() == R3, "should match");
1776 __ b(_unwind_handler_entry);
1777 }
1778
1779
1780 void LIR_Assembler::arraycopy_inlinetype_check(Register obj, Register tmp, CodeStub* slow_path, bool is_dest, bool null_check) {
1781 if (null_check) {
1782 __ cmpdi(CR0, obj, 0);
1783 __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::equal), *slow_path->entry());
1784 }
1785 if (is_dest) {
1786 __ test_null_free_array_oop(obj, tmp, *slow_path->entry(), true);
1787 __ test_flat_array_oop(obj, tmp, *slow_path->entry(), true);
1788 } else {
1789 __ test_flat_array_oop(obj, tmp, *slow_path->entry(), true);
1790 }
1791 }
1792
1793
1794 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
1795 Register src = op->src()->as_register();
1796 Register dst = op->dst()->as_register();
1797 Register src_pos = op->src_pos()->as_register();
1798 Register dst_pos = op->dst_pos()->as_register();
1799 Register length = op->length()->as_register();
1800 Register tmp = op->tmp()->as_register();
1801 Register tmp2 = R0;
1802
1803 int flags = op->flags();
1804 ciArrayKlass* default_type = op->expected_type();
1805 BasicType basic_type = (default_type != nullptr) ? default_type->element_type()->basic_type() : T_ILLEGAL;
1806 if (basic_type == T_ARRAY) basic_type = T_OBJECT;
1807
1808 // Set up the arraycopy stub information.
1809 ArrayCopyStub* stub = op->stub();
1810
1811 if (flags & LIR_OpArrayCopy::always_slow_path) {
1812 __ b(*stub->entry());
1813 __ bind(*stub->continuation());
1814 return;
1815 }
1816
1817 // Always do stub if no type information is available. It's ok if
1818 // the known type isn't loaded since the code sanity checks
1819 // in debug mode and the type isn't required when we know the exact type
1820 // also check that the type is an array type.
1821 if (default_type == nullptr) {
1822 assert(src->is_nonvolatile() && src_pos->is_nonvolatile() && dst->is_nonvolatile() && dst_pos->is_nonvolatile() &&
1823 length->is_nonvolatile(), "must preserve");
1824 address copyfunc_addr = StubRoutines::generic_arraycopy();
1825 assert(copyfunc_addr != nullptr, "generic arraycopy stub required");
1826
1827 // 3 parms are int. Convert to long.
1828 __ mr(R3_ARG1, src);
1829 __ extsw(R4_ARG2, src_pos);
1830 __ mr(R5_ARG3, dst);
1831 __ extsw(R6_ARG4, dst_pos);
1832 __ extsw(R7_ARG5, length);
1833
1834 #ifndef PRODUCT
1835 if (PrintC1Statistics) {
1836 address counter = (address)&Runtime1::_generic_arraycopystub_cnt;
1837 int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
1838 __ lwz(R11_scratch1, simm16_offs, tmp);
1839 __ addi(R11_scratch1, R11_scratch1, 1);
1840 __ stw(R11_scratch1, simm16_offs, tmp);
1841 }
1842 #endif
1843 __ call_c(copyfunc_addr, relocInfo::runtime_call_type);
1844
1845 __ nand(tmp, R3_RET, R3_RET);
1846 __ subf(length, tmp, length);
1847 __ add(src_pos, tmp, src_pos);
1848 __ add(dst_pos, tmp, dst_pos);
1849
1850 __ cmpwi(CR0, R3_RET, 0);
1851 __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::less), *stub->entry());
1852 __ bind(*stub->continuation());
1853 return;
1854 }
1855
1856 // Handle inline type arrays
1857 if (flags & LIR_OpArrayCopy::src_inlinetype_check) {
1858 arraycopy_inlinetype_check(src, tmp, stub, false, (flags & LIR_OpArrayCopy::src_null_check));
1859 }
1860 if (flags & LIR_OpArrayCopy::dst_inlinetype_check) {
1861 arraycopy_inlinetype_check(dst, tmp, stub, true, (flags & LIR_OpArrayCopy::dst_null_check));
1862 }
1863
1864 assert(default_type != nullptr && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
1865 Label cont, slow, copyfunc;
1866
1867 bool simple_check_flag_set = flags & (LIR_OpArrayCopy::src_null_check |
1868 LIR_OpArrayCopy::dst_null_check |
1869 LIR_OpArrayCopy::src_pos_positive_check |
1870 LIR_OpArrayCopy::dst_pos_positive_check |
1871 LIR_OpArrayCopy::length_positive_check);
1872
1873 // Use only one conditional branch for simple checks.
1874 if (simple_check_flag_set) {
1875 ConditionRegister combined_check = CR1, tmp_check = CR1;
1876
1877 // Make sure src and dst are non-null.
1878 if (flags & LIR_OpArrayCopy::src_null_check) {
1879 __ cmpdi(combined_check, src, 0);
1880 tmp_check = CR0;
1881 }
1882
1883 if (flags & LIR_OpArrayCopy::dst_null_check) {
2338 __ bind(not_null);
2339
2340 Register recv = klass_RInfo;
2341 __ load_klass(recv, obj);
2342 type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2343 } else {
2344 __ cmpdi(CR0, obj, 0);
2345 __ beq(CR0, *obj_is_null);
2346 }
2347
2348 // get object class
2349 __ load_klass(klass_RInfo, obj);
2350
2351 if (k->is_loaded()) {
2352 metadata2reg(k->constant_encoding(), k_RInfo);
2353 } else {
2354 klass2reg_with_patching(k_RInfo, op->info_for_patch());
2355 }
2356
2357 if (op->fast_check()) {
2358 assert(!k->is_loaded() || !k->is_obj_array_klass(), "Use refined array for a direct pointer comparison");
2359 assert_different_registers(klass_RInfo, k_RInfo);
2360 __ cmpd(CR0, k_RInfo, klass_RInfo);
2361 __ beq(CR0, *success);
2362 // Fall through to failure case.
2363 } else {
2364 bool need_slow_path = true;
2365 if (k->is_loaded()) {
2366 if ((int) k->super_check_offset() != in_bytes(Klass::secondary_super_cache_offset())) {
2367 need_slow_path = false;
2368 }
2369 // Perform the fast part of the checking logic.
2370 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, (need_slow_path ? success : nullptr),
2371 failure, nullptr, RegisterOrConstant(k->super_check_offset()));
2372 } else {
2373 // Perform the fast part of the checking logic.
2374 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, success, failure);
2375 }
2376 if (!need_slow_path) {
2377 __ b(*success);
2378 } else {
2408 Register array = op->array()->as_register();
2409 Register k_RInfo = op->tmp1()->as_register();
2410 Register klass_RInfo = op->tmp2()->as_register();
2411 Register Rtmp1 = op->tmp3()->as_register();
2412 bool should_profile = op->should_profile();
2413
2414 __ verify_oop(value, FILE_AND_LINE);
2415 CodeStub* stub = op->stub();
2416 // Check if it needs to be profiled.
2417 ciMethodData* md = nullptr;
2418 ciProfileData* data = nullptr;
2419 int mdo_offset_bias = 0;
2420 if (should_profile) {
2421 ciMethod* method = op->profiled_method();
2422 assert(method != nullptr, "Should have method");
2423 setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
2424 }
2425
2426 Label done;
2427
2428 if (op->need_null_check()) {
2429 if (should_profile) {
2430 Label not_null;
2431 Register mdo = k_RInfo;
2432 Register data_val = Rtmp1;
2433 metadata2reg(md->constant_encoding(), mdo);
2434 __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
2435 __ cmpdi(CR0, value, 0);
2436 __ bne(CR0, not_null);
2437 __ lbz(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2438 __ ori(data_val, data_val, BitData::null_seen_byte_constant());
2439 __ stb(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
2440 __ b(done);
2441 __ bind(not_null);
2442
2443 Register recv = klass_RInfo;
2444 __ load_klass(recv, value);
2445 type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1); // kills recv
2446 } else {
2447 __ cmpdi(CR0, value, 0);
2448 __ beq(CR0, done);
2449 }
2450 }
2451 if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
2452 explicit_null_check(array, op->info_for_exception());
2453 } else {
2454 add_debug_info_for_null_check_here(op->info_for_exception());
2455 }
2456 __ load_klass(k_RInfo, array);
2457 __ load_klass(klass_RInfo, value);
2458
2459 Label failure;
2460
2461 // Get instance klass.
2462 __ ld(k_RInfo, in_bytes(ObjArrayKlass::element_klass_offset()), k_RInfo);
2463 // Perform the fast part of the checking logic.
2464 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, &done, &failure, nullptr);
2465
2466 // Call out-of-line instance of __ check_klass_subtype_slow_path(...):
2467 const address slow_path = Runtime1::entry_for(StubId::c1_slow_subtype_check_id);
2468 //__ load_const_optimized(R0, slow_path);
2469 __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(slow_path));
3053 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
3054
3055 // Already unknown. Nothing to do anymore.
3056 __ andi_(R0, tmp, TypeEntries::type_unknown);
3057 __ bne(CR0, Lnext);
3058
3059 // Different than before. Cannot keep accurate profile.
3060 __ ori(R0, tmp, TypeEntries::type_unknown);
3061 }
3062 }
3063
3064 __ bind(Ldo_update);
3065 __ std(R0, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
3066
3067 __ bind(Lnext);
3068 if (klass_reg_used) { __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); } // reinit
3069 }
3070 __ bind(Ldone);
3071 }
3072
3073 void LIR_Assembler::emit_profile_inline_type(LIR_OpProfileInlineType* op) {
3074 Register obj = op->obj()->as_register();
3075 //Register tmp = op->tmp()->as_pointer_register(); not needed!
3076 LIR_Address* mdo_addr = op->mdp()->as_address_ptr();
3077 assert(!mdo_addr->index()->is_valid(), "index unsupported");
3078 Register mdo_base = mdo_addr->base()->as_pointer_register();
3079 int mdo_offs = mdo_addr->disp();
3080 bool not_null = op->not_null();
3081 int flag = op->flag();
3082
3083 Label not_inline_type;
3084 __ test_oop_is_not_inline_type(obj, not_inline_type, !not_null);
3085
3086 __ lbz(R0, mdo_offs, mdo_base);
3087 __ ori(R0, R0, flag);
3088 __ stb(R0, mdo_offs, mdo_base);
3089
3090 __ bind(not_inline_type);
3091 }
3092
3093 void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
3094 assert(op->crc()->is_single_cpu(), "crc must be register");
3095 assert(op->val()->is_single_cpu(), "byte value must be register");
3096 assert(op->result_opr()->is_single_cpu(), "result must be register");
3097 Register crc = op->crc()->as_register();
3098 Register val = op->val()->as_register();
3099 Register res = op->result_opr()->as_register();
3100
3101 assert_different_registers(val, crc, res);
3102
3103 __ load_const_optimized(res, StubRoutines::crc_table_addr(), R0);
3104 __ kernel_crc32_singleByteReg(crc, val, res, true);
3105 __ mr(res, crc);
3106 }
3107
3108 // Valhalla support
3109
3110 void LIR_Assembler::check_orig_pc() {
3111 Address address_for_orig_pc_addr = frame_map()->address_for_orig_pc_addr();
3112 __ ld(R0, address_for_orig_pc_addr);
3113 __ cmpdi(BOOL_RESULT, R0, (u1)NULL_WORD);
3114 }
3115
3116 int LIR_Assembler::store_inline_type_fields_to_buf(ciInlineKlass* vk) {
3117 return (__ store_inline_type_fields_to_buf(vk, false));
3118 }
3119
3120 void LIR_Assembler::emit_opFlattenedArrayCheck(LIR_OpFlattenedArrayCheck* op) {
3121 // We are loading/storing from/to an array that *may* be a flat array (the
3122 // declared type is Object[], abstract[], interface[] or VT.ref[]).
3123 // If this array is a flat array, take the slow path.
3124 __ test_flat_array_oop(op->array()->as_register(), op->tmp()->as_register(), *op->stub()->entry(), true);
3125 }
3126
3127 void LIR_Assembler::emit_opNullFreeArrayCheck(LIR_OpNullFreeArrayCheck* op) {
3128 // We are storing into an array that *may* be null-free (the declared type is
3129 // Object[], abstract[], interface[] or VT.ref[]).
3130 Label test_mark_word;
3131 Register tmp = op->tmp()->as_register();
3132 __ ld(tmp, oopDesc::mark_offset_in_bytes(), op->array()->as_register());
3133 __ andi_(R0, tmp, markWord::unlocked_value);
3134 __ bne(CR0, test_mark_word);
3135 __ load_prototype_header(tmp, op->array()->as_register());
3136 __ bind(test_mark_word);
3137 __ andi(R0, tmp, markWord::null_free_array_bit_in_place);
3138 __ cmpwi(BOOL_RESULT, R0, 0);
3139 }
3140
3141 void LIR_Assembler::emit_opSubstitutabilityCheck(LIR_OpSubstitutabilityCheck* op) {
3142 Label L_oops_equal;
3143 Label L_oops_not_equal;
3144 Label L_end;
3145
3146 Register left = op->left()->as_register();
3147 Register right = op->right()->as_register();
3148
3149 __ cmpd(CR0, left, right);
3150 __ beq(CR0, L_oops_equal);
3151
3152 // (1) Null check -- if one of the operands is null, the other must not be null (because
3153 // the two references are not equal), so they are not substitutable,
3154 __ cmpdi(CR0, left, 0);
3155 __ cmpdi(CR1, right, 0);
3156 __ cror(CR0, Assembler::equal, CR1, Assembler::equal);
3157 __ beq(CR0, L_oops_not_equal);
3158
3159 ciKlass* left_klass = op->left_klass();
3160 ciKlass* right_klass = op->right_klass();
3161
3162 // (2) Inline type check -- if either of the operands is not an inline type,
3163 // they are not substitutable. We do this only if we are not sure that the
3164 // operands are inline type
3165 if ((left_klass == nullptr || right_klass == nullptr) ||// The klass is still unloaded, or came from a Phi node.
3166 !left_klass->is_inlinetype() || !right_klass->is_inlinetype()) {
3167 Register tmp = op->tmp1()->as_register();
3168 __ ld(tmp, oopDesc::mark_offset_in_bytes(), left);
3169 __ ld(R0, oopDesc::mark_offset_in_bytes(), right);
3170 __ andi(tmp, tmp, (intptr_t)markWord::inline_type_pattern);
3171 __ andr(tmp, tmp, R0);
3172 __ cmpdi(CR0, tmp, (intptr_t)markWord::inline_type_pattern);
3173 __ bne(CR0, L_oops_not_equal);
3174 }
3175
3176 // (3) Same klass check: if the operands are of different klasses, they are not substitutable.
3177 if (left_klass != nullptr && left_klass->is_inlinetype() && left_klass == right_klass) {
3178 // No need to load klass -- the operands are statically known to be the same inline klass.
3179 __ b(*op->stub()->entry());
3180 } else {
3181 Register tmp1 = op->tmp1()->as_register();
3182 Register tmp2 = op->tmp2()->as_register();
3183 if (left == right) { // same operand, so clearly the same klasses, let's save the check
3184 __ b(*op->stub()->entry()); // -> do slow check
3185 } else {
3186 __ cmp_klasses_from_objects(CR0, left, right, tmp1, tmp2);
3187 __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CR0, Assembler::equal),
3188 *op->stub()->entry()); // same klass -> do slow check
3189 }
3190 // fall through to L_oops_not_equal
3191 }
3192
3193 __ bind(L_oops_not_equal);
3194 load_to_reg(this, op->not_equal_result(), op->result_opr());
3195 __ b(L_end);
3196
3197 // We've returned from the stub. R3_RET (stub's _scratch_reg) contains 0x0 IFF the two
3198 // operands are not substitutable. (Don't compare against 0x1 in case the
3199 // C compiler is naughty)
3200 __ bind(*op->stub()->continuation());
3201 __ cmpdi(CR0, R3_RET, 0);
3202 __ beq(CR0, L_oops_not_equal);
3203
3204 __ bind(L_oops_equal);
3205 load_to_reg(this, op->equal_result(), op->result_opr()); // (call_stub() != 0x0) -> equal
3206 // fall-through
3207 __ bind(L_end);
3208 }
3209 #undef __
|