< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page

1286   if (x->needs_null_check()) {
1287     info = state_for(x);
1288   }
1289 
1290   LabelObj* L_not_prim = new LabelObj();
1291   LabelObj* L_done = new LabelObj();
1292 
1293   LIR_Opr klass = new_register(T_METADATA);
1294   // Checking if it's a java mirror of primitive type
1295   __ move(new LIR_Address(receiver.result(), java_lang_Class::klass_offset(), T_ADDRESS), klass, info);
1296   __ cmp(lir_cond_notEqual, klass, LIR_OprFact::metadataConst(0));
1297   __ branch(lir_cond_notEqual, L_not_prim->label());
1298   __ move(LIR_OprFact::intConst(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC), result);
1299   __ branch(lir_cond_always, L_done->label());
1300 
1301   __ branch_destination(L_not_prim->label());
1302   __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_INT), result);
1303   __ branch_destination(L_done->label());
1304 }
1305 
1306 // Example: Thread.currentThread()
1307 void LIRGenerator::do_currentThread(Intrinsic* x) {
1308   assert(x->number_of_arguments() == 0, "wrong type");
1309   LIR_Opr temp = new_register(T_ADDRESS);
1310   LIR_Opr reg = rlock_result(x);
1311   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_ADDRESS), temp);
1312   // threadObj = ((OopHandle)_threadObj)->resolve();
1313   access_load(IN_NATIVE, T_OBJECT,
1314               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1315 }
1316 
1317 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1318   assert(x->number_of_arguments() == 3, "wrong type");
1319   LIR_Opr result_reg = rlock_result(x);
1320 
1321   LIRItem value(x->argument_at(2), this);
1322   value.load_item();
1323 
1324   LIR_Opr klass = new_register(T_METADATA);
1325   __ move(new LIR_Address(value.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, NULL);
1326   LIR_Opr layout = new_register(T_INT);
1327   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);

1400   // Mix all up, round, and push to the result.
1401 #ifdef _LP64
1402   LIR_Opr header_size_long = new_register(T_LONG);
1403   __ convert(Bytecodes::_i2l, header_size, header_size_long);
1404   __ add(length, header_size_long, length);
1405   if (round_mask != 0) {
1406     __ logical_and(length, LIR_OprFact::longConst(~round_mask), length);
1407   }
1408   __ move(length, result_reg);
1409 #else
1410   __ add(length_int, header_size, length_int);
1411   if (round_mask != 0) {
1412     __ logical_and(length_int, LIR_OprFact::intConst(~round_mask), length_int);
1413   }
1414   __ convert(Bytecodes::_i2l, length_int, result_reg);
1415 #endif
1416 
1417   __ branch_destination(L_done->label());
1418 }
1419 






















1420 void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) {
1421   assert(x->number_of_arguments() == 1, "wrong type");
1422   LIRItem receiver(x->argument_at(0), this);
1423 
1424   receiver.load_item();
1425   BasicTypeList signature;
1426   signature.append(T_OBJECT); // receiver
1427   LIR_OprList* args = new LIR_OprList();
1428   args->append(receiver.result());
1429   CodeEmitInfo* info = state_for(x, x->state());
1430   call_runtime(&signature, args,
1431                CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::register_finalizer_id)),
1432                voidType, info);
1433 
1434   set_no_result(x);
1435 }
1436 
1437 
1438 //------------------------local access--------------------------------------
1439 

