< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page
rev 64191 : Merge


1306     info = state_for(x);
1307   }
1308 
1309   __ move(new LIR_Address(rcvr.result(), java_lang_Class::klass_offset(), T_ADDRESS), temp, info);
1310   __ cmp(lir_cond_notEqual, temp, LIR_OprFact::metadataConst(0));
1311   __ cmove(lir_cond_notEqual, LIR_OprFact::intConst(0), LIR_OprFact::intConst(1), result, T_BOOLEAN);
1312 }
1313 
1314 
1315 // Example: Thread.currentThread()
1316 void LIRGenerator::do_currentThread(Intrinsic* x) {
1317   assert(x->number_of_arguments() == 0, "wrong type");
1318   LIR_Opr temp = new_register(T_ADDRESS);
1319   LIR_Opr reg = rlock_result(x);
1320   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_ADDRESS), temp);
1321   // threadObj = ((OopHandle)_threadObj)->resolve();
1322   access_load(IN_NATIVE, T_OBJECT,
1323               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1324 }
1325 




















































































































































1326 
1327 void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) {
1328   assert(x->number_of_arguments() == 1, "wrong type");
1329   LIRItem receiver(x->argument_at(0), this);
1330 
1331   receiver.load_item();
1332   BasicTypeList signature;
1333   signature.append(T_OBJECT); // receiver
1334   LIR_OprList* args = new LIR_OprList();
1335   args->append(receiver.result());
1336   CodeEmitInfo* info = state_for(x, x->state());
1337   call_runtime(&signature, args,
1338                CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::register_finalizer_id)),
1339                voidType, info);
1340 
1341   set_no_result(x);
1342 }
1343 
1344 
1345 //------------------------local access--------------------------------------


3031     do_getEventWriter(x);
3032     break;
3033   case vmIntrinsics::_counterTime:
3034     do_RuntimeCall(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), x);
3035     break;
3036 #endif
3037 
3038   case vmIntrinsics::_currentTimeMillis:
3039     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
3040     break;
3041 
3042   case vmIntrinsics::_nanoTime:
3043     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
3044     break;
3045 
3046   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
3047   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
3048   case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
3049   case vmIntrinsics::_getClass:       do_getClass(x);      break;
3050   case vmIntrinsics::_currentThread:  do_currentThread(x); break;



3051 
3052   case vmIntrinsics::_dlog:           // fall through
3053   case vmIntrinsics::_dlog10:         // fall through
3054   case vmIntrinsics::_dabs:           // fall through
3055   case vmIntrinsics::_dsqrt:          // fall through
3056   case vmIntrinsics::_dtan:           // fall through
3057   case vmIntrinsics::_dsin :          // fall through
3058   case vmIntrinsics::_dcos :          // fall through
3059   case vmIntrinsics::_dexp :          // fall through
3060   case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
3061   case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
3062 
3063   case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
3064   case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
3065 
3066   // java.nio.Buffer.checkIndex
3067   case vmIntrinsics::_checkIndex:     do_NIOCheckIndex(x); break;
3068 
3069   case vmIntrinsics::_compareAndSetReference:
3070     do_CompareAndSwap(x, objectType);




