< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page

 619     default: ShouldNotReachHere();
 620   }
 621 }
 622 
 623 
 624 void LIRGenerator::monitor_enter(LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info) {
 625   if (!GenerateSynchronizationCode) return;
 626   // for slow path, use debug info for state after successful locking
 627   CodeStub* slow_path = new MonitorEnterStub(object, lock, info);
 628   __ load_stack_address_monitor(monitor_no, lock);
 629   // for handling NullPointerException, use debug info representing just the lock stack before this monitorenter
 630   __ lock_object(hdr, object, lock, scratch, slow_path, info_for_exception);
 631 }
 632 
 633 
 634 void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, LIR_Opr scratch, int monitor_no) {
 635   if (!GenerateSynchronizationCode) return;
 636   // setup registers
 637   LIR_Opr hdr = lock;
 638   lock = new_hdr;
 639   CodeStub* slow_path = new MonitorExitStub(lock, UseFastLocking, monitor_no);
 640   __ load_stack_address_monitor(monitor_no, lock);
 641   __ unlock_object(hdr, object, lock, scratch, slow_path);
 642 }
 643 
 644 #ifndef PRODUCT
 645 void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) {
 646   if (PrintNotLoaded && !new_instance->klass()->is_loaded()) {
 647     tty->print_cr("   ###class not loaded at new bci %d", new_instance->printable_bci());
 648   } else if (PrintNotLoaded && (!CompilerConfig::is_c1_only_no_jvmci() && new_instance->is_unresolved())) {
 649     tty->print_cr("   ###class not resolved at new bci %d", new_instance->printable_bci());
 650   }
 651 }
 652 #endif
 653 
 654 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) {
 655   klass2reg_with_patching(klass_reg, klass, info, is_unresolved);
 656   // If klass is not loaded we do not know if the klass has finalizers:
 657   if (UseFastNewInstance && klass->is_loaded()
 658       && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) {
 659 

1238 
1239   LIRItem clazz(x->argument_at(0), this);
1240   LIRItem object(x->argument_at(1), this);
1241   clazz.load_item();
1242   object.load_item();
1243   LIR_Opr result = rlock_result(x);
1244 
1245   // need to perform null check on clazz
1246   if (x->needs_null_check()) {
1247     CodeEmitInfo* info = state_for(x);
1248     __ null_check(clazz.result(), info);
1249   }
1250 
1251   LIR_Opr call_result = call_runtime(clazz.value(), object.value(),
1252                                      CAST_FROM_FN_PTR(address, Runtime1::is_instance_of),
1253                                      x->type(),
1254                                      NULL); // NULL CodeEmitInfo results in a leaf call
1255   __ move(call_result, result);
1256 }
1257 





1258 // Example: object.getClass ()
1259 void LIRGenerator::do_getClass(Intrinsic* x) {
1260   assert(x->number_of_arguments() == 1, "wrong type");
1261 
1262   LIRItem rcvr(x->argument_at(0), this);
1263   rcvr.load_item();
1264   LIR_Opr temp = new_register(T_METADATA);
1265   LIR_Opr result = rlock_result(x);
1266 
1267   // need to perform the null check on the rcvr
1268   CodeEmitInfo* info = NULL;
1269   if (x->needs_null_check()) {
1270     info = state_for(x);
1271   }
1272 
1273   // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
1274   // meaning of these two is mixed up (see JDK-8026837).
1275   __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), temp, info);
1276   __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_ADDRESS), temp);
1277   // mirror = ((OopHandle)mirror)->resolve();
1278   access_load(IN_NATIVE, T_OBJECT,
1279               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), result);
1280 }
1281 
1282 // java.lang.Class::isPrimitive()
1283 void LIRGenerator::do_isPrimitive(Intrinsic* x) {
1284   assert(x->number_of_arguments() == 1, "wrong type");
1285 
1286   LIRItem rcvr(x->argument_at(0), this);
1287   rcvr.load_item();
1288   LIR_Opr temp = new_register(T_METADATA);
1289   LIR_Opr result = rlock_result(x);
1290 
1291   CodeEmitInfo* info = NULL;
1292   if (x->needs_null_check()) {
1293     info = state_for(x);
1294   }
1295 
1296   __ move(new LIR_Address(rcvr.result(), java_lang_Class::klass_offset(), T_ADDRESS), temp, info);

1336 
1337 // Example: Thread.currentThread()
1338 void LIRGenerator::do_currentThread(Intrinsic* x) {
1339   assert(x->number_of_arguments() == 0, "wrong type");
1340   LIR_Opr temp = new_register(T_ADDRESS);
1341   LIR_Opr reg = rlock_result(x);
1342   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_ADDRESS), temp);
1343   // threadObj = ((OopHandle)_threadObj)->resolve();
1344   access_load(IN_NATIVE, T_OBJECT,
1345               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1346 }
1347 
1348 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1349   assert(x->number_of_arguments() == 3, "wrong type");
1350   LIR_Opr result_reg = rlock_result(x);
1351 
1352   LIRItem value(x->argument_at(2), this);
1353   value.load_item();
1354 
1355   LIR_Opr klass = new_register(T_METADATA);
1356   __ move(new LIR_Address(value.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, NULL);
1357   LIR_Opr layout = new_register(T_INT);
1358   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
1359 
1360   LabelObj* L_done = new LabelObj();
1361   LabelObj* L_array = new LabelObj();
1362 
1363   __ cmp(lir_cond_lessEqual, layout, 0);
1364   __ branch(lir_cond_lessEqual, L_array->label());
1365 
1366   // Instance case: the layout helper gives us instance size almost directly,
1367   // but we need to mask out the _lh_instance_slow_path_bit.
1368   __ convert(Bytecodes::_i2l, layout, result_reg);
1369 
1370   assert((int) Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit");
1371   jlong mask = ~(jlong) right_n_bits(LogBytesPerLong);
1372   __ logical_and(result_reg, LIR_OprFact::longConst(mask), result_reg);
1373 
1374   __ branch(lir_cond_always, L_done->label());
1375 
1376   // Array case: size is round(header + element_size*arraylength).

3727   case lir_membar_acquire   : __ membar_acquire(); break;
3728   case lir_membar_release   : __ membar_release(); break;
3729   case lir_membar           : __ membar(); break;
3730   case lir_membar_loadload  : __ membar_loadload(); break;
3731   case lir_membar_storestore: __ membar_storestore(); break;
3732   case lir_membar_loadstore : __ membar_loadstore(); break;
3733   case lir_membar_storeload : __ membar_storeload(); break;
3734   default                   : ShouldNotReachHere(); break;
3735   }
3736 }
3737 
3738 LIR_Opr LIRGenerator::mask_boolean(LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
3739   LIR_Opr value_fixed = rlock_byte(T_BYTE);
3740   if (TwoOperandLIRForm) {
3741     __ move(value, value_fixed);
3742     __ logical_and(value_fixed, LIR_OprFact::intConst(1), value_fixed);
3743   } else {
3744     __ logical_and(value, LIR_OprFact::intConst(1), value_fixed);
3745   }
3746   LIR_Opr klass = new_register(T_METADATA);
3747   __ move(new LIR_Address(array, oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, null_check_info);
3748   null_check_info = NULL;
3749   LIR_Opr layout = new_register(T_INT);
3750   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
3751   int diffbit = Klass::layout_helper_boolean_diffbit();
3752   __ logical_and(layout, LIR_OprFact::intConst(diffbit), layout);
3753   __ cmp(lir_cond_notEqual, layout, LIR_OprFact::intConst(0));
3754   __ cmove(lir_cond_notEqual, value_fixed, value, value_fixed, T_BYTE);
3755   value = value_fixed;
3756   return value;
3757 }
3758 
3759 LIR_Opr LIRGenerator::maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
3760   if (x->check_boolean()) {
3761     value = mask_boolean(array, value, null_check_info);
3762   }
3763   return value;
3764 }

 619     default: ShouldNotReachHere();
 620   }
 621 }
 622 
 623 
 624 void LIRGenerator::monitor_enter(LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info) {
 625   if (!GenerateSynchronizationCode) return;
 626   // for slow path, use debug info for state after successful locking
 627   CodeStub* slow_path = new MonitorEnterStub(object, lock, info);
 628   __ load_stack_address_monitor(monitor_no, lock);
 629   // for handling NullPointerException, use debug info representing just the lock stack before this monitorenter
 630   __ lock_object(hdr, object, lock, scratch, slow_path, info_for_exception);
 631 }
 632 
 633 
 634 void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, LIR_Opr scratch, int monitor_no) {
 635   if (!GenerateSynchronizationCode) return;
 636   // setup registers
 637   LIR_Opr hdr = lock;
 638   lock = new_hdr;
 639   CodeStub* slow_path = new MonitorExitStub(lock, LockingMode != LM_MONITOR, monitor_no);
 640   __ load_stack_address_monitor(monitor_no, lock);
 641   __ unlock_object(hdr, object, lock, scratch, slow_path);
 642 }
 643 
 644 #ifndef PRODUCT
 645 void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) {
 646   if (PrintNotLoaded && !new_instance->klass()->is_loaded()) {
 647     tty->print_cr("   ###class not loaded at new bci %d", new_instance->printable_bci());
 648   } else if (PrintNotLoaded && (!CompilerConfig::is_c1_only_no_jvmci() && new_instance->is_unresolved())) {
 649     tty->print_cr("   ###class not resolved at new bci %d", new_instance->printable_bci());
 650   }
 651 }
 652 #endif
 653 
 654 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) {
 655   klass2reg_with_patching(klass_reg, klass, info, is_unresolved);
 656   // If klass is not loaded we do not know if the klass has finalizers:
 657   if (UseFastNewInstance && klass->is_loaded()
 658       && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) {
 659 

1238 
1239   LIRItem clazz(x->argument_at(0), this);
1240   LIRItem object(x->argument_at(1), this);
1241   clazz.load_item();
1242   object.load_item();
1243   LIR_Opr result = rlock_result(x);
1244 
1245   // need to perform null check on clazz
1246   if (x->needs_null_check()) {
1247     CodeEmitInfo* info = state_for(x);
1248     __ null_check(clazz.result(), info);
1249   }
1250 
1251   LIR_Opr call_result = call_runtime(clazz.value(), object.value(),
1252                                      CAST_FROM_FN_PTR(address, Runtime1::is_instance_of),
1253                                      x->type(),
1254                                      NULL); // NULL CodeEmitInfo results in a leaf call
1255   __ move(call_result, result);
1256 }
1257 
1258 void LIRGenerator::load_klass(LIR_Opr obj, LIR_Opr klass, CodeEmitInfo* null_check_info) {
1259   CodeStub* slow_path = UseCompactObjectHeaders ? new LoadKlassStub(klass) : NULL;
1260   __ load_klass(obj, klass, null_check_info, slow_path);
1261 }
1262 
1263 // Example: object.getClass ()
1264 void LIRGenerator::do_getClass(Intrinsic* x) {
1265   assert(x->number_of_arguments() == 1, "wrong type");
1266 
1267   LIRItem rcvr(x->argument_at(0), this);
1268   rcvr.load_item();
1269   LIR_Opr temp = new_register(T_ADDRESS);
1270   LIR_Opr result = rlock_result(x);
1271 
1272   // need to perform the null check on the rcvr
1273   CodeEmitInfo* info = NULL;
1274   if (x->needs_null_check()) {
1275     info = state_for(x);
1276   }
1277 
1278   LIR_Opr klass = new_register(T_METADATA);
1279   load_klass(rcvr.result(), klass, info);
1280   __ move_wide(new LIR_Address(klass, in_bytes(Klass::java_mirror_offset()), T_ADDRESS), temp);

1281   // mirror = ((OopHandle)mirror)->resolve();
1282   access_load(IN_NATIVE, T_OBJECT,
1283               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), result);
1284 }
1285 
1286 // java.lang.Class::isPrimitive()
1287 void LIRGenerator::do_isPrimitive(Intrinsic* x) {
1288   assert(x->number_of_arguments() == 1, "wrong type");
1289 
1290   LIRItem rcvr(x->argument_at(0), this);
1291   rcvr.load_item();
1292   LIR_Opr temp = new_register(T_METADATA);
1293   LIR_Opr result = rlock_result(x);
1294 
1295   CodeEmitInfo* info = NULL;
1296   if (x->needs_null_check()) {
1297     info = state_for(x);
1298   }
1299 
1300   __ move(new LIR_Address(rcvr.result(), java_lang_Class::klass_offset(), T_ADDRESS), temp, info);

1340 
1341 // Example: Thread.currentThread()
1342 void LIRGenerator::do_currentThread(Intrinsic* x) {
1343   assert(x->number_of_arguments() == 0, "wrong type");
1344   LIR_Opr temp = new_register(T_ADDRESS);
1345   LIR_Opr reg = rlock_result(x);
1346   __ move(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_ADDRESS), temp);
1347   // threadObj = ((OopHandle)_threadObj)->resolve();
1348   access_load(IN_NATIVE, T_OBJECT,
1349               LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), reg);
1350 }
1351 
1352 void LIRGenerator::do_getObjectSize(Intrinsic* x) {
1353   assert(x->number_of_arguments() == 3, "wrong type");
1354   LIR_Opr result_reg = rlock_result(x);
1355 
1356   LIRItem value(x->argument_at(2), this);
1357   value.load_item();
1358 
1359   LIR_Opr klass = new_register(T_METADATA);
1360   load_klass(value.result(), klass, NULL);
1361   LIR_Opr layout = new_register(T_INT);
1362   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
1363 
1364   LabelObj* L_done = new LabelObj();
1365   LabelObj* L_array = new LabelObj();
1366 
1367   __ cmp(lir_cond_lessEqual, layout, 0);
1368   __ branch(lir_cond_lessEqual, L_array->label());
1369 
1370   // Instance case: the layout helper gives us instance size almost directly,
1371   // but we need to mask out the _lh_instance_slow_path_bit.
1372   __ convert(Bytecodes::_i2l, layout, result_reg);
1373 
1374   assert((int) Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit");
1375   jlong mask = ~(jlong) right_n_bits(LogBytesPerLong);
1376   __ logical_and(result_reg, LIR_OprFact::longConst(mask), result_reg);
1377 
1378   __ branch(lir_cond_always, L_done->label());
1379 
1380   // Array case: size is round(header + element_size*arraylength).

3731   case lir_membar_acquire   : __ membar_acquire(); break;
3732   case lir_membar_release   : __ membar_release(); break;
3733   case lir_membar           : __ membar(); break;
3734   case lir_membar_loadload  : __ membar_loadload(); break;
3735   case lir_membar_storestore: __ membar_storestore(); break;
3736   case lir_membar_loadstore : __ membar_loadstore(); break;
3737   case lir_membar_storeload : __ membar_storeload(); break;
3738   default                   : ShouldNotReachHere(); break;
3739   }
3740 }
3741 
3742 LIR_Opr LIRGenerator::mask_boolean(LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
3743   LIR_Opr value_fixed = rlock_byte(T_BYTE);
3744   if (TwoOperandLIRForm) {
3745     __ move(value, value_fixed);
3746     __ logical_and(value_fixed, LIR_OprFact::intConst(1), value_fixed);
3747   } else {
3748     __ logical_and(value, LIR_OprFact::intConst(1), value_fixed);
3749   }
3750   LIR_Opr klass = new_register(T_METADATA);
3751   load_klass(array, klass, null_check_info);
3752   null_check_info = NULL;
3753   LIR_Opr layout = new_register(T_INT);
3754   __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
3755   int diffbit = Klass::layout_helper_boolean_diffbit();
3756   __ logical_and(layout, LIR_OprFact::intConst(diffbit), layout);
3757   __ cmp(lir_cond_notEqual, layout, LIR_OprFact::intConst(0));
3758   __ cmove(lir_cond_notEqual, value_fixed, value, value_fixed, T_BYTE);
3759   value = value_fixed;
3760   return value;
3761 }
3762 
3763 LIR_Opr LIRGenerator::maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
3764   if (x->check_boolean()) {
3765     value = mask_boolean(array, value, null_check_info);
3766   }
3767   return value;
3768 }
< prev index next >