1
1
/*
2
- * Copyright (c) 2016, 2023 , Oracle and/or its affiliates. All rights reserved.
3
- * Copyright (c) 2016, 2023 SAP SE. All rights reserved.
2
+ * Copyright (c) 2016, 2024 , Oracle and/or its affiliates. All rights reserved.
3
+ * Copyright (c) 2016, 2024 SAP SE. All rights reserved.
4
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
5
*
6
6
* This code is free software; you can redistribute it and/or modify it
@@ -2480,23 +2480,30 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L
2480
2480
assert_different_registers (obj, k_RInfo, klass_RInfo);
2481
2481
2482
2482
if (op->should_profile ()) {
2483
+ Register mdo = klass_RInfo;
2484
+ metadata2reg (md->constant_encoding (), mdo);
2483
2485
NearLabel not_null;
2484
2486
__ compareU64_and_branch (obj, (intptr_t ) 0 , Assembler::bcondNotEqual, not_null);
2485
2487
// Object is null; update MDO and exit.
2486
- Register mdo = klass_RInfo;
2487
- metadata2reg (md->constant_encoding (), mdo);
2488
2488
Address data_addr (mdo, md->byte_offset_of_slot (data, DataLayout::header_offset ()));
2489
2489
int header_bits = DataLayout::flag_mask_to_header_mask (BitData::null_seen_byte_constant ());
2490
2490
__ or2mem_8 (data_addr, header_bits);
2491
2491
__ branch_optimized (Assembler::bcondAlways, *obj_is_null);
2492
2492
__ bind (not_null);
2493
+
2494
+ NearLabel update_done;
2495
+ Register recv = k_RInfo;
2496
+ __ load_klass (recv, obj);
2497
+ type_profile_helper (mdo, md, data, recv, Rtmp1, &update_done);
2498
+ Address counter_addr (mdo, md->byte_offset_of_slot (data, CounterData::count_offset ()));
2499
+ __ add2mem_64 (counter_addr, DataLayout::counter_increment, Rtmp1);
2500
+ __ bind (update_done);
2493
2501
} else {
2494
2502
__ compareU64_and_branch (obj, (intptr_t ) 0 , Assembler::bcondEqual, *obj_is_null);
2495
2503
}
2496
2504
2497
- NearLabel profile_cast_failure, profile_cast_success;
2498
- Label *failure_target = op->should_profile () ? &profile_cast_failure : failure;
2499
- Label *success_target = op->should_profile () ? &profile_cast_success : success;
2505
+ Label *failure_target = failure;
2506
+ Label *success_target = success;
2500
2507
2501
2508
// Patching may screw with our temporaries,
2502
2509
// so let's do it before loading the class.
@@ -2536,28 +2543,12 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L
2536
2543
store_parameter (klass_RInfo, 0 ); // sub
2537
2544
store_parameter (k_RInfo, 1 ); // super
2538
2545
emit_call_c (a); // Sets condition code 0 for match (2 otherwise).
2539
- CHECK_BAILOUT2 (profile_cast_failure, profile_cast_success);
2540
2546
__ branch_optimized (Assembler::bcondNotEqual, *failure_target);
2541
2547
// Fall through to success case.
2542
2548
}
2543
2549
}
2544
2550
2545
- if (op->should_profile ()) {
2546
- Register mdo = klass_RInfo, recv = k_RInfo;
2547
- assert_different_registers (obj, mdo, recv);
2548
- __ bind (profile_cast_success);
2549
- metadata2reg (md->constant_encoding (), mdo);
2550
- __ load_klass (recv, obj);
2551
- type_profile_helper (mdo, md, data, recv, Rtmp1, success);
2552
- __ branch_optimized (Assembler::bcondAlways, *success);
2553
-
2554
- __ bind (profile_cast_failure);
2555
- metadata2reg (md->constant_encoding (), mdo);
2556
- __ add2mem_64 (Address (mdo, md->byte_offset_of_slot (data, CounterData::count_offset ())), -(int )DataLayout::counter_increment, Rtmp1);
2557
- __ branch_optimized (Assembler::bcondAlways, *failure);
2558
- } else {
2559
- __ branch_optimized (Assembler::bcondAlways, *success);
2560
- }
2551
+ __ branch_optimized (Assembler::bcondAlways, *success);
2561
2552
}
2562
2553
2563
2554
void LIR_Assembler::emit_opTypeCheck (LIR_OpTypeCheck* op) {
@@ -2587,21 +2578,29 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
2587
2578
assert (data != nullptr , " need data for type check" );
2588
2579
assert (data->is_ReceiverTypeData (), " need ReceiverTypeData for type check" );
2589
2580
}
2590
- NearLabel profile_cast_success, profile_cast_failure, done;
2591
- Label *success_target = op-> should_profile () ? &profile_cast_success : &done;
2592
- Label *failure_target = op-> should_profile () ? &profile_cast_failure : stub->entry ();
2581
+ NearLabel done;
2582
+ Label *success_target = &done;
2583
+ Label *failure_target = stub->entry ();
2593
2584
2594
2585
if (op->should_profile ()) {
2586
+ Register mdo = klass_RInfo;
2587
+ metadata2reg (md->constant_encoding (), mdo);
2595
2588
NearLabel not_null;
2596
2589
__ compareU64_and_branch (value, (intptr_t ) 0 , Assembler::bcondNotEqual, not_null);
2597
2590
// Object is null; update MDO and exit.
2598
- Register mdo = klass_RInfo;
2599
- metadata2reg (md->constant_encoding (), mdo);
2600
2591
Address data_addr (mdo, md->byte_offset_of_slot (data, DataLayout::header_offset ()));
2601
2592
int header_bits = DataLayout::flag_mask_to_header_mask (BitData::null_seen_byte_constant ());
2602
2593
__ or2mem_8 (data_addr, header_bits);
2603
2594
__ branch_optimized (Assembler::bcondAlways, done);
2604
2595
__ bind (not_null);
2596
+
2597
+ NearLabel update_done;
2598
+ Register recv = k_RInfo;
2599
+ __ load_klass (recv, value);
2600
+ type_profile_helper (mdo, md, data, recv, Rtmp1, &update_done);
2601
+ Address counter_addr (mdo, md->byte_offset_of_slot (data, CounterData::count_offset ()));
2602
+ __ add2mem_64 (counter_addr, DataLayout::counter_increment, Rtmp1);
2603
+ __ bind (update_done);
2605
2604
} else {
2606
2605
__ compareU64_and_branch (value, (intptr_t ) 0 , Assembler::bcondEqual, done);
2607
2606
}
@@ -2619,25 +2618,9 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
2619
2618
store_parameter (klass_RInfo, 0 ); // sub
2620
2619
store_parameter (k_RInfo, 1 ); // super
2621
2620
emit_call_c (a); // Sets condition code 0 for match (2 otherwise).
2622
- CHECK_BAILOUT3 (profile_cast_success, profile_cast_failure, done);
2623
2621
__ branch_optimized (Assembler::bcondNotEqual, *failure_target);
2624
2622
// Fall through to success case.
2625
2623
2626
- if (op->should_profile ()) {
2627
- Register mdo = klass_RInfo, recv = k_RInfo;
2628
- assert_different_registers (value, mdo, recv);
2629
- __ bind (profile_cast_success);
2630
- metadata2reg (md->constant_encoding (), mdo);
2631
- __ load_klass (recv, value);
2632
- type_profile_helper (mdo, md, data, recv, Rtmp1, &done);
2633
- __ branch_optimized (Assembler::bcondAlways, done);
2634
-
2635
- __ bind (profile_cast_failure);
2636
- metadata2reg (md->constant_encoding (), mdo);
2637
- __ add2mem_64 (Address (mdo, md->byte_offset_of_slot (data, CounterData::count_offset ())), -(int )DataLayout::counter_increment, Rtmp1);
2638
- __ branch_optimized (Assembler::bcondAlways, *stub->entry ());
2639
- }
2640
-
2641
2624
__ bind (done);
2642
2625
} else {
2643
2626
if (code == lir_checkcast) {
0 commit comments