1306     info = state_for(x);
1307   }
1308 
1309   __ move(new LIR_Address(rcvr.result(), java_lang_Class::klass_offset(), T_ADDRESS), temp, info);
1310   __ cmp(lir_cond_notEqual, temp, LIR_OprFact::metadataConst(0));
1311   __ cmove(lir_cond_notEqual, LIR_OprFact::intConst(0), LIR_OprFact::intConst(1), result, T_BOOLEAN);
1312 }
1313 
1314 
1315 // Example: Thread.currentThread()
1316 void LIRGenerator::do_currentThread(Intrinsic* x) {
1317   assert(x->number_of_arguments() == 0, "wrong type");
1318   LIR_Opr temp = new_register(T_ADDRESS);
1319   LIR_Opr reg = rlock_result(x);
1320   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_ADDRESS), temp);
1321   // threadObj = ((OopHandle)_threadObj)->resolve();
1322   access_load(IN_NATIVE, T_OBJECT,
1323               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1324 }
1325 
1326 void LIRGenerator::do_getReferencedObjects(Intrinsic* x) {
1327   BasicTypeList signature;
1328   signature.append(T_OBJECT); // obj
1329   signature.append(T_ARRAY);  // reference buffer
1330 
1331   LIRItem a0(x->argument_at(0), this);
1332   LIRItem a1(x->argument_at(1), this);
1333   a0.load_item();
1334   a1.load_item();
1335 
1336   LIR_OprList* args = new LIR_OprList();
1337   args->append(a0.result());
1338   args->append(a1.result());
1339 
1340   LIR_Opr result = call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::get_referenced_objects), intType, NULL);
1341   __ move(result, rlock_result(x), NULL);
1342 }
1343 
1344 void LIRGenerator::do_addressOf(Intrinsic* x) {
1345   assert(x->number_of_arguments() == 1, "wrong type");
1346   LIR_Opr reg = rlock_result(x);
1347 
1348   if (!RuntimeAddressOf) {
1349     __ move(LIR_OprFact::longConst(-1), reg, NULL);
1350     return;
1351   }
1352 
1353   LIRItem value(x->argument_at(0), this);
1354   value.load_item();
1355 
1356 #ifdef _LP64
1357   __ move(value.result(), reg, NULL);
1358   __ add(reg, LIR_OprFact::intptrConst(Universe::non_heap_offset()), reg);
1359 #else
1360   LIR_Opr res = new_register(T_INT);
1361   __ move(value.result(), res, NULL);
1362   __ add(res, LIR_OprFact::intptrConst(Universe::non_heap_offset()), res);
1363   __ convert(Bytecodes::_i2l, res, reg);
1364 #endif
1365 }
1366 
1367 void LIRGenerator::do_sizeOf(Intrinsic* x) {
1368   assert(x->number_of_arguments() == 1, "wrong type");
1369   LIR_Opr result_reg = rlock_result(x);
1370 
1371   if (!RuntimeSizeOf) {
1372     __ move(LIR_OprFact::longConst(-1), result_reg);
1373     return;
1374   }
1375 
1376   LIRItem value(x->argument_at(0), this);
1377   value.load_item();
1378 
1379   LIR_Opr klass = new_register(T_METADATA);
1380   __ move(new LIR_Address(value.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, NULL);
1381   LIR_Opr layout = new_register(T_INT);
1382   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
1383 
1384   LabelObj* L_done = new LabelObj();
1385   LabelObj* L_array = new LabelObj();
1386 
1387   __ cmp(lir_cond_lessEqual, layout, 0);
1388   __ branch(lir_cond_lessEqual, L_array->label());
1389 
1390   // Instance case: the layout helper gives us instance size almost directly,
1391   // but we need to mask out the _lh_instance_slow_path_bit.
1392   __ convert(Bytecodes::_i2l, layout, result_reg);
1393 
1394   assert((int) Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit");
1395   jlong mask = ~(jlong) right_n_bits(LogBytesPerLong);
1396   __ logical_and(result_reg, LIR_OprFact::longConst(mask), result_reg);
1397 
1398   __ branch(lir_cond_always, L_done->label());
1399 
1400   // Array case: size is round(header + element_size*arraylength).
1401   // Since arraylength is different for every array instance, we have to
1402   // compute the whole thing at runtime.
1403 
1404   __ branch_destination(L_array->label());
1405 
1406   int round_mask = MinObjAlignmentInBytes - 1;
1407 
1408   // Figure out header sizes first.
1409   LIR_Opr hss = LIR_OprFact::intConst(Klass::_lh_header_size_shift);
1410   LIR_Opr hsm = LIR_OprFact::intConst(Klass::_lh_header_size_mask);
1411 
1412   LIR_Opr header_size = new_register(T_INT);
1413   __ move(layout, header_size);
1414   LIR_Opr tmp = new_register(T_INT);
1415   __ unsigned_shift_right(header_size, hss, header_size, tmp);
1416   __ logical_and(header_size, hsm, header_size);
1417   __ add(header_size, LIR_OprFact::intConst(round_mask), header_size);
1418 
1419   // Figure out the array length in bytes
1420   assert(Klass::_lh_log2_element_size_shift == 0, "use shift in place");
1421   LIR_Opr l2esm = LIR_OprFact::intConst(Klass::_lh_log2_element_size_mask);
1422   __ logical_and(layout, l2esm, layout);
1423 
1424   LIR_Opr length_int = new_register(T_INT);
1425   __ move(new LIR_Address(value.result(), arrayOopDesc::length_offset_in_bytes(), T_INT), length_int);
1426 
1427 #ifdef _LP64
1428   LIR_Opr length = new_register(T_LONG);
1429   __ convert(Bytecodes::_i2l, length_int, length);
1430 #endif
1431 
1432   // Shift-left awkwardness. Normally it is just:
1433   //   __ shift_left(length, layout, length);
1434   // But C1 cannot perform shift_left with non-constant count, so we end up
1435   // doing the per-bit loop dance here. x86_32 also does not know how to shift
1436   // longs, so we have to act on ints.
1437   LabelObj* L_shift_loop = new LabelObj();
1438   LabelObj* L_shift_exit = new LabelObj();
1439 
1440   __ branch_destination(L_shift_loop->label());
1441   __ cmp(lir_cond_equal, layout, 0);
1442   __ branch(lir_cond_equal, L_shift_exit->label());
1443 
1444 #ifdef _LP64
1445   __ shift_left(length, 1, length);
1446 #else
1447   __ shift_left(length_int, 1, length_int);
1448 #endif
1449 
1450   __ sub(layout, LIR_OprFact::intConst(1), layout);
1451 
1452   __ branch(lir_cond_always, L_shift_loop->label());
1453   __ branch_destination(L_shift_exit->label());
1454 
1455   // Mix all up, round, and push to the result.
1456 #ifdef _LP64
1457   LIR_Opr header_size_long = new_register(T_LONG);
1458   __ convert(Bytecodes::_i2l, header_size, header_size_long);
1459   __ add(length, header_size_long, length);
1460   if (round_mask != 0) {
1461     __ logical_and(length, LIR_OprFact::longConst(~round_mask), length);
1462   }
1463   __ move(length, result_reg);
1464 #else
1465   __ add(length_int, header_size, length_int);
1466   if (round_mask != 0) {
1467     __ logical_and(length_int, LIR_OprFact::intConst(~round_mask), length_int);
1468   }
1469   __ convert(Bytecodes::_i2l, length_int, result_reg);
1470 #endif
1471 
1472   __ branch_destination(L_done->label());
1473 }
1474 
1475 void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) {
1476   assert(x->number_of_arguments() == 1, "wrong type");
1477   LIRItem receiver(x->argument_at(0), this);
1478 
1479   receiver.load_item();
1480   BasicTypeList signature;
1481   signature.append(T_OBJECT); // receiver
1482   LIR_OprList* args = new LIR_OprList();
1483   args->append(receiver.result());
1484   CodeEmitInfo* info = state_for(x, x->state());
1485   call_runtime(&signature, args,
1486                CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::register_finalizer_id)),
1487                voidType, info);
1488 
1489   set_no_result(x);
1490 }
1491 
1492 
1493 //------------------------local access--------------------------------------


