From e2fde5133cd050614c643944fa09e7ff42cd1822 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 17 Jan 2007 12:49:25 +0000 Subject: [PATCH] 2007-01-17 13:50 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/compiler/gencc.c * harbour/source/vm/hvm.c ! fixed typo in hb_xvmGreaterEqualThenIntIs() - <= was used instead of >= ! fixed :¯o() messages used in WITH OBJECT structure and -gc3 output + added some missing optimizations in -gc3 output --- harbour/ChangeLog | 9 +++++ harbour/source/compiler/gencc.c | 68 +++++++++++++++++++++++---------- harbour/source/vm/hvm.c | 37 ++++++++---------- 3 files changed, 73 insertions(+), 41 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9c285b28fe..5f57343934 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-01-17 13:50 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/compiler/gencc.c + * harbour/source/vm/hvm.c + ! fixed typo in hb_xvmGreaterEqualThenIntIs() - <= was used instead + of >= + ! fixed :¯o() messages used in WITH OBJECT structure and -gc3 + output + + added some missing optimizations in -gc3 output + 2007-01-17 03:55 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/libct/ctc.c * harbour/contrib/libct/files.c diff --git a/harbour/source/compiler/gencc.c b/harbour/source/compiler/gencc.c index 7df2c9dc00..e397114b35 100644 --- a/harbour/source/compiler/gencc.c +++ b/harbour/source/compiler/gencc.c @@ -79,29 +79,53 @@ static int hb_gencc_checkJumpCondAhead( LONG lValue, PFUNCTION pFunc, ULONG lPCo { if( HB_GENC_GETLABEL( lPCodePos + 1 ) == 0 ) { + LONG lOffset = 0; + BOOL fNot = FALSE; + int iSize = 0; + switch( pFunc->pCode[ lPCodePos + 1 ] ) { case HB_P_JUMPFALSENEAR: - fprintf( cargo->yyc, "\tif( hb_xvm%sIntIs( %ld, &fValue ) ) break;\n", - szFunc, lValue ); - fprintf( cargo->yyc, "\tif( !fValue )\n\t\tgoto lab%05ld;\n", - HB_GENC_GETLABEL( lPCodePos + 1 + - ( signed char ) ( pFunc->pCode[ lPCodePos + 2 ] ) ) ); - return 3; + lOffset = ( signed char ) ( pFunc->pCode[ lPCodePos + 2 ] ); + fNot = TRUE; + iSize = 3; + break; + case HB_P_JUMPFALSE: - fprintf( cargo->yyc, "\tif( hb_xvm%sIntIs( %ld, &fValue ) ) break;\n", - szFunc, lValue ); - fprintf( cargo->yyc, "\tif( !fValue )\n\t\tgoto lab%05ld;\n", - HB_GENC_GETLABEL( lPCodePos + 1 + - HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 2 ] ) ) ); - return 4; + lOffset = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 2 ] ); + fNot = TRUE; + iSize = 4; + break; + case HB_P_JUMPFALSEFAR: - fprintf( cargo->yyc, "\tif( hb_xvm%sIntIs( %ld, &fValue ) ) break;\n", - szFunc, lValue ); - fprintf( cargo->yyc, "\tif( !fValue )\n\t\tgoto lab%05ld;\n", - HB_GENC_GETLABEL( lPCodePos + 1 + - HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 2 ] ) ) ); - return 5; + lOffset = HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 2 ] ); + fNot = TRUE; + iSize = 5; + break; + + case HB_P_JUMPTRUENEAR: + lOffset = ( signed char ) ( pFunc->pCode[ lPCodePos + 2 ] ); + iSize = 3; + break; + + case HB_P_JUMPTRUE: + lOffset = HB_PCODE_MKSHORT( &pFunc->pCode[ lPCodePos + 2 ] ); + iSize = 4; + break; + + case HB_P_JUMPTRUEFAR: + lOffset = HB_PCODE_MKINT24( &pFunc->pCode[ lPCodePos + 2 ] ); + iSize = 5; + break; + } + + if( iSize ) + { + fprintf( cargo->yyc, "\tif( hb_xvm%sIntIs( %ld, &fValue ) ) break;\n", + szFunc, lValue ); + fprintf( cargo->yyc, "\tif( %sfValue )\n\t\tgoto lab%05ld;\n", + fNot ? "!" : "", HB_GENC_GETLABEL( lPCodePos + 1 + lOffset ) ); + return iSize; } } fprintf( cargo->yyc, "\tif( hb_xvm%sInt( %ld ) ) break;\n", @@ -1688,10 +1712,14 @@ static HB_GENC_FUNC( hb_p_withobjectend ) static HB_GENC_FUNC( hb_p_withobjectmessage ) { + USHORT usSym = HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ); HB_GENC_LABEL(); - fprintf( cargo->yyc, "\thb_xvmWithObjectMessage( symbols + %hu );\n", - HB_PCODE_MKUSHORT( &pFunc->pCode[ lPCodePos + 1 ] ) ); + if( usSym == 0xFFFF ) + fprintf( cargo->yyc, "\thb_xvmWithObjectMessage( NULL );\n" ); + else + fprintf( cargo->yyc, "\thb_xvmWithObjectMessage( symbols + %hu );\n", + usSym ); return 3; } diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 87f11d077b..fb42fe5f57 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -574,6 +574,8 @@ HB_EXPORT int hb_vmQuit( void ) hb_dynsymRelease(); /* releases the dynamic symbol table */ hb_cdpReleaseAll(); /* releases codepages */ + hb_itemClear( hb_stackReturnItem() ); + /* release all known garbage */ if( hb_xquery( HB_MEM_USEDMAX ) ) /* check if fmstat is ON */ hb_gcCollectAll(); @@ -7096,7 +7098,7 @@ HB_EXPORT BOOL hb_xvmEqualIntIs( LONG lValue, BOOL * pfValue ) if( HB_IS_NIL( pItem ) ) { * pfValue = FALSE; - hb_stackPop(); + hb_stackDec(); } else if( HB_IS_NUMINT( pItem ) ) { @@ -7201,7 +7203,7 @@ HB_EXPORT BOOL hb_xvmNotEqualIntIs( LONG lValue, BOOL * pfValue ) if( HB_IS_NIL( pItem ) ) { * pfValue = TRUE; - hb_stackPop(); + hb_stackDec(); } else if( HB_IS_NUMINT( pItem ) ) { @@ -7257,13 +7259,11 @@ HB_EXPORT BOOL hb_xvmLessThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - HB_LONG lNumber = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber < ( HB_LONG ) lValue ); + hb_vmPushLogical( hb_vmPopHBLong() < ( HB_LONG ) lValue ); } else if( HB_IS_NUMERIC( pItem ) ) { - double dNumber = hb_vmPopNumber(); - hb_vmPushLogical( dNumber < ( double ) lValue ); + hb_vmPushLogical( hb_vmPopNumber() < ( double ) lValue ); } else if( hb_objHasOperator( pItem, HB_OO_OP_LESS ) ) { @@ -7352,13 +7352,11 @@ HB_EXPORT BOOL hb_xvmLessEqualThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - HB_LONG lNumber = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber <= ( HB_LONG ) lValue ); + hb_vmPushLogical( hb_vmPopHBLong() <= ( HB_LONG ) lValue ); } else if( HB_IS_NUMERIC( pItem ) ) { - double dNumber = hb_vmPopNumber(); - hb_vmPushLogical( dNumber <= ( double ) lValue ); + hb_vmPushLogical( hb_vmPopNumber() <= ( double ) lValue ); } else if( hb_objHasOperator( pItem, HB_OO_OP_LESSEQUAL ) ) { @@ -7447,13 +7445,11 @@ HB_EXPORT BOOL hb_xvmGreaterThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - HB_LONG lNumber = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber > ( HB_LONG ) lValue ); + hb_vmPushLogical( hb_vmPopHBLong() > ( HB_LONG ) lValue ); } else if( HB_IS_NUMERIC( pItem ) ) { - double dNumber = hb_vmPopNumber(); - hb_vmPushLogical( dNumber > ( double ) lValue ); + hb_vmPushLogical( hb_vmPopNumber() > ( double ) lValue ); } else if( hb_objHasOperator( pItem, HB_OO_OP_GREATER ) ) { @@ -7542,13 +7538,11 @@ HB_EXPORT BOOL hb_xvmGreaterEqualThenInt( LONG lValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - HB_LONG lNumber = hb_vmPopHBLong(); - hb_vmPushLogical( lNumber >= ( HB_LONG ) lValue ); + hb_vmPushLogical( hb_vmPopHBLong() >= ( HB_LONG ) lValue ); } else if( HB_IS_NUMERIC( pItem ) ) { - double dNumber = hb_vmPopNumber(); - hb_vmPushLogical( dNumber >= ( double ) lValue ); + hb_vmPushLogical( hb_vmPopNumber() >= ( double ) lValue ); } else if( hb_objHasOperator( pItem, HB_OO_OP_GREATEREQUAL ) ) { @@ -7585,11 +7579,11 @@ HB_EXPORT BOOL hb_xvmGreaterEqualThenIntIs( LONG lValue, BOOL * pfValue ) pItem = hb_stackItemFromTop( -1 ); if( HB_IS_NUMINT( pItem ) ) { - * pfValue = hb_vmPopHBLong() <= ( HB_LONG ) lValue; + * pfValue = hb_vmPopHBLong() >= ( HB_LONG ) lValue; } else if( HB_IS_NUMERIC( pItem ) ) { - * pfValue = hb_vmPopNumber() <= ( double ) lValue; + * pfValue = hb_vmPopNumber() >= ( double ) lValue; } else if( hb_objHasOperator( pItem, HB_OO_OP_GREATEREQUAL ) ) { @@ -8417,7 +8411,8 @@ HB_EXPORT void hb_xvmWithObjectMessage( PHB_SYMB pSymbol ) { HB_TRACE(HB_TR_DEBUG, ("hb_xvmWithObjectMessage(%p)", pSymbol)); - hb_vmPushSymbol( pSymbol ); + if( pSymbol ) + hb_vmPushSymbol( pSymbol ); hb_vmPush( hb_stackWithObjectItem() ); }