Re: [fpc-devel] creating call nodes for managed operators

2023-07-25 Thread Benito van der Zander via fpc-devel
se because "copy" was not public in the record. I can set a flag [cnf_ignore_visibility] in the compiler Bye, Benito On 23.07.23 16:35, Hairy Pixels via fpc-devel wrote: On Jul 23, 2023, at 7:13 AM, Benito van der Zander via fpc-devel wrote: with my patch, "copy&qu

Re: [fpc-devel] creating call nodes for managed operators

2023-07-23 Thread Benito van der Zander via fpc-devel
had about them is why they can't be inlined. Does anyone have the answer for that? Not being able to be inlined is the biggest performance problem I suspect, followed by the copy operator which gets called redundantly on assignment to temporary memory. On Jul 22, 2023, at 7:07 AM, Benito van der

[fpc-devel] creating call nodes for managed operators

2023-07-22 Thread Benito van der Zander via fpc-devel
Hallo, i made a patch for faster management operators: https://gitlab.com/benibela/fpc-source/-/commit/1aa0866112c97dd0c7ed7f3a4b1c7ab6420cb942 And it has been working fine on fixes3_2, but when I tried to apply it on main, I get an error message: views.inc(4318,17) Error: Wrong number

Re: [fpc-devel] Sorting tests