3179     do_getEventWriter(x);
3180     break;
3181   case vmIntrinsics::_counterTime:
3182     do_RuntimeCall(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), x);
3183     break;
3184 #endif
3185 
3186   case vmIntrinsics::_currentTimeMillis:
3187     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
3188     break;
3189 
3190   case vmIntrinsics::_nanoTime:
3191     do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
3192     break;
3193 
3194   case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
3195   case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
3196   case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
3197   case vmIntrinsics::_getClass:       do_getClass(x);      break;
3198   case vmIntrinsics::_currentThread:  do_currentThread(x); break;
3199   case vmIntrinsics::_addressOf:      do_addressOf(x);     break;
3200   case vmIntrinsics::_sizeOf:         do_sizeOf(x);        break;
3201   case vmIntrinsics::_getReferencedObjects: do_getReferencedObjects(x); break;
3202 
3203   case vmIntrinsics::_dlog:           // fall through
3204   case vmIntrinsics::_dlog10:         // fall through
3205   case vmIntrinsics::_dabs:           // fall through
3206   case vmIntrinsics::_dsqrt:          // fall through
3207   case vmIntrinsics::_dtan:           // fall through
3208   case vmIntrinsics::_dsin :          // fall through
3209   case vmIntrinsics::_dcos :          // fall through
3210   case vmIntrinsics::_dexp :          // fall through
3211   case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
3212   case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
3213 
3214   case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
3215   case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
3216 
3217   // java.nio.Buffer.checkIndex
3218   case vmIntrinsics::_checkIndex:     do_NIOCheckIndex(x); break;
3219 
3220   case vmIntrinsics::_compareAndSetReference:
3221     do_CompareAndSwap(x, objectType);


< prev index next >