< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page

1304   // object here is correct as long as it returns the same modifiers we would expect
1305   // from the primitive class itself. See spec for Class.getModifiers that provides
1306   // the typed array klasses with similar modifiers as their component types.
1307 
1308   Klass* univ_klass_obj = Universe::byteArrayKlassObj();
1309   assert(univ_klass_obj->modifier_flags() == (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC), "Sanity");
1310   LIR_Opr prim_klass = LIR_OprFact::metadataConst(univ_klass_obj);
1311 
1312   LIR_Opr recv_klass = new_register(T_METADATA);
1313   __ move(new LIR_Address(receiver.result(), java_lang_Class::klass_offset(), T_ADDRESS), recv_klass, info);
1314 
1315   // Check if this is a Java mirror of primitive type, and select the appropriate klass.
1316   LIR_Opr klass = new_register(T_METADATA);
1317   __ cmp(lir_cond_equal, recv_klass, LIR_OprFact::metadataConst(0));
1318   __ cmove(lir_cond_equal, prim_klass, recv_klass, klass, T_ADDRESS);
1319 
1320   // Get the answer.
1321   __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_INT), result);
1322 }
1323 





















1324 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1325   assert(x->number_of_arguments() == 3, "wrong type");




1326   LIR_Opr result_reg = rlock_result(x);
1327 
1328   LIRItem value(x->argument_at(2), this);
1329   value.load_item();
1330 
1331   LIR_Opr klass = new_register(T_METADATA);
1332   load_klass(value.result(), klass, NULL);
1333   LIR_Opr layout = new_register(T_INT);
1334   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
1335 
1336   LabelObj* L_done = new LabelObj();
1337   LabelObj* L_array = new LabelObj();
1338 
1339   __ cmp(lir_cond_lessEqual, layout, 0);
1340   __ branch(lir_cond_lessEqual, L_array->label());
1341 
1342   // Instance case: the layout helper gives us instance size almost directly,
1343   // but we need to mask out the _lh_instance_slow_path_bit.
1344 
1345   assert((int) Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit");
1346 
1347   LIR_Opr mask = load_immediate(~(jint) right_n_bits(LogBytesPerLong), T_INT);
1348   __ logical_and(layout, mask, layout);

2935     break;
2936 #endif
2937 
2938   case vmIntrinsics::_currentTimeMillis:
2939     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
2940     break;
2941 
2942   case vmIntrinsics::_nanoTime:
2943     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
2944     break;
2945 
2946   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
2947   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
2948   case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
2949   case vmIntrinsics::_getModifiers:   do_getModifiers(x);  break;
2950   case vmIntrinsics::_getClass:       do_getClass(x);      break;
2951   case vmIntrinsics::_getObjectSize:  do_getObjectSize(x); break;
2952   case vmIntrinsics::_currentCarrierThread: do_currentCarrierThread(x); break;
2953   case vmIntrinsics::_currentThread:  do_vthread(x);       break;
2954   case vmIntrinsics::_extentLocalCache: do_extentLocalCache(x); break;


2955 
2956   case vmIntrinsics::_dlog:           // fall through
2957   case vmIntrinsics::_dlog10:         // fall through
2958   case vmIntrinsics::_dabs:           // fall through
2959   case vmIntrinsics::_dsqrt:          // fall through
2960   case vmIntrinsics::_dsqrt_strict:   // fall through
2961   case vmIntrinsics::_dtan:           // fall through
2962   case vmIntrinsics::_dsin :          // fall through
2963   case vmIntrinsics::_dcos :          // fall through
2964   case vmIntrinsics::_dexp :          // fall through
2965   case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
2966   case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
2967 
2968   case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
2969   case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
2970 
2971   case vmIntrinsics::_Preconditions_checkIndex:
2972     do_PreconditionsCheckIndex(x, T_INT);
2973     break;
2974   case vmIntrinsics::_Preconditions_checkLongIndex:

1304   // object here is correct as long as it returns the same modifiers we would expect
1305   // from the primitive class itself. See spec for Class.getModifiers that provides
1306   // the typed array klasses with similar modifiers as their component types.
1307 
1308   Klass* univ_klass_obj = Universe::byteArrayKlassObj();
1309   assert(univ_klass_obj->modifier_flags() == (JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC), "Sanity");
1310   LIR_Opr prim_klass = LIR_OprFact::metadataConst(univ_klass_obj);
1311 
1312   LIR_Opr recv_klass = new_register(T_METADATA);
1313   __ move(new LIR_Address(receiver.result(), java_lang_Class::klass_offset(), T_ADDRESS), recv_klass, info);
1314 
1315   // Check if this is a Java mirror of primitive type, and select the appropriate klass.
1316   LIR_Opr klass = new_register(T_METADATA);
1317   __ cmp(lir_cond_equal, recv_klass, LIR_OprFact::metadataConst(0));
1318   __ cmove(lir_cond_equal, prim_klass, recv_klass, klass, T_ADDRESS);
1319 
1320   // Get the answer.
1321   __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_INT), result);
1322 }
1323 
1324 void LIRGenerator::do_addressOf(Intrinsic* x) {
1325   assert(x->number_of_arguments() == 1, "wrong type");
1326   LIR_Opr reg = rlock_result(x);
1327 
1328   LIRItem value(x->argument_at(0), this);
1329   value.load_item();
1330 
1331 #ifdef _LP64
1332   __ move(value.result(), reg, NULL);
1333 #else
1334   LIR_Opr res = new_register(T_INT);
1335   __ move(value.result(), res, NULL);
1336   __ convert(Bytecodes::_i2l, res, reg);
1337 #endif
1338 }
1339 
1340 void LIRGenerator::do_sizeOf(Intrinsic* x) {
1341   assert(x->number_of_arguments() == 1, "wrong type");
1342   do_sizeOf_impl(x, 0);
1343 }
1344 
1345 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1346   assert(x->number_of_arguments() == 3, "wrong type");
1347   do_sizeOf_impl(x, 2);
1348 }
1349 
1350 void LIRGenerator::do_sizeOf_impl(Intrinsic* x, int arg_idx) {
1351   LIR_Opr result_reg = rlock_result(x);
1352 
1353   LIRItem value(x->argument_at(arg_idx), this);
1354   value.load_item();
1355 
1356   LIR_Opr klass = new_register(T_METADATA);
1357   load_klass(value.result(), klass, NULL);
1358   LIR_Opr layout = new_register(T_INT);
1359   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
1360 
1361   LabelObj* L_done = new LabelObj();
1362   LabelObj* L_array = new LabelObj();
1363 
1364   __ cmp(lir_cond_lessEqual, layout, 0);
1365   __ branch(lir_cond_lessEqual, L_array->label());
1366 
1367   // Instance case: the layout helper gives us instance size almost directly,
1368   // but we need to mask out the _lh_instance_slow_path_bit.
1369 
1370   assert((int) Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit");
1371 
1372   LIR_Opr mask = load_immediate(~(jint) right_n_bits(LogBytesPerLong), T_INT);
1373   __ logical_and(layout, mask, layout);

2960     break;
2961 #endif
2962 
2963   case vmIntrinsics::_currentTimeMillis:
2964     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
2965     break;
2966 
2967   case vmIntrinsics::_nanoTime:
2968     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
2969     break;
2970 
2971   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
2972   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
2973   case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
2974   case vmIntrinsics::_getModifiers:   do_getModifiers(x);  break;
2975   case vmIntrinsics::_getClass:       do_getClass(x);      break;
2976   case vmIntrinsics::_getObjectSize:  do_getObjectSize(x); break;
2977   case vmIntrinsics::_currentCarrierThread: do_currentCarrierThread(x); break;
2978   case vmIntrinsics::_currentThread:  do_vthread(x);       break;
2979   case vmIntrinsics::_extentLocalCache: do_extentLocalCache(x); break;
2980   case vmIntrinsics::_shipilev_magic_sizeOf:         do_sizeOf(x);        break;
2981   case vmIntrinsics::_shipilev_magic_addressOf:      do_addressOf(x);     break;
2982 
2983   case vmIntrinsics::_dlog:           // fall through
2984   case vmIntrinsics::_dlog10:         // fall through
2985   case vmIntrinsics::_dabs:           // fall through
2986   case vmIntrinsics::_dsqrt:          // fall through
2987   case vmIntrinsics::_dsqrt_strict:   // fall through
2988   case vmIntrinsics::_dtan:           // fall through
2989   case vmIntrinsics::_dsin :          // fall through
2990   case vmIntrinsics::_dcos :          // fall through
2991   case vmIntrinsics::_dexp :          // fall through
2992   case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
2993   case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
2994 
2995   case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
2996   case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
2997 
2998   case vmIntrinsics::_Preconditions_checkIndex:
2999     do_PreconditionsCheckIndex(x, T_INT);
3000     break;
3001   case vmIntrinsics::_Preconditions_checkLongIndex:
< prev index next >