Strings concatenation optimisation

Re: Strings concatenation optimisation

Postby Zorko » Mon Nov 04, 2019 5:38 pm

Then why does the current compiler use string copying in the first operation instead of just counting its length (search 0X)? Specifically calling CPC486.AddCopy and CPV486.AddCopy to do this., i.e.:

Code: Select all
MODULE TestConcat;
VAR a: ARRAY 100 OF CHAR;
BEGIN
   a := a + "abc" (* a := a$ + "abc" be the same *)
END TestConcat.

Image
https://forum.oberoncore.ru/viewtopic.php?f=131&t=6462
Zorko
 
Posts: 21
Joined: Tue Sep 17, 2013 10:13 pm
Location: Ukraine

Re: Strings concatenation optimisation

Postby Zorko » Mon Nov 04, 2019 5:43 pm

Note that copying the string is not even in itself, but in some buffer?

Code: Select all
mov edi, 1677721600 \
mov esi, 1677721606 / not the same address

Question: why does BlackBox need this buffer if this optimization case involves using the string itself as the buffer?

Still, something tells me that all is not well with the strings concatenation in the Kingdom of Denmark... ;-)
Zorko
 
Posts: 21
Joined: Tue Sep 17, 2013 10:13 pm
Location: Ukraine

Re: Strings concatenation optimisation

Postby luowy » Tue Nov 05, 2019 2:48 am

Zorko wrote:Note that copying the string is not even in itself, but in some buffer?

CODE: SELECT ALL
mov edi, 1677721600 \
mov esi, 1677721606 / not the same address
oo, You are bothered by the decoder! It decodes the static file instead of loading the code stream of the module;

the loaded one is:
Code: Select all
StdCoder.Decode ..,, ..QV....3Qw7uP5PRPPNR9Rbf9b8R79FTvMf1GomCrlAy2xhX,Cb2x
 hXhC6FU1xhiZiVBhihgmRiioedhgrZcZRiXFfaqmSrtuGfa4700zdGrr8rmCLLCJuyKtYcZRiX
 7.2.s,MsD.,6.5Qw7uP51QCPuP7PNN9F9vQAy1xB.gdj,UBxhYhAbf9P0G2sIdvPZntgcghghZ
 cZRC8T0E.kLS.H.Dt,2.,U08J99SdfJHPNjvQCJuGKfaqmY6MwdONl1QCh0708T,U..w.Au4.,
 sUGpmWbBxhYhAbndMHT9NY6Mw.sQq2Y6cwB.0.FO,w,2c3E.0E.E95.86.QC18RdfQHfMf9R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aEcyIcakWCZ7g,.hdC,76fdFaEcy2GY7.kPeHE0W0lO0m2qobUEZZUgc03e7g,.n
 dC,76GIE2eDV0N0.Acu225uA,N0ZOFdO0HM13QwdONQcjphoJijZhghgmRiiQ87vEdfQN9F9vQ
 59.X5..RtETfPd16FQg.sEMMu4.Z1...bf9.EWE.8D2.Y02.AV.2.,6..M.3I5E.0.P1D.9H.2
 U.sUZD2,6.,6..W.,sGE.cUZj2E..Uk2.0k.0.0.0A6.m5W1W140CU.TCg5.8cBU.2..c4E.k.
 Ue.0.,6Y1.0.UA2Tm.mQfaa92T,eUXDF.sET1.UJ6.2..606.A.F.,6EruQ0uGCe.az86Utj00
 QjWaUAZM0L70...
 --- end of encoding ---

luowy
luowy
 
Posts: 48
Joined: Thu Dec 17, 2015 1:32 pm

Re: Strings concatenation optimisation

Postby Josef Templ » Wed Nov 06, 2019 6:33 am

As far as I have seen in the compiler output there are two aspects here.
One is the usage of an extra buffer and the other is the copying of s in a pattern like s := s + ...;
The BB compiler optimized the first aspect, i.e. it tries to avoid an extra buffer when it is save to do so.
So far, I don't know where this check is done in the compiler.
The second aspect is not optimized. The code for s := s + "xxx" looks the same as for
t := s + "xxx". But in both cases there is no extra buffer.
In other words, the compiler does not output a counting loop for the length of s but simply
copies it and thereby also counts its length. The difference is marginal in practice because string concatenation
normally is not a time critical operation done in some inner loop.

- Josef
Josef Templ
 
Posts: 234
Joined: Tue Sep 17, 2013 6:50 am

Re: Strings concatenation optimisation

Postby luowy » Thu Nov 07, 2019 7:55 am

Josef Templ wrote:The BB compiler optimized the first aspect, i.e. it tries to avoid an extra buffer when it is save to do so.
So far, I don't know where this check is done in the compiler.
View DevCPB.CheckBuffering and Overlap;
I have pointed out some improvements, which is not difficult to implement(I have completed the prototype), But it doesn’t make much sense,I think; If anyone wants help on this issue, contact me directly.
luowy
 
Posts: 48
Joined: Thu Dec 17, 2015 1:32 pm

Previous

Return to Feature

Who is online

Users browsing this forum: No registered users and 1 guest

cron