Implement RTTI related runtime support.
For passing IntMath test.
Change-Id: I1d2a23480c2848e0834f5d2a6169a480e4498631
diff --git a/src/compiler_llvm/runtime_support_llvm.cc b/src/compiler_llvm/runtime_support_llvm.cc
index 0bf2699..917b57e 100644
--- a/src/compiler_llvm/runtime_support_llvm.cc
+++ b/src/compiler_llvm/runtime_support_llvm.cc
@@ -422,11 +422,21 @@
// RTTI
//----------------------------------------------------------------------------
-int32_t art_is_assignable_from_code(Object* dest_type, Object* src_type) {
- return 0;
+int32_t art_is_assignable_from_code(const Class* dest_type, const Class* src_type) {
+ DCHECK(dest_type != NULL);
+ DCHECK(src_type != NULL);
+ return dest_type->IsAssignableFrom(src_type) ? 1 : 0;
}
-void art_check_cast_from_code(Object* dest_type, Object* src_type) {
+void art_check_cast_from_code(const Class* dest_type, const Class* src_type) {
+ DCHECK(dest_type->IsClass()) << PrettyClass(dest_type);
+ DCHECK(src_type->IsClass()) << PrettyClass(src_type);
+ if (UNLIKELY(!dest_type->IsAssignableFrom(src_type))) {
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/ClassCastException;",
+ "%s cannot be cast to %s",
+ PrettyDescriptor(dest_type).c_str(),
+ PrettyDescriptor(src_type).c_str());
+ }
}
//----------------------------------------------------------------------------