src/share/vm/c1/c1_LIRGenerator.cpp

Print this page




1292   LIR_Opr thrd = getThreadPointer();
1293   LIR_Address* mark_active_flag_addr =
1294     new LIR_Address(thrd,
1295                     in_bytes(JavaThread::satb_mark_queue_offset() +
1296                              PtrQueue::byte_offset_of_active()),
1297                     flag_type);
1298   // Read the marking-in-progress flag.
1299   LIR_Opr flag_val = new_register(T_INT);
1300   __ load(mark_active_flag_addr, flag_val);
1301 
1302   LabelObj* start_store = new LabelObj();
1303 
1304   LIR_PatchCode pre_val_patch_code =
1305     patch ? lir_patch_normal : lir_patch_none;
1306 
1307   LIR_Opr pre_val = new_register(T_OBJECT);
1308 
1309   __ cmp(lir_cond_notEqual, flag_val, LIR_OprFact::intConst(0));
1310   if (!addr_opr->is_address()) {
1311     assert(addr_opr->is_register(), "must be");
1312     addr_opr = LIR_OprFact::address(new LIR_Address(addr_opr, 0, T_OBJECT));
1313   }
1314   CodeStub* slow = new G1PreBarrierStub(addr_opr, pre_val, pre_val_patch_code,
1315                                         info);
1316   __ branch(lir_cond_notEqual, T_INT, slow);
1317   __ branch_destination(slow->continuation());
1318 }
1319 
1320 void LIRGenerator::G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
1321   if (G1DisablePostBarrier) return;
1322 
1323   // If the "new_val" is a constant NULL, no barrier is necessary.
1324   if (new_val->is_constant() &&
1325       new_val->as_constant_ptr()->as_jobject() == NULL) return;
1326 
1327   if (!new_val->is_register()) {
1328     LIR_Opr new_val_reg = new_pointer_register();
1329     if (new_val->is_constant()) {
1330       __ move(new_val, new_val_reg);
1331     } else {
1332       __ leal(new_val, new_val_reg);
1333     }
1334     new_val = new_val_reg;
1335   }
1336   assert(new_val->is_register(), "must be a register at this point");
1337 
1338   if (addr->is_address()) {
1339     LIR_Address* address = addr->as_address_ptr();
1340     LIR_Opr ptr = new_pointer_register();
1341     if (!address->index()->is_valid() && address->disp() == 0) {
1342       __ move(address->base(), ptr);
1343     } else {
1344       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
1345       __ leal(addr, ptr);
1346     }
1347     addr = ptr;
1348   }
1349   assert(addr->is_register(), "must be a register at this point");
1350 
1351   LIR_Opr xor_res = new_pointer_register();
1352   LIR_Opr xor_shift_res = new_pointer_register();
1353 
1354   if (TwoOperandLIRForm ) {
1355     __ move(addr, xor_res);
1356     __ logical_xor(xor_res, new_val, xor_res);
1357     __ move(xor_res, xor_shift_res);
1358     __ unsigned_shift_right(xor_shift_res,
1359                             LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes),
1360                             xor_shift_res,
1361                             LIR_OprDesc::illegalOpr());
1362   } else {
1363     __ logical_xor(addr, new_val, xor_res);
1364     __ unsigned_shift_right(xor_res,
1365                             LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes),
1366                             xor_shift_res,
1367                             LIR_OprDesc::illegalOpr());
1368   }
1369 
1370   if (!new_val->is_register()) {
1371     LIR_Opr new_val_reg = new_pointer_register();
1372     __ leal(new_val, new_val_reg);
1373     new_val = new_val_reg;
1374   }
1375   assert(new_val->is_register(), "must be a register at this point");
1376 
1377   __ cmp(lir_cond_notEqual, xor_shift_res, LIR_OprFact::intptrConst(NULL_WORD));
1378 
1379   CodeStub* slow = new G1PostBarrierStub(addr, new_val);
1380   __ branch(lir_cond_notEqual, T_INT, slow);
1381   __ branch_destination(slow->continuation());
1382 }
1383 
1384 #endif // SERIALGC
1385 ////////////////////////////////////////////////////////////////////////
1386 
1387 void LIRGenerator::CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
1388 
1389   assert(sizeof(*((CardTableModRefBS*)_bs)->byte_map_base) == sizeof(jbyte), "adjust this code");
1390   LIR_Const* card_table_base = new LIR_Const(((CardTableModRefBS*)_bs)->byte_map_base);
1391   if (addr->is_address()) {
1392     LIR_Address* address = addr->as_address_ptr();
1393     LIR_Opr ptr = new_register(T_OBJECT);
1394     if (!address->index()->is_valid() && address->disp() == 0) {
1395       __ move(address->base(), ptr);
1396     } else {
1397       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
1398       __ leal(addr, ptr);
1399     }
1400     addr = ptr;




1292   LIR_Opr thrd = getThreadPointer();
1293   LIR_Address* mark_active_flag_addr =
1294     new LIR_Address(thrd,
1295                     in_bytes(JavaThread::satb_mark_queue_offset() +
1296                              PtrQueue::byte_offset_of_active()),
1297                     flag_type);
1298   // Read the marking-in-progress flag.
1299   LIR_Opr flag_val = new_register(T_INT);
1300   __ load(mark_active_flag_addr, flag_val);
1301 
1302   LabelObj* start_store = new LabelObj();
1303 
1304   LIR_PatchCode pre_val_patch_code =
1305     patch ? lir_patch_normal : lir_patch_none;
1306 
1307   LIR_Opr pre_val = new_register(T_OBJECT);
1308 
1309   __ cmp(lir_cond_notEqual, flag_val, LIR_OprFact::intConst(0));
1310   if (!addr_opr->is_address()) {
1311     assert(addr_opr->is_register(), "must be");
1312     addr_opr = LIR_OprFact::address(new LIR_Address(addr_opr, (intx)0, T_OBJECT));
1313   }
1314   CodeStub* slow = new G1PreBarrierStub(addr_opr, pre_val, pre_val_patch_code,
1315                                         info);
1316   __ branch(lir_cond_notEqual, T_INT, slow);
1317   __ branch_destination(slow->continuation());
1318 }
1319 
1320 void LIRGenerator::G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
1321   if (G1DisablePostBarrier) return;
1322 
1323   // If the "new_val" is a constant NULL, no barrier is necessary.
1324   if (new_val->is_constant() &&
1325       new_val->as_constant_ptr()->as_jobject() == NULL) return;
1326 
1327   if (!new_val->is_register()) {
1328     LIR_Opr new_val_reg = new_register(T_OBJECT);
1329     if (new_val->is_constant()) {
1330       __ move(new_val, new_val_reg);
1331     } else {
1332       __ leal(new_val, new_val_reg);
1333     }
1334     new_val = new_val_reg;
1335   }
1336   assert(new_val->is_register(), "must be a register at this point");
1337 
1338   if (addr->is_address()) {
1339     LIR_Address* address = addr->as_address_ptr();
1340     LIR_Opr ptr = new_register(T_OBJECT);
1341     if (!address->index()->is_valid() && address->disp() == 0) {
1342       __ move(address->base(), ptr);
1343     } else {
1344       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
1345       __ leal(addr, ptr);
1346     }
1347     addr = ptr;
1348   }
1349   assert(addr->is_register(), "must be a register at this point");
1350 
1351   LIR_Opr xor_res = new_pointer_register();
1352   LIR_Opr xor_shift_res = new_pointer_register();

