mirror of
https://github.com/FEX-Emu/FEX.git
synced 2024-11-23 14:40:14 +00:00
Thunks: Flip order of nullptr check and custom repacking
This commit is contained in:
parent
162733130c
commit
fb15cf0db4
@ -275,14 +275,14 @@ struct repack_wrapper {
|
|||||||
~repack_wrapper() {
|
~repack_wrapper() {
|
||||||
// TODO: Properly detect opaque types
|
// TODO: Properly detect opaque types
|
||||||
if constexpr (requires(guest_layout<T> t, decltype(data) h) { t.get_pointer(); (bool)h; *data; }) {
|
if constexpr (requires(guest_layout<T> t, decltype(data) h) { t.get_pointer(); (bool)h; *data; }) {
|
||||||
// NOTE: It's assumed that the native host library didn't modify any
|
if (data) {
|
||||||
// const-pointees, so we skip automatic exit repacking for them.
|
// NOTE: It's assumed that the native host library didn't modify any
|
||||||
// However, *custom* repacking must still be applied since it might
|
// const-pointees, so we skip automatic exit repacking for them.
|
||||||
// have unrelated side effects (such as deallocation of memory
|
// However, *custom* repacking must still be applied since it
|
||||||
// reserved on entry)
|
// might have unrelated side effects (such as deallocation of
|
||||||
if (!fex_apply_custom_repacking_exit(*orig_arg.get_pointer(), *data)) {
|
// memory reserved on entry)
|
||||||
if constexpr (!std::is_const_v<std::remove_pointer_t<T>>) { // Skip exit-repacking for const pointees
|
if (!fex_apply_custom_repacking_exit(*orig_arg.get_pointer(), *data)) {
|
||||||
if (data) {
|
if constexpr (!std::is_const_v<std::remove_pointer_t<T>>) { // Skip exit-repacking for const pointees
|
||||||
constexpr bool is_compatible = has_compatible_data_layout<T> && std::is_same_v<T, GuestT>;
|
constexpr bool is_compatible = has_compatible_data_layout<T> && std::is_same_v<T, GuestT>;
|
||||||
if constexpr (!is_compatible && std::is_class_v<std::remove_pointer_t<T>>) {
|
if constexpr (!is_compatible && std::is_class_v<std::remove_pointer_t<T>>) {
|
||||||
*orig_arg.get_pointer() = to_guest(*data); // TODO: Only if annotated as out-parameter
|
*orig_arg.get_pointer() = to_guest(*data); // TODO: Only if annotated as out-parameter
|
||||||
|
Loading…
Reference in New Issue
Block a user