From a6153e5087c31d73595e62b2131f7cd184060f85 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 29 Mar 2010 20:43:03 +0000 Subject: [PATCH] 2010-03-29 22:42 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbthread.h * harbour/src/vm/thread.c % use thread local memory to optimize _hb_gettid() % use _hb_gettid() instead of _gettid() in OS2 GCC builds * harbour/src/vm/hvm.c % minor speed improvement * harbour/src/vm/memvars.c ! cleaned local vars detaching code --- harbour/ChangeLog | 12 ++++++++++++ harbour/include/hbthread.h | 2 +- harbour/src/vm/hvm.c | 3 +-- harbour/src/vm/memvars.c | 25 ++++++++++++++----------- harbour/src/vm/thread.c | 36 ++++++++++++++++++++++++++++-------- 5 files changed, 56 insertions(+), 22 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5f18330e3d..3f6f64ca6e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,18 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-03-29 22:42 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbthread.h + * harbour/src/vm/thread.c + % use thread local memory to optimize _hb_gettid() + % use _hb_gettid() instead of _gettid() in OS2 GCC builds + + * harbour/src/vm/hvm.c + % minor speed improvement + + * harbour/src/vm/memvars.c + ! cleaned local vars detaching code + 2010-03-29 22:34 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg ! Fixed to always convert pathseps in icon filename to forward diff --git a/harbour/include/hbthread.h b/harbour/include/hbthread.h index a25ed45669..9e8fad4635 100644 --- a/harbour/include/hbthread.h +++ b/harbour/include/hbthread.h @@ -230,7 +230,7 @@ HB_EXTERN_BEGIN # define HB_THREAD_END _endthread(); return; # define HB_THREAD_RAWEND return; -# if defined( __GNUC__ ) +# if defined( __GNUC__ ) && 0 # define HB_THREAD_SELF() ( ( TID ) _gettid() ) # else # define HB_THREAD_SELF() ( ( TID ) _hb_gettid() ) diff --git a/harbour/src/vm/hvm.c b/harbour/src/vm/hvm.c index 215d66d72d..f4bd8d588a 100644 --- a/harbour/src/vm/hvm.c +++ b/harbour/src/vm/hvm.c @@ -4535,10 +4535,9 @@ static void hb_vmEnumReference( PHB_ITEM pBase ) HB_TRACE(HB_TR_DEBUG, ("hb_vmEnumReference(%p)", pBase)); pEnumExtRef = ( PHB_ENUMREF ) hb_xgrab( sizeof( HB_ENUMREF ) ); - pEnumExtRef->basevalue.type = HB_IT_NIL; pEnumExtRef->oldvalue.type = HB_IT_NIL; pEnumExtRef->enumref.type = HB_IT_NIL; - hb_itemMove( &pEnumExtRef->basevalue, pBase ); + hb_itemRawCpy( &pEnumExtRef->basevalue, pBase ); pBase->type = HB_IT_BYREF | HB_IT_EXTREF; pBase->item.asExtRef.value = ( void * ) pEnumExtRef; pBase->item.asExtRef.func = &s_EnumExtRef; diff --git a/harbour/src/vm/memvars.c b/harbour/src/vm/memvars.c index 9c96d58ece..c717184ae4 100644 --- a/harbour/src/vm/memvars.c +++ b/harbour/src/vm/memvars.c @@ -167,20 +167,23 @@ HB_ITEM_PTR hb_memvarDetachLocal( PHB_ITEM pLocal ) { do { - if( HB_IS_MEMVAR( pLocal ) ) + if( HB_IS_MEMVAR( pLocal ) || HB_IS_EXTREF( pLocal ) ) break; - else if( HB_IS_ENUM( pLocal ) && !pLocal->item.asEnum.valuePtr ) + else if( HB_IS_ENUM( pLocal ) ) { - PHB_ITEM pBase = HB_IS_BYREF( pLocal->item.asEnum.basePtr ) ? - hb_itemUnRef( pLocal->item.asEnum.basePtr ) : - pLocal->item.asEnum.basePtr; - if( HB_IS_ARRAY( pBase ) ) + if( !pLocal->item.asEnum.valuePtr ) { - PHB_ITEM pItem = hb_itemNew( NULL ); - hb_arrayGetItemRef( pBase, pLocal->item.asEnum.offset, pItem ); - pLocal->item.asEnum.valuePtr = pItem; - pLocal = pItem; - break; + PHB_ITEM pBase = HB_IS_BYREF( pLocal->item.asEnum.basePtr ) ? + hb_itemUnRef( pLocal->item.asEnum.basePtr ) : + pLocal->item.asEnum.basePtr; + if( HB_IS_ARRAY( pBase ) ) + { + PHB_ITEM pItem = hb_itemNew( NULL ); + hb_arrayGetItemRef( pBase, pLocal->item.asEnum.offset, pItem ); + pLocal->item.asEnum.valuePtr = pItem; + pLocal = pItem; + break; + } } } else if( pLocal->item.asRefer.value >= 0 && diff --git a/harbour/src/vm/thread.c b/harbour/src/vm/thread.c index c6e3da7f1b..98660dc76f 100644 --- a/harbour/src/vm/thread.c +++ b/harbour/src/vm/thread.c @@ -441,16 +441,36 @@ static HB_BOOL _hb_thread_cond_wait( HB_COND_T * cond, HB_RAWCRITICAL_T * critic #endif #if defined( HB_OS_OS2 ) && !defined( __GNUC__ ) -ULONG _hb_gettid( void ) -{ - ULONG tid = 0; - PTIB ptib = NULL; +#if 0 + ULONG _hb_gettid( void ) + { + ULONG tid = 0; + PTIB ptib = NULL; - if( DosGetInfoBlocks( &ptib, NULL ) == NO_ERROR ) - tid = ptib->tib_ptib2->tib2_ultid; + if( DosGetInfoBlocks( &ptib, NULL ) == NO_ERROR ) + tid = ptib->tib_ptib2->tib2_ultid; - return tid; -} + return tid; + } +#else + ULONG _hb_gettid( void ) + { + static PULONG s_pThID = NULL; + + if( !s_pThID ) + { + DosAllocThreadLocalMemory( 1, &s_pThID ); + *s_pThID = 0; + } + if( ! *s_pThID ) + { + PTIB ptib = NULL; + if( DosGetInfoBlocks( &ptib, NULL ) == NO_ERROR ) + *s_pThID = ptib->tib_ptib2->tib2_ultid; + } + return *s_pThID; + } +#endif #endif /*