Re: [fpc-devel] crash with -gt -O2 (regvar) in trunk

2010-06-07 Thread Martin

On 06/06/2010 20:44, Martin wrote:

It seems it is RegVar ( and -gt )

  -gh -gt -g  -gl  -gw -godwarfsets-CX -XX -Xs   -O2  -OpPENTIUMM  
-Oonoregvar

  -gh -gt -g  -gl  -gw -godwarfsets-CX -XX -Xs   -O2  -OpPENTIUMM

the first one, works fine, the 2nd causes the crash.


I have no idea if the following is relevant.
 Compiling the same unit with/without -gt / both times with -O2 leads 
to some difference in the order registers are used.


In the example below this is probably not relevant => I wonder  if in 
other cases it could be relevant.


.section .text.n_buttons_tcustombitbtn_$__realizekind
.balign 16,0x90
.balign 16,0x90
.globlBUTTONS_TCUSTOMBITBTN_$__REALIZEKIND
BUTTONS_TCUSTOMBITBTN_$__REALIZEKIND:

* WITH -gt has the following extra lines (of course, since it does the 
random intialize)

.Ll205:
movb$85,-64(%ebp)
movb$85,-4(%ebp)
movl$0,%esi
movl$1431655765,-8(%ebp)
movl$1431655765,-12(%ebp)

* I noted neiter eax nor edx are in this code => so I wonder if they 
should be affected later on?


then they share the SAME code
movl$0,-56(%ebp)
leal-24(%ebp),%ecx
leal-48(%ebp),%edx
movl$1,%eax
callFPC_PUSHEXCEPTADDR
callFPC_SETJMP
pushl%eax
testl%eax,%eax
jne.Lj494

** and then:

 with -gt
.Ll206:
# [185] if (Kind <> bkCustom) then
movl-60(%ebp),%eax
movl852(%eax),%edx
testl%edx,%edx
je.Lj498

 without -gt
.Ll194:
# [185] if (Kind <> bkCustom) then
movl-60(%ebp),%edx
movl852(%edx),%eax
testl%eax,%eax
je.Lj498

==> eax and adx have just been swapped.

In this case the result should be the same, and since both cases are 
using both registers, the 2 registers should in both cases be avail for 
usage.


I wonder if in other cases, eax may drop in for edx (or vice versa) 
where it may cause a proble (data replaced?)


The question is, should -gt have caused this change?


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] crash with -gt -O2 (regvar) in trunk

2010-06-07 Thread Jonas Maebe

On 07 Jun 2010, at 18:40, Martin wrote:

> In this case the result should be the same, and since both cases are using 
> both registers, the 2 registers should in both cases be avail for usage.
> 
> I wonder if in other cases, eax may drop in for edx (or vice versa) where it 
> may cause a proble (data replaced?)
> 
> The question is, should -gt have caused this change?

The register allocator uses a graph colouring algorithm. It can easily produce 
slightly different but equivalent register allocations when the graphs change 
(i.e., when more virtual registers are used, e.g. because of extra 
initialisation code). So yes, it is entirely expected that such changes occur 
with -gt.


Jonas___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] crash with -gt -O2 (regvar) in trunk

2010-06-07 Thread Martin

On 06/06/2010 20:44, Martin wrote:

On 05/06/2010 19:57, Jonas Maebe wrote:


One thing that was added is the node level CSE optimiser. You can 
disable it with the -Oonocse command line option (put it in the 
command line after -O2). There are no changes to -gt that I remember.




Comparing the assembler of the same file with and without -gt I noted 
soemthing else, I am not sure about


local vars are:
  GlyphValid, Handled: Boolean;
  CustomGlyph: TGraphic;
  BitmapHandle, MaskHandle: HBitmap;

As expected the begin of the method is equal, I only copied it for 
completeness


