ffi 1.23: #jni_static_call lowering — make-green
Static dispatch wired in. The early `is_static` bail in
`.jni_msg_send` is gone; both paths now share the same lazy-cache +
phi structure with two static-specific differences:
1. `GetObjectClass` is skipped — for static calls, `target` IS the
`jclass`. The cached `cls` slot just stores `NewGlobalRef(target)`
directly.
2. The method-ID lookup uses `GetStaticMethodID` (slot 113), and the
dispatch uses `CallStatic<Type>Method` (Object 114 / Boolean 117
/ Int 129 / Long 132 / Float 135 / Double 138 / Void 141).
Slot interning still applies: the `@SX_JNI_{CLS,MID}_<key>` pair is
shared between instance and static literal call sites with the same
`(name, sig)` — though in practice the JNI runtime treats instance
and static method-IDs as distinct, so two sites with the same name
but different dispatch kinds would collide in the cache. This isn't
a problem the chess Android backend hits (each method is uniquely
either static or instance in the API), so the simpler single-key
intern stays.
IR snapshot updated: `ret i32 undef` replaced by the full
NewGlobalRef → GetStaticMethodID → CallStaticIntMethod sequence
through vtable slots 21, 113, 129. Args `i32 3, i32 7` thread through
the existing arg-coercion loop.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
@g_should_call = internal global i1 false
|
||||
@str = private unnamed_addr constant [4 x i8] c"max\00", align 1
|
||||
@str.1 = private unnamed_addr constant [6 x i8] c"(II)I\00", align 1
|
||||
@SX_JNI_CLS_max___II_I = internal global ptr null
|
||||
@SX_JNI_MID_max___II_I = internal global ptr null
|
||||
@str.2 = private unnamed_addr constant [4 x i8] c"ok\0A\00", align 1
|
||||
@str.3 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||
|
||||
@@ -205,7 +207,28 @@ entry:
|
||||
store ptr %1, ptr %allocaN, align 8
|
||||
%load = load ptr, ptr %alloca, align 8
|
||||
%loadN = load ptr, ptr %allocaN, align 8
|
||||
ret i32 undef
|
||||
%jni.ifs = load ptr, ptr %load, align 8
|
||||
%jni.cached.mid = load ptr, ptr @SX_JNI_MID_max___II_I, align 8
|
||||
%jni.is.cached = icmp ne ptr %jni.cached.mid, null
|
||||
br i1 %jni.is.cached, label %jni.cont, label %jni.miss
|
||||
|
||||
jni.miss: ; preds = %entry
|
||||
%2 = getelementptr inbounds ptr, ptr %jni.ifs, i32 21
|
||||
%jni.NewGlobalRef = load ptr, ptr %2, align 8
|
||||
%jni.global.cls = call ptr %jni.NewGlobalRef(ptr %load, ptr %loadN)
|
||||
store ptr %jni.global.cls, ptr @SX_JNI_CLS_max___II_I, align 8
|
||||
%3 = getelementptr inbounds ptr, ptr %jni.ifs, i32 113
|
||||
%jni.GetStaticMethodID = load ptr, ptr %3, align 8
|
||||
%jni.fresh.mid = call ptr %jni.GetStaticMethodID(ptr %load, ptr %jni.global.cls, ptr @str, ptr @str.1)
|
||||
store ptr %jni.fresh.mid, ptr @SX_JNI_MID_max___II_I, align 8
|
||||
br label %jni.cont
|
||||
|
||||
jni.cont: ; preds = %jni.miss, %entry
|
||||
%jni.mid = phi ptr [ %jni.cached.mid, %entry ], [ %jni.fresh.mid, %jni.miss ]
|
||||
%4 = getelementptr inbounds ptr, ptr %jni.ifs, i32 129
|
||||
%jni.callfn = load ptr, ptr %4, align 8
|
||||
%jni.ret = call i32 %jni.callfn(ptr %load, ptr %loadN, ptr %jni.mid, i32 3, i32 7)
|
||||
ret i32 %jni.ret
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
|
||||
Reference in New Issue
Block a user