2859   left.load_item();
2860   if (can_inline_as_constant(right.value())) {
2861     right.dont_load_item();
2862   } else {
2863     right.load_item();
2864   }
2865 
2866   LIRItem t_val(x->tval(), this);
2867   LIRItem f_val(x->fval(), this);
2868   t_val.dont_load_item();
2869   f_val.dont_load_item();
2870   LIR_Opr reg = rlock_result(x);
2871 
2872   __ cmp(lir_cond(x->cond()), left.result(), right.result());
2873   __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
2874 }
2875 
2876 #ifdef JFR_HAVE_INTRINSICS
2877 
2878 void LIRGenerator::do_getEventWriter(Intrinsic* x) {
2879   LabelObj* L_end = new LabelObj();
2880 
2881   // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
2882   // meaning of these two is mixed up (see JDK-8026837).
2883   LIR_Address* jobj_addr = new LIR_Address(getThreadPointer(),
2884                                            in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR),
2885                                            T_ADDRESS);
2886   LIR_Opr result = rlock_result(x);
2887   __ move(LIR_OprFact::oopConst(NULL), result);
2888   LIR_Opr jobj = new_register(T_METADATA);
2889   __ move_wide(jobj_addr, jobj);
2890   __ cmp(lir_cond_equal, jobj, LIR_OprFact::metadataConst(0));
2891   __ branch(lir_cond_equal, L_end->label());
2892 
2893   access_load(IN_NATIVE, T_OBJECT, LIR_OprFact::address(new LIR_Address(jobj, T_OBJECT)), result);
2894 
2895   __ branch_destination(L_end->label());
2896 }
2897 
2898 #endif
2899 
2900 
2901 void LIRGenerator::do_RuntimeCall(address routine, Intrinsic* x) {
2902   assert(x->number_of_arguments() == 0, "wrong type");
2903   // Enforce computation of _reserved_argument_area_size which is required on some platforms.
2904   BasicTypeList signature;
2905   CallingConvention* cc = frame_map()->c_calling_convention(&signature);
2906   LIR_Opr reg = result_register_for(x->type());
2907   __ call_runtime_leaf(routine, getThreadTemp(),
2908                        reg, new LIR_OprList());
2909   LIR_Opr result = rlock_result(x);
2910   __ move(reg, result);
2911 }
2912 
2913 
2914 
2915 void LIRGenerator::do_Intrinsic(Intrinsic* x) {

2927     do_getEventWriter(x);
2928     break;
2929   case vmIntrinsics::_counterTime:
2930     do_RuntimeCall(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), x);
2931     break;
2932 #endif
2933 
2934   case vmIntrinsics::_currentTimeMillis:
2935     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
2936     break;
2937 
2938   case vmIntrinsics::_nanoTime:
2939     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
2940     break;
2941 
2942   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
2943   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
2944   case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
2945   case vmIntrinsics::_getModifiers:   do_getModifiers(x);  break;
2946   case vmIntrinsics::_getClass:       do_getClass(x);      break;
2947   case vmIntrinsics::_currentThread:  do_currentThread(x); break;
2948   case vmIntrinsics::_getObjectSize:  do_getObjectSize(x); break;



2949 
2950   case vmIntrinsics::_dlog:           // fall through
2951   case vmIntrinsics::_dlog10:         // fall through
2952   case vmIntrinsics::_dabs:           // fall through
2953   case vmIntrinsics::_dsqrt:          // fall through
2954   case vmIntrinsics::_dtan:           // fall through
2955   case vmIntrinsics::_dsin :          // fall through
2956   case vmIntrinsics::_dcos :          // fall through
2957   case vmIntrinsics::_dexp :          // fall through
2958   case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
2959   case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
2960 
2961   case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
2962   case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
2963 
2964   case vmIntrinsics::_Preconditions_checkIndex:
2965     do_PreconditionsCheckIndex(x, T_INT);
2966     break;
2967   case vmIntrinsics::_Preconditions_checkLongIndex:
2968     do_PreconditionsCheckIndex(x, T_LONG);

2991     __ on_spin_wait();
2992     break;
2993   case vmIntrinsics::_Reference_get:
2994     do_Reference_get(x);
2995     break;
2996 
2997   case vmIntrinsics::_updateCRC32:
2998   case vmIntrinsics::_updateBytesCRC32:
2999   case vmIntrinsics::_updateByteBufferCRC32:
3000     do_update_CRC32(x);
3001     break;
3002 
3003   case vmIntrinsics::_updateBytesCRC32C:
3004   case vmIntrinsics::_updateDirectByteBufferCRC32C:
3005     do_update_CRC32C(x);
3006     break;
3007 
3008   case vmIntrinsics::_vectorizedMismatch:
3009     do_vectorizedMismatch(x);
3010     break;




