1320 // object here is correct as long as it returns the same modifiers we would expect
1321 // from the primitive class itself. See spec for Class.getModifiers that provides
1322 // the typed array klasses with similar modifiers as their component types.
1323
1324 Klass* univ_klass_obj = Universe::byteArrayKlassObj();
1325 assert(univ_klass_obj->modifier_flags() == (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC), "Sanity");
1326 LIR_Opr prim_klass = LIR_OprFact::metadataConst(univ_klass_obj);
1327
1328 LIR_Opr recv_klass = new_register(T_METADATA);
1329 __ move(new LIR_Address(receiver.result(), java_lang_Class::klass_offset(), T_ADDRESS), recv_klass, info);
1330
1331 // Check if this is a Java mirror of primitive type, and select the appropriate klass.
1332 LIR_Opr klass = new_register(T_METADATA);
1333 __ cmp(lir_cond_equal, recv_klass, LIR_OprFact::metadataConst(0));
1334 __ cmove(lir_cond_equal, prim_klass, recv_klass, klass, T_ADDRESS);
1335
1336 // Get the answer.
1337 __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_INT), result);
1338 }
1339
1340 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1341 assert(x->number_of_arguments() == 3, "wrong type");
1342 LIR_Opr result_reg = rlock_result(x);
1343
1344 LIRItem value(x->argument_at(2), this);
1345 value.load_item();
1346
1347 LIR_Opr klass = new_register(T_METADATA);
1348 load_klass(value.result(), klass, nullptr);
1349 LIR_Opr layout = new_register(T_INT);
1350 __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
1351
1352 LabelObj* L_done = new LabelObj();
1353 LabelObj* L_array = new LabelObj();
1354
1355 __ cmp(lir_cond_lessEqual, layout, 0);
1356 __ branch(lir_cond_lessEqual, L_array->label());
1357
1358 // Instance case: the layout helper gives us instance size almost directly,
1359 // but we need to mask out the _lh_instance_slow_path_bit.
1360
1361 assert((int) Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit");
1362
1363 LIR_Opr mask = load_immediate(~(jint) right_n_bits(LogBytesPerLong), T_INT);
1364 __ logical_and(layout, mask, layout);
2948 break;
2949 #endif
2950
2951 case vmIntrinsics::_currentTimeMillis:
2952 do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
2953 break;
2954
2955 case vmIntrinsics::_nanoTime:
2956 do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
2957 break;
2958
2959 case vmIntrinsics::_Object_init: do_RegisterFinalizer(x); break;
2960 case vmIntrinsics::_isInstance: do_isInstance(x); break;
2961 case vmIntrinsics::_isPrimitive: do_isPrimitive(x); break;
2962 case vmIntrinsics::_getModifiers: do_getModifiers(x); break;
2963 case vmIntrinsics::_getClass: do_getClass(x); break;
2964 case vmIntrinsics::_getObjectSize: do_getObjectSize(x); break;
2965 case vmIntrinsics::_currentCarrierThread: do_currentCarrierThread(x); break;
2966 case vmIntrinsics::_currentThread: do_vthread(x); break;
2967 case vmIntrinsics::_scopedValueCache: do_scopedValueCache(x); break;
2968
2969 case vmIntrinsics::_dlog: // fall through
2970 case vmIntrinsics::_dlog10: // fall through
2971 case vmIntrinsics::_dabs: // fall through
2972 case vmIntrinsics::_dsqrt: // fall through
2973 case vmIntrinsics::_dsqrt_strict: // fall through
2974 case vmIntrinsics::_dtan: // fall through
2975 case vmIntrinsics::_dsin : // fall through
2976 case vmIntrinsics::_dcos : // fall through
2977 case vmIntrinsics::_dexp : // fall through
2978 case vmIntrinsics::_dpow : do_MathIntrinsic(x); break;
2979 case vmIntrinsics::_arraycopy: do_ArrayCopy(x); break;
2980
2981 case vmIntrinsics::_fmaD: do_FmaIntrinsic(x); break;
2982 case vmIntrinsics::_fmaF: do_FmaIntrinsic(x); break;
2983
2984 // Use java.lang.Math intrinsics code since it works for these intrinsics too.
2985 case vmIntrinsics::_floatToFloat16: // fall through
2986 case vmIntrinsics::_float16ToFloat: do_MathIntrinsic(x); break;
2987
|
1320 // object here is correct as long as it returns the same modifiers we would expect
1321 // from the primitive class itself. See spec for Class.getModifiers that provides
1322 // the typed array klasses with similar modifiers as their component types.
1323
1324 Klass* univ_klass_obj = Universe::byteArrayKlassObj();
1325 assert(univ_klass_obj->modifier_flags() == (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC), "Sanity");
1326 LIR_Opr prim_klass = LIR_OprFact::metadataConst(univ_klass_obj);
1327
1328 LIR_Opr recv_klass = new_register(T_METADATA);
1329 __ move(new LIR_Address(receiver.result(), java_lang_Class::klass_offset(), T_ADDRESS), recv_klass, info);
1330
1331 // Check if this is a Java mirror of primitive type, and select the appropriate klass.
1332 LIR_Opr klass = new_register(T_METADATA);
1333 __ cmp(lir_cond_equal, recv_klass, LIR_OprFact::metadataConst(0));
1334 __ cmove(lir_cond_equal, prim_klass, recv_klass, klass, T_ADDRESS);
1335
1336 // Get the answer.
1337 __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_INT), result);
1338 }
1339
1340 void LIRGenerator::do_addressOf(Intrinsic* x) {
1341 assert(x->number_of_arguments() == 1, "wrong type");
1342 LIR_Opr reg = rlock_result(x);
1343
1344 LIRItem value(x->argument_at(0), this);
1345 value.load_item();
1346
1347 #ifdef _LP64
1348 __ move(value.result(), reg, NULL);
1349 #else
1350 LIR_Opr res = new_register(T_INT);
1351 __ move(value.result(), res, NULL);
1352 __ convert(Bytecodes::_i2l, res, reg);
1353 #endif
1354 }
1355
1356 void LIRGenerator::do_sizeOf(Intrinsic* x) {
1357 assert(x->number_of_arguments() == 1, "wrong type");
1358 do_sizeOf_impl(x, 0);
1359 }
1360
1361 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1362 assert(x->number_of_arguments() == 3, "wrong type");
1363 do_sizeOf_impl(x, 2);
1364 }
1365
1366 void LIRGenerator::do_sizeOf_impl(Intrinsic* x, int arg_idx) {
1367 LIR_Opr result_reg = rlock_result(x);
1368
1369 LIRItem value(x->argument_at(arg_idx), this);
1370 value.load_item();
1371
1372 LIR_Opr klass = new_register(T_METADATA);
1373 load_klass(value.result(), klass, nullptr);
1374 LIR_Opr layout = new_register(T_INT);
1375 __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
1376
1377 LabelObj* L_done = new LabelObj();
1378 LabelObj* L_array = new LabelObj();
1379
1380 __ cmp(lir_cond_lessEqual, layout, 0);
1381 __ branch(lir_cond_lessEqual, L_array->label());
1382
1383 // Instance case: the layout helper gives us instance size almost directly,
1384 // but we need to mask out the _lh_instance_slow_path_bit.
1385
1386 assert((int) Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit");
1387
1388 LIR_Opr mask = load_immediate(~(jint) right_n_bits(LogBytesPerLong), T_INT);
1389 __ logical_and(layout, mask, layout);
2973 break;
2974 #endif
2975
2976 case vmIntrinsics::_currentTimeMillis:
2977 do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
2978 break;
2979
2980 case vmIntrinsics::_nanoTime:
2981 do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
2982 break;
2983
2984 case vmIntrinsics::_Object_init: do_RegisterFinalizer(x); break;
2985 case vmIntrinsics::_isInstance: do_isInstance(x); break;
2986 case vmIntrinsics::_isPrimitive: do_isPrimitive(x); break;
2987 case vmIntrinsics::_getModifiers: do_getModifiers(x); break;
2988 case vmIntrinsics::_getClass: do_getClass(x); break;
2989 case vmIntrinsics::_getObjectSize: do_getObjectSize(x); break;
2990 case vmIntrinsics::_currentCarrierThread: do_currentCarrierThread(x); break;
2991 case vmIntrinsics::_currentThread: do_vthread(x); break;
2992 case vmIntrinsics::_scopedValueCache: do_scopedValueCache(x); break;
2993 case vmIntrinsics::_shipilev_magic_sizeOf: do_sizeOf(x); break;
2994 case vmIntrinsics::_shipilev_magic_addressOf: do_addressOf(x); break;
2995
2996 case vmIntrinsics::_dlog: // fall through
2997 case vmIntrinsics::_dlog10: // fall through
2998 case vmIntrinsics::_dabs: // fall through
2999 case vmIntrinsics::_dsqrt: // fall through
3000 case vmIntrinsics::_dsqrt_strict: // fall through
3001 case vmIntrinsics::_dtan: // fall through
3002 case vmIntrinsics::_dsin : // fall through
3003 case vmIntrinsics::_dcos : // fall through
3004 case vmIntrinsics::_dexp : // fall through
3005 case vmIntrinsics::_dpow : do_MathIntrinsic(x); break;
3006 case vmIntrinsics::_arraycopy: do_ArrayCopy(x); break;
3007
3008 case vmIntrinsics::_fmaD: do_FmaIntrinsic(x); break;
3009 case vmIntrinsics::_fmaF: do_FmaIntrinsic(x); break;
3010
3011 // Use java.lang.Math intrinsics code since it works for these intrinsics too.
3012 case vmIntrinsics::_floatToFloat16: // fall through
3013 case vmIntrinsics::_float16ToFloat: do_MathIntrinsic(x); break;
3014
|