From c3abd753c9f62597e2beebecceb7bd5f900a4294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Mon, 30 Jan 2023 15:18:58 +0100 Subject: [PATCH] 2023-01-30 15:18 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/arc4.c ! include hbarc4.h instead of arc4.h which does not contain required for dynamic libraries export attributes in function declaration * src/vm/classes.c ! cleaned module symbol range checking * src/vm/arrays.c % optimized AClone() and hb_HClone() * src/vm/hvmall.c % changed the order of included files to keep alive function macros undefined in garbage.c and fm.c * src/vm/hvm.c ! fixed hb_vmGetRealFuncSym() to work with PRG functions written in C and registered in HVM without their own symbol table * src/vm/dynsym.c ; comment updated --- ChangeLog.txt | 23 +++++++++++++++++++++++ src/rtl/arc4.c | 2 +- src/vm/arrays.c | 26 +++++++++++++++++++------- src/vm/classes.c | 2 +- src/vm/dynsym.c | 2 +- src/vm/hvm.c | 3 ++- src/vm/hvmall.c | 4 ++-- 7 files changed, 49 insertions(+), 13 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index a6a86c1002..6f1804c118 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,29 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2023-01-30 15:18 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/arc4.c + ! include hbarc4.h instead of arc4.h which does not contain + required for dynamic libraries export attributes in function + declaration + + * src/vm/classes.c + ! cleaned module symbol range checking + + * src/vm/arrays.c + % optimized AClone() and hb_HClone() + + * src/vm/hvmall.c + % changed the order of included files to keep alive function macros + undefined in garbage.c and fm.c + + * src/vm/hvm.c + ! fixed hb_vmGetRealFuncSym() to work with PRG functions written in C + and registered in HVM without their own symbol table + + * src/vm/dynsym.c + ; comment updated + 2023-01-23 12:46 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * include/harbour.hbx ! added missing hb_socketSetNoSigPipe() diff --git a/src/rtl/arc4.c b/src/rtl/arc4.c index fdc237ce7d..e6650b6399 100644 --- a/src/rtl/arc4.c +++ b/src/rtl/arc4.c @@ -43,7 +43,7 @@ * RC4 is a registered trademark of RSA Laboratories. */ -#include "arc4.h" +#include "hbarc4.h" #include "hbdate.h" #include "hbthread.h" diff --git a/src/vm/arrays.c b/src/vm/arrays.c index a19af5c7b9..14b1857fd1 100644 --- a/src/vm/arrays.c +++ b/src/vm/arrays.c @@ -1505,17 +1505,26 @@ static void hb_arrayCloneBody( PHB_ITEM pDest, PHB_ITEM pArray, PHB_NESTED_CLONE void hb_nestedCloneInit( PHB_NESTED_CLONED pClonedList, void * pValue, PHB_ITEM pDest ) { - pClonedList->nSize = 16; - pClonedList->nCount = 1; - pClonedList->pRefs = ( PHB_NESTED_REF ) - hb_xgrab( pClonedList->nSize * sizeof( HB_NESTED_REF ) ); - pClonedList->pRefs[ 0 ].value = pValue; - pClonedList->pRefs[ 0 ].pDest = pDest; + if( hb_gcRefCount( pValue ) > 1 ) + { + pClonedList->nCount = 1; + pClonedList->nSize = 16; + pClonedList->pRefs = ( PHB_NESTED_REF ) + hb_xgrab( pClonedList->nSize * sizeof( HB_NESTED_REF ) ); + pClonedList->pRefs[ 0 ].value = pValue; + pClonedList->pRefs[ 0 ].pDest = pDest; + } + else + { + pClonedList->nCount = pClonedList->nSize = 0; + pClonedList->pRefs = NULL; + } } void hb_nestedCloneFree( PHB_NESTED_CLONED pClonedList ) { - hb_xfree( pClonedList->pRefs ); + if( pClonedList->pRefs ) + hb_xfree( pClonedList->pRefs ); } static HB_BOOL hb_nestedCloneFind( PHB_NESTED_CLONED pClonedList, void * pValue, PHB_ITEM pDest ) @@ -1523,6 +1532,9 @@ static HB_BOOL hb_nestedCloneFind( PHB_NESTED_CLONED pClonedList, void * pValue, HB_SIZE nFirst, nLast, nMiddle; PHB_NESTED_REF pRef; + if( hb_gcRefCount( pValue ) <= 1 ) + return HB_FALSE; + nFirst = 0; nLast = pClonedList->nCount; nMiddle = ( nFirst + nLast ) >> 1; diff --git a/src/vm/classes.c b/src/vm/classes.c index c8a9572d09..653bc8b12c 100644 --- a/src/vm/classes.c +++ b/src/vm/classes.c @@ -1064,7 +1064,7 @@ static HB_BOOL hb_clsIsFriendSymbol( PCLASS pClass, PHB_SYMB pSym ) HB_TRACE( HB_TR_DEBUG, ( "hb_clsIsFriendSymbol(%p,%p)", ( void * ) pClass, ( void * ) pSym ) ); - if( pSym >= pClass->pFriendModule && + if( pClass->pFriendModule && pSym >= pClass->pFriendModule && pSym < pClass->pFriendModule + pClass->uiFriendModule ) return HB_TRUE; diff --git a/src/vm/dynsym.c b/src/vm/dynsym.c index cc09b66b1b..2d60c0bc0e 100644 --- a/src/vm/dynsym.c +++ b/src/vm/dynsym.c @@ -267,7 +267,7 @@ PHB_DYNS hb_dynsymNew( PHB_SYMB pSymbol ) if( pDynSym->pSymbol->value.pFunPtr == pSymbol->value.pFunPtr ) { /* The addresses have been updated, f.e. in such way works GCC - * in Linux (but not MinGW and DJGPP) if user will allow to create + * in Linux (but not MinGW and DJGPP) if user allows to create * binaries with multiple symbols by * -Wl,--allow-multiple-definition * when whole module cannot be cleanly replaced. diff --git a/src/vm/hvm.c b/src/vm/hvm.c index fd9a73369f..7f41c85644 100644 --- a/src/vm/hvm.c +++ b/src/vm/hvm.c @@ -7533,7 +7533,8 @@ PHB_SYMB hb_vmGetRealFuncSym( PHB_SYMB pSym ) if( pSym && ! ( pSym->scope.value & HB_FS_LOCAL ) ) { pSym = pSym->pDynSym && - ( pSym->pDynSym->pSymbol->scope.value & HB_FS_LOCAL ) ? + ( ( pSym->pDynSym->pSymbol->scope.value & HB_FS_LOCAL ) || + pSym->pDynSym->pSymbol->value.pFunPtr == pSym->value.pFunPtr ) ? pSym->pDynSym->pSymbol : NULL; } diff --git a/src/vm/hvmall.c b/src/vm/hvmall.c index d76a24ba81..3234eaa359 100644 --- a/src/vm/hvmall.c +++ b/src/vm/hvmall.c @@ -106,8 +106,8 @@ #include "set.c" #include "memvars.c" #include "thread.c" -#include "garbage.c" -#include "fm.c" #include "strapi.c" #include "extend.c" #include "estack.c" +#include "garbage.c" +#include "fm.c"