RFR: 8372634: C2: Materialize type information from instanceof checks

ExE Boss duke at openjdk.org
Thu Nov 27 14:59:51 UTC 2025


On Thu, 27 Nov 2025 01:17:15 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

>> test/hotspot/jtreg/compiler/inlining/TestSubtypeCheckTypeInfo.java line 323:
>> 
>>> 321:     static boolean lateInlineIsInstanceCondPost(A o, boolean cond) {
>>> 322:         return B.class.isInstance(o) && cond;
>>> 323:     }
>> 
>> What about the non‑late version of these methods?
>
> There are corresponding test cases (`testInstanceOfCondPre` et al) where conditions are embedded.
> 
> The idea of `testInstanceOfCondLate` and similar test cases is to check how inlining works when condition improves receiver type during incremental inlining phase.

What I meant was where the `instanceof` is in the called method, the `testInstanceOfCondPre` all have the `instanceof` checks as part of the `if` statement.

--------------------------------------------------------------------------------

Something like:

static void testInstanceOfCondDefaultInlinePre(A a, boolean cond) {
	if (defaultInlineInstanceOfCondPre(a, cond)) {
		a.m();
	}
}
static void testInstanceOfCondDefaultInlinePost(A a, boolean cond) {
	if (defaultInlineInstanceOfCondPost(a, cond)) {
		a.m();
	}
}

static void testIsInstanceCondDefaultInlinePre(A a, boolean cond) {
	if (defaultInlineIsInstanceCondPre(a, cond)) {
		a.m();
	}
}
static void testIsInstanceCondDefaultInlinePost(A a, boolean cond) {
	if (defaultInlineIsInstanceCondPost(a, cond)) {
		a.m();
	}
}


--------------------------------------------------------------------------------

I suggest adding such a test because of real world code which use different internal implementation classes but expose their public API as only a single common supertype, like `java.lang.constant.ClassDesc` and its `isPrimitive()`/`isArray()`/`isClassOrInterface()` methods (which currently don’t do the `instanceof` check, but they probably should so that they can be reliably inlined).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28517#discussion_r2569108988


More information about the hotspot-compiler-dev mailing list