2006-10-05 01:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbexprc.c
    * Temporary disabled optimization with references to object variables
      until we will not have extended reference items in our HVM.
      It can be enabled by compiling with HB_USE_OBJMSG_REF

  * harbour/include/hbclass.h
    * restored previous CLASSDATA behavior which ignores SHARED clause
      and always create shared class variables
This commit is contained in:
Przemyslaw Czerpak
2006-10-04 23:39:52 +00:00
parent 654374653c
commit 57b1473404
3 changed files with 129 additions and 46 deletions

View File

@@ -8,6 +8,16 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
hb_stack.pPos <= hb_stack.pBase
The old condition was generating usable error message only in the
startup function. In deeply called functions it was only waste of
CPU time on one of the most often call functions. Before it was
activated internal stack structures were corrupted.
If we were leaving for many years without really working stack
underflow protection then maybe we should think about disabling
it at when HB_STACK_MACROS are used and keep it only in real
stack functions for HVM developers. Single protection in
hb_stackOldFrame() I've just added is enough for basic C code
validation.
I created the second version of stack macros without it in
hbstack.h but I would like to hear other developers opinion.

View File

@@ -473,9 +473,11 @@ DECLARE HBClass ;
_HB_MEMBER {[AS <type>] <DataNames>} ;;
s_oClass:AddMultiData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
/* Warning! For backward compatibility this CLASSDATA ignores the
SHARED clause and always create shared class variables */
#xcommand CLASSDATA <DataNames,...> [ AS <type> ] [ INIT <uValue> ] [<export: EXPORTED, VISIBLE>] [<protect: PROTECTED>] [<hidde: HIDDEN>] [<ro: READONLY, RO>] [<share: SHARED>] [<persistent: PERSISTENT, PROPERTY>] => ;
_HB_MEMBER {[AS <type>] <DataNames>} ;;
s_oClass:AddMultiClsData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.share.>, HB_OO_CLSTP_SHARED, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
s_oClass:AddMultiClsData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( /* <.share.> */ .T., HB_OO_CLSTP_SHARED, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
#endif /* HB_CLS_FWO */
@@ -512,9 +514,4 @@ DECLARE HBClass ;
_HB_MEMBER {[AS <type>] <DataNames>} ;;
s_oClass:AddMultiClsData( <(type)>, <uValue>, __HB_CLS_SCOPE( <.export.>, <.protect.>, <.hidde.> ) + iif( <.ro.>, HB_OO_CLSTP_READONLY, 0 ) + iif( <.share.>, HB_OO_CLSTP_SHARED, 0 ) + iif( <.persistent.>, HB_OO_CLSTP_PERSIST, 0 ), {<(DataNames)>}, __HB_CLS_NOINI )
/*
* Why CLASSDATA was always shared?
* - I changed it to respect SHARED definition clause. [druzus]
*/
#endif /* HB_CLASS_CH_ */

View File

@@ -90,6 +90,19 @@ static void hb_compExprSendPopPush( HB_EXPR_PTR pObj )
}
/* Push object */
HB_EXPR_USE( pObj->value.asMessage.pObject, HB_EA_PUSH_PCODE );
#ifndef HB_USE_OBJMSG_REF
/* Now push current value of variable */
if( pObj->value.asMessage.szMessage )
{
HB_EXPR_PCODE2( hb_compGenMessage, pObj->value.asMessage.szMessage, TRUE );
}
else
{
HB_EXPR_USE( pObj->value.asMessage.pMessage, HB_EA_PUSH_PCODE );
}
/* Push object */
HB_EXPR_USE( pObj->value.asMessage.pObject, HB_EA_PUSH_PCODE );
#endif
}
else
{
@@ -104,6 +117,19 @@ static void hb_compExprSendPopPush( HB_EXPR_PTR pObj )
/* Push WITHOBJECTMESSAGE pcode */
HB_EXPR_PCODE2( hb_compGenMessage, NULL, FALSE );
}
#ifndef HB_USE_OBJMSG_REF
/* Now push current value of variable */
if( pObj->value.asMessage.szMessage )
{
HB_EXPR_PCODE2( hb_compGenMessage, pObj->value.asMessage.szMessage, FALSE );
}
else
{
HB_EXPR_USE( pObj->value.asMessage.pMessage, HB_EA_PUSH_PCODE );
/* Push WITHOBJECTMESSAGE pcode */
HB_EXPR_PCODE2( hb_compGenMessage, NULL, FALSE );
}
#endif
}
}
@@ -134,9 +160,6 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq )
*/
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
{
HB_EXPR_PCODE1( hb_compExprSendPopPush, pSelf->value.asOperator.pLeft );
/* Do it. */
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF );
/* NOTE: COMPATIBILITY ISSUE:
* The above HB_C52_STRICT setting determines
@@ -163,26 +186,48 @@ void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq )
* be changed
*/
/* push increment value */
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
/* increase operation */
switch( bOpEq )
HB_EXPR_PCODE1( hb_compExprSendPopPush, pSelf->value.asOperator.pLeft );
/* Do it. */
/* Temporary disabled optimization with references to object variables
untill we will not have extended reference items in our HVM [druzus] */
#ifdef HB_USE_OBJMSG_REF
if( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ||
bOpEq == HB_P_MULT || bOpEq == HB_P_DIVIDE )
{
case HB_P_PLUS:
bOpEq = HB_P_PLUSEQ;
break;
case HB_P_MINUS:
bOpEq = HB_P_MINUSEQ;
break;
case HB_P_MULT:
bOpEq = HB_P_MULTEQ;
break;
case HB_P_DIVIDE:
bOpEq = HB_P_DIVEQ;
break;
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF );
/* push increment value */
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
/* increase operation */
switch( bOpEq )
{
case HB_P_PLUS:
bOpEq = HB_P_PLUSEQ;
break;
case HB_P_MINUS:
bOpEq = HB_P_MINUSEQ;
break;
case HB_P_MULT:
bOpEq = HB_P_MULTEQ;
break;
case HB_P_DIVIDE:
bOpEq = HB_P_DIVEQ;
break;
}
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq );
}
else
#endif
{
HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 0, ( BOOL ) 1 );
/* push increment value */
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
/* increase operation */
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq );
/* call pop message with one argument */
HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 1, ( BOOL ) 1 );
}
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq );
return;
}
/* TODO: add a special code for arrays to correctly handle a[ i++ ]++
@@ -308,28 +353,48 @@ void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, BYTE bOpEq )
{
HB_EXPR_PCODE1( hb_compExprSendPopPush, pSelf->value.asOperator.pLeft );
/* Do it.*/
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF );
/* push increment value */
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
/* increase operation and pop the unneeded value from the stack */
switch( bOpEq )
/* Temporary disabled optimization with references to object variables
untill we will not have extended reference items in our HVM [druzus] */
#ifdef HB_USE_OBJMSG_REF
if( bOpEq == HB_P_PLUS || bOpEq == HB_P_MINUS ||
bOpEq == HB_P_MULT || bOpEq == HB_P_DIVIDE )
{
case HB_P_PLUS:
bOpEq = HB_P_PLUSEQPOP;
break;
case HB_P_MINUS:
bOpEq = HB_P_MINUSEQPOP;
break;
case HB_P_MULT:
bOpEq = HB_P_MULTEQPOP;
break;
case HB_P_DIVIDE:
bOpEq = HB_P_DIVEQPOP;
break;
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF );
/* push increment value */
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
/* increase operation and pop the unneeded value from the stack */
switch( bOpEq )
{
case HB_P_PLUS:
bOpEq = HB_P_PLUSEQPOP;
break;
case HB_P_MINUS:
bOpEq = HB_P_MINUSEQPOP;
break;
case HB_P_MULT:
bOpEq = HB_P_MULTEQPOP;
break;
case HB_P_DIVIDE:
bOpEq = HB_P_DIVEQPOP;
break;
}
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq );
}
else
#endif
{
HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 0, ( BOOL ) 1 );
/* push increment value */
HB_EXPR_USE( pSelf->value.asOperator.pRight, HB_EA_PUSH_PCODE );
/* increase operation */
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq );
/* Now do the assignment - call pop message with one argument */
HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 1, ( BOOL ) 1 );
/* pop the unneeded value from the stack */
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_POP );
}
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOpEq );
return;
}
/* TODO: add a special code for arrays to correctly handle a[ i++ ]++
@@ -455,6 +520,10 @@ void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper )
{
HB_EXPR_PCODE1( hb_compExprSendPopPush, pSelf->value.asOperator.pLeft );
/* Do it. */
/* Temporary disabled optimization with references to object variables
untill we will not have extended reference items in our HVM [druzus] */
#ifdef HB_USE_OBJMSG_REF
HB_EXPR_GENPCODE1( hb_compGenPCode1, HB_P_PUSHOVARREF );
/* increase/decrease operation */
@@ -467,6 +536,13 @@ void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, BYTE bOper )
bOper = ( bOper == HB_P_INC ) ? HB_P_PLUSEQ : HB_P_MINUSEQ;
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOper );
#else
HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 0, ( BOOL ) 1 );
/* increase/decrease operation */
HB_EXPR_GENPCODE1( hb_compGenPCode1, bOper );
/* Now, do the assignment - call pop message with one argument - it leaves the value on the stack */
HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_SENDSHORT, 1, ( BOOL ) 1 );
#endif
}
else
{