11/*
2- * Copyright (c) 2018, 2025 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2018, 2026 , Oracle and/or its affiliates. All rights reserved.
33 * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
44 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55 *
4141
4242static int slow_path_size (nmethod* nm) {
4343 // The slow path code is out of line with C2.
44- // Leave a jal to the stub in the fast path.
45- return nm->is_compiled_by_c2 () ? 1 : 8 ;
44+ return nm->is_compiled_by_c2 () ? 0 : 4 ;
4645}
4746
4847static int entry_barrier_offset (nmethod* nm) {
4948 BarrierSetAssembler* bs_asm = BarrierSet::barrier_set ()->barrier_set_assembler ();
5049 switch (bs_asm->nmethod_patching_type ()) {
5150 case NMethodPatchingType::stw_instruction_and_data_patch:
52- return -4 * (4 + slow_path_size (nm));
51+ return -4 * (5 + slow_path_size (nm));
5352 case NMethodPatchingType::conc_instruction_and_data_patch:
54- return -4 * (15 + slow_path_size (nm));
53+ return -4 * ((UseZtso ? 14 : 16 ) + slow_path_size (nm));
5554 }
5655 ShouldNotReachHere ();
5756 return 0 ;
@@ -103,6 +102,10 @@ class NativeNMethodBarrier {
103102 }
104103 _guard_addr = reinterpret_cast <int *>(instruction_address () + local_guard_offset (nm));
105104 }
105+
106+ // Perform the checking as verification.
107+ err_msg msg (" %s" , " " );
108+ assert (check_barrier (msg), " %s" , msg.buffer ());
106109 }
107110
108111 int get_value () {
@@ -114,10 +117,6 @@ class NativeNMethodBarrier {
114117 }
115118
116119 bool check_barrier (err_msg& msg) const ;
117- void verify () const {
118- err_msg msg (" %s" , " " );
119- assert (check_barrier (msg), " %s" , msg.buffer ());
120- }
121120};
122121
123122// Store the instruction bitmask, bits and name for checking the barrier.
@@ -128,8 +127,8 @@ struct CheckInsn {
128127};
129128
130129static const struct CheckInsn barrierInsn[] = {
131- { 0x00000fff , 0x00000297 , " auipc t0, 0 " },
132- { 0x000fffff , 0x0002e283 , " lwu t0, guard_offset(t0) " },
130+ { 0x00000fff , 0x00000297 , " auipc t0, 0 " },
131+ { 0x000fffff , 0x0002e283 , " lwu t0, guard_offset(t0)" },
133132 /* ...... */
134133 /* ...... */
135134 /* guard: */
@@ -141,10 +140,11 @@ static const struct CheckInsn barrierInsn[] = {
141140// register numbers and immediate values in the encoding.
142141bool NativeNMethodBarrier::check_barrier (err_msg& msg) const {
143142 address addr = instruction_address ();
144- for (unsigned int i = 0 ; i < sizeof (barrierInsn)/ sizeof (struct CheckInsn ); i++ ) {
143+ for (unsigned int i = 0 ; i < sizeof (barrierInsn) / sizeof (struct CheckInsn ); i++) {
145144 uint32_t inst = Assembler::ld_instr (addr);
146145 if ((inst & barrierInsn[i].mask ) != barrierInsn[i].bits ) {
147- msg.print (" Addr: " INTPTR_FORMAT " Code: 0x%x not an %s instruction" , p2i (addr), inst, barrierInsn[i].name );
146+ msg.print (" Nmethod entry barrier did not start with auipc & lwu as expected. "
147+ " Addr: " INTPTR_FORMAT " Code: 0x%x not an %s instruction." , p2i (addr), inst, barrierInsn[i].name );
148148 return false ;
149149 }
150150 addr += 4 ;
0 commit comments