.section .text.n_buttons_tcustombitbtn_$__realizekind
.balign 16,0x90
.balign 16,0x90
.globlBUTTONS_TCUSTOMBITBTN_$__REALIZEKIND
BUTTONS_TCUSTOMBITBTN_$__REALIZEKIND:
.Lc82:
# Temps allocated between ebp-76 and ebp-12
# path: .\include\
# file: bitbtn.inc
# indx: 2
.Ll204:
# [184] begin
pushl%ebp
.Lc84:
.Lc85:
movl%esp,%ebp
.Lc86:
subl$76,%esp
# Var $self located in register eax
# Var GlyphValid located in register al
# Var CustomGlyph located in register esi
movl%ebx,-76(%ebp)
movl%esi,-72(%ebp)
movl%edi,-68(%ebp)
# Var Handled located at ebp-4
# Var BitmapHandle located at ebp-8
# Var MaskHandle located at ebp-12
movl%eax,-60(%ebp)
# = here starts the difference
# here is the trashing of locals

.Ll205:
movb$85,-64(%ebp)
movb$85,-4(%ebp)
movl$0,%esi  # <<<
movl$1431655765,-8(%ebp)
movl$1431655765,-12(%ebp)


The line I marked trashes " CustomGlyph: TGraphic"

Other objects are trashed with 1431655765 , but this one is trashed with 
$0 ? (that isn't really trash?)


Martin
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Register usage with -gt [Re: [fpc-devel] crash with -gt -O2 (regvar) in trunk]

2010-06-07 Thread Martin

I found another thing, I don't understand (or I suspect to be not ok)
( see also the 0 initialization by -gt as indicated in the other mail / 
below)



First method in buttons.pp

.section .text.n_buttons_getlcldefaultbtnglyph$tbitbtnkind$$tgraphic
.balign 16,0x90
.balign 16,0x90
.globlBUTTONS_GETLCLDEFAULTBTNGLYPH$TBITBTNKIND$$TGRAPHIC
BUTTONS_GETLCLDEFAULTBTNGLYPH$TBITBTNKIND$$TGRAPHIC:
.Lc1:
# Temps allocated between esp+0 and esp+0
# Var Kind located in register eax
# Var $result located in register eax
# [buttons.pp]
# [452] begin
.Ll1:
movl$0,%edx
.Ll2:
# [453] Result := GetDefaultButtonIcon(BitBtnImages[Kind]);
movlTC_BUTTONS_BITBTNIMAGES(,%eax,4),%eax
callBUTTONS_GETDEFAULTBUTTONICON$LONGINT$$TCUSTOMBITMAP
.Ll3:
# [454] end;
ret

The code is identical between with/withou -gt => except for :
movl$0,%edx

which is inserted by -gt
But edx isn't used at all (the call returns it's result in eax)?

So why trashing it, and why with 0?

Martin

On 07/06/2010 17:44, Martin wrote:

On 06/06/2010 20:44, Martin wrote:

On 05/06/2010 19:57, Jonas Maebe wrote:


One thing that was added is the node level CSE optimiser. You can 
disable it with the -Oonocse command line option (put it in the 
command line after -O2). There are no changes to -gt that I remember.




Comparing the assembler of the same file with and without -gt I noted 
soemthing else, I am not sure about


local vars are:
  GlyphValid, Handled: Boolean;
  CustomGlyph: TGraphic;
  BitmapHandle, MaskHandle: HBitmap;

As expected the begin of the method is equal, I only copied it for 
completeness


.section .text.n_buttons_tcustombitbtn_$__realizekind
.balign 16,0x90
.balign 16,0x90
.globlBUTTONS_TCUSTOMBITBTN_$__REALIZEKIND
BUTTONS_TCUSTOMBITBTN_$__REALIZEKIND:
.Lc82:
# Temps allocated between ebp-76 and ebp-12
# path: .\include\
# file: bitbtn.inc
# indx: 2
.Ll204:
# [184] begin
pushl%ebp
.Lc84:
.Lc85:
movl%esp,%ebp
.Lc86:
subl$76,%esp
# Var $self located in register eax
# Var GlyphValid located in register al
# Var CustomGlyph located in register esi
movl%ebx,-76(%ebp)
movl%esi,-72(%ebp)
movl%edi,-68(%ebp)
# Var Handled located at ebp-4
# Var BitmapHandle located at ebp-8
# Var MaskHandle located at ebp-12
movl%eax,-60(%ebp)
# = here starts the difference
# here is the trashing of locals