1353   if (TwoOperandLIRForm ) {
1354     __ move(addr, xor_res);
1355     __ logical_xor(xor_res, new_val, xor_res);
1356     __ move(xor_res, xor_shift_res);
1357     __ unsigned_shift_right(xor_shift_res,
1358                             LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes),
1359                             xor_shift_res,
1360                             LIR_OprDesc::illegalOpr());
1361   } else {
1362     __ logical_xor(addr, new_val, xor_res);
1363     __ unsigned_shift_right(xor_res,
1364                             LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes),
1365                             xor_shift_res,
1366                             LIR_OprDesc::illegalOpr());
1367   }
1368 
1369   if (!new_val->is_register()) {
1370     LIR_Opr new_val_reg = new_register(T_OBJECT);
1371     __ leal(new_val, new_val_reg);
1372     new_val = new_val_reg;
1373   }
1374   assert(new_val->is_register(), "must be a register at this point");
1375 
1376   __ cmp(lir_cond_notEqual, xor_shift_res, LIR_OprFact::intptrConst(NULL_WORD));
1377 
1378   CodeStub* slow = new G1PostBarrierStub(addr, new_val);
1379   __ branch(lir_cond_notEqual, LP64_ONLY(T_LONG) NOT_LP64(T_INT), slow);
1380   __ branch_destination(slow->continuation());
1381 }
1382 
1383 #endif // SERIALGC
1384 ////////////////////////////////////////////////////////////////////////
1385 
1386 void LIRGenerator::CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
1387 
1388   assert(sizeof(*((CardTableModRefBS*)_bs)->byte_map_base) == sizeof(jbyte), "adjust this code");
1389   LIR_Const* card_table_base = new LIR_Const(((CardTableModRefBS*)_bs)->byte_map_base);
1390   if (addr->is_address()) {
1391     LIR_Address* address = addr->as_address_ptr();
1392     LIR_Opr ptr = new_register(T_OBJECT);
1393     if (!address->index()->is_valid() && address->disp() == 0) {
1394       __ move(address->base(), ptr);
1395     } else {
1396       assert(address->disp() != max_jint, "lea doesn't support patched addresses!");
1397       __ leal(addr, ptr);
1398     }
1399     addr = ptr;