diff --git a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp index 017e86a9dc30f..836caa86cb0af 100644 --- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -503,7 +503,7 @@ void InterpreterMacroAssembler::remove_activation( // get method access flags ldr(r1, Address(rfp, frame::interpreter_frame_method_offset * wordSize)); - ldrh(r2, Address(r1, Method::access_flags_offset())); + ldr(r2, Address(r1, Method::access_flags_offset())); tbz(r2, exact_log2(JVM_ACC_SYNCHRONIZED), unlocked); // Don't unlock anything if the _do_not_unlock_if_synchronized flag diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 6010ddd25fe33..fa48092fd505a 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -760,7 +760,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm Label L_skip_barrier; { // Bypass the barrier for non-static methods - __ ldrh(rscratch1, Address(rmethod, Method::access_flags_offset())); + __ ldrw(rscratch1, Address(rmethod, Method::access_flags_offset())); __ andsw(zr, rscratch1, JVM_ACC_STATIC); __ br(Assembler::EQ, L_skip_barrier); // non-static } diff --git a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp index 0a3240fa56efc..f70450b722223 100644 --- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -809,7 +809,7 @@ void TemplateInterpreterGenerator::lock_method() { #ifdef ASSERT { Label L; - __ ldrh(r0, access_flags); + __ ldrw(r0, access_flags); __ tst(r0, JVM_ACC_SYNCHRONIZED); __ br(Assembler::NE, L); __ stop("method doesn't need synchronization"); @@ -820,7 +820,7 @@ void TemplateInterpreterGenerator::lock_method() { // get synchronization object { Label done; - __ ldrh(r0, access_flags); + __ ldrw(r0, access_flags); __ tst(r0, JVM_ACC_STATIC); // get receiver (assume this is frequent case) __ ldr(r0, Address(rlocals, Interpreter::local_offset_in_bytes(0))); @@ -1225,7 +1225,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // make sure method is native & not abstract #ifdef ASSERT - __ ldrh(r0, access_flags); + __ ldrw(r0, access_flags); { Label L; __ tst(r0, JVM_ACC_NATIVE); @@ -1277,7 +1277,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { #ifdef ASSERT { Label L; - __ ldrh(r0, access_flags); + __ ldrw(r0, access_flags); __ tst(r0, JVM_ACC_SYNCHRONIZED); __ br(Assembler::EQ, L); __ stop("method needs synchronization"); @@ -1354,7 +1354,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // pass mirror handle if static call { Label L; - __ ldrh(t, Address(rmethod, Method::access_flags_offset())); + __ ldrw(t, Address(rmethod, Method::access_flags_offset())); __ tbz(t, exact_log2(JVM_ACC_STATIC), L); // get mirror __ load_mirror(t, rmethod, r10, rscratch2); @@ -1564,7 +1564,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // do unlocking if necessary { Label L; - __ ldrh(t, Address(rmethod, Method::access_flags_offset())); + __ ldrw(t, Address(rmethod, Method::access_flags_offset())); __ tbz(t, exact_log2(JVM_ACC_SYNCHRONIZED), L); // the code below should be shared with interpreter macro // assembler implementation @@ -1695,7 +1695,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { // make sure method is not native & not abstract #ifdef ASSERT - __ ldrh(r0, access_flags); + __ ldrw(r0, access_flags); { Label L; __ tst(r0, JVM_ACC_NATIVE); @@ -1751,7 +1751,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { #ifdef ASSERT { Label L; - __ ldrh(r0, access_flags); + __ ldrw(r0, access_flags); __ tst(r0, JVM_ACC_SYNCHRONIZED); __ br(Assembler::EQ, L); __ stop("method needs synchronization"); diff --git a/src/hotspot/cpu/arm/interp_masm_arm.cpp b/src/hotspot/cpu/arm/interp_masm_arm.cpp index b70a4b495b2cc..3a81fdddb3c32 100644 --- a/src/hotspot/cpu/arm/interp_masm_arm.cpp +++ b/src/hotspot/cpu/arm/interp_masm_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -736,7 +736,7 @@ void InterpreterMacroAssembler::remove_activation(TosState state, Register ret_a ldrb(Rflag, do_not_unlock_if_synchronized); // get method access flags - ldrh(Raccess_flags, Address(Rmethod, Method::access_flags_offset())); + ldr_u32(Raccess_flags, Address(Rmethod, Method::access_flags_offset())); strb(zero_register(Rtemp), do_not_unlock_if_synchronized); // reset the flag diff --git a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp index d84ae9d14d67a..9df7a455eeb84 100644 --- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -579,7 +579,7 @@ void TemplateInterpreterGenerator::lock_method() { #ifdef ASSERT { Label L; - __ ldrh(Rtemp, Address(Rmethod, Method::access_flags_offset())); + __ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); __ tbnz(Rtemp, JVM_ACC_SYNCHRONIZED_BIT, L); __ stop("method doesn't need synchronization"); __ bind(L); @@ -588,7 +588,7 @@ void TemplateInterpreterGenerator::lock_method() { // get synchronization object { Label done; - __ ldrh(Rtemp, Address(Rmethod, Method::access_flags_offset())); + __ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); __ tst(Rtemp, JVM_ACC_STATIC); __ ldr(R0, Address(Rlocals, Interpreter::local_offset_in_bytes(0)), eq); // get receiver (assume this is frequent case) __ b(done, eq); @@ -851,7 +851,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // make sure method is native & not abstract #ifdef ASSERT - __ ldrh(Rtemp, Address(Rmethod, Method::access_flags_offset())); + __ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); { Label L; __ tbnz(Rtemp, JVM_ACC_NATIVE_BIT, L); @@ -893,7 +893,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // no synchronization necessary #ifdef ASSERT { Label L; - __ ldrh(Rtemp, Address(Rmethod, Method::access_flags_offset())); + __ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); __ tbz(Rtemp, JVM_ACC_SYNCHRONIZED_BIT, L); __ stop("method needs synchronization"); __ bind(L); @@ -975,7 +975,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // Pass JNIEnv and mirror for static methods { Label L; - __ ldrh(Rtemp, Address(Rmethod, Method::access_flags_offset())); + __ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); __ add(R0, Rthread, in_bytes(JavaThread::jni_environment_offset())); __ tbz(Rtemp, JVM_ACC_STATIC_BIT, L); __ load_mirror(Rtemp, Rmethod, Rtemp); @@ -1204,7 +1204,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { // make sure method is not native & not abstract #ifdef ASSERT - __ ldrh(Rtemp, Address(Rmethod, Method::access_flags_offset())); + __ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); { Label L; __ tbz(Rtemp, JVM_ACC_NATIVE_BIT, L); @@ -1249,7 +1249,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { // no synchronization necessary #ifdef ASSERT { Label L; - __ ldrh(Rtemp, Address(Rmethod, Method::access_flags_offset())); + __ ldr_u32(Rtemp, Address(Rmethod, Method::access_flags_offset())); __ tbz(Rtemp, JVM_ACC_SYNCHRONIZED_BIT, L); __ stop("method needs synchronization"); __ bind(L); diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index e097adb1dbfc6..67b9bdc04142f 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -681,14 +681,14 @@ void InterpreterMacroAssembler::unlock_if_synchronized_method(TosState state, // Check if synchronized method or unlocking prevented by // JavaThread::do_not_unlock_if_synchronized flag. lbz(Rdo_not_unlock_flag, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread); - lhz(Raccess_flags, in_bytes(Method::access_flags_offset()), R19_method); + lwz(Raccess_flags, in_bytes(Method::access_flags_offset()), R19_method); li(R0, 0); stb(R0, in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()), R16_thread); // reset flag push(state); // Skip if we don't have to unlock. - testbitdi(CCR0, R0, Raccess_flags, JVM_ACC_SYNCHRONIZED_BIT); + rldicl_(R0, Raccess_flags, 64-JVM_ACC_SYNCHRONIZED_BIT, 63); // Extract bit and compare to 0. beq(CCR0, Lunlocked); cmpwi(CCR0, Rdo_not_unlock_flag, 0); diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp index bad1a037b9a20..c2e4c2e9b55c9 100644 --- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp +++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1202,7 +1202,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm Label L_skip_barrier; { // Bypass the barrier for non-static methods - __ lhz(R0, in_bytes(Method::access_flags_offset()), R19_method); + __ lwz(R0, in_bytes(Method::access_flags_offset()), R19_method); __ andi_(R0, R0, JVM_ACC_STATIC); __ beq(CCR0, L_skip_barrier); // non-static } diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp index ec372bfb07d9d..9147dfc1677ab 100644 --- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -144,9 +144,9 @@ address TemplateInterpreterGenerator::generate_slow_signature_handler() { // TODO PPC port: requires change in shared code. //assert(in_bytes(AccessFlags::flags_offset()) == 0, // "MethodDesc._access_flags == MethodDesc._access_flags._flags"); - // _access_flags must be a 16 bit value. - assert(sizeof(AccessFlags) == 2, "wrong size"); - __ lhz(R11_scratch1/*access_flags*/, method_(access_flags)); + // _access_flags must be a 32 bit value. + assert(sizeof(AccessFlags) == 4, "wrong size"); + __ lwa(R11_scratch1/*access_flags*/, method_(access_flags)); // testbit with condition register. __ testbitdi(CCR0, R0, R11_scratch1/*access_flags*/, JVM_ACC_STATIC_BIT); __ btrue(CCR0, L); @@ -823,7 +823,7 @@ void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratc { if (!flags_preloaded) { - __ lhz(Rflags, method_(access_flags)); + __ lwz(Rflags, method_(access_flags)); } #ifdef ASSERT @@ -1301,8 +1301,8 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { assert(__ nonvolatile_accross_vthread_preemtion(access_flags), "access_flags not preserved"); // Type check. - assert(2 == sizeof(AccessFlags), "unexpected field size"); - __ lhz(access_flags, method_(access_flags)); + assert(4 == sizeof(AccessFlags), "unexpected field size"); + __ lwz(access_flags, method_(access_flags)); // We don't want to reload R19_method and access_flags after calls // to some helper functions. @@ -1769,7 +1769,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { #ifdef ASSERT else { Label Lok; - __ lhz(R0, in_bytes(Method::access_flags_offset()), R19_method); + __ lwz(R0, in_bytes(Method::access_flags_offset()), R19_method); __ andi_(R0, R0, JVM_ACC_SYNCHRONIZED); __ asm_assert_eq("method needs synchronization"); __ bind(Lok); diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp index 70fec29d4f7e7..e17a3765b50ec 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -544,7 +544,7 @@ void InterpreterMacroAssembler::remove_activation( // get method access flags ld(x11, Address(fp, frame::interpreter_frame_method_offset * wordSize)); - load_unsigned_short(x12, Address(x11, Method::access_flags_offset())); + ld(x12, Address(x11, Method::access_flags_offset())); test_bit(t0, x12, exact_log2(JVM_ACC_SYNCHRONIZED)); beqz(t0, unlocked); diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp index 12e38d97b1342..9af1b6a9bb128 100644 --- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp +++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -641,7 +641,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm Label L_skip_barrier; { // Bypass the barrier for non-static methods - __ load_unsigned_short(t0, Address(xmethod, Method::access_flags_offset())); + __ lwu(t0, Address(xmethod, Method::access_flags_offset())); __ test_bit(t1, t0, exact_log2(JVM_ACC_STATIC)); __ beqz(t1, L_skip_barrier); // non-static } diff --git a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp index a2187b35bd5b1..5ea9077a2b72a 100644 --- a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -714,14 +714,14 @@ void TemplateInterpreterGenerator::lock_method() { const int entry_size = frame::interpreter_frame_monitor_size_in_bytes(); #ifdef ASSERT - __ load_unsigned_short(x10, access_flags); + __ lwu(x10, access_flags); __ verify_access_flags(x10, JVM_ACC_SYNCHRONIZED, "method doesn't need synchronization", false); #endif // ASSERT // get synchronization object { Label done; - __ load_unsigned_short(x10, access_flags); + __ lwu(x10, access_flags); __ andi(t0, x10, JVM_ACC_STATIC); // get receiver (assume this is frequent case) __ ld(x10, Address(xlocals, Interpreter::local_offset_in_bytes(0))); @@ -1028,7 +1028,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // make sure method is native & not abstract #ifdef ASSERT - __ load_unsigned_short(x10, access_flags); + __ lwu(x10, access_flags); __ verify_access_flags(x10, JVM_ACC_NATIVE, "tried to execute non-native method as native", false); __ verify_access_flags(x10, JVM_ACC_ABSTRACT, "tried to execute abstract method in interpreter"); #endif @@ -1066,7 +1066,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { } else { // no synchronization necessary #ifdef ASSERT - __ load_unsigned_short(x10, access_flags); + __ lwu(x10, access_flags); __ verify_access_flags(x10, JVM_ACC_SYNCHRONIZED, "method needs synchronization"); #endif } @@ -1130,7 +1130,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // pass mirror handle if static call { Label L; - __ load_unsigned_short(t, Address(xmethod, Method::access_flags_offset())); + __ lwu(t, Address(xmethod, Method::access_flags_offset())); __ test_bit(t0, t, exact_log2(JVM_ACC_STATIC)); __ beqz(t0, L); // get mirror @@ -1346,7 +1346,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // do unlocking if necessary { Label L; - __ load_unsigned_short(t, Address(xmethod, Method::access_flags_offset())); + __ lwu(t, Address(xmethod, Method::access_flags_offset())); __ test_bit(t0, t, exact_log2(JVM_ACC_SYNCHRONIZED)); __ beqz(t0, L); // the code below should be shared with interpreter macro @@ -1472,7 +1472,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { // make sure method is not native & not abstract #ifdef ASSERT - __ load_unsigned_short(x10, access_flags); + __ lwu(x10, access_flags); __ verify_access_flags(x10, JVM_ACC_NATIVE, "tried to execute native method as non-native"); __ verify_access_flags(x10, JVM_ACC_ABSTRACT, "tried to execute abstract method in interpreter"); #endif @@ -1519,7 +1519,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { } else { // no synchronization necessary #ifdef ASSERT - __ load_unsigned_short(x10, access_flags); + __ lwu(x10, access_flags); __ verify_access_flags(x10, JVM_ACC_SYNCHRONIZED, "method needs synchronization"); #endif } diff --git a/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/hotspot/cpu/s390/interp_masm_s390.cpp index 0e31dbd33e198..5e80817aaba7b 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -780,7 +780,7 @@ void InterpreterMacroAssembler::unlock_if_synchronized_method(TosState state, get_method(R_method); verify_oop(Z_tos, state); push(state); // Save tos/result. - testbit_ushort(method2_(R_method, access_flags), JVM_ACC_SYNCHRONIZED_BIT); + testbit(method2_(R_method, access_flags), JVM_ACC_SYNCHRONIZED_BIT); z_bfalse(unlocked); // Don't unlock anything if the _do_not_unlock_if_synchronized flag diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index 3647aca0008b8..a069d6ceafbf0 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * Copyright 2024 IBM Corporation. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -1015,18 +1015,6 @@ void MacroAssembler::load_and_test_long(Register dst, const Address &a) { z_ltg(dst, a); } -// Test a bit in memory for 2 byte datatype. -void MacroAssembler::testbit_ushort(const Address &a, unsigned int bit) { - assert(a.index() == noreg, "no index reg allowed in testbit"); - if (bit <= 7) { - z_tm(a.disp() + 1, a.base(), 1 << bit); - } else if (bit <= 15) { - z_tm(a.disp() + 0, a.base(), 1 << (bit - 8)); - } else { - ShouldNotReachHere(); - } -} - // Test a bit in memory. void MacroAssembler::testbit(const Address &a, unsigned int bit) { assert(a.index() == noreg, "no index reg allowed in testbit"); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index d45f1321e0f28..159688128189a 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * Copyright (c) 2024 IBM Corporation. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -199,7 +199,6 @@ class MacroAssembler: public Assembler { // Test a bit in memory. Result is reflected in CC. void testbit(const Address &a, unsigned int bit); - void testbit_ushort(const Address &a, unsigned int bit); // Test a bit in a register. Result is reflected in CC. void testbit(Register r, unsigned int bitPos); diff --git a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp index 62f5c8fa524b4..2396a2a71059f 100644 --- a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp +++ b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -2395,7 +2395,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm Label L_skip_barrier; { // Bypass the barrier for non-static methods - __ testbit_ushort(Address(Z_method, Method::access_flags_offset()), JVM_ACC_STATIC_BIT); + __ testbit(Address(Z_method, Method::access_flags_offset()), JVM_ACC_STATIC_BIT); __ z_bfalse(L_skip_barrier); // non-static } diff --git a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp index 99179bcad0611..1c4089d5beb07 100644 --- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -164,7 +164,7 @@ address TemplateInterpreterGenerator::generate_slow_signature_handler() { // Therefore add 3 to address that byte within "_flags". // Reload method. VM call above may have destroyed register contents __ get_method(method); - __ testbit_ushort(method2_(method, access_flags), JVM_ACC_STATIC_BIT); + __ testbit(method2_(method, access_flags), JVM_ACC_STATIC_BIT); method = noreg; // end of life __ z_btrue(isStatic); @@ -883,7 +883,7 @@ void TemplateInterpreterGenerator::lock_method(void) { address reentry = nullptr; { Label L; - __ testbit_ushort(method2_(method, access_flags), JVM_ACC_SYNCHRONIZED_BIT); + __ testbit(method2_(method, access_flags), JVM_ACC_SYNCHRONIZED_BIT); __ z_btrue(L); reentry = __ stop_chain_static(reentry, "method doesn't need synchronization"); __ bind(L); @@ -897,7 +897,7 @@ void TemplateInterpreterGenerator::lock_method(void) { Label done; Label static_method; - __ testbit_ushort(method2_(method, access_flags), JVM_ACC_STATIC_BIT); + __ testbit(method2_(method, access_flags), JVM_ACC_STATIC_BIT); __ z_btrue(static_method); // non-static method: Load receiver obj from stack. @@ -1349,17 +1349,15 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // Make sure method is native and not abstract. #ifdef ASSERT - // _access_flags must be a 16 bit value. - assert(sizeof(AccessFlags) == 2, "testbit_ushort will fail"); address reentry = nullptr; { Label L; - __ testbit_ushort(method_(access_flags), JVM_ACC_NATIVE_BIT); + __ testbit(method_(access_flags), JVM_ACC_NATIVE_BIT); __ z_btrue(L); reentry = __ stop_chain_static(reentry, "tried to execute non-native method as native"); __ bind(L); } { Label L; - __ testbit_ushort(method_(access_flags), JVM_ACC_ABSTRACT_BIT); + __ testbit(method_(access_flags), JVM_ACC_ABSTRACT_BIT); __ z_bfalse(L); reentry = __ stop_chain_static(reentry, "tried to execute abstract method as non-abstract"); __ bind(L); @@ -1405,7 +1403,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { #ifdef ASSERT { Label L; __ get_method(Z_R1_scratch); - __ testbit_ushort(method2_(Z_R1_scratch, access_flags), JVM_ACC_SYNCHRONIZED_BIT); + __ testbit(method2_(Z_R1_scratch, access_flags), JVM_ACC_SYNCHRONIZED_BIT); __ z_bfalse(L); reentry = __ stop_chain_static(reentry, "method needs synchronization"); __ bind(L); @@ -1463,7 +1461,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // Pass mirror handle if static call. { Label method_is_not_static; - __ testbit_ushort(method2_(Rmethod, access_flags), JVM_ACC_STATIC_BIT); + __ testbit(method2_(Rmethod, access_flags), JVM_ACC_STATIC_BIT); __ z_bfalse(method_is_not_static); // Load mirror from interpreter frame. __ z_lg(Z_R1, _z_ijava_state_neg(mirror), Z_fp); @@ -1721,13 +1719,13 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { #ifdef ASSERT address reentry = nullptr; { Label L; - __ testbit_ushort(method_(access_flags), JVM_ACC_NATIVE_BIT); + __ testbit(method_(access_flags), JVM_ACC_NATIVE_BIT); __ z_bfalse(L); reentry = __ stop_chain_static(reentry, "tried to execute native method as non-native"); __ bind(L); } { Label L; - __ testbit_ushort(method_(access_flags), JVM_ACC_ABSTRACT_BIT); + __ testbit(method_(access_flags), JVM_ACC_ABSTRACT_BIT); __ z_bfalse(L); reentry = __ stop_chain_static(reentry, "tried to execute abstract method as non-abstract"); __ bind(L); @@ -1777,7 +1775,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { #ifdef ASSERT { Label L; __ get_method(Z_R1_scratch); - __ testbit_ushort(method2_(Z_R1_scratch, access_flags), JVM_ACC_SYNCHRONIZED_BIT); + __ testbit(method2_(Z_R1_scratch, access_flags), JVM_ACC_SYNCHRONIZED_BIT); __ z_bfalse(L); reentry = __ stop_chain_static(reentry, "method needs synchronization"); __ bind(L); diff --git a/src/hotspot/cpu/x86/interp_masm_x86.cpp b/src/hotspot/cpu/x86/interp_masm_x86.cpp index ff5b1c1454dfc..3a3f01a640983 100644 --- a/src/hotspot/cpu/x86/interp_masm_x86.cpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1030,7 +1030,7 @@ void InterpreterMacroAssembler::remove_activation( // get method access flags movptr(rcx, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); - load_unsigned_short(rcx, Address(rcx, Method::access_flags_offset())); + movl(rcx, Address(rcx, Method::access_flags_offset())); testl(rcx, JVM_ACC_SYNCHRONIZED); jcc(Assembler::zero, unlocked); diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp index b9901a1e95bf7..ab7cbb9437453 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1099,7 +1099,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm { // Bypass the barrier for non-static methods Register flags = rscratch1; - __ load_unsigned_short(flags, Address(method, Method::access_flags_offset())); + __ movl(flags, Address(method, Method::access_flags_offset())); __ testl(flags, JVM_ACC_STATIC); __ jcc(Assembler::zero, L_skip_barrier); // non-static } diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp index b4e005faff3b9..823b965a09b51 100644 --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -596,7 +596,7 @@ void TemplateInterpreterGenerator::lock_method() { #ifdef ASSERT { Label L; - __ load_unsigned_short(rax, access_flags); + __ movl(rax, access_flags); __ testl(rax, JVM_ACC_SYNCHRONIZED); __ jcc(Assembler::notZero, L); __ stop("method doesn't need synchronization"); @@ -607,7 +607,7 @@ void TemplateInterpreterGenerator::lock_method() { // get synchronization object { Label done; - __ load_unsigned_short(rax, access_flags); + __ movl(rax, access_flags); __ testl(rax, JVM_ACC_STATIC); // get receiver (assume this is frequent case) __ movptr(rax, Address(rlocals, Interpreter::local_offset_in_bytes(0))); @@ -855,7 +855,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // make sure method is native & not abstract #ifdef ASSERT - __ load_unsigned_short(rax, access_flags); + __ movl(rax, access_flags); { Label L; __ testl(rax, JVM_ACC_NATIVE); @@ -909,7 +909,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { #ifdef ASSERT { Label L; - __ load_unsigned_short(rax, access_flags); + __ movl(rax, access_flags); __ testl(rax, JVM_ACC_SYNCHRONIZED); __ jcc(Assembler::zero, L); __ stop("method needs synchronization"); @@ -999,7 +999,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // pass mirror handle if static call { Label L; - __ load_unsigned_short(t, Address(method, Method::access_flags_offset())); + __ movl(t, Address(method, Method::access_flags_offset())); __ testl(t, JVM_ACC_STATIC); __ jcc(Assembler::zero, L); // get mirror @@ -1280,7 +1280,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // do unlocking if necessary { Label L; - __ load_unsigned_short(t, Address(method, Method::access_flags_offset())); + __ movl(t, Address(method, Method::access_flags_offset())); __ testl(t, JVM_ACC_SYNCHRONIZED); __ jcc(Assembler::zero, L); // the code below should be shared with interpreter macro @@ -1432,7 +1432,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { // make sure method is not native & not abstract #ifdef ASSERT - __ load_unsigned_short(rax, access_flags); + __ movl(rax, access_flags); { Label L; __ testl(rax, JVM_ACC_NATIVE); @@ -1489,7 +1489,7 @@ address TemplateInterpreterGenerator::generate_normal_entry(bool synchronized) { #ifdef ASSERT { Label L; - __ load_unsigned_short(rax, access_flags); + __ movl(rax, access_flags); __ testl(rax, JVM_ACC_SYNCHRONIZED); __ jcc(Assembler::zero, L); __ stop("method needs synchronization"); diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp index b2124c6b157f4..5ea2d8eba259b 100644 --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,7 +74,7 @@ address TemplateInterpreterGenerator::generate_slow_signature_handler() { // Do Int register here switch ( i ) { case 0: - __ load_unsigned_short(rscratch1, Address(rbx, Method::access_flags_offset())); + __ movl(rscratch1, Address(rbx, Method::access_flags_offset())); __ testl(rscratch1, JVM_ACC_STATIC); __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0)); break; @@ -159,7 +159,7 @@ address TemplateInterpreterGenerator::generate_slow_signature_handler() { } // Now handle integrals. Only do c_rarg1 if not static. - __ load_unsigned_short(c_rarg3, Address(rbx, Method::access_flags_offset())); + __ movl(c_rarg3, Address(rbx, Method::access_flags_offset())); __ testl(c_rarg3, JVM_ACC_STATIC); __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0)); diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index 2df2fbf8adca9..74fdf7a5b76a3 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1337,7 +1337,7 @@ void LIRGenerator::do_getModifiers(Intrinsic* x) { __ cmove(lir_cond_equal, prim_klass, recv_klass, klass, T_ADDRESS); // Get the answer. - __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_CHAR), result); + __ move(new LIR_Address(klass, in_bytes(Klass::modifier_flags_offset()), T_INT), result); } void LIRGenerator::do_getObjectSize(Intrinsic* x) { diff --git a/src/hotspot/share/ci/ciFlags.cpp b/src/hotspot/share/ci/ciFlags.cpp index 043470a32a227..1401a432a9e18 100644 --- a/src/hotspot/share/ci/ciFlags.cpp +++ b/src/hotspot/share/ci/ciFlags.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,5 +92,5 @@ void ciFlags::print_member_flags(outputStream* st) { // ------------------------------------------------------------------ // ciFlags::print void ciFlags::print(outputStream* st) { - st->print(" flags=%x", _flags.as_unsigned_short()); + st->print(" flags=%x", _flags); } diff --git a/src/hotspot/share/ci/ciFlags.hpp b/src/hotspot/share/ci/ciFlags.hpp index 426f953611fee..dd1df622487f3 100644 --- a/src/hotspot/share/ci/ciFlags.hpp +++ b/src/hotspot/share/ci/ciFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #define SHARE_CI_CIFLAGS_HPP #include "ci/ciClassList.hpp" +#include "jvm_constants.h" #include "utilities/accessFlags.hpp" #include "utilities/ostream.hpp" @@ -38,37 +39,37 @@ class ciFlags { friend class ciField; friend class ciMethod; - AccessFlags _flags; + jint _flags; bool _stable; - bool _initialized_final_update; + bool _intialized_final_update; - ciFlags() :_flags(0), _stable(false), _initialized_final_update(false) { } + ciFlags() :_flags(0), _stable(false), _intialized_final_update(false) { } ciFlags(AccessFlags flags, bool is_stable = false, bool is_initialized_final_update = false) : - _flags(flags), _stable(is_stable), _initialized_final_update(is_initialized_final_update) { } + _flags(flags.as_int()), _stable(is_stable), _intialized_final_update(is_initialized_final_update) { } public: // Java access flags - bool is_public () const { return _flags.is_public(); } - bool is_private () const { return _flags.is_private(); } - bool is_protected () const { return _flags.is_protected(); } - bool is_static () const { return _flags.is_static(); } - bool is_final () const { return _flags.is_final(); } - bool is_synchronized () const { return _flags.is_synchronized(); } - bool is_super () const { return _flags.is_super(); } - bool is_volatile () const { return _flags.is_volatile(); } - bool is_transient () const { return _flags.is_transient(); } - bool is_native () const { return _flags.is_native(); } - bool is_interface () const { return _flags.is_interface(); } - bool is_abstract () const { return _flags.is_abstract(); } + bool is_public () const { return (_flags & JVM_ACC_PUBLIC ) != 0; } + bool is_private () const { return (_flags & JVM_ACC_PRIVATE ) != 0; } + bool is_protected () const { return (_flags & JVM_ACC_PROTECTED ) != 0; } + bool is_static () const { return (_flags & JVM_ACC_STATIC ) != 0; } + bool is_final () const { return (_flags & JVM_ACC_FINAL ) != 0; } + bool is_synchronized () const { return (_flags & JVM_ACC_SYNCHRONIZED ) != 0; } + bool is_super () const { return (_flags & JVM_ACC_SUPER ) != 0; } + bool is_volatile () const { return (_flags & JVM_ACC_VOLATILE ) != 0; } + bool is_transient () const { return (_flags & JVM_ACC_TRANSIENT ) != 0; } + bool is_native () const { return (_flags & JVM_ACC_NATIVE ) != 0; } + bool is_interface () const { return (_flags & JVM_ACC_INTERFACE ) != 0; } + bool is_abstract () const { return (_flags & JVM_ACC_ABSTRACT ) != 0; } bool is_stable () const { return _stable; } // In case the current object represents a field, return true if // the field is modified outside of instance initializer methods // (or class/initializer methods if the field is static) and false // otherwise. - bool has_initialized_final_update() const { return _initialized_final_update; }; + bool has_initialized_final_update() const { return _intialized_final_update; }; // Conversion - jint as_int() { return _flags.as_unsigned_short(); } + jint as_int() { return _flags; } void print_klass_flags(outputStream* st = tty); void print_member_flags(outputStream* st = tty); diff --git a/src/hotspot/share/ci/ciKlass.cpp b/src/hotspot/share/ci/ciKlass.cpp index e14e237167d8c..f65d4a0311c82 100644 --- a/src/hotspot/share/ci/ciKlass.cpp +++ b/src/hotspot/share/ci/ciKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -222,7 +222,7 @@ jint ciKlass::modifier_flags() { jint ciKlass::access_flags() { assert(is_loaded(), "not loaded"); GUARDED_VM_ENTRY( - return get_Klass()->access_flags().as_unsigned_short(); + return get_Klass()->access_flags().as_int(); ) } diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index c552e48c8b8e9..5c58f20000616 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2981,7 +2981,7 @@ u2 ClassFileParser::parse_classfile_inner_classes_attribute(const ClassFileStrea "Class is both outer and inner class in class file %s", CHECK_0); } // Access flags - u2 flags; + jint flags; // JVM_ACC_MODULE is defined in JDK-9 and later. if (_major_version >= JAVA_9_VERSION) { flags = cfs->get_u2_fast() & (RECOGNIZED_INNER_CLASS_MODIFIERS | JVM_ACC_MODULE); @@ -2998,7 +2998,7 @@ u2 ClassFileParser::parse_classfile_inner_classes_attribute(const ClassFileStrea inner_classes->at_put(index++, inner_class_info_index); inner_classes->at_put(index++, outer_class_info_index); inner_classes->at_put(index++, inner_name_index); - inner_classes->at_put(index++, inner_access_flags.as_unsigned_short()); + inner_classes->at_put(index++, inner_access_flags.as_short()); } // Check for circular and duplicate entries. @@ -3750,7 +3750,7 @@ void ClassFileParser::apply_parsed_class_metadata( // Initialize cached modifier_flags to support Class.getModifiers(). // This must follow setting inner_class attributes. - u2 computed_modifiers = this_klass->compute_modifier_flags(); + int computed_modifiers = this_klass->compute_modifier_flags(); this_klass->set_modifier_flags(computed_modifiers); // Delay the setting of _local_interfaces and _transitive_interfaces until after @@ -5336,7 +5336,7 @@ ClassFileParser::ClassFileParser(ClassFileStream* stream, assert(_stream != nullptr, "invariant"); assert(_stream->buffer() == _stream->current(), "invariant"); assert(_class_name != nullptr, "invariant"); - assert(0 == _access_flags.as_unsigned_short(), "invariant"); + assert(0 == _access_flags.as_int(), "invariant"); // Figure out whether we can skip format checking (matching classic VM behavior) _need_verify = Verifier::should_verify_for(_loader_data->class_loader()); @@ -5488,7 +5488,7 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, stream->guarantee_more(8, CHECK); // flags, this_class, super_class, infs_len // Access flags - u2 flags; + jint flags; // JVM_ACC_MODULE is defined in JDK-9 and later. if (_major_version >= JAVA_9_VERSION) { flags = stream->get_u2_fast() & (JVM_RECOGNIZED_CLASS_MODIFIERS | JVM_ACC_MODULE); diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 650d0a9fa744d..1aedb43973c57 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3169,7 +3169,7 @@ void java_lang_ClassFrameInfo::serialize_offsets(SerializeClosure* f) { #endif static int get_flags(const methodHandle& m) { - int flags = m->access_flags().as_method_flags(); + int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); if (m->is_object_initializer()) { flags |= java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR; } else { @@ -5537,7 +5537,7 @@ int InjectedField::compute_offset() { ik->print(); tty->print_cr("all fields:"); for (AllFieldStream fs(ik); !fs.done(); fs.next()) { - tty->print_cr(" name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_field_flags()); + tty->print_cr(" name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int()); } #endif //PRODUCT vm_exit_during_initialization("Invalid layout of well-known class: use -Xlog:class+load=info to see the origin of the problem class"); diff --git a/src/hotspot/share/classfile/vmIntrinsics.cpp b/src/hotspot/share/classfile/vmIntrinsics.cpp index 38226d232ef66..407cdafaf2017 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.cpp +++ b/src/hotspot/share/classfile/vmIntrinsics.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,31 +36,31 @@ #include "utilities/tribool.hpp" // These are flag-matching functions: -inline bool match_F_R(u2 flags) { +inline bool match_F_R(jshort flags) { const int req = 0; const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED | JVM_ACC_NATIVE; return (flags & (req | neg)) == req; } -inline bool match_F_Y(u2 flags) { +inline bool match_F_Y(jshort flags) { const int req = JVM_ACC_SYNCHRONIZED; const int neg = JVM_ACC_STATIC | JVM_ACC_NATIVE; return (flags & (req | neg)) == req; } -inline bool match_F_RN(u2 flags) { +inline bool match_F_RN(jshort flags) { const int req = JVM_ACC_NATIVE; const int neg = JVM_ACC_STATIC | JVM_ACC_SYNCHRONIZED; return (flags & (req | neg)) == req; } -inline bool match_F_S(u2 flags) { +inline bool match_F_S(jshort flags) { const int req = JVM_ACC_STATIC; const int neg = JVM_ACC_SYNCHRONIZED | JVM_ACC_NATIVE; return (flags & (req | neg)) == req; } -inline bool match_F_SN(u2 flags) { +inline bool match_F_SN(jshort flags) { const int req = JVM_ACC_STATIC | JVM_ACC_NATIVE; const int neg = JVM_ACC_SYNCHRONIZED; return (flags & (req | neg)) == req; @@ -711,7 +711,7 @@ bool vmIntrinsics::is_disabled_by_flags(vmIntrinsics::ID id) { vmIntrinsics::ID vmIntrinsics::find_id_impl(vmSymbolID holder, vmSymbolID name, vmSymbolID sig, - u2 flags) { + jshort flags) { assert((int)vmSymbolID::SID_LIMIT <= (1<is_array_klass()) { // We need to change "protected" to "public". assert(flags.is_protected(), "clone not protected?"); - u2 new_flags = flags.as_method_flags(); + jint new_flags = flags.as_int(); new_flags = new_flags & (~JVM_ACC_PROTECTED); new_flags = new_flags | JVM_ACC_PUBLIC; flags.set_flags(new_flags); diff --git a/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp b/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp index 27b01e99e5567..edb87c7fc8e41 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ const Symbol* EdgeUtils::field_name(const Edge& edge, jshort* modifiers) { JavaFieldStream jfs(ik); while (!jfs.done()) { if (offset == jfs.offset()) { - *modifiers = jfs.access_flags().as_field_flags(); + *modifiers = jfs.access_flags().as_short(); return jfs.name(); } jfs.next(); diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp index bc5f97c719af9..a53eaa474f3f0 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -227,9 +227,9 @@ static traceid method_id(KlassPtr klass, MethodPtr method) { } template -static u2 get_flags(const T* ptr) { +static s4 get_flags(const T* ptr) { assert(ptr != nullptr, "invariant"); - return ptr->access_flags().as_unsigned_short(); + return ptr->access_flags().get_flags(); } // Same as JVM_GetClassModifiers @@ -968,7 +968,7 @@ static int write_method(JfrCheckpointWriter* writer, MethodPtr method, bool leak writer->write(artifact_id(klass)); writer->write(mark_symbol(method->name(), leakp)); writer->write(mark_symbol(method->signature(), leakp)); - writer->write(get_flags(method)); + writer->write(static_cast(get_flags(method))); writer->write(get_visibility(method)); return 1; } diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index 1fa3f23173ce3..9052e6228945b 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1000,7 +1000,7 @@ C2V_VMENTRY_NULL(jobject, resolveFieldInPool, (JNIEnv* env, jobject, ARGUMENT_PA if (info.is_null() || JVMCIENV->get_length(info) != 4) { JVMCI_ERROR_NULL("info must not be null and have a length of 4"); } - JVMCIENV->put_int_at(info, 0, fd.access_flags().as_field_flags()); + JVMCIENV->put_int_at(info, 0, fd.access_flags().as_int()); JVMCIENV->put_int_at(info, 1, fd.offset()); JVMCIENV->put_int_at(info, 2, fd.index()); JVMCIENV->put_int_at(info, 3, fd.field_flags().as_uint()); diff --git a/src/hotspot/share/jvmci/jvmciEnv.cpp b/src/hotspot/share/jvmci/jvmciEnv.cpp index 1a53f6b6d2cc1..712745e2a021c 100644 --- a/src/hotspot/share/jvmci/jvmciEnv.cpp +++ b/src/hotspot/share/jvmci/jvmciEnv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1592,7 +1592,7 @@ JVMCIObject JVMCIEnv::new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS) { HotSpotJVMCI::FieldInfo::set_nameIndex(JVMCIENV, obj_h(), (jint)fieldinfo->name_index()); HotSpotJVMCI::FieldInfo::set_signatureIndex(JVMCIENV, obj_h(), (jint)fieldinfo->signature_index()); HotSpotJVMCI::FieldInfo::set_offset(JVMCIENV, obj_h(), (jint)fieldinfo->offset()); - HotSpotJVMCI::FieldInfo::set_classfileFlags(JVMCIENV, obj_h(), (jint)fieldinfo->access_flags().as_field_flags()); + HotSpotJVMCI::FieldInfo::set_classfileFlags(JVMCIENV, obj_h(), (jint)fieldinfo->access_flags().as_int()); HotSpotJVMCI::FieldInfo::set_internalFlags(JVMCIENV, obj_h(), (jint)fieldinfo->field_flags().as_uint()); HotSpotJVMCI::FieldInfo::set_initializerIndex(JVMCIENV, obj_h(), (jint)fieldinfo->initializer_index()); return wrap(obj_h()); @@ -1603,7 +1603,7 @@ JVMCIObject JVMCIEnv::new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS) { (jint)fieldinfo->name_index(), (jint)fieldinfo->signature_index(), (jint)fieldinfo->offset(), - (jint)fieldinfo->access_flags().as_field_flags(), + (jint)fieldinfo->access_flags().as_int(), (jint)fieldinfo->field_flags().as_uint(), (jint)fieldinfo->initializer_index()); diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 97447c43b6e5a..ba47e5599578f 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -273,7 +273,7 @@ nonstatic_field(Klass, _name, Symbol*) \ volatile_nonstatic_field(Klass, _next_sibling, Klass*) \ nonstatic_field(Klass, _java_mirror, OopHandle) \ - nonstatic_field(Klass, _modifier_flags, u2) \ + nonstatic_field(Klass, _modifier_flags, jint) \ nonstatic_field(Klass, _access_flags, AccessFlags) \ nonstatic_field(Klass, _class_loader_data, ClassLoaderData*) \ nonstatic_field(Klass, _secondary_supers_bitmap, uintx) \ @@ -488,6 +488,7 @@ declare_constant(InvocationEntryBci) \ declare_constant(JVMCINMethodData::SPECULATION_LENGTH_BITS) \ \ + declare_constant(JVM_ACC_WRITTEN_FLAGS) \ declare_constant(FieldInfo::FieldFlags::_ff_injected) \ declare_constant(FieldInfo::FieldFlags::_ff_stable) \ declare_preprocessor_constant("JVM_ACC_VARARGS", JVM_ACC_VARARGS) \ diff --git a/src/hotspot/share/oops/fieldInfo.cpp b/src/hotspot/share/oops/fieldInfo.cpp index 3ae91a03b6797..50a3b427d178e 100644 --- a/src/hotspot/share/oops/fieldInfo.cpp +++ b/src/hotspot/share/oops/fieldInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ void FieldInfo::print(outputStream* os, ConstantPool* cp) { name_index(), name(cp)->as_utf8(), signature_index(), signature(cp)->as_utf8(), offset(), - access_flags().as_field_flags(), + access_flags().as_int(), field_flags().as_uint(), initializer_index(), generic_signature_index(), @@ -97,7 +97,7 @@ Array* FieldInfoStream::create_FieldInfoStream(GrowableArray* fie assert(fi_ref->name_index() == fi.name_index(), "Must be"); assert(fi_ref->signature_index() == fi.signature_index(), "Must be"); assert(fi_ref->offset() == fi.offset(), "Must be"); - assert(fi_ref->access_flags().as_field_flags() == fi.access_flags().as_field_flags(), "Must be"); + assert(fi_ref->access_flags().as_int() == fi.access_flags().as_int(), "Must be"); assert(fi_ref->field_flags().as_uint() == fi.field_flags().as_uint(), " Must be"); if(fi_ref->field_flags().is_initialized()) { assert(fi_ref->initializer_index() == fi.initializer_index(), "Must be"); diff --git a/src/hotspot/share/oops/fieldInfo.inline.hpp b/src/hotspot/share/oops/fieldInfo.inline.hpp index bf37d280510f7..2e6727f1fb9f1 100644 --- a/src/hotspot/share/oops/fieldInfo.inline.hpp +++ b/src/hotspot/share/oops/fieldInfo.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ inline void Mapper::map_field_info(const FieldInfo& fi) { _consumer->accept_uint(fi.name_index()); _consumer->accept_uint(fi.signature_index()); _consumer->accept_uint(fi.offset()); - _consumer->accept_uint(fi.access_flags().as_field_flags()); + _consumer->accept_uint(fi.access_flags().as_int()); _consumer->accept_uint(fi.field_flags().as_uint()); if(fi.field_flags().has_any_optionals()) { if (fi.field_flags().is_initialized()) { diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 43b078a8af233..ce46da55f986b 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3339,8 +3339,8 @@ InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRA return outer_klass; } -u2 InstanceKlass::compute_modifier_flags() const { - u2 access = access_flags().as_unsigned_short(); +jint InstanceKlass::compute_modifier_flags() const { + jint access = access_flags().as_int(); // But check if it happens to be member class. InnerClassesIterator iter(this); @@ -3360,7 +3360,7 @@ u2 InstanceKlass::compute_modifier_flags() const { } } // Remember to strip ACC_SUPER bit - return (access & (~JVM_ACC_SUPER)); + return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS; } jint InstanceKlass::jvmti_class_status() const { diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index cedc17e9bafde..8209a692a8242 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -391,7 +391,7 @@ class InstanceKlass: public Klass { public: int field_offset (int index) const { return field(index).offset(); } - int field_access_flags(int index) const { return field(index).access_flags().as_field_flags(); } + int field_access_flags(int index) const { return field(index).access_flags().as_int(); } FieldInfo::FieldFlags field_flags(int index) const { return field(index).field_flags(); } FieldStatus field_status(int index) const { return fields_status()->at(index); } inline Symbol* field_name (int index) const; @@ -682,6 +682,8 @@ class InstanceKlass: public Klass { #if INCLUDE_JVMTI // Redefinition locking. Class can only be redefined by one thread at a time. + // The flag is in access_flags so that it can be set and reset using atomic + // operations, and not be reset by other misc_flag settings. bool is_being_redefined() const { return _misc_flags.is_being_redefined(); } void set_is_being_redefined(bool value) { _misc_flags.set_is_being_redefined(value); } @@ -1125,7 +1127,7 @@ class InstanceKlass: public Klass { void compute_has_loops_flag_for_methods(); #endif - u2 compute_modifier_flags() const; + jint compute_modifier_flags() const; public: // JVMTI support diff --git a/src/hotspot/share/oops/klass.hpp b/src/hotspot/share/oops/klass.hpp index d27665bbcc121..2c75d6da3b8cb 100644 --- a/src/hotspot/share/oops/klass.hpp +++ b/src/hotspot/share/oops/klass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,7 +66,7 @@ class Klass : public Metadata { friend class JVMCIVMStructs; public: // Klass Kinds for all subclasses of Klass - enum KlassKind : u2 { + enum KlassKind { InstanceKlassKind, InstanceRefKlassKind, InstanceMirrorKlassKind, @@ -113,20 +113,15 @@ class Klass : public Metadata { // // Final note: This comes first, immediately after C++ vtable, // because it is frequently queried. - jint _layout_helper; + jint _layout_helper; // Klass kind used to resolve the runtime type of the instance. // - Used to implement devirtualized oop closure dispatching. // - Various type checking in the JVM const KlassKind _kind; - AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here. - // Some flags created by the JVM, not in the class file itself, - // are in _misc_flags below. // Processed access flags, for use by Class.getModifiers. - u2 _modifier_flags; - - KlassFlags _misc_flags; + jint _modifier_flags; // The fields _super_check_offset, _secondary_super_cache, _secondary_supers // and _primary_supers all help make fast subtype checks. See big discussion @@ -162,12 +157,22 @@ class Klass : public Metadata { // Provide access the corresponding instance java.lang.ClassLoader. ClassLoaderData* _class_loader_data; - markWord _prototype_header; // Used to initialize objects' header - // Bitmap and hash code used by hashed secondary supers. uintx _secondary_supers_bitmap; uint8_t _hash_slot; + markWord _prototype_header; // Used to initialize objects' header + + int _vtable_len; // vtable length. This field may be read very often when we + // have lots of itable dispatches (e.g., lambdas and streams). + // Keep it away from the beginning of a Klass to avoid cacheline + // contention that may happen when a nearby object is modified. + AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here. + // Some flags created by the JVM, not in the class file itself, + // are in _misc_flags below. + + JFR_ONLY(DEFINE_TRACE_ID_FIELD;) + private: // This is an index into FileMapHeader::_shared_path_table[], to // associate this class with the JAR file where it's loaded from during @@ -195,17 +200,10 @@ class Klass : public Metadata { }; #endif - int _vtable_len; // vtable length. This field may be read very often when we - // have lots of itable dispatches (e.g., lambdas and streams). - // Keep it away from the beginning of a Klass to avoid cacheline - // contention that may happen when a nearby object is modified. + KlassFlags _misc_flags; CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;) -public: - - JFR_ONLY(DEFINE_TRACE_ID_FIELD;) - protected: Klass(KlassKind kind); @@ -294,8 +292,8 @@ class Klass : public Metadata { void clear_java_mirror_handle() { _java_mirror = OopHandle(); } // modifier flags - u2 modifier_flags() const { return _modifier_flags; } - void set_modifier_flags(u2 flags) { _modifier_flags = flags; } + jint modifier_flags() const { return _modifier_flags; } + void set_modifier_flags(jint flags) { _modifier_flags = flags; } // size helper int layout_helper() const { return _layout_helper; } @@ -758,7 +756,7 @@ class Klass : public Metadata { virtual void release_C_heap_structures(bool release_constant_pool = true); public: - virtual u2 compute_modifier_flags() const = 0; + virtual jint compute_modifier_flags() const = 0; // JVMTI support virtual jint jvmti_class_status() const; diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp index ab15379409f76..d0b29a4a30992 100644 --- a/src/hotspot/share/oops/method.cpp +++ b/src/hotspot/share/oops/method.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1652,8 +1652,8 @@ void Method::init_intrinsic_id(vmSymbolID klass_id) { && sig_id == vmSymbolID::NO_SID) { return; } + jshort flags = access_flags().as_short(); - u2 flags = access_flags().as_method_flags(); vmIntrinsics::ID id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags); if (id != vmIntrinsics::_none) { set_intrinsic_id(id); @@ -2300,7 +2300,7 @@ void Method::print_on(outputStream* st) const { st->print (" - method holder: "); method_holder()->print_value_on(st); st->cr(); st->print (" - constants: " PTR_FORMAT " ", p2i(constants())); constants()->print_value_on(st); st->cr(); - st->print (" - access: 0x%x ", access_flags().as_method_flags()); access_flags().print_on(st); st->cr(); + st->print (" - access: 0x%x ", access_flags().as_int()); access_flags().print_on(st); st->cr(); st->print (" - flags: 0x%x ", _flags.as_int()); _flags.print_on(st); st->cr(); st->print (" - name: "); name()->print_value_on(st); st->cr(); st->print (" - signature: "); signature()->print_value_on(st); st->cr(); diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index 7b13337ecafcf..271d8b3986378 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,8 +75,8 @@ class Method : public Metadata { MethodData* _method_data; MethodCounters* _method_counters; AdapterHandlerEntry* _adapter; - int _vtable_index; // vtable index of this method (see VtableIndexFlag) AccessFlags _access_flags; // Access flags + int _vtable_index; // vtable index of this method (see VtableIndexFlag) MethodFlags _flags; u2 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none) diff --git a/src/hotspot/share/oops/objArrayKlass.cpp b/src/hotspot/share/oops/objArrayKlass.cpp index 903c5660d5311..04bc374e5226c 100644 --- a/src/hotspot/share/oops/objArrayKlass.cpp +++ b/src/hotspot/share/oops/objArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -341,12 +341,12 @@ void ObjArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) { it->push(&_bottom_klass); } -u2 ObjArrayKlass::compute_modifier_flags() const { +jint ObjArrayKlass::compute_modifier_flags() const { // The modifier for an objectArray is the same as its element assert (element_klass() != nullptr, "should be initialized"); // Return the flags of the bottom element type. - u2 element_flags = bottom_klass()->compute_modifier_flags(); + jint element_flags = bottom_klass()->compute_modifier_flags(); return (element_flags & (JVM_ACC_PUBLIC | JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL); diff --git a/src/hotspot/share/oops/objArrayKlass.hpp b/src/hotspot/share/oops/objArrayKlass.hpp index c44c8d28f6247..e16f1f2eb0fcd 100644 --- a/src/hotspot/share/oops/objArrayKlass.hpp +++ b/src/hotspot/share/oops/objArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -143,7 +143,7 @@ class ObjArrayKlass : public ArrayKlass { inline void oop_oop_iterate_elements_bounded(objArrayOop a, OopClosureType* closure, void* low, void* high); public: - u2 compute_modifier_flags() const; + jint compute_modifier_flags() const; public: // Printing diff --git a/src/hotspot/share/oops/typeArrayKlass.cpp b/src/hotspot/share/oops/typeArrayKlass.cpp index 86c4f9d7138c4..8ca6a49fc46a4 100644 --- a/src/hotspot/share/oops/typeArrayKlass.cpp +++ b/src/hotspot/share/oops/typeArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ TypeArrayKlass* TypeArrayKlass::allocate(ClassLoaderData* loader_data, BasicType return new (loader_data, size, THREAD) TypeArrayKlass(type, name); } -u2 TypeArrayKlass::compute_modifier_flags() const { +jint TypeArrayKlass::compute_modifier_flags() const { return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC; } diff --git a/src/hotspot/share/oops/typeArrayKlass.hpp b/src/hotspot/share/oops/typeArrayKlass.hpp index 6ec72ae49c0c8..9dc3ed607fe3a 100644 --- a/src/hotspot/share/oops/typeArrayKlass.hpp +++ b/src/hotspot/share/oops/typeArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ class TypeArrayKlass : public ArrayKlass { // Copying void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); - u2 compute_modifier_flags() const; + jint compute_modifier_flags() const; // Oop iterators. Since there are no oops in TypeArrayKlasses, // these functions only return the size of the object. diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index 56cfb9fe16e7b..40b19eecd9f65 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3871,7 +3871,7 @@ Node* LibraryCallKit::generate_klass_flags_guard(Node* kls, int modifier_mask, i } Node* LibraryCallKit::generate_interface_guard(Node* kls, RegionNode* region) { return generate_klass_flags_guard(kls, JVM_ACC_INTERFACE, 0, region, - Klass::access_flags_offset(), TypeInt::CHAR, T_CHAR); + Klass::access_flags_offset(), TypeInt::INT, T_INT); } // Use this for testing if Klass is_hidden, has_finalizer, and is_cloneable_fast. @@ -3904,7 +3904,8 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { break; case vmIntrinsics::_getModifiers: prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); - return_type = TypeInt::CHAR; + assert(is_power_of_2((int)JVM_ACC_WRITTEN_FLAGS+1), "change next line"); + return_type = TypeInt::make(0, JVM_ACC_WRITTEN_FLAGS, Type::WidenMin); break; case vmIntrinsics::_isInterface: prim_return_value = intcon(0); @@ -3926,7 +3927,7 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { break; case vmIntrinsics::_getClassAccessFlags: prim_return_value = intcon(JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC); - return_type = TypeInt::CHAR; + return_type = TypeInt::INT; // not bool! 6297094 break; default: fatal_unexpected_iid(id); @@ -3987,7 +3988,7 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { case vmIntrinsics::_getModifiers: p = basic_plus_adr(kls, in_bytes(Klass::modifier_flags_offset())); - query_value = make_load(nullptr, p, TypeInt::CHAR, T_CHAR, MemNode::unordered); + query_value = make_load(nullptr, p, TypeInt::INT, T_INT, MemNode::unordered); break; case vmIntrinsics::_isInterface: @@ -4052,7 +4053,7 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { case vmIntrinsics::_getClassAccessFlags: p = basic_plus_adr(kls, in_bytes(Klass::access_flags_offset())); - query_value = make_load(nullptr, p, TypeInt::CHAR, T_CHAR, MemNode::unordered); + query_value = make_load(nullptr, p, TypeInt::INT, T_INT, MemNode::unordered); break; default: diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 78ffbe05ae492..ad351fb81add7 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2024, Alibaba Group Holding Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1976,24 +1976,24 @@ LoadNode::load_array_final_field(const TypeKlassPtr *tkls, if (tkls->offset() == in_bytes(Klass::modifier_flags_offset())) { // The field is Klass::_modifier_flags. Return its (constant) value. // (Folds up the 2nd indirection in aClassConstant.getModifiers().) - assert(Opcode() == Op_LoadUS, "must load an unsigned short from _modifier_flags"); + assert(this->Opcode() == Op_LoadI, "must load an int from _modifier_flags"); return TypeInt::make(klass->modifier_flags()); } if (tkls->offset() == in_bytes(Klass::access_flags_offset())) { // The field is Klass::_access_flags. Return its (constant) value. // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).) - assert(Opcode() == Op_LoadUS, "must load an unsigned short from _access_flags"); + assert(this->Opcode() == Op_LoadI, "must load an int from _access_flags"); return TypeInt::make(klass->access_flags()); } if (tkls->offset() == in_bytes(Klass::misc_flags_offset())) { // The field is Klass::_misc_flags. Return its (constant) value. // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).) - assert(Opcode() == Op_LoadUB, "must load an unsigned byte from _misc_flags"); + assert(this->Opcode() == Op_LoadUB, "must load an unsigned byte from _misc_flags"); return TypeInt::make(klass->misc_flags()); } if (tkls->offset() == in_bytes(Klass::layout_helper_offset())) { // The field is Klass::_layout_helper. Return its constant value if known. - assert(Opcode() == Op_LoadI, "must load an int from _layout_helper"); + assert(this->Opcode() == Op_LoadI, "must load an int from _layout_helper"); return TypeInt::make(klass->layout_helper()); } diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 198165cdd1ed9..12c7898f4cf19 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1306,7 +1306,7 @@ JVM_ENTRY(jint, JVM_GetClassModifiers(JNIEnv *env, jclass cls)) } Klass* k = java_lang_Class::as_Klass(mirror); - debug_only(u2 computed_modifiers = k->compute_modifier_flags()); + debug_only(int computed_modifiers = k->compute_modifier_flags()); assert(k->modifier_flags() == computed_modifiers, "modifiers cache is OK"); return k->modifier_flags(); JVM_END @@ -1817,7 +1817,7 @@ JVM_ENTRY(jint, JVM_GetClassAccessFlags(JNIEnv *env, jclass cls)) } Klass* k = java_lang_Class::as_Klass(mirror); - return k->access_flags().as_class_flags(); + return k->access_flags().as_int() & JVM_ACC_WRITTEN_FLAGS; } JVM_END @@ -2460,14 +2460,14 @@ JVM_ENTRY(jint, JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_ind Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); Method* method = InstanceKlass::cast(k)->methods()->at(method_index); - return method->access_flags().as_method_flags(); + return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; JVM_END JVM_ENTRY(jint, JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)) Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); - return InstanceKlass::cast(k)->field_access_flags(field_index); + return InstanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS; JVM_END @@ -2657,7 +2657,7 @@ JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, j InstanceKlass* ik = InstanceKlass::cast(k_called); for (JavaFieldStream fs(ik); !fs.done(); fs.next()) { if (fs.name() == name && fs.signature() == signature) { - return fs.access_flags().as_field_flags(); + return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS; } } return -1; @@ -2686,7 +2686,7 @@ JVM_ENTRY(jint, JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, for (int i = 0; i < methods_count; i++) { Method* method = methods->at(i); if (method->name() == name && method->signature() == signature) { - return method->access_flags().as_method_flags(); + return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; } } return -1; diff --git a/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp b/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp index 10fb4121472e4..ceed1d8ad952a 100644 --- a/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp +++ b/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,7 @@ void JvmtiClassFileReconstituter::write_field_infos() { // JVMSpec| attribute_info attributes[attributes_count]; // JVMSpec| } - write_u2(access_flags.as_field_flags()); + write_u2(access_flags.get_flags() & JVM_RECOGNIZED_FIELD_MODIFIERS); write_u2(name_index); write_u2(signature_index); u2 attr_count = 0; @@ -704,7 +704,7 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method) return; } - write_u2(access_flags.as_method_flags()); + write_u2(access_flags.get_flags() & JVM_RECOGNIZED_METHOD_MODIFIERS); write_u2(const_method->name_index()); write_u2(const_method->signature_index()); @@ -919,7 +919,7 @@ void JvmtiClassFileReconstituter::write_class_file_format() { copy_cpool_bytes(writeable_address(cpool_size())); // JVMSpec| u2 access_flags; - write_u2(ik()->access_flags().as_class_flags()); + write_u2(ik()->access_flags().get_flags() & JVM_RECOGNIZED_CLASS_MODIFIERS); // JVMSpec| u2 this_class; // JVMSpec| u2 super_class; diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index e97bfc300422e..554b4baf7b2a3 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3149,7 +3149,7 @@ jvmtiError JvmtiEnv::GetFieldModifiers(fieldDescriptor* fdesc_ptr, jint* modifiers_ptr) { AccessFlags resultFlags = fdesc_ptr->access_flags(); - jint result = resultFlags.as_field_flags(); + jint result = resultFlags.as_int(); *modifiers_ptr = result; return JVMTI_ERROR_NONE; @@ -3228,7 +3228,7 @@ JvmtiEnv::GetMethodDeclaringClass(Method* method, jclass* declaring_class_ptr) { jvmtiError JvmtiEnv::GetMethodModifiers(Method* method, jint* modifiers_ptr) { NULL_CHECK(method, JVMTI_ERROR_INVALID_METHODID); - (*modifiers_ptr) = method->access_flags().as_method_flags(); + (*modifiers_ptr) = method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; return JVMTI_ERROR_NONE; } /* end GetMethodModifiers */ diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index 0a53eadbbd88b..a982ac97c4786 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1005,8 +1005,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( } // Check whether class modifiers are the same. - u2 old_flags = the_class->access_flags().as_class_flags(); - u2 new_flags = scratch_class->access_flags().as_class_flags(); + jushort old_flags = (jushort) the_class->access_flags().get_flags(); + jushort new_flags = (jushort) scratch_class->access_flags().get_flags(); if (old_flags != new_flags) { log_info(redefine, class, normalize) ("redefined class %s modifiers change error: modifiers changed from %d to %d.", @@ -1040,9 +1040,9 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED; } // access - old_flags = old_fs.access_flags().as_field_flags(); - new_flags = new_fs.access_flags().as_field_flags(); - if (old_flags != new_flags) { + old_flags = old_fs.access_flags().as_short(); + new_flags = new_fs.access_flags().as_short(); + if ((old_flags ^ new_flags) & JVM_RECOGNIZED_FIELD_MODIFIERS) { log_info(redefine, class, normalize) ("redefined class %s field %s change error: modifiers changed from %d to %d.", the_class->external_name(), name_sym2->as_C_string(), old_flags, new_flags); @@ -1147,8 +1147,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( switch (method_was) { case matched: // methods match, be sure modifiers do too - old_flags = k_old_method->access_flags().as_method_flags(); - new_flags = k_new_method->access_flags().as_method_flags(); + old_flags = (jushort) k_old_method->access_flags().get_flags(); + new_flags = (jushort) k_new_method->access_flags().get_flags(); if ((old_flags ^ new_flags) & ~(JVM_ACC_NATIVE)) { log_info(redefine, class, normalize) ("redefined class %s method %s modifiers error: modifiers changed from %d to %d", diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 5b40682851042..1e44ea957311e 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -239,7 +239,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { assert(m.not_null(), "null method handle"); InstanceKlass* m_klass = m->method_holder(); assert(m_klass != nullptr, "null holder for method handle"); - int flags = (m->access_flags().as_method_flags()); + int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS ); int vmindex = Method::invalid_vtable_index; LogTarget(Debug, methodhandles, indy) lt_indy; @@ -352,7 +352,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) { oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) { InstanceKlass* ik = fd.field_holder(); - int flags = fd.access_flags().as_field_flags(); + int flags = (jushort)( fd.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS ); flags |= IS_FIELD | ((fd.is_static() ? JVM_REF_getStatic : JVM_REF_getField) << REFERENCE_KIND_SHIFT); if (fd.is_trusted_final()) flags |= TRUSTED_FINAL; if (is_setter) flags += ((JVM_REF_putField - JVM_REF_getField) << REFERENCE_KIND_SHIFT); @@ -404,7 +404,7 @@ bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) { Method* m = iklass->find_method(name, poly_sig); if (m != nullptr) { int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS; - int flags = m->access_flags().as_method_flags(); + int flags = m->access_flags().as_int(); if ((flags & required) == required) { return true; } @@ -417,7 +417,7 @@ bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) { for (; ms < me; ms++) { Method* m = iklass->methods()->at(ms); int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS; - int flags = m->access_flags().as_method_flags(); + int flags = m->access_flags().as_int(); if ((flags & required) == required && ArgumentCount(m->signature()).size() == 1) { return true; } @@ -522,7 +522,7 @@ bool MethodHandles::is_signature_polymorphic_public_name(Klass* klass, Symbol* n for (; ms < me; ms++) { Method* m = iklass->methods()->at(ms); int required = JVM_ACC_NATIVE | JVM_ACC_VARARGS | JVM_ACC_PUBLIC; - int flags = m->access_flags().as_method_flags(); + int flags = m->access_flags().as_int(); if ((flags & required) == required && ArgumentCount(m->signature()).size() == 1) { return true; } diff --git a/src/hotspot/share/runtime/reflection.cpp b/src/hotspot/share/runtime/reflection.cpp index 3aef7028a7970..7739cff03bf23 100644 --- a/src/hotspot/share/runtime/reflection.cpp +++ b/src/hotspot/share/runtime/reflection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -778,7 +778,7 @@ oop Reflection::new_method(const methodHandle& method, bool for_constant_pool_ac Handle name = Handle(THREAD, name_oop); if (name == nullptr) return nullptr; - const int modifiers = method->access_flags().as_method_flags(); + const int modifiers = method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; Handle mh = java_lang_reflect_Method::create(CHECK_NULL); @@ -819,7 +819,7 @@ oop Reflection::new_constructor(const methodHandle& method, TRAPS) { objArrayHandle exception_types = get_exception_types(method, CHECK_NULL); assert(!exception_types.is_null(), "cannot return null"); - const int modifiers = method->access_flags().as_method_flags(); + const int modifiers = method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; Handle ch = java_lang_reflect_Constructor::create(CHECK_NULL); @@ -859,7 +859,7 @@ oop Reflection::new_field(fieldDescriptor* fd, TRAPS) { java_lang_reflect_Field::set_trusted_final(rh()); } // Note the ACC_ANNOTATION bit, which is a per-class access flag, is never set here. - java_lang_reflect_Field::set_modifiers(rh(), fd->access_flags().as_field_flags()); + java_lang_reflect_Field::set_modifiers(rh(), fd->access_flags().as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS); java_lang_reflect_Field::set_override(rh(), false); if (fd->has_generic_signature()) { Symbol* gs = fd->generic_signature(); diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index b6e5457551929..f5cb2805c8ed9 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -263,7 +263,7 @@ nonstatic_field(Klass, _secondary_supers, Array*) \ nonstatic_field(Klass, _primary_supers[0], Klass*) \ nonstatic_field(Klass, _java_mirror, OopHandle) \ - nonstatic_field(Klass, _modifier_flags, u2) \ + nonstatic_field(Klass, _modifier_flags, jint) \ nonstatic_field(Klass, _super, Klass*) \ volatile_nonstatic_field(Klass, _subklass, Klass*) \ nonstatic_field(Klass, _layout_helper, jint) \ @@ -1017,7 +1017,7 @@ nonstatic_field(vframeArrayElement, _bci, int) \ nonstatic_field(vframeArrayElement, _method, Method*) \ \ - nonstatic_field(AccessFlags, _flags, u2) \ + nonstatic_field(AccessFlags, _flags, jint) \ nonstatic_field(elapsedTimer, _counter, jlong) \ nonstatic_field(elapsedTimer, _active, bool) \ nonstatic_field(InvocationCounter, _counter, unsigned int) \ diff --git a/src/hotspot/share/utilities/accessFlags.cpp b/src/hotspot/share/utilities/accessFlags.cpp index fc11491174f71..ec68d1244889c 100644 --- a/src/hotspot/share/utilities/accessFlags.cpp +++ b/src/hotspot/share/utilities/accessFlags.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,5 +47,5 @@ void AccessFlags::print_on(outputStream* st) const { #endif // !PRODUCT || INCLUDE_JVMTI void accessFlags_init() { - assert(sizeof(AccessFlags) == sizeof(u2), "just checking size of flags"); + assert(sizeof(AccessFlags) == sizeof(jint), "just checking size of flags"); } diff --git a/src/hotspot/share/utilities/accessFlags.hpp b/src/hotspot/share/utilities/accessFlags.hpp index a752c09cb4272..74ccbd20ac142 100644 --- a/src/hotspot/share/utilities/accessFlags.hpp +++ b/src/hotspot/share/utilities/accessFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,19 +30,28 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" -// AccessFlags is an abstraction over Java ACC flags. -// See generated file classfile_constants.h for shared JVM_ACC_XXX access flags +// AccessFlags is an abstraction over Java access flags. class outputStream; +enum { + // See jvm.h for shared JVM_ACC_XXX access flags + + // flags actually put in .class file + JVM_ACC_WRITTEN_FLAGS = 0x00007FFF, + + // Do not add new ACC flags here. +}; + + class AccessFlags { friend class VMStructs; private: - u2 _flags; + jint _flags; // TODO: move 4 access flags above to Klass and change to u2 public: AccessFlags() : _flags(0) {} - explicit AccessFlags(u2 flags) : _flags(flags) {} + explicit AccessFlags(jint flags) : _flags(flags) {} // Java access flags bool is_public () const { return (_flags & JVM_ACC_PUBLIC ) != 0; } @@ -61,10 +70,15 @@ class AccessFlags { // Attribute flags bool is_synthetic () const { return (_flags & JVM_ACC_SYNTHETIC ) != 0; } - // get as integral value - u2 as_unsigned_short() const { return _flags; } + // get .class file flags + jint get_flags () const { return (_flags & JVM_ACC_WRITTEN_FLAGS); } - void set_flags(u2 flags) { _flags = flags; } + // Initialization + void set_field_flags(jint flags) { + assert((flags & JVM_RECOGNIZED_FIELD_MODIFIERS) == flags, "only recognized flags"); + _flags = (flags & JVM_RECOGNIZED_FIELD_MODIFIERS); + } + void set_flags(jint flags) { _flags = (flags & JVM_ACC_WRITTEN_FLAGS); } private: friend class Klass; @@ -76,22 +90,11 @@ class AccessFlags { void set_is_synthetic() { _flags |= JVM_ACC_SYNTHETIC; } public: - inline friend AccessFlags accessFlags_from(u2 flags); + // Conversion + jshort as_short() const { return (jshort)_flags; } + jint as_int() const { return _flags; } - u2 as_method_flags() const { - assert((_flags & JVM_RECOGNIZED_METHOD_MODIFIERS) == _flags, "only recognized flags"); - return _flags; - } - - u2 as_field_flags() const { - assert((_flags & JVM_RECOGNIZED_FIELD_MODIFIERS) == _flags, "only recognized flags"); - return _flags; - } - - u2 as_class_flags() const { - assert((_flags & JVM_RECOGNIZED_CLASS_MODIFIERS) == _flags, "only recognized flags"); - return _flags; - } + inline friend AccessFlags accessFlags_from(jint flags); // Printing/debugging #if INCLUDE_JVMTI @@ -101,7 +104,7 @@ class AccessFlags { #endif }; -inline AccessFlags accessFlags_from(u2 flags) { +inline AccessFlags accessFlags_from(jint flags) { AccessFlags af; af._flags = flags; return af; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java index 66ebd6551a4fd..2f310effc87f4 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/AccessFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,4 +75,9 @@ public void printOn(PrintStream tty) { if (isStrict ()) tty.print("strict " ); if (isSynthetic ()) tty.print("synthetic " ); } + + // get flags written to .class files + public int getStandardFlags() { + return (int) (flags & JVM_ACC_WRITTEN_FLAGS); + } } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java index 7f9a6b4b49d2a..25f40ec443f50 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,7 +98,16 @@ public interface ClassConstants public static final long JVM_ACC_ENUM = 0x4000; /* field is declared as element of enum */ + // from accessFlags.hpp - hotspot internal flags + + // flags actually put in .class file + public static final long JVM_ACC_WRITTEN_FLAGS = 0x00007FFF; + + // flags accepted by set_field_flags + public static final long JVM_ACC_FIELD_FLAGS = 0x00008000 | JVM_ACC_WRITTEN_FLAGS; + // from jvm.h + public static final long JVM_RECOGNIZED_CLASS_MODIFIERS = (JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SUPER |