Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-08

temp strings for constants,and double dec_ref

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

While I an open array

     DebugLn(['abc']);

The string constant, is passed directly to the method (no temporary vars used)

but ( procedure DebugLn(const s: string = ''); inline; overload; )
   DebugLn('abc');

generates the code at the end of the mail. It first makes a copy of the string (the pointer, not the content) to a temp var.

And not only this there is an unnecessary fpc_ansistr_decr_ref
- in 2.6 there are 2 calls to fpc_ansistr_decr_ref
- in trunc it is fpc_ansistr_decr_ref and fpc_ansistr_assign (the latter including a further call to the former)

That is I have no problem, that the temp var (if it has to be there at all) is dec-refed once. After all, if there was more pascal code before, the temp may be in use....

But since fpc_ansistr_assign, does dec_red the target, why needs there to be another explicit call?

UNIT1$_$TFORM1_$__$$_FORMCREATE$TOBJECT:
.Lc6:
# Temps allocated between ebp-56 and ebp-8
.Ll7:
# [42] begin
pushl %ebp
.Lc8:
.Lc9:
movl %esp,%ebp
.Lc10:
subl $56,%esp
movl %ebx,-56(%ebp)
# Var Sender located at ebp-4
# Var $self located at ebp-8
movl %eax,-8(%ebp)
movl %edx,-4(%ebp)
.Ll8:
movl $0,-52(%ebp)
.Ll9:
# [44] DebugLn('abc');
leal -20(%ebp),%ecx
leal -44(%ebp),%edx
movl $1,%eax
call FPC_PUSHEXCEPTADDR
call FPC_SETJMP
pushl %eax
testl %eax,%eax
jne .Lj18
leal -52(%ebp),%eax
call fpc_ansistr_decr_ref
movl $_$UNIT1$_Ld1,%edx
leal -52(%ebp),%eax
call fpc_ansistr_assign
call LAZLOGGERBASE_$$_GETDEBUGLOGGER$$TLAZLOGGER movl %eax,%ebx
movl -52(%ebp),%edx
movl %ebx,%eax
call LAZLOGGERBASE$_$TLAZLOGGER_$__$$_DEBUGLN$ANSISTRING .Lj18:
call FPC_POPADDRSTACK
.Ll10:
# [45] end;
leal -52(%ebp),%eax
call fpc_ansistr_decr_ref
popl %eax
testl %eax,%eax
je .Lj19
call FPC_RERAISE
.Lj19:
movl -56(%ebp),%ebx
leave
ret
.Lc7:
.Lt2:
.Ll11:
# End asmlist al_procedures

Reply by email

Jonas Maebe
to Martin

Martin wrote on Fri, 24 Aug 2012:

And not only this there is an unnecessary fpc_ansistr_decr_ref - in 2.6 there are 2 calls to fpc_ansistr_decr_ref - in trunc it is fpc_ansistr_decr_ref and fpc_ansistr_assign (the latter including a further call to the former)

The reference counting has been optimized a lot in FPC 2.7.1, you may want to try again with that version.

Jonas

Reply by email

Martin
to Jonas Maebe
Jonas Maebe wrote 11 lines
Martin wrote on Fri, 24 Aug 2012: > And not only this there is an unnecessary fpc_ansistr_decr_ref > - in 2.6 there are 2 calls to fpc_ansistr_decr_ref > - in trunc it is fpc_ansistr_decr_ref and fpc_ansistr_assign (the > latter including a further call to the former) The reference counting has been optimized a lot in FPC 2.7.1, you may want to try again with that version.

I did. See the 2nd statement "in trunk". That refers to trunk updated yesterday.

Reply by email

Martin
to Martin
Martin wrote 15 lines
On 24/08/2012 12:07, Jonas Maebe wrote: > > Martin wrote on Fri, 24 Aug 2012: > >> And not only this there is an unnecessary fpc_ansistr_decr_ref >> - in 2.6 there are 2 calls to fpc_ansistr_decr_ref >> - in trunc it is fpc_ansistr_decr_ref and fpc_ansistr_assign (the >> latter including a further call to the former) > > The reference counting has been optimized a lot in FPC 2.7.1, you may > want to try again with that version. > I did. See the 2nd statement "in trunk". That refers to trunk updated yesterday.

r 22207

Reply by email