Add a GTest for Assembly Stubs, Add some ARM64 and X86-64 Stubs
This GTest adds some runtime testing for the stubs that does not
rely on the compiler. This should allow to add or update the stubs
and do testing, especially on architectures without working compiler.
This test is a bit dangerous: if it doesn't know how to handle an
architecture, it will only log a warning. This is so that testing
does not break at the moment. The warning is forced to stdout, too,
so that it is always visible.
Add art_quick_check_cast to ARM64 and X86-64. Add art_quick_memcpy
to X86-64. The latter should be removed in a good compiler, as it is
practically only overhead. Add minor CFI information in ARM.
Change-Id: Ia9c6d0f4035eb1527c12b5f6067dece59e25528d
diff --git a/runtime/arch/arm64/quick_entrypoints_arm64.S b/runtime/arch/arm64/quick_entrypoints_arm64.S
index 6ce5d06..1350198 100644
--- a/runtime/arch/arm64/quick_entrypoints_arm64.S
+++ b/runtime/arch/arm64/quick_entrypoints_arm64.S
@@ -864,7 +864,58 @@
UNIMPLEMENTED art_quick_lock_object
UNIMPLEMENTED art_quick_unlock_object
-UNIMPLEMENTED art_quick_check_cast
+
+ /*
+ * Entry from managed code that calls artIsAssignableFromCode and on failure calls
+ * artThrowClassCastException.
+ */
+ .extern artThrowClassCastException
+ENTRY art_quick_check_cast
+ // Store arguments and link register
+ sub sp, sp, #32 // Stack needs to be 16b aligned on calls
+ .cfi_adjust_cfa_offset 32
+ stp x0, x1, [sp]
+ .cfi_rel_offset x0, 0
+ .cfi_rel_offset x1, 8
+ stp xSELF, xLR, [sp, #16]
+ .cfi_rel_offset x18, 16
+ .cfi_rel_offset x30, 24
+
+ // Call runtime code
+ bl artIsAssignableFromCode
+
+ // Check for exception
+ cbz x0, .Lthrow_class_cast_exception
+
+ // Restore and return
+ ldp x0, x1, [sp]
+ .cfi_restore x0
+ .cfi_restore x1
+ ldp xSELF, xLR, [sp, #16]
+ .cfi_restore x18
+ .cfi_restore x30
+ add sp, sp, #32
+ .cfi_adjust_cfa_offset -32
+ ret
+
+.Lthrow_class_cast_exception:
+ // Restore
+ ldp x0, x1, [sp]
+ .cfi_restore x0
+ .cfi_restore x1
+ ldp xSELF, xLR, [sp, #16]
+ .cfi_restore x18
+ .cfi_restore x30
+ add sp, sp, #32
+ .cfi_adjust_cfa_offset -32
+
+ SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
+ mov x2, xSELF // pass Thread::Current
+ mov x3, sp // pass SP
+ b artThrowClassCastException // (Class*, Class*, Thread*, SP)
+ brk 0 // We should not return here...
+END art_quick_check_cast
+
UNIMPLEMENTED art_quick_aput_obj_with_null_and_bound_check
UNIMPLEMENTED art_quick_aput_obj_with_bound_check
UNIMPLEMENTED art_quick_aput_obj