summaryrefslogtreecommitdiff
path: root/stubs/src/kotlin/proxy/KotlinProxyLog.java
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-11-05 21:18:56 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-11-05 21:18:56 +0100
commit64223f61fc8413ad69ba0e814fbbc552a6c57c33 (patch)
tree79f47335e71dfe6d702fbca520513b2b7eb90fae /stubs/src/kotlin/proxy/KotlinProxyLog.java
parentaefb3dbf687b46775bca1b600317bc053648b211 (diff)
Pass the receiver instance to KotlinProxyOverrides.invoke
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… .
Diffstat (limited to 'stubs/src/kotlin/proxy/KotlinProxyLog.java')
-rw-r--r--stubs/src/kotlin/proxy/KotlinProxyLog.java24
1 files changed, 16 insertions, 8 deletions
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;
}