2022-11-29 Thread Benito van der Zander via fpc-devel
Hi, and the FPC implementation is actually documented to not be stable in the code: { QuickSort Average performance: O(n log n) Worst performance: O(n*n) Extra memory use: O(log n) on the stack Stable: no Additional notes: Uses the middle element asthe pivot. This makes it work well also on

Re: [fpc-devel] Thoughts: Make FillChar etc. an intrinsic for specialised performance potential

2022-04-16 Thread Benito van der Zander via fpc-devel
Hi, FillChar is on most platforms an assembly function and FPC *never* inlines assembly functions. even without inlining, rep stosb is faster than FillChar:  {$asmmode intel} procedure repfillchar(var buffer; len: sizeuint; c: byte); begin   asm     mov al, c     mov rdi, buffer     mov

Re: [fpc-devel] Thoughts: Make FillChar etc. an intrinsic for specialised performance potential

2022-04-16 Thread Benito van der Zander via fpc-devel
Hi, it could always inline it. For small sizes do that mov and for large sizes do rep stosb on x86. It is very fast nowadays. Faster than FillChar on my Intel laptop. (except for mid sizes like 128 bytes) Bye, Benito On 16.04.22 01:26, J. Gareth Moreton via fpc-devel wrote: Hi everyone,

Re: [fpc-devel] The "magic div" algorithm

2021-11-16 Thread Benito van der Zander via fpc-devel
Hi, in my big decimal unit, I need to divide by 10 all the time, e.g. https://github.com/benibela/bigdecimalmath/blob/master/bigdecimalmath.pas#L1324-L1325 would the magic div help there much? Bye, Benito On 09.11.21 22:12, J. Gareth Moreton via fpc-devel wrote: This one for

Re: [fpc-devel] Merging identical procedure proposals

2021-10-16 Thread Benito van der Zander via fpc-devel
Hi,  that is a great idea It especially useful for generics, where each specialization can create a huge amount of identical methods Best, Benito On 13.10.21 19:33, J. Gareth Moreton via fpc-devel wrote: Hi everyone, So one optimisation that has cropped up a couple of times is finding

Re: [fpc-devel] Defer keyword

2021-05-07 Thread Benito van der Zander via fpc-devel
Hi, Don't forget that the record/management operator approach will again blow up binary size; for every variable declared like this you risk creating a new type. the classic Delphi way was to use an interface for freeing. It only requires one type and nothing blows up. type   TDefer =

Re: [fpc-devel] Generic class comparison operators

2021-04-21 Thread Benito van der Zander via fpc-devel
Hi,  what about overloading operators for OBJECTs? They do not conflict with any default operators. I expected this to work, but it did not compile:   type generic TXQHashset = object //(specialize TXQBaseHashmap)...     class operator =(const a, b: TXQHashset): boolean;   end; Cheers,

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Benito van der Zander via fpc-devel
Hi, I'm against adding support for this. Dynamic arrays have guaranteed behavior. If users find that this behavior is not appropriate for their use case then they should not use them (or as you already suggested, preallocate them). well, setlength does not always initialize the array

Re: [fpc-devel] Merge request for 3.2 fixes

2020-07-25 Thread Benito van der Zander
and: https://bugs.freepascal.org/view.php?id=36603 a regression when passing empty strings to regexpr perhaps its follow-up: https://bugs.freepascal.org/view.php?id=36701 On 25.07.20 16:26, Martin wrote: Could the fix for issue https://bugs.freepascal.org/view.php?id=36017 be merged to

Re: [fpc-devel] Binary size discrepancy with -a

2020-07-18 Thread Benito van der Zander
Hi J. Gareth, I once added -a to debug my Android app, and then it did not start anymore on some devices... Bye, Benito On 19.07.20 05:09, J. Gareth Moreton wrote: Hi everyone, I've noticed something a bit weird with the Free Pascal Compiler when you use the the -a option to dump the

Re: [fpc-devel] Fwd: Re: An optimization suggestion for FPC

2020-06-28 Thread Benito van der Zander
Hi J. Gareth, that is a really important optimization. Especially with new record management operators. I am going to wrap almost all my variables in records, so they will be automatically initialized. I have suggested it in the bug tracker, but it was closed, because they say the bug

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-28 Thread Benito van der Zander
, Benito On 27.04.20 07:46, Sven Barth wrote: Am 26.04.2020 um 23:42 schrieb Benito van der Zander: Hi Sven, It's not that simple. In principle you're right that the compiler could try to merge more implementations, but this does not depend on the declaration of the generic, but the use

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Benito van der Zander
, Sven Barth wrote: Am 26.04.2020 um 14:01 schrieb Benito van der Zander: Hi, perhaps it could be used to merge specializations (if fpc cannot do that on its own): Like when you have a hashmap THashMap, and need three specializations: THashMap THashMap THashMap It is basically three times

Re: [fpc-devel] New feature announcement: constant parameters for generics

2020-04-26 Thread Benito van der Zander
Hi, perhaps it could be used to merge specializations (if fpc cannot do that on its own): Like when you have a hashmap THashMap, and need three specializations: THashMap THashMap THashMap It is basically three times the same hashmap, but if fpc does not detect that, it might generate

Re: [fpc-devel] FPC now supports Windows 33-bit

2020-04-23 Thread Benito van der Zander
Hi, if someone needs even more bits: I once made a 65-bit integer type Cheers, Benito On 23.04.20 07:27, Sven Barth via fpc-devel wrote: Am 22.04.2020 um 22:21 schrieb Bart via fpc-devel: Hi, Please don't feel offended, but this typo just made me smile: (And a smile is what we need in

Re: [fpc-devel] Progress on reviewing x86_64 optimizer overhaul and node semantic pass

2019-10-27 Thread Benito van der Zander
Hi, I use TortoiseHg and then a Mercurial to Git converter... Unfortunately the linux distributions do not want to maintain it and most ship with an outdated TortoiseHg in their package management Best, Benito On 27.10.19 17:48, Florian Klämpfl wrote: Am 27.10.19 um 15:32 schrieb Martok:

Re: [fpc-devel] Some thoughts on multi-line string support, and a possible syntax that I think is perfectly clean and Pascal-ish.

2019-07-05 Thread Benito van der Zander
Hi, Am 04.07.19 um 19:51 schrieb Marco van de Voort: If $ifdef was a single char token, maybe. And for a trivial feature, not a core one, like conditional compiling. So the compiler will correctly give an error. ... but not at or near the place where the mistake is made. Some

Re: [fpc-devel] atomic reads and writes, was: "Maybe Gareth can be convinced to spend his energy on this ... "

2019-07-02 Thread Benito van der Zander
Hi, Am 28.06.19 um 11:24 schrieb George Bakhtadze: If FPC somehow guarantees that a global field (even only of simple types) can be atomically read and written from any thread for ANY platform that is a very strong guarantee and worth mention in documentation.  btw, how would you do that if

Re: [fpc-devel] "Maybe Gareth can be convinced to spend his energy on this ... "

2019-06-27 Thread Benito van der Zander
Hi Gareth, there are more optimizations to look at An user could write custom string enumerators to replace such assignments in loops and try to manually solve that issue. But then https://bugs.freepascal.org/view.php?id=34915 the enumerators are stored in memory rather than registers, so

Re: [fpc-devel] Object upgrades (new)

2019-06-16 Thread Benito van der Zander
Hi', I don't see a need to add management operators to objects. Objects have constructors and destructors, so they don't need Initialize and Finalize operators One need would be to automatically call the destructor It could make the code much simpler, especially when it also replaces

Re: [fpc-devel] Standard generic classes

2019-06-08 Thread Benito van der Zander
An object based container library would also be helpful. With classes stored on the heap you always need additional memory access. Just one, but that is already bad in performance critical loops Best, Benito Am 06.06.19 um 18:23 schrieb George Bakhtadze: It would be also great if there

Re: [fpc-devel] "Blank slate" next version of FPC

2019-02-22 Thread Benito van der Zander
Hi, The trick with enumerators is to never make them classes, and use advanced records instead, I've found. This way you avoid the heap allocation and the implicit try/finally. Also make sure you inline the MoveNext and GetCurrent! that's what I do. But the generated assembly is still

Re: [fpc-devel] "Blank slate" next version of FPC

2019-02-16 Thread Benito van der Zander
Hi, there is NewPascal with improved memory safety/smart pointers: http://newpascal.org/ but we try as much as possible to break old code. I have noticed that. All my code has been broken by the codepage aware strings and TEncoding and FPC's goal to remain Delphi-compatible. So

Re: [fpc-devel] ref count types / threadsave question

2019-01-03 Thread Benito van der Zander
van der Zander mailto:ben...@benibela.de>> geschrieben: Hi, The issue I was talking about is the fact that atomic operations do function as global memory synchronisation operations across all cores (at least not on all architectures). If core 1 atomatically inc

Re: [fpc-devel] ref count types / threadsave question

2019-01-03 Thread Benito van der Zander
us not use the string for anything . Bye, Benito Am 02.01.19 um 21:52 schrieb Jonas Maebe: On 02/01/19 21:46, Martin Frb wrote: On 02/01/2019 21:22, Benito van der Zander wrote: Hi, but if another core can do anything to the string, the refcount should already be 2, one for this core and one for

Re: [fpc-devel] ref count types / threadsave question

2019-01-02 Thread Benito van der Zander
Hi, but if another core can do anything to the string, the refcount should already be 2, one for this core and one for the other core, should it not? UniqueString has such a test: Function fpc_ansistr_Unique(Var S : Pointer): Pointer; [Public,Alias : 'FPC_ANSISTR_UNIQUE']; compilerproc;

Re: [fpc-devel] [Patch/RFC] Warnings for (in/over)complete case statements

2019-01-02 Thread Benito van der Zander
Wait - why does that code not raise a 5033 "Function Result does not seem to be set"? Add a second property "Property MyOtherString : String Index 2 Read GetString;", and now its provably wrong. No warning. This seems wrong, considering what we just talked about on fpc-pascal. Because there

Re: [fpc-devel] Where to set proper alignment default of const strings?

2018-11-28 Thread Benito van der Zander
Hi Michael, there was a discussion in this issue https://bugs.freepascal.org/view.php?id=33323 Cheers, Benito Am 28.11.18 um 19:51 schrieb Michael Ring: The more I dig the more I ask myself if not the rtl routine is to blame for the issue in the first place because it only takes

[fpc-devel] sizeof member in class procedure

2018-08-14 Thread Benito van der Zander
Hi, why is sizeof on object/class fields sometimes allowed and sometimes not? type TTest = object   f: integer;   class procedure test; end; class procedure TTest.test; begin   writeln(sizeof(f)); // does not compile   writeln(sizeof(TTest.f));  // compiles end; --- type TTest =

Re: [fpc-devel] Loop unrolling question

2018-08-04 Thread Benito van der Zander
Hi, case of strings could also use some optimization does it still call fpc_ansistr_compare_equal ? fpc could hash the strings, or build a trie, even testing the length first would help Cheers, Benito Am 03.08.2018 um 21:57 schrieb J. Gareth Moreton: Hi everyone, So I'm pondering

Re: [fpc-devel] FPProfiler

2018-02-19 Thread Benito van der Zander
Hi, In theory a call to _mcount could be replaced with a compilerproc, which you could then override in the RTL, allowing a way to add support for various profilers. If it became fully overridable,  you could put a callback between any branch/line/function and create instrumentalization not

Re: [fpc-devel] End of support for Win XP?

2018-01-31 Thread Benito van der Zander
Hi, XP is still important yesterday I had a dream about some kind of ebook reader with multiple pages, like 7 displays in a row on a foldable sheet, each for one page. (and something about a washing machine) At first the displays looked like Android, but when you took it apart, you noticed

Re: [fpc-devel] First pas2js public release

2017-12-18 Thread Benito van der Zander
7 14:55:53 +0100 Benito van der Zander<ben...@benibela.de> wrote: [...] That would be quite a slow down. Is it? I saw no speed difference between var x = 1; for (var i=0;i<10;i++) x++; and var x = [1]; for (var i=0;i<10;i++) x[0]++; in Firefox. Of course not. First

Re: [fpc-devel] First pas2js public release

2017-12-18 Thread Benito van der Zander
22:24, Mattias Gaertner wrote: On Sun, 17 Dec 2017 21:43:45 +0100 Benito van der Zander <ben...@benibela.de> wrote: Hi, Naturally, any memory pointer operation is not possible in Javascript. Code that relies on this will not work. it would be great, if pointers were added. There

Re: [fpc-devel] First pas2js public release

2017-12-17 Thread Benito van der Zander
Hi, Naturally, any memory pointer operation is not possible in Javascript. Code that relies on this will not work. it would be great, if pointers were added. One trick would be to wrap every variable that is accessed by a pointer in an array (or object).  The array can then be used as

[fpc-devel] Quickly recompiling fpc

2017-12-09 Thread Benito van der Zander
Hi, how do you recompile fpc after making a small change in the compiler, like enabling the debugmsg define in x86/aoptx86.pas? make buildbase says nothing was changed, and make clean; make buildbase recompiles not just the compiler, but also the rtl, which is a waste of time. Bye,

Re: [fpc-devel] trunk broken

2017-09-02 Thread Benito van der Zander
Hi,  trunk is always broken, is it not? Perhaps that is why it is called trunk. After all a trunk is an incomplete tree. Just a little bit more than a completely broken tree (stump) Best, Benito Am 02.09.2017 um 19:03 schrieb Sven Barth via fpc-devel: Am 02.09.2017 17:06 schrieb

Re: [fpc-devel] Optimizing unused return values of inline functions

2017-08-23 Thread Benito van der Zander
Hi, Isn't rax needed for the call to Free? I think self stays in rdi Perhaps we need a new calling convention that keeps self in rax. Or the return value in rdi Cheers, Benito Am 21.08.2017 um 15:45 schrieb Stefan Glienke: Isn't rax needed for the call to Free?

Re: [fpc-devel] Optimizing unused return values of inline functions

2017-08-23 Thread Benito van der Zander
Hi,, SomeProc(Builder .Build('1') .Build('2') .Build('3').Value); That's exactly what I wanted to use it for And since a string builder is such a low level construct, mostly used for performance improvements, it needs to be fast without additional

Re: [fpc-devel] Optimizing unused return values of inline functions

2017-08-21 Thread Benito van der Zander
Hi, This pattern is not inherently efficient. Why should it be ? It is not efficient, because of the pointless instruction! Bye, Benito Am 21.08.2017 um 08:39 schrieb Michael Van Canneyt: On Sun, 20 Aug 2017, Benito van der Zander wrote: Hi, why does fpc not remove

[fpc-devel] Optimizing unused return values of inline functions

2017-08-20 Thread Benito van der Zander
Hi, why does fpc not remove the calculation of the return value of inline functions, when the return value is unused? For example type TUtility = class function doSomething: TUtility; inline; end; function TUtility.dosomething: TUtility; begin writeln(); result := self; end; adds a

Re: [fpc-devel] Request for an interim release of the 3.0 branch

2017-04-28 Thread Benito van der Zander
Hi, r35545, too ? (http://bugs.freepascal.org/view.php?id=31135) Bye, Benito On 04/26/2017 03:17 PM, Marco van de Voort wrote: In our previous episode, Bart said: The issue is fixed by merging r33007, 33008, 33561 and 34384 (unit exeinfo). Probably r35886 should be merged as well.