1326 } else if (obj == klass_RInfo) {
1327 klass_RInfo = dst;
1328 }
1329 if (k->is_loaded() && !UseCompressedClassPointers) {
1330 select_different_registers(obj, dst, k_RInfo, klass_RInfo);
1331 } else {
1332 Rtmp1 = op->tmp3()->as_register();
1333 select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1);
1334 }
1335
1336 assert_different_registers(obj, k_RInfo, klass_RInfo);
1337
1338 if (should_profile) {
1339 Label not_null;
1340 __ cbnz(obj, not_null);
1341 // Object is null; update MDO and exit
1342 Register mdo = klass_RInfo;
1343 __ mov_metadata(mdo, md->constant_encoding());
1344 Address data_addr
1345 = __ form_address(rscratch2, mdo,
1346 md->byte_offset_of_slot(data, DataLayout::DataLayout::header_offset()),
1347 LogBytesPerWord);
1348 int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
1349 __ ldr(rscratch1, data_addr);
1350 __ orr(rscratch1, rscratch1, header_bits);
1351 __ str(rscratch1, data_addr);
1352 __ b(*obj_is_null);
1353 __ bind(not_null);
1354 } else {
1355 __ cbz(obj, *obj_is_null);
1356 }
1357
1358 if (!k->is_loaded()) {
1359 klass2reg_with_patching(k_RInfo, op->info_for_patch());
1360 } else {
1361 __ mov_metadata(k_RInfo, k->constant_encoding());
1362 }
1363 __ verify_oop(obj);
1364
1365 if (op->fast_check()) {
1366 // get object class
1367 // not a safepoint as obj null check happens earlier
1368 __ load_klass(rscratch1, obj);
1369 __ cmp( rscratch1, k_RInfo);
1370
1371 __ br(Assembler::NE, *failure_target);
1404 __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize)));
1405 // result is a boolean
1406 __ cbz(k_RInfo, *failure_target);
1407 // successful cast, fall through to profile or jump
1408 }
1409 }
1410 if (should_profile) {
1411 Register mdo = klass_RInfo, recv = k_RInfo;
1412 __ bind(profile_cast_success);
1413 __ mov_metadata(mdo, md->constant_encoding());
1414 __ load_klass(recv, obj);
1415 Label update_done;
1416 type_profile_helper(mdo, md, data, recv, success);
1417 __ b(*success);
1418
1419 __ bind(profile_cast_failure);
1420 __ mov_metadata(mdo, md->constant_encoding());
1421 Address counter_addr
1422 = __ form_address(rscratch2, mdo,
1423 md->byte_offset_of_slot(data, CounterData::count_offset()),
1424 LogBytesPerWord);
1425 __ ldr(rscratch1, counter_addr);
1426 __ sub(rscratch1, rscratch1, DataLayout::counter_increment);
1427 __ str(rscratch1, counter_addr);
1428 __ b(*failure);
1429 }
1430 __ b(*success);
1431 }
1432
1433
1434 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
1435 const bool should_profile = op->should_profile();
1436
1437 LIR_Code code = op->code();
1438 if (code == lir_store_check) {
1439 Register value = op->object()->as_register();
1440 Register array = op->array()->as_register();
1441 Register k_RInfo = op->tmp1()->as_register();
1442 Register klass_RInfo = op->tmp2()->as_register();
1443 Register Rtmp1 = op->tmp3()->as_register();
1444
1453 assert(method != NULL, "Should have method");
1454 int bci = op->profiled_bci();
1455 md = method->method_data_or_null();
1456 assert(md != NULL, "Sanity");
1457 data = md->bci_to_data(bci);
1458 assert(data != NULL, "need data for type check");
1459 assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
1460 }
1461 Label profile_cast_success, profile_cast_failure, done;
1462 Label *success_target = should_profile ? &profile_cast_success : &done;
1463 Label *failure_target = should_profile ? &profile_cast_failure : stub->entry();
1464
1465 if (should_profile) {
1466 Label not_null;
1467 __ cbnz(value, not_null);
1468 // Object is null; update MDO and exit
1469 Register mdo = klass_RInfo;
1470 __ mov_metadata(mdo, md->constant_encoding());
1471 Address data_addr
1472 = __ form_address(rscratch2, mdo,
1473 md->byte_offset_of_slot(data, DataLayout::header_offset()),
1474 LogBytesPerInt);
1475 int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
1476 __ ldrw(rscratch1, data_addr);
1477 __ orrw(rscratch1, rscratch1, header_bits);
1478 __ strw(rscratch1, data_addr);
1479 __ b(done);
1480 __ bind(not_null);
1481 } else {
1482 __ cbz(value, done);
1483 }
1484
1485 add_debug_info_for_null_check_here(op->info_for_exception());
1486 __ load_klass(k_RInfo, array);
1487 __ load_klass(klass_RInfo, value);
1488
1489 // get instance klass (it's already uncompressed)
1490 __ ldr(k_RInfo, Address(k_RInfo, ObjArrayKlass::element_klass_offset()));
1491 // perform the fast part of the checking logic
1492 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
1493 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
1494 __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize)));
1495 __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1496 __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize)));
1497 // result is a boolean
1498 __ cbzw(k_RInfo, *failure_target);
|
1326 } else if (obj == klass_RInfo) {
1327 klass_RInfo = dst;
1328 }
1329 if (k->is_loaded() && !UseCompressedClassPointers) {
1330 select_different_registers(obj, dst, k_RInfo, klass_RInfo);
1331 } else {
1332 Rtmp1 = op->tmp3()->as_register();
1333 select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1);
1334 }
1335
1336 assert_different_registers(obj, k_RInfo, klass_RInfo);
1337
1338 if (should_profile) {
1339 Label not_null;
1340 __ cbnz(obj, not_null);
1341 // Object is null; update MDO and exit
1342 Register mdo = klass_RInfo;
1343 __ mov_metadata(mdo, md->constant_encoding());
1344 Address data_addr
1345 = __ form_address(rscratch2, mdo,
1346 md->byte_offset_of_slot(data, DataLayout::flags_offset()),
1347 0);
1348 __ ldrb(rscratch1, data_addr);
1349 __ orr(rscratch1, rscratch1, BitData::null_seen_byte_constant());
1350 __ strb(rscratch1, data_addr);
1351 __ b(*obj_is_null);
1352 __ bind(not_null);
1353 } else {
1354 __ cbz(obj, *obj_is_null);
1355 }
1356
1357 if (!k->is_loaded()) {
1358 klass2reg_with_patching(k_RInfo, op->info_for_patch());
1359 } else {
1360 __ mov_metadata(k_RInfo, k->constant_encoding());
1361 }
1362 __ verify_oop(obj);
1363
1364 if (op->fast_check()) {
1365 // get object class
1366 // not a safepoint as obj null check happens earlier
1367 __ load_klass(rscratch1, obj);
1368 __ cmp( rscratch1, k_RInfo);
1369
1370 __ br(Assembler::NE, *failure_target);
1403 __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize)));
1404 // result is a boolean
1405 __ cbz(k_RInfo, *failure_target);
1406 // successful cast, fall through to profile or jump
1407 }
1408 }
1409 if (should_profile) {
1410 Register mdo = klass_RInfo, recv = k_RInfo;
1411 __ bind(profile_cast_success);
1412 __ mov_metadata(mdo, md->constant_encoding());
1413 __ load_klass(recv, obj);
1414 Label update_done;
1415 type_profile_helper(mdo, md, data, recv, success);
1416 __ b(*success);
1417
1418 __ bind(profile_cast_failure);
1419 __ mov_metadata(mdo, md->constant_encoding());
1420 Address counter_addr
1421 = __ form_address(rscratch2, mdo,
1422 md->byte_offset_of_slot(data, CounterData::count_offset()),
1423 0);
1424 __ ldr(rscratch1, counter_addr);
1425 __ sub(rscratch1, rscratch1, DataLayout::counter_increment);
1426 __ str(rscratch1, counter_addr);
1427 __ b(*failure);
1428 }
1429 __ b(*success);
1430 }
1431
1432
1433 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
1434 const bool should_profile = op->should_profile();
1435
1436 LIR_Code code = op->code();
1437 if (code == lir_store_check) {
1438 Register value = op->object()->as_register();
1439 Register array = op->array()->as_register();
1440 Register k_RInfo = op->tmp1()->as_register();
1441 Register klass_RInfo = op->tmp2()->as_register();
1442 Register Rtmp1 = op->tmp3()->as_register();
1443
1452 assert(method != NULL, "Should have method");
1453 int bci = op->profiled_bci();
1454 md = method->method_data_or_null();
1455 assert(md != NULL, "Sanity");
1456 data = md->bci_to_data(bci);
1457 assert(data != NULL, "need data for type check");
1458 assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
1459 }
1460 Label profile_cast_success, profile_cast_failure, done;
1461 Label *success_target = should_profile ? &profile_cast_success : &done;
1462 Label *failure_target = should_profile ? &profile_cast_failure : stub->entry();
1463
1464 if (should_profile) {
1465 Label not_null;
1466 __ cbnz(value, not_null);
1467 // Object is null; update MDO and exit
1468 Register mdo = klass_RInfo;
1469 __ mov_metadata(mdo, md->constant_encoding());
1470 Address data_addr
1471 = __ form_address(rscratch2, mdo,
1472 md->byte_offset_of_slot(data, DataLayout::flags_offset()),
1473 LogBytesPerInt);
1474 __ ldrb(rscratch1, data_addr);
1475 __ orr(rscratch1, rscratch1, BitData::null_seen_byte_constant());
1476 __ strb(rscratch1, data_addr);
1477 __ b(done);
1478 __ bind(not_null);
1479 } else {
1480 __ cbz(value, done);
1481 }
1482
1483 add_debug_info_for_null_check_here(op->info_for_exception());
1484 __ load_klass(k_RInfo, array);
1485 __ load_klass(klass_RInfo, value);
1486
1487 // get instance klass (it's already uncompressed)
1488 __ ldr(k_RInfo, Address(k_RInfo, ObjArrayKlass::element_klass_offset()));
1489 // perform the fast part of the checking logic
1490 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
1491 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
1492 __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize)));
1493 __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1494 __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize)));
1495 // result is a boolean
1496 __ cbzw(k_RInfo, *failure_target);
|