Module: wine Branch: master Commit: 4c7503395616ebfa3250270fd244f773c886348a URL: https://gitlab.winehq.org/wine/wine/-/commit/4c7503395616ebfa3250270fd244f77...
Author: Alexandre Julliard julliard@winehq.org Date: Tue May 21 20:33:59 2024 +0200
msvcp: Unify call_copy_ctor/call_dtor implementations.
---
dlls/msvcp90/exception.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-)
diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index 3abf776a508..3d569d8d855 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -1173,7 +1173,7 @@ static inline void *get_this_pointer( const this_ptr_offsets *off, void *object return object; }
-#ifdef __i386__ +#ifdef __ASM_USE_THISCALL_WRAPPER extern void call_copy_ctor( void *func, void *this, void *src, int has_vbase ); __ASM_GLOBAL_FUNC( call_copy_ctor, "pushl %ebp\n\t" @@ -1188,15 +1188,24 @@ __ASM_GLOBAL_FUNC( call_copy_ctor, "leave\n" __ASM_CFI(".cfi_def_cfa %esp,4\n\t") __ASM_CFI(".cfi_same_value %ebp\n\t") - "ret" ); + "ret" ) +extern void call_dtor( void *func, void *this ); +__ASM_GLOBAL_FUNC( call_dtor, + "movl 8(%esp),%ecx\n\t" + "call *4(%esp)\n\t" + "ret" ) #else static inline void call_copy_ctor( void *func, void *this, void *src, int has_vbase ) { TRACE( "calling copy ctor %p object %p src %p\n", func, this, src ); if (has_vbase) - ((void (__cdecl*)(void*, void*, BOOL))func)(this, src, 1); + ((void (__thiscall*)(void*, void*, BOOL))func)(this, src, 1); else - ((void (__cdecl*)(void*, void*))func)(this, src); + ((void (__thiscall*)(void*, void*))func)(this, src); +} +static inline void call_dtor( void *func, void *this ) +{ + ((void (__thiscall*)(void*))func)( this ); } #endif
@@ -1217,24 +1226,6 @@ void __cdecl __ExceptionPtrCreate(exception_ptr *ep) ep->ref = NULL; }
-#ifdef __ASM_USE_THISCALL_WRAPPER -extern void call_dtor(const cxx_exception_type *type, void *func, void *object); - -__ASM_GLOBAL_FUNC( call_dtor, - "movl 12(%esp),%ecx\n\t" - "call *8(%esp)\n\t" - "ret" ); -#elif __x86_64__ -static inline void call_dtor(const cxx_exception_type *type, unsigned int dtor, void *object) -{ - char *base = RtlPcToFileHeader((void*)type, (void**)&base); - void (__cdecl *func)(void*) = (void*)(base + dtor); - func(object); -} -#else -#define call_dtor(type, func, object) ((void (__thiscall*)(void*))(func))(object) -#endif - /********************************************************************* * ?__ExceptionPtrDestroy@@YAXPAX@Z * ?__ExceptionPtrDestroy@@YAXPEAX@Z @@ -1252,8 +1243,9 @@ void __cdecl __ExceptionPtrDestroy(exception_ptr *ep) { const cxx_exception_type *type = (void*)ep->rec->ExceptionInformation[2]; void *obj = (void*)ep->rec->ExceptionInformation[1]; + uintptr_t base = rtti_rva_base( type );
- if (type && type->destructor) call_dtor(type, type->destructor, obj); + if (type && type->destructor) call_dtor( rtti_rva(type->destructor, base), obj ); HeapFree(GetProcessHeap(), 0, obj); }