From c72ee124b367911bc9a01ccfa71d8792d936a86a Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 2 Jun 2011 19:05:56 +0000 Subject: [PATCH] 2011-06-02 21:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/vm/thread.c * set sleep timeout in *nix version of hb_threadReleaseCPU() to 10 ms * harbour/src/compiler/hbpcode.c ! fixed typo which could cause compile time crash when debugger code is generated (-b) and file name with extenssion has only one or two characters * harbour/include/hbcompdf.h * harbour/src/compiler/hbmain.c * harbour/src/compiler/hbstripl.c * harbour/src/compiler/harbour.y * harbour/src/compiler/harbour.yyc ! removed old code designed to optimize line numbers generated in PCODE. It cannot work correctly and in some cases it was generating HB_P_LINE pcodes in wrong places. % enabled new code for HB_P_LINE PCODEs optimization also in debugger (-b) compilation so it can be used to replaced the old one. --- harbour/ChangeLog | 20 ++++++++++++++++++++ harbour/include/hbcompdf.h | 1 - harbour/src/compiler/harbour.y | 1 - harbour/src/compiler/harbour.yyc | 1 - harbour/src/compiler/hbmain.c | 25 +++---------------------- harbour/src/compiler/hbpcode.c | 2 +- harbour/src/compiler/hbstripl.c | 6 ++++-- harbour/src/vm/thread.c | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 70cbe8f773..5da6b7a49a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,26 @@ The license applies to all entries newer than 2009-04-28. */ +2011-06-02 21:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/vm/thread.c + * set sleep timeout in *nix version of hb_threadReleaseCPU() to 10 ms + + * harbour/src/compiler/hbpcode.c + ! fixed typo which could cause compile time crash when debugger code + is generated (-b) and file name with extenssion has only one or + two characters + + * harbour/include/hbcompdf.h + * harbour/src/compiler/hbmain.c + * harbour/src/compiler/hbstripl.c + * harbour/src/compiler/harbour.y + * harbour/src/compiler/harbour.yyc + ! removed old code designed to optimize line numbers generated in PCODE. + It cannot work correctly and in some cases it was generating HB_P_LINE + pcodes in wrong places. + % enabled new code for HB_P_LINE PCODEs optimization also in debugger (-b) + compilation so it can be used to replaced the old one. + 2011-06-02 14:51 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/wapi_winbase.c ! fixed to pull proper default getlasterror value diff --git a/harbour/include/hbcompdf.h b/harbour/include/hbcompdf.h index 3ac0e37821..3f66e1cceb 100644 --- a/harbour/include/hbcompdf.h +++ b/harbour/include/hbcompdf.h @@ -780,7 +780,6 @@ typedef struct _HB_COMP HB_SIZE nOutBufSize; /* memory output buffer size */ HB_BYTE * pOutBuf; /* memory output buffer address */ - HB_SIZE lastLinePos; /* position of last opcode with line number */ int lastLine; /* last generated in PCODE line number */ int currLine; /* currently compiled line number */ const char * lastModule; /* last generated in PCODE module name */ diff --git a/harbour/src/compiler/harbour.y b/harbour/src/compiler/harbour.y index 1da7aa48b5..1470e06799 100644 --- a/harbour/src/compiler/harbour.y +++ b/harbour/src/compiler/harbour.y @@ -1065,7 +1065,6 @@ CodeBlock : BlockHead HB_COMP_PARAM->functions.pLast->pCode + $3, HB_COMP_PARAM->functions.pLast->nPCodePos - $3 ); HB_COMP_PARAM->functions.pLast->nPCodePos = $3; - HB_COMP_PARAM->lastLinePos = 0; } ; diff --git a/harbour/src/compiler/harbour.yyc b/harbour/src/compiler/harbour.yyc index 407076c883..c43f400402 100644 --- a/harbour/src/compiler/harbour.yyc +++ b/harbour/src/compiler/harbour.yyc @@ -5719,7 +5719,6 @@ yyreduce: HB_COMP_PARAM->functions.pLast->pCode + (yyvsp[(3) - (5)].sNumber), HB_COMP_PARAM->functions.pLast->nPCodePos - (yyvsp[(3) - (5)].sNumber) ); HB_COMP_PARAM->functions.pLast->nPCodePos = (yyvsp[(3) - (5)].sNumber); - HB_COMP_PARAM->lastLinePos = 0; ;} break; diff --git a/harbour/src/compiler/hbmain.c b/harbour/src/compiler/hbmain.c index 17a224a594..bd031d97e9 100644 --- a/harbour/src/compiler/hbmain.c +++ b/harbour/src/compiler/hbmain.c @@ -1284,7 +1284,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL ) HB_BYTE * pCode = HB_COMP_PARAM->functions.pLast->pCode; HB_SIZE * pNOOPs, * pJumps; HB_SIZE nOptimized, nNextByte, nBytes2Copy, nJumpAddr, nNOOP, nJump; - HB_BOOL fLineStrip = !HB_COMP_PARAM->fDebugInfo && HB_COMP_PARAM->fLineNumbers; + HB_BOOL fLineStrip = HB_COMP_PARAM->fLineNumbers; int iPass; if( ! HB_COMP_ISSUPPORTED(HB_COMPFLAG_OPTJUMP) ) @@ -2141,7 +2141,6 @@ void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cS hb_compAddFunc( HB_COMP_PARAM, pFunc ); - HB_COMP_PARAM->lastLinePos = 0; /* optimization of line numbers opcode generation */ HB_COMP_PARAM->ilastLineErr = 0; /* position of last syntax error (line number) */ hb_compGenPCode3( HB_P_FRAME, 0, 0, HB_COMP_PARAM ); /* frame for locals and parameters */ @@ -2351,27 +2350,12 @@ void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently c if( HB_COMP_PARAM->fLineNumbers ) { if( HB_COMP_PARAM->fDebugInfo && HB_COMP_PARAM->lastModule != HB_COMP_PARAM->currModule ) - { - if( HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos ] == HB_P_LINE && - HB_COMP_PARAM->functions.pLast->nPCodePos - HB_COMP_PARAM->lastLinePos == 3 ) - HB_COMP_PARAM->functions.pLast->nPCodePos -= 3; hb_compGenModuleName( HB_COMP_PARAM, NULL ); - } if( HB_COMP_PARAM->currLine != HB_COMP_PARAM->lastLine ) { - if( HB_COMP_PARAM->functions.pLast->nPCodePos - HB_COMP_PARAM->lastLinePos == 3 && - HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos ] == HB_P_LINE ) - { - HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos + 1 ] = HB_LOBYTE( HB_COMP_PARAM->currLine ); - HB_COMP_PARAM->functions.pLast->pCode[ HB_COMP_PARAM->lastLinePos + 2 ] = HB_HIBYTE( HB_COMP_PARAM->currLine ); - } - else - { - HB_COMP_PARAM->lastLinePos = HB_COMP_PARAM->functions.pLast->nPCodePos; - hb_compGenPCode3( HB_P_LINE, HB_LOBYTE( HB_COMP_PARAM->currLine ), - HB_HIBYTE( HB_COMP_PARAM->currLine ), HB_COMP_PARAM ); - } + hb_compGenPCode3( HB_P_LINE, HB_LOBYTE( HB_COMP_PARAM->currLine ), + HB_HIBYTE( HB_COMP_PARAM->currLine ), HB_COMP_PARAM ); HB_COMP_PARAM->lastLine = HB_COMP_PARAM->currLine; } } @@ -3263,7 +3247,6 @@ void hb_compSequenceFinish( HB_COMP_DECL, HB_SIZE nStartPos, HB_SIZE nEndPos, HB_COMP_PARAM->functions.pLast->nPCodePos - nStartPos, fCanMove ); } - HB_COMP_PARAM->lastLinePos = nStartPos - 3; } else if( !nAlways ) { @@ -3484,7 +3467,6 @@ void hb_compCodeBlockStart( HB_COMP_DECL, HB_BOOL bLateEval ) pBlock->bLateEval = bLateEval; HB_COMP_PARAM->functions.pLast = pBlock; - HB_COMP_PARAM->lastLinePos = 0; } void hb_compCodeBlockEnd( HB_COMP_DECL ) @@ -3736,7 +3718,6 @@ static void hb_compInitVars( HB_COMP_DECL ) HB_COMP_PARAM->pLineFunc = NULL; HB_COMP_PARAM->pDeclFunc = NULL; - HB_COMP_PARAM->lastLinePos = 0; HB_COMP_PARAM->iStaticCnt = 0; HB_COMP_PARAM->iVarScope = VS_LOCAL; diff --git a/harbour/src/compiler/hbpcode.c b/harbour/src/compiler/hbpcode.c index beb354de58..a6c2efacab 100644 --- a/harbour/src/compiler/hbpcode.c +++ b/harbour/src/compiler/hbpcode.c @@ -93,7 +93,7 @@ static HB_PSIZE_FUNC( hb_p_modulename ) HB_SIZE nStart = nPCodePos; HB_SYMBOL_UNUSED( cargo ); - nPCodePos += 3; + nPCodePos++; while( pFunc->pCode[ nPCodePos++ ]) {}; return ( nPCodePos - nStart ); diff --git a/harbour/src/compiler/hbstripl.c b/harbour/src/compiler/hbstripl.c index d3e9c6ae95..70fe24ae58 100644 --- a/harbour/src/compiler/hbstripl.c +++ b/harbour/src/compiler/hbstripl.c @@ -67,9 +67,11 @@ HB_EXTERN_END static HB_STRIP_FUNC( hb_p_line ) { HB_SYMBOL_UNUSED( cargo ); - if( pFunc->pCode[ nPCodePos + 3 ] == HB_P_LINE ) + switch( pFunc->pCode[ nPCodePos + 3 ] ) { - hb_compNOOPfill( pFunc, nPCodePos, 3, HB_FALSE, HB_FALSE ); + case HB_P_LINE: + case HB_P_MODULENAME: + hb_compNOOPfill( pFunc, nPCodePos, 3, HB_FALSE, HB_FALSE ); } return 3; diff --git a/harbour/src/vm/thread.c b/harbour/src/vm/thread.c index e1a7e11669..13f035d04e 100644 --- a/harbour/src/vm/thread.c +++ b/harbour/src/vm/thread.c @@ -299,7 +299,7 @@ void hb_threadReleaseCPU( void ) { struct timeval tv; tv.tv_sec = 0; - tv.tv_usec = 1000; + tv.tv_usec = 10000; select( 0, NULL, NULL, NULL, &tv ); }