Use runtime bitcode to get size of primitive types
As an alternative to explicitly setting type size in konan.properties or backend code we can "ask" LLVM about it. Unfortunately, there is no Clang/LLVM API for it, so we use a trivial workaround: Create dumb function in runtime code, and then extract info about return type size using LLVM.
This commit is contained in:
committed by
TeamCityServer
parent
790fea635d
commit
9b1498abad
@@ -39,6 +39,9 @@ extern "C" OBJ_GETTER(Kotlin_ObjCExport_refFromObjC, id obj);
|
||||
extern "C" id Kotlin_Interop_CreateNSStringFromKString(KRef str);
|
||||
extern "C" OBJ_GETTER(Kotlin_Interop_CreateKStringFromNSString, NSString* str);
|
||||
|
||||
/// Utility function that is used to determine NSInteger size in compile time.
|
||||
extern "C" NSInteger Kotlin_ObjCExport_NSIntegerTypeProvider();
|
||||
|
||||
#endif // KONAN_OBJC_INTEROP
|
||||
|
||||
#endif // RUNTIME_OBJCEXPORT_H
|
||||
|
||||
@@ -1090,6 +1090,10 @@ extern "C" void Kotlin_ObjCExport_AbstractMethodCalled(id self, SEL selector) {
|
||||
class_getName(object_getClass(self)), sel_getName(selector)];
|
||||
}
|
||||
|
||||
extern "C" NSInteger Kotlin_ObjCExport_NSIntegerTypeProvider() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
extern "C" ALWAYS_INLINE void* Kotlin_Interop_refToObjC(ObjHeader* obj) {
|
||||
|
||||
@@ -108,4 +108,8 @@ KVector4f Kotlin_Vector4i32_of(KInt f0, KInt f1, KInt f2, KInt f3) {
|
||||
return (KVector4f)v4i;
|
||||
}
|
||||
|
||||
long Kotlin_longTypeProvider() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -124,6 +124,9 @@ void CheckCast(const ObjHeader* obj, const TypeInfo* type_info);
|
||||
KBoolean IsArray(KConstRef obj) RUNTIME_PURE;
|
||||
bool IsSubInterface(const TypeInfo* thiz, const TypeInfo* other) RUNTIME_PURE;
|
||||
|
||||
/// Utility function that is used to determine long type size in compile time.
|
||||
long Kotlin_longTypeProvider();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user