< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page

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





















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




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

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


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

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

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