Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-10 Thread Coleen Phillimore
On Fri, 7 Feb 2025 12:34:40 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-10 Thread Yudi Zheng
On Fri, 7 Feb 2025 12:34:40 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-08 Thread Alan Bateman
On Fri, 7 Feb 2025 12:34:40 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-07 Thread Chen Liang
On Fri, 7 Feb 2025 12:34:40 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-07 Thread Coleen Phillimore
On Fri, 7 Feb 2025 19:58:12 GMT, Vladimir Ivanov wrote: > Good point. Moreover, it seems most of intrinsics on Class queries can be > replaced with a flag bit check on the mirror. (Do we have 16 unused bits in > Class::modifiers after this change?) Yes, I think so. isArray and isPrimitive def

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-07 Thread Vladimir Ivanov
On Fri, 7 Feb 2025 19:13:07 GMT, Coleen Phillimore wrote: > I think the intrinsic for isInterface can be removed Good point. Moreover, it seems most of intrinsics on Class queries can be replaced with a flag bit check on the mirror. (Do we have 16 unused bits in Class::modifiers after this cha

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-07 Thread Vladimir Ivanov
On Fri, 7 Feb 2025 12:34:40 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-07 Thread Coleen Phillimore
On Fri, 7 Feb 2025 12:34:40 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v7]

2025-02-07 Thread Coleen Phillimore
> The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so there's no real need for the jdk code to call into the VM to get

Re: RFR: 8346567: Make Class.getModifiers() non-native [v6]

2025-02-06 Thread Coleen Phillimore
> The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so there's no real need for the jdk code to call into the VM to get

Re: RFR: 8346567: Make Class.getModifiers() non-native [v5]

2025-02-06 Thread Coleen Phillimore
On Thu, 6 Feb 2025 14:31:28 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v5]

2025-02-06 Thread Vladimir Ivanov
On Thu, 6 Feb 2025 14:31:28 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-06 Thread Vladimir Ivanov
On Thu, 6 Feb 2025 13:08:31 GMT, Coleen Phillimore wrote: >> Does `static final` help here? > > Yes. Yes it does. Cases when a class mirror is a compile-time constant are already well-optimized. Non constant cases are the ones where missing optimization opportunities arise. In this particul

Re: RFR: 8346567: Make Class.getModifiers() non-native [v5]

2025-02-06 Thread Chen Liang
On Thu, 6 Feb 2025 12:08:59 GMT, Coleen Phillimore wrote: >> If Class had other fields smaller than `int`, would be consider making this >> something like `char` to save space (allowing all the sub-word fields to be >> compacted)? > > I thought of doing this since I made modifiers u2 in the Hot

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-06 Thread Coleen Phillimore
On Wed, 5 Feb 2025 21:26:29 GMT, Dean Long wrote: >> Coleen Phillimore has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Fix copyright and param name > > src/hotspot/share/oops/instanceKlass.hpp line 1128: > >> 1126: #endif >> 1127: >> 1

Re: RFR: 8346567: Make Class.getModifiers() non-native [v5]

2025-02-06 Thread Coleen Phillimore
> The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so there's no real need for the jdk code to call into the VM to get

Re: RFR: 8346567: Make Class.getModifiers() non-native [v4]

