From 64223f61fc8413ad69ba0e814fbbc552a6c57c33 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 5 Nov 2026 21:18:56 +0100 Subject: Pass the receiver instance to KotlinProxyOverrides.invoke MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated returnValue call now carries the stub instance the method was called on (null for statics), so overrides can keep per-compiler state instead of statics: the performance manager is now stored in an IdentityHashMap keyed by receiver, and OVERRIDE log lines carry the receiver's identityHashCode as inst=0x… . --- stubs/src/kotlin/proxy/KotlinProxyLog.java | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'stubs/src/kotlin/proxy/KotlinProxyLog.java') diff --git a/stubs/src/kotlin/proxy/KotlinProxyLog.java b/stubs/src/kotlin/proxy/KotlinProxyLog.java index 3afdb38..af5db37 100644 --- a/stubs/src/kotlin/proxy/KotlinProxyLog.java +++ b/stubs/src/kotlin/proxy/KotlinProxyLog.java @@ -53,20 +53,28 @@ public final class KotlinProxyLog { /** * Return value for stub methods with a reference return type (other than * String). Asks {@link KotlinProxyOverrides#invoke} first — per-method - * custom implementations, passed the full argument list — and falls back - * to materializing a real no-arg instance of the declared return type. - * The generated body checkcasts the result to the declared type. + * custom implementations, passed the full argument list and the receiver + * (the stub instance the method was called on, null for statics) — and + * falls back to materializing a real no-arg instance of the declared + * return type. The generated body checkcasts the result to the declared + * type. * - * The generated bytecode pushes the args array FIRST (member, owner and - * return type last) so its stack stays shallow (peak 4) — keep this - * parameter order in sync with RETURN_VALUE_DESC in gen_class.py. + * The generated bytecode pushes the args array FIRST (member, owner, + * return type and receiver last) so its stack stays shallow (peak 5) — + * keep this parameter order in sync with RETURN_VALUE_DESC in + * gen_class.py. */ public static Object returnValue(Object[] args, String member, - String ownerDotName, String returnDotName) { + String ownerDotName, String returnDotName, + Object instance) { Object v = KotlinProxyOverrides.invoke(member, ownerDotName, - returnDotName, args); + returnDotName, args, instance); if (v != KotlinProxyOverrides.NO_VALUE) { log("OVERRIDE " + ownerDotName + "." + member + + (instance != null + ? " inst=0x" + + Integer.toHexString(System.identityHashCode(instance)) + : "") + " -> " + dump(v)); return v; } -- cgit v1.3.1