riscv64: add suport for mem* trampolines
Perf results: go/berberis-mem-trampolines-perf-results
Bug: 330396874
Test: m berberis_all
Change-Id: Id5d5e0dad57ed7a55e1d5a1dabc30f69d08930de
diff --git a/android_api/libc/proxy/custom_trampolines_riscv64_to_x86_64.json b/android_api/libc/proxy/custom_trampolines_riscv64_to_x86_64.json
index e57d8a7..c177ad3 100644
--- a/android_api/libc/proxy/custom_trampolines_riscv64_to_x86_64.json
+++ b/android_api/libc/proxy/custom_trampolines_riscv64_to_x86_64.json
@@ -234,6 +234,24 @@
"header": "setjump.h",
"signature": "vpi"
},
+ "memset": {
+ "call_method": "default",
+ "comment": "performance optimization",
+ "is_compatible": true,
+ "signature": "ppii"
+ },
+ "memcpy": {
+ "call_method": "default",
+ "comment": "performance optimization",
+ "is_compatible": true,
+ "signature": "pppi"
+ },
+ "memcmp": {
+ "call_method": "default",
+ "comment": "performance optimization",
+ "is_compatible": true,
+ "signature": "ippi"
+ },
"native_bridge___cxa_thread_atexit_impl": {
"call_method": "custom_trampoline",
"header": "c++ abi"
@@ -570,4 +588,4 @@
}
},
"types": {}
-}
+}
\ No newline at end of file
diff --git a/android_api/libc/proxy/trampolines_riscv64_to_x86_64-inl.h b/android_api/libc/proxy/trampolines_riscv64_to_x86_64-inl.h
index ad316dc..8b5ab35 100644
--- a/android_api/libc/proxy/trampolines_riscv64_to_x86_64-inl.h
+++ b/android_api/libc/proxy/trampolines_riscv64_to_x86_64-inl.h
@@ -36,6 +36,9 @@
{"getnameinfo", GetTrampolineFunc<auto(void*, int32_t, void*, int32_t, void*, int32_t, int32_t) -> int32_t>(), reinterpret_cast<void*>(NULL)},
{"gettimeofday", GetTrampolineFunc<auto(void*, void*) -> int32_t>(), reinterpret_cast<void*>(NULL)},
{"longjmp", GetTrampolineFunc<auto(void*, int32_t) -> void>(), reinterpret_cast<void*>(DoThunk_longjmp)},
+{"memcmp", GetTrampolineFunc<auto(void*, void*, int32_t) -> int32_t>(), reinterpret_cast<void*>(NULL)},
+{"memcpy", GetTrampolineFunc<auto(void*, void*, int32_t) -> void*>(), reinterpret_cast<void*>(NULL)},
+{"memset", GetTrampolineFunc<auto(void*, int32_t, int32_t) -> void*>(), reinterpret_cast<void*>(NULL)},
{"native_bridge___cxa_thread_atexit_impl", DoCustomTrampoline_native_bridge___cxa_thread_atexit_impl, reinterpret_cast<void*>(DoBadThunk)},
{"native_bridge_aligned_alloc", GetTrampolineFunc<auto(size_t, size_t) -> void*>(), reinterpret_cast<void*>(aligned_alloc)},
{"native_bridge_calloc", GetTrampolineFunc<auto(size_t, size_t) -> void*>(), reinterpret_cast<void*>(calloc)},
diff --git a/android_api/libc/stubs_riscv64.cpp b/android_api/libc/stubs_riscv64.cpp
index 9855a8b..88c3711 100644
--- a/android_api/libc/stubs_riscv64.cpp
+++ b/android_api/libc/stubs_riscv64.cpp
@@ -53,6 +53,9 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(getnameinfo);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(gettimeofday);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(longjmp);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(memcmp);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(memcpy);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(memset);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge___cxa_thread_atexit_impl);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_aligned_alloc);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_calloc);
@@ -148,6 +151,9 @@
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", getnameinfo);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", gettimeofday);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", longjmp);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", memcmp);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", memcpy);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", memset);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge___cxa_thread_atexit_impl);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_aligned_alloc);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_calloc);