On Fri, 30 Nov 2012, Walter Negro wrote:

Hi,

> This is not correct asumption.
> Not all the pcodes writed are executed.
[...]

Very good note.
I'll only add that statistic information about generated and executed
PCODEs is important but only if compiler makes basic optimization
automatically. Otherwise programmer can optimize manually his code
just only to reach better results with primitive compiler optimizer
but this manually updated code can be much worse for automatic
optimizations then the original one.
So it's good that some statistic can be collected but it does not
mean that existing code should be immediately updated to follow
the statistic results because so far neither Harbour nor xHarbour
has advanced PCODE optimizer.

How it's important I'll show on this example:

   #include "hbclass.ch"
   class cls
      var    V
      method M
   end class

   method M()
   return ::V


This is PCODE for method M generated by Harbour:


   HB_FUNC_STATIC( CLS_M )
   {
      static const HB_BYTE pcode[] =
      {
         /* 00000 */ HB_P_LINE, 8, 0,   /* 8 */
         HB_P_MESSAGE, 13, 0,   /* V */
         HB_P_PUSHSELF,
         HB_P_SENDSHORT, 0,
         HB_P_RETVALUE,
         HB_P_ENDPROC
         /* 00011 */
      };
      hb_vmExecute( pcode, symbols );
   }

and this is PCODE for method M generated by xHarbour:

   HB_FUNC_STATIC( CLS_M )
   {
      static const BYTE pcode[] =
      {
         HB_P_FRAME, 1, 0,      /* locals, params */
         HB_P_PUSHSELF,
         HB_P_POPLOCALNEAR, 1,  /* SELF */
         /* 00006 */ HB_P_BASELINE, 8, 0,       /* 8 */
         HB_P_MESSAGE, 18, 0,   /* V */
         HB_P_PUSHLOCALNEAR, 1, /* SELF */
         HB_P_SENDSHORT, 0,
         HB_P_RETVALUE,
         HB_P_ENDPROC
         /* 00018 */
   };

as you can see even such trivial example can create huge difference
and shows how some simple and often used constructions can be optimized.
Many thanks to Mindaugas for above optimization and I suggest to
work on real optimizations like above because it will help all users
then investing time in tools which collects some statistic to give
some "good advices" only for current (far from perfect) compiler
implementation.

best regards,
Przemek

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to