ffi 1.21: #jni_call(bool) → CallBooleanMethod (slot 37) — make-green
One-line addition: `.bool => Jni.CallBooleanMethod`. The lazy-cache
+ dispatch from 1.17 handles the rest. JNI's `jboolean` is i8 in the
C ABI but always carries 0 or 1; LLVM's call boundary truncates the
return byte to i1 and the sx-level bool reads the low bit
canonically.
IR snapshot updated: `ret i1 undef` replaced by the full sequence
through vtable slot 37 keyed on `("isShown", "()Z")`.
This commit is contained in:
@@ -1244,6 +1244,7 @@ pub const LLVMEmitter = struct {
|
||||
.s32 => Jni.CallIntMethod,
|
||||
.s64 => Jni.CallLongMethod,
|
||||
.f64 => Jni.CallDoubleMethod,
|
||||
.bool => Jni.CallBooleanMethod,
|
||||
else => {
|
||||
self.mapRef(c.LLVMGetUndef(self.toLLVMType(instruction.ty)));
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
@g_should_call = internal global i1 false
|
||||
@str = private unnamed_addr constant [8 x i8] c"isShown\00", align 1
|
||||
@str.1 = private unnamed_addr constant [4 x i8] c"()Z\00", align 1
|
||||
@SX_JNI_CLS_isShown____Z = internal global ptr null
|
||||
@SX_JNI_MID_isShown____Z = 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,31 @@ entry:
|
||||
store ptr %1, ptr %allocaN, align 8
|
||||
%load = load ptr, ptr %alloca, align 8
|
||||
%loadN = load ptr, ptr %allocaN, align 8
|
||||
ret i1 undef
|
||||
%jni.ifs = load ptr, ptr %load, align 8
|
||||
%jni.cached.mid = load ptr, ptr @SX_JNI_MID_isShown____Z, 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 31
|
||||
%jni.GetObjectClass = load ptr, ptr %2, align 8
|
||||
%jni.cls = call ptr %jni.GetObjectClass(ptr %load, ptr %loadN)
|
||||
%3 = getelementptr inbounds ptr, ptr %jni.ifs, i32 21
|
||||
%jni.NewGlobalRef = load ptr, ptr %3, align 8
|
||||
%jni.global.cls = call ptr %jni.NewGlobalRef(ptr %load, ptr %jni.cls)
|
||||
store ptr %jni.global.cls, ptr @SX_JNI_CLS_isShown____Z, align 8
|
||||
%4 = getelementptr inbounds ptr, ptr %jni.ifs, i32 33
|
||||
%jni.GetMethodID = load ptr, ptr %4, align 8
|
||||
%jni.fresh.mid = call ptr %jni.GetMethodID(ptr %load, ptr %jni.global.cls, ptr @str, ptr @str.1)
|
||||
store ptr %jni.fresh.mid, ptr @SX_JNI_MID_isShown____Z, 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 ]
|
||||
%5 = getelementptr inbounds ptr, ptr %jni.ifs, i32 37
|
||||
%jni.callfn = load ptr, ptr %5, align 8
|
||||
%jni.ret = call i1 %jni.callfn(ptr %load, ptr %loadN, ptr %jni.mid)
|
||||
ret i1 %jni.ret
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
|
||||
Reference in New Issue
Block a user