3011 
3012   case vmIntrinsics::_blackhole:
3013     do_blackhole(x);
3014     break;
3015 
3016   default: ShouldNotReachHere(); break;
3017   }
3018 }
3019 
3020 void LIRGenerator::profile_arguments(ProfileCall* x) {
3021   if (compilation()->profile_arguments()) {
3022     int bci = x->bci_of_invoke();
3023     ciMethodData* md = x->method()->method_data_or_null();
3024     assert(md != NULL, "Sanity");
3025     ciProfileData* data = md->bci_to_data(bci);
3026     if (data != NULL) {
3027       if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
3028           (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
3029         ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
3030         int base_offset = md->byte_offset_of_slot(data, extra);

1286   if (x->needs_null_check()) {
1287     info = state_for(x);
1288   }
1289 
1290   LabelObj* L_not_prim = new LabelObj();
1291   LabelObj* L_done = new LabelObj();
1292 
1293   LIR_Opr klass = new_register(T_METADATA);
1294   // Checking if it's a java mirror of primitive type
1295   __ move(new LIR_Address(receiver.result(), java_lang_Class::klass_offset(), T_ADDRESS), klass, info);
1296   __ cmp(lir_cond_notEqual, klass, LIR_OprFact::metadataConst(0));
1297   __ branch(lir_cond_notEqual, L_not_prim->label());
1298   __ move(LIR_OprFact::intConst(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC), result);
1299   __ branch(lir_cond_always, L_done->label());
1300 
1301   __ branch_destination(L_not_prim->label());
1302   __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_INT), result);
1303   __ branch_destination(L_done->label());
1304 }
1305 
1306 // Example: Thread.currentThread0()
1307 void LIRGenerator::do_currentThread0(Intrinsic* x) {
1308   assert(x->number_of_arguments() == 0, "wrong type");
1309   LIR_Opr temp = new_register(T_ADDRESS);
1310   LIR_Opr reg = rlock_result(x);
1311   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_ADDRESS), temp);
1312   // threadObj = ((OopHandle)_threadObj)->resolve();
1313   access_load(IN_NATIVE, T_OBJECT,
1314               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1315 }
1316 
1317 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1318   assert(x->number_of_arguments() == 3, "wrong type");
1319   LIR_Opr result_reg = rlock_result(x);
1320 
1321   LIRItem value(x->argument_at(2), this);
1322   value.load_item();
1323 
1324   LIR_Opr klass = new_register(T_METADATA);
1325   __ move(new LIR_Address(value.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, NULL);
1326   LIR_Opr layout = new_register(T_INT);
1327   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);

1400   // Mix all up, round, and push to the result.
1401 #ifdef _LP64
1402   LIR_Opr header_size_long = new_register(T_LONG);
1403   __ convert(Bytecodes::_i2l, header_size, header_size_long);
1404   __ add(length, header_size_long, length);
1405   if (round_mask != 0) {
1406     __ logical_and(length, LIR_OprFact::longConst(~round_mask), length);
1407   }
1408   __ move(length, result_reg);
1409 #else
1410   __ add(length_int, header_size, length_int);
1411   if (round_mask != 0) {
1412     __ logical_and(length_int, LIR_OprFact::intConst(~round_mask), length_int);
1413   }
1414   __ convert(Bytecodes::_i2l, length_int, result_reg);
1415 #endif
1416 
1417   __ branch_destination(L_done->label());
1418 }
1419 
1420 void LIRGenerator::do_scopeLocalCache(Intrinsic* x) {
1421   assert(x->number_of_arguments() == 0, "wrong type");
1422   LIR_Opr temp = new_register(T_ADDRESS);
1423   LIR_Opr reg = rlock_result(x);
1424   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::scopeLocalCache_offset()), T_ADDRESS), temp);
1425   // threadObj = ((OopHandle)_vthread)->resolve();
1426   access_load(IN_NATIVE, T_OBJECT,
1427               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1428 }
1429 
1430 
1431 void LIRGenerator::do_vthread(Intrinsic* x) {
1432   assert(x->number_of_arguments() == 0, "wrong type");
1433   LIR_Opr temp = new_register(T_ADDRESS);
1434   LIR_Opr reg = rlock_result(x);
1435   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::vthread_offset()), T_ADDRESS), temp);
1436   // threadObj = ((OopHandle)_vthread)->resolve();
1437   access_load(IN_NATIVE, T_OBJECT,
1438               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1439 }
1440 
1441 
1442 void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) {
1443   assert(x->number_of_arguments() == 1, "wrong type");
1444   LIRItem receiver(x->argument_at(0), this);
1445 
1446   receiver.load_item();
1447   BasicTypeList signature;
1448   signature.append(T_OBJECT); // receiver
1449   LIR_OprList* args = new LIR_OprList();
1450   args->append(receiver.result());
1451   CodeEmitInfo* info = state_for(x, x->state());
1452   call_runtime(&signature, args,
1453                CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::register_finalizer_id)),
1454                voidType, info);
1455 
1456   set_no_result(x);
1457 }
1458 
1459 
1460 //------------------------local access--------------------------------------
1461 

2881   left.load_item();
2882   if (can_inline_as_constant(right.value())) {
2883     right.dont_load_item();
2884   } else {
2885     right.load_item();
2886   }
2887 
2888   LIRItem t_val(x->tval(), this);
2889   LIRItem f_val(x->fval(), this);
2890   t_val.dont_load_item();
2891   f_val.dont_load_item();
2892   LIR_Opr reg = rlock_result(x);
2893 
2894   __ cmp(lir_cond(x->cond()), left.result(), right.result());
2895   __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
2896 }
2897 
2898 #ifdef JFR_HAVE_INTRINSICS
2899 
2900 void LIRGenerator::do_getEventWriter(Intrinsic* x) {
2901   LabelObj* L_NULL = new LabelObj();
2902   BasicTypeList signature(0);
2903   CallingConvention* cc = frame_map()->c_calling_convention(&signature);
2904   LIR_Opr reg = result_register_for(x->type());
2905   address entry = StubRoutines::jfr_get_event_writer();
2906   CodeEmitInfo* info = state_for(x, x->state());
2907   __ call_runtime(entry, getThreadTemp(), reg, cc->args(), info);
2908   LIR_Opr result = rlock_result(x);
2909   __ move(reg, result);








2910 }
2911 
2912 #endif
2913 
2914 
2915 void LIRGenerator::do_RuntimeCall(address routine, Intrinsic* x) {
2916   assert(x->number_of_arguments() == 0, "wrong type");
2917   // Enforce computation of _reserved_argument_area_size which is required on some platforms.
2918   BasicTypeList signature;
2919   CallingConvention* cc = frame_map()->c_calling_convention(&signature);
2920   LIR_Opr reg = result_register_for(x->type());
2921   __ call_runtime_leaf(routine, getThreadTemp(),
2922                        reg, new LIR_OprList());
2923   LIR_Opr result = rlock_result(x);
2924   __ move(reg, result);
2925 }
2926 
2927 
2928 
2929 void LIRGenerator::do_Intrinsic(Intrinsic* x) {

2941     do_getEventWriter(x);
2942     break;
2943   case vmIntrinsics::_counterTime:
2944     do_RuntimeCall(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), x);
2945     break;
2946 #endif
2947 
2948   case vmIntrinsics::_currentTimeMillis:
2949     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
2950     break;
2951 
2952   case vmIntrinsics::_nanoTime:
2953     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
2954     break;
2955 
2956   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
2957   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
2958   case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
2959   case vmIntrinsics::_getModifiers:   do_getModifiers(x);  break;
2960   case vmIntrinsics::_getClass:       do_getClass(x);      break;

2961   case vmIntrinsics::_getObjectSize:  do_getObjectSize(x); break;
2962   case vmIntrinsics::_currentThread0: do_currentThread0(x); break;
2963   case vmIntrinsics::_currentThread:  do_vthread(x);       break;
2964   case vmIntrinsics::_scopeLocalCache: do_scopeLocalCache(x); break;
2965 
2966   case vmIntrinsics::_dlog:           // fall through
2967   case vmIntrinsics::_dlog10:         // fall through
2968   case vmIntrinsics::_dabs:           // fall through
2969   case vmIntrinsics::_dsqrt:          // fall through
2970   case vmIntrinsics::_dtan:           // fall through
2971   case vmIntrinsics::_dsin :          // fall through
2972   case vmIntrinsics::_dcos :          // fall through
2973   case vmIntrinsics::_dexp :          // fall through
2974   case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
2975   case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
2976 
2977   case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
2978   case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
2979 
2980   case vmIntrinsics::_Preconditions_checkIndex:
2981     do_PreconditionsCheckIndex(x, T_INT);
2982     break;
2983   case vmIntrinsics::_Preconditions_checkLongIndex:
2984     do_PreconditionsCheckIndex(x, T_LONG);

3007     __ on_spin_wait();
3008     break;
3009   case vmIntrinsics::_Reference_get:
3010     do_Reference_get(x);
3011     break;
3012 
3013   case vmIntrinsics::_updateCRC32:
3014   case vmIntrinsics::_updateBytesCRC32:
3015   case vmIntrinsics::_updateByteBufferCRC32:
3016     do_update_CRC32(x);
3017     break;
3018 
3019   case vmIntrinsics::_updateBytesCRC32C:
3020   case vmIntrinsics::_updateDirectByteBufferCRC32C:
3021     do_update_CRC32C(x);
3022     break;
3023 
3024   case vmIntrinsics::_vectorizedMismatch:
3025     do_vectorizedMismatch(x);
3026     break;
3027           
3028   case vmIntrinsics::_Continuation_doYield:
3029     do_continuation_doYield(x);
3030     break;
3031 
3032   case vmIntrinsics::_blackhole:
3033     do_blackhole(x);
3034     break;
3035 
3036   default: ShouldNotReachHere(); break;
3037   }
3038 }
3039 
3040 void LIRGenerator::profile_arguments(ProfileCall* x) {
3041   if (compilation()->profile_arguments()) {
3042     int bci = x->bci_of_invoke();
3043     ciMethodData* md = x->method()->method_data_or_null();
3044     assert(md != NULL, "Sanity");
3045     ciProfileData* data = md->bci_to_data(bci);
3046     if (data != NULL) {
3047       if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
3048           (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
3049         ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
3050         int base_offset = md->byte_offset_of_slot(data, extra);
< prev index next >