2025-02-06 Thread Coleen Phillimore
> The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so there's no real need for the jdk code to call into the VM to get

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-06 Thread Coleen Phillimore
On Wed, 5 Feb 2025 21:24:25 GMT, Dean Long wrote: >> Coleen Phillimore has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Fix copyright and param name > > src/hotspot/share/compiler/compileLog.cpp line 116: > >> 114: print(" unload

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-06 Thread Coleen Phillimore
On Thu, 6 Feb 2025 04:37:17 GMT, Chen Liang wrote: >> OK, if the extra load turns out to be a problem in the future, we could look >> into why the compilers are generating the load when the Class is >> known/constant. If the old intrinsic was able to pull the constant out of >> the Klass, the

Re: RFR: 8346567: Make Class.getModifiers() non-native [v3]

2025-02-06 Thread Coleen Phillimore
> The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so there's no real need for the jdk code to call into the VM to get

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-06 Thread Coleen Phillimore
On Tue, 4 Feb 2025 14:43:51 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-06 Thread Coleen Phillimore
On Wed, 5 Feb 2025 21:44:37 GMT, Dean Long wrote: >> @DanHeidinga Great explanation, thank you! > > If Class had other fields smaller than `int`, would be consider making this > something like `char` to save space (allowing all the sub-word fields to be > compacted)? I thought of doing this si

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-05 Thread Chen Liang
On Wed, 5 Feb 2025 20:23:05 GMT, Dean Long wrote: >> Name Cnt Base Error Test Error Unit Change >> getAppArrayModifiers 30 0.923 ± 0.004 1.260 ± 0.001 ns/op 0.73x (p >> = 0.000*) >> getAppArrayModifiersFinal 30 0.922 ± 0.000 1.260 ± 0.001 ns/op 0.73x (p

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-05 Thread Dean Long
On Thu, 12 Dec 2024 10:16:01 GMT, Viktor Klang wrote: >> @viktorklang-ora `@Stable` is not about how the field was set, but about the >> JIT observing a non-default value at compile time. If it observes a >> non-default value, it can treat it as a compile time constant. > > @DanHeidinga Great

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-05 Thread Dean Long
On Tue, 4 Feb 2025 14:43:51 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-05 Thread Dean Long
On Tue, 4 Feb 2025 14:43:51 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-05 Thread Dean Long
On Tue, 4 Feb 2025 14:43:51 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-05 Thread Dean Long
On Wed, 5 Feb 2025 19:42:02 GMT, Coleen Phillimore wrote: >> test/micro/org/openjdk/bench/java/lang/reflect/Clazz.java line 73: >> >>> 71: public int getAppArrayModifiers() { >>> 72: return clazzArray.getClass().getModifiers(); >>> 73: } >> >> I'm guessing this is the benchmark

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-05 Thread Coleen Phillimore
On Wed, 5 Feb 2025 01:10:39 GMT, Dean Long wrote: >> Coleen Phillimore has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Fix copyright and param name > > test/micro/org/openjdk/bench/java/lang/reflect/Clazz.java line 73: > >> 71: publ

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-04 Thread Dean Long
On Tue, 4 Feb 2025 14:43:51 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-04 Thread Coleen Phillimore
On Tue, 4 Feb 2025 13:36:44 GMT, Alan Bateman wrote: >> Coleen Phillimore has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Fix copyright and param name > > src/hotspot/share/oops/arrayKlass.hpp line 2: > >> 1: /* >> 2: * Copyright (c) 1

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-04 Thread Coleen Phillimore
On Tue, 4 Feb 2025 14:40:47 GMT, Coleen Phillimore wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so

Re: RFR: 8346567: Make Class.getModifiers() non-native [v2]

2025-02-04 Thread Coleen Phillimore
> The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so there's no real need for the jdk code to call into the VM to get

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-04 Thread Alan Bateman
On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore wrote: > The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-04 Thread Alan Bateman
On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore wrote: > The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Viktor Klang
On Wed, 11 Dec 2024 18:17:43 GMT, Dan Heidinga wrote: >> Yeah, I was just thinking whether something set from inside the VM which is >> marked @Stable is constant-folded :) > > @viktorklang-ora `@Stable` is not about how the field was set, but about the > JIT observing a non-default value at c

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Dan Heidinga
On Wed, 11 Dec 2024 15:06:54 GMT, Viktor Klang wrote: >> I don't think this needs to be stable - finals in java.lang is trusted by >> the JIT compiler. > > Yeah, I was just thinking whether something set from inside the VM which is > marked @Stable is constant-folded :) @viktorklang-ora `@Stab

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Coleen Phillimore
On Wed, 11 Dec 2024 15:06:54 GMT, Viktor Klang wrote: >> I don't think this needs to be stable - finals in java.lang is trusted by >> the JIT compiler. > > Yeah, I was just thinking whether something set from inside the VM which is > marked @Stable is constant-folded :) I don't think @Stable w

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Viktor Klang
On Wed, 11 Dec 2024 14:52:48 GMT, Chen Liang wrote: >> src/java.base/share/classes/java/lang/Class.java line 1006: >> >>> 1004: private final transient int modifiers; // Set by the VM >>> 1005: >>> 1006: // package-private >> >> @coleenp Could this field be @Stable, or does that only

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Chen Liang
On Wed, 11 Dec 2024 10:24:03 GMT, Viktor Klang wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Coleen Phillimore
On Tue, 17 Dec 2024 15:54:48 GMT, ExE Boss wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so there's

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Viktor Klang
On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore wrote: > The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread ExE Boss
On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore wrote: > The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Coleen Phillimore
On Wed, 11 Dec 2024 18:15:57 GMT, Dan Heidinga wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Dan Heidinga
On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore wrote: > The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Coleen Phillimore
On Mon, 9 Dec 2024 21:35:42 GMT, ExE Boss wrote: >> yes. it is needed. > > This is **C++**, so yes. > Suggestion: > > macro(_modifiers_offset, k, vmSymbols::modifiers_name(), > int_signature,false); I see, there's a trailing semi somewhere in the expansion of this macro so it

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread ExE Boss
On Mon, 9 Dec 2024 20:27:52 GMT, Coleen Phillimore wrote: >> src/hotspot/share/classfile/javaClasses.cpp line 1504: >> >>> 1502: macro(_reflectionData_offset, k, "reflectionData", >>> java_lang_ref_SoftReference_signature, false); \ >>> 1503: macro(_signers_offset, k,

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Coleen Phillimore
On Mon, 9 Dec 2024 19:46:43 GMT, Chen Liang wrote: >> The Class.getModifiers() method is implemented as a native method in >> java.lang.Class to access a field that we've calculated when creating the >> mirror. The field is final after that point. The VM doesn't need it >> anymore, so there's

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Coleen Phillimore
On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore wrote: > The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so ther

Re: RFR: 8346567: Make Class.getModifiers() non-native

2025-02-03 Thread Chen Liang
On Mon, 9 Dec 2024 19:26:53 GMT, Coleen Phillimore wrote: > The Class.getModifiers() method is implemented as a native method in > java.lang.Class to access a field that we've calculated when creating the > mirror. The field is final after that point. The VM doesn't need it anymore, > so ther