[K/N][runtime] Used internal isInstance
This commit is contained in:
@@ -36,7 +36,7 @@ extern "C" void Kotlin_runUnhandledExceptionHook(KRef exception);
|
||||
extern "C" void ReportUnhandledException(KRef exception);
|
||||
|
||||
void ThrowException(KRef exception) {
|
||||
RuntimeAssert(exception != nullptr && IsInstance(exception, theThrowableTypeInfo),
|
||||
RuntimeAssert(exception != nullptr && IsInstanceInternal(exception, theThrowableTypeInfo),
|
||||
"Throwing something non-throwable");
|
||||
#if KONAN_NO_EXCEPTIONS
|
||||
PrintThrowable(exception);
|
||||
|
||||
@@ -59,6 +59,9 @@ int32_t Konan_DebugPrint(KRef obj);
|
||||
RUNTIME_USED RUNTIME_WEAK
|
||||
int32_t Konan_DebugIsArray(KRef obj);
|
||||
|
||||
RUNTIME_USED RUNTIME_WEAK
|
||||
int32_t Konan_DebugIsInstance(KRef obj, const TypeInfo* typeInfo);
|
||||
|
||||
// Returns number of fields in an objects, or elements in an array.
|
||||
RUNTIME_USED RUNTIME_WEAK
|
||||
int32_t Konan_DebugGetFieldCount(KRef obj);
|
||||
|
||||
@@ -48,9 +48,12 @@ extern "C" RUNTIME_NORETURN void Kotlin_ObjCExport_trapOnUndeclaredException(KRe
|
||||
static char kotlinExceptionOriginChar;
|
||||
|
||||
static bool isExceptionOfType(KRef exception, const TypeInfo** types) {
|
||||
if (types) for (int i = 0; types[i] != nullptr; ++i) {
|
||||
// TODO: use fast instance check when possible.
|
||||
if (IsInstance(exception, types[i])) return true;
|
||||
if (types) {
|
||||
const TypeInfo* type = exception->type_info();
|
||||
for (int i = 0; types[i] != nullptr; ++i) {
|
||||
// TODO: use fast instance check when possible.
|
||||
if (IsSubtype(type, types[i])) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
KBoolean IsInstance(const ObjHeader* obj, const TypeInfo* type_info) {
|
||||
// Note: keeping it for compatibility with external tools only, will be deprecated and removed in the future.
|
||||
RUNTIME_PURE RUNTIME_USED RUNTIME_WEAK KBoolean IsInstance(const ObjHeader* obj, const TypeInfo* type_info) {
|
||||
return IsInstanceInternal(obj, type_info);
|
||||
}
|
||||
|
||||
KBoolean IsInstanceInternal(const ObjHeader* obj, const TypeInfo* type_info) {
|
||||
// We assume null check is handled by caller.
|
||||
RuntimeAssert(obj != nullptr, "must not be null");
|
||||
const TypeInfo* obj_type_info = obj->type_info();
|
||||
@@ -42,7 +47,7 @@ KBoolean IsArray(KConstRef obj) {
|
||||
}
|
||||
|
||||
KBoolean Kotlin_TypeInfo_isInstance(KConstRef obj, KNativePtr typeInfo) {
|
||||
return IsInstance(obj, reinterpret_cast<const TypeInfo*>(typeInfo));
|
||||
return IsInstanceInternal(obj, reinterpret_cast<const TypeInfo*>(typeInfo));
|
||||
}
|
||||
|
||||
OBJ_GETTER(Kotlin_TypeInfo_getPackageName, KNativePtr typeInfo, KBoolean checkFlags) {
|
||||
|
||||
@@ -72,7 +72,8 @@ extern const TypeInfo* theWorkerBoundReferenceTypeInfo;
|
||||
extern const TypeInfo* theCleanerImplTypeInfo;
|
||||
extern const TypeInfo* theRegularWeakReferenceImplTypeInfo;
|
||||
|
||||
KBoolean IsInstance(const ObjHeader* obj, const TypeInfo* type_info) RUNTIME_PURE RUNTIME_USED; // Used in konan_lldb.py
|
||||
KBoolean IsInstance(const ObjHeader* obj, const TypeInfo* type_info) RUNTIME_PURE RUNTIME_USED RUNTIME_WEAK;
|
||||
KBoolean IsInstanceInternal(const ObjHeader* obj, const TypeInfo* type_info) RUNTIME_PURE;
|
||||
KBoolean IsSubtype(const TypeInfo* obj_type_info, const TypeInfo* type_info) RUNTIME_PURE;
|
||||
KBoolean IsSubclassFast(const TypeInfo* obj_type_info, int32_t lo, int32_t hi) RUNTIME_PURE;
|
||||
void CheckCast(const ObjHeader* obj, const TypeInfo* type_info);
|
||||
|
||||
Reference in New Issue
Block a user