.Ll205:
movb$85,-64(%ebp)
movb$85,-4(%ebp)
movl$0,%esi  # <<<
movl$1431655765,-8(%ebp)
movl$1431655765,-12(%ebp)


The line I marked trashes " CustomGlyph: TGraphic"

Other objects are trashed with 1431655765 , but this one is trashed 
with $0 ? (that isn't really trash?)


Martin
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] fpWeb recursive tag replace

2010-06-07 Thread Leonardo M . Ramé
Hi, when I use html templates with tags that contains inner tags, the 
ReplaceTag event is fired only once, for the 1st order tag, but not for the 
inner tags.
Example, a home page containing a header (a tag) and a body which contains 
another tag like, for example {+search_form+}. The search_form tag, also 
contains some {+tags+} to be replaced by the main program.
Is there an "official" way to handle this use case?

Leonardo M. Ramé

http://leonardorame.blogspot.com




  ___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] fpWeb recursive tag replace

2010-06-07 Thread ABorka

On 6/7/2010 16:40, Leonardo M. Ramé wrote:

Hi, when I use html templates with tags that contains inner tags, the
ReplaceTag event is fired only once, for the 1st order tag, but not for
the inner tags.

Example, a home page containing a header (a tag) and a body which
contains another tag like, for example {+search_form+}. The search_form
tag, also contains some {+tags+} to be replaced by the main program.

Is there an "official" way to handle this use case?

Leonardo M. Ramé
http://leonardorame.blogspot.com


An example template attached would have helped, but guessing your problem...

If you use the "AllowTagParams := true;" for a template, then you cannot 
have recursive embedded tags. That is what the tag parameters can be 
used for instead.

For example:
{+search_form
[-formheader=-]

[-formbody=-]

[-formfooter=-]
+}

Your program needs to replace the "search_form" tag by also processing 
the tag parameters.

To see some examples for template usage, try the demo programs under
...\lazarus\components\fpweb\demo\fptemplate\...

AB

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] fpWeb recursive tag replace

2010-06-07 Thread Leonardo M . Ramé
Thanks I have forgotten the listings example.

Leonardo M. Ramé

http://leonardorame.blogspot.com

--- On Mon, 6/7/10, ABorka  wrote:

From: ABorka 
Subject: Re: [fpc-devel] fpWeb recursive tag replace
To: "FPC developers' list" 
Date: Monday, June 7, 2010, 9:02 PM

On 6/7/2010 16:40, Leonardo M. Ramé wrote:
> Hi, when I use html templates with tags that contains inner tags, the
> ReplaceTag event is fired only once, for the 1st order tag, but not for
> the inner tags.
>
> Example, a home page containing a header (a tag) and a body which
> contains another tag like, for example {+search_form+}. The search_form
> tag, also contains some {+tags+} to be replaced by the main program.
>
> Is there an "official" way to handle this use case?
>
> Leonardo M. Ramé
> http://leonardorame.blogspot.com

An example template attached would have helped, but guessing your problem...

If you use the "AllowTagParams := true;" for a template, then you cannot 
have recursive embedded tags. That is what the tag parameters can be 
used for instead.
For example:
{+search_form
[-formheader=-]

[-formbody=-]

[-formfooter=-]
+}

Your program needs to replace the "search_form" tag by also processing 
the tag parameters.
To see some examples for template usage, try the demo programs under
...\lazarus\components\fpweb\demo\fptemplate\...

AB

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel



  ___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel