Re: [fpc-devel] First pas2js public release

2017-12-18 Thread Mattias Gaertner
On Mon, 18 Dec 2017 20:16:03 +0100
Benito van der Zander  wrote:

>[...]
> But recently I have started to change everything to pointers.
> 
> For example when you have an array and want a subrange without the first 
> element of the array, you can either copy almost everything in a new 
> array, or just use a pointer to the second element.
> 
> Or in my XQuery interpreter I used interfaces to get ref counting, but 
> at many places the ref counting was too slow, so I replaced it with 
> pointers to interfaces.

js has different runtimes. Some things are slow some things are simple
and fast. If you need speed you have to use different tricks than on
an assembly target.

Your pointers work for some cases, but not for all. They are fast on
some browsers, on others not so much.
I agree with Michael, that this has low priority.

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


Re: [fpc-devel] First pas2js public release

2017-12-18 Thread Benito van der Zander


Hi,


Of course not. First of all 10 is ridiculously small and second
the above example is probably optimized by the engine.
For example under V8 with 1 iterations you get 1.1s and 1.9s.


It is not so small or optimized with Firefox.

It took around 100ms

With 1000, it gives 5479ms and 4814ms, i.e. the array is faster here

With 1 the script does not complete, before Firefox ask "do you 
want to stop the too slow script"



Like what?
What pointer code do you want to port?



I have not looked at any specific.

But recently I have started to change everything to pointers.

For example when you have an array and want a subrange without the first 
element of the array, you can either copy almost everything in a new 
array, or just use a pointer to the second element.


Or in my XQuery interpreter I used interfaces to get ref counting, but 
at many places the ref counting was too slow, so I replaced it with 
pointers to interfaces.


E.g. when iterating over an array of interfaces with an enumerator. for 
x in thearray do, the array keeps the ref count >= 1, so x is much more 
efficient as pointer to an interface.





Isn't that a contradiction to "port all existing"?


Not with full program static analysis

Or people could mark the values they need as pointers in other units (by 
adding an unused public function just accessing it as pointer)


Best,
Benito



On 18.12.2017 17:19, Mattias Gaertner wrote:

On Mon, 18 Dec 2017 14:55:53 +0100
Benito van der Zander  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 of all 10 is ridiculously small and second
the above example is probably optimized by the engine.
For example under V8 with 1 iterations you get 1.1s and 1.9s.

Test with some more real world code.


Perhaps more memory usage

Pretty sure more memory usage.

  

Isn't speed the main idea of using pointers?

It would be to port all existing pascal code

Like what?
What pointer code do you want to port?



Also what if var and @var are in different units?

Either it needs full program static analysis, or pointers are only
allowed to something that was used with a pointer in its unit

Isn't that a contradiction to "port all existing"?



You may want to take a look at asm.js, which has a working
model for emulating pointers in JavaScript. It would be possible to add
a pas2js target for that. But then again there is webassembly
as well and it seems to have better support.

That model looks like quite a slow down

The js engines have some optimizations for that model.

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


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


Re: [fpc-devel] First pas2js public release

2017-12-18 Thread Mattias Gaertner
On Mon, 18 Dec 2017 14:55:53 +0100
Benito van der Zander  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 of all 10 is ridiculously small and second
the above example is probably optimized by the engine.
For example under V8 with 1 iterations you get 1.1s and 1.9s.

Test with some more real world code.

> Perhaps more memory usage

Pretty sure more memory usage.

 
> > Isn't speed the main idea of using pointers?  
> 
> It would be to port all existing pascal code

Like what?
What pointer code do you want to port?


> > Also what if var and @var are in different units?  
> 
> Either it needs full program static analysis, or pointers are only 
> allowed to something that was used with a pointer in its unit

Isn't that a contradiction to "port all existing"?


> > You may want to take a look at asm.js, which has a working
> > model for emulating pointers in JavaScript. It would be possible to add
> > a pas2js target for that. But then again there is webassembly
> > as well and it seems to have better support.  
> 
> That model looks like quite a slow down

The js engines have some optimizations for that model.

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


Re: [fpc-devel] First pas2js public release

2017-12-18 Thread Sven Barth via fpc-devel
Am 18.12.2017 14:56 schrieb "Benito van der Zander" :


Isn't speed the main idea of using pointers?

It would be to port all existing pascal code


But that isn't the goal of pas2js. That is what WebAsm is for.


You may want to take a look at asm.js, which has a working
model for emulating pointers in JavaScript. It would be possible to add
a pas2js target for that. But then again there is webassembly
as well and it seems to have better support.


That model looks like quite a slow down


Considering that asm.js and its successor WebAsm can be used to run
ordinary computer games (e.g. DOS games running in DosBox, though there are
also more modern examples - then again running a VM is no small feat
either) I'd say that it works fast enough.

Regards,
Sven
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] First pas2js public release

2017-12-18 Thread Benito van der Zander


Hi,


It seems you want to emulate pointer of integer.


Of all primitive types

In the JavaScript example there was no more integer typing.



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. Perhaps more memory usage


Isn't speed the main idea of using pointers?


It would be to port all existing pascal code



Also what if var and @var are in different units?


Either it needs full program static analysis, or pointers are only 
allowed to something that was used with a pointer in its unit


Local pointers (like var arguments) could always be changed to an array 
when the address is taken, and copied back at the end of scope.




And what about pointer of pointer?


It becomes an array of arrays with the same construction



You may want to take a look at asm.js, which has a working
model for emulating pointers in JavaScript. It would be possible to add
a pas2js target for that. But then again there is webassembly
as well and it seems to have better support.



That model looks like quite a slow down

Cheers,
Benito



On 17.12.2017 22:24, Mattias Gaertner wrote:

On Sun, 17 Dec 2017 21:43:45 +0100
Benito van der Zander  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 are pointers already. For example references to class and
arrays.
It seems you want to emulate pointer of integer.

  

One trick would be to wrap every variable that is accessed by a pointer
in an array (or object).

That would be quite a slow down.
Isn't speed the main idea of using pointers?

Also what if var and @var are in different units?
And what about pointer of pointer?

You may want to take a look at asm.js, which has a working
model for emulating pointers in JavaScript. It would be possible to add
a pas2js target for that. But then again there is webassembly
as well and it seems to have better support.

Mattias

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


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


Re: [fpc-devel] Compiler for current function name

2017-12-18 Thread Mattias Gaertner
On Mon, 18 Dec 2017 10:57:59 +0100
Ondrej Pokorny  wrote:

> On 18.12.2017 10:54, Marco van de Voort wrote:
> > {$i %CURRENTROUTINE%}  
> 
> Thank you!
> Ondrej

Lazarus completion box shows that too.

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


Re: [fpc-devel] Compiler for current function name

2017-12-18 Thread Ondrej Pokorny

On 18.12.2017 10:54, Marco van de Voort wrote:

{$i %CURRENTROUTINE%}


Thank you!
Ondrej
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Compiler for current function name

2017-12-18 Thread Marco van de Voort
In our previous episode, Ondrej Pokorny said:
> 
> I remember there should be a compiler macro in current FPC trunk to get 
> the function name but I cannot find it:
> 
> function TMyObject.DoSomething: Integer;
> begin
>  ? Writeln(_CLASSNAME_, '.', _FUNCTIONNAME_);
> end;
> 
> Does anybody know the macros or do I remember it wrongly?

{$i %CURRENTROUTINE%}
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] Compiler for current function name

2017-12-18 Thread Ondrej Pokorny

Hello!

I remember there should be a compiler macro in current FPC trunk to get 
the function name but I cannot find it:


function TMyObject.DoSomething: Integer;
begin
  Writeln(_CLASSNAME_, '.', _FUNCTIONNAME_);
end;

Does anybody know the macros or do I remember it wrongly?

Thanks
Ondrej

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


Re: [fpc-devel] FPC 3.0.4 released!

2017-12-18 Thread Markus Beth
Hallo,

I want to share my experience with FreePascal 3.0.4 so far. Maybe this
can save someone else (that comes across the same problems) some time:


fpcbuild-3.0.4.tar.gz:
I tried to build RPM packages for OpenSUSE from fpcbuild-3.0.4.tar.gz
(downloaded from sourceforge.net). But that failed because the included
fpcdocs seems to be outdated (r1447?). A "make pdf" breaks because
linuxex/ex71.pp cannot be found. Using r1449 from fpcdocs resolves this problem.
See also https://bugs.freepascal.org/view.php?id=32843.


fpc-3.0.4-1.x86_64.rpm:
Some included object files 
(e.g. /usr/lib64/fpc/3.0.4/units/x86_64-linux/rtl/prt0.o, 
/usr/lib64/fpc/3.0.4/units/x86_64-linux/rtl/dllprt0.o) 
use the "new" relocation type R_X86_64_REX_GOTPCRELX (42) that "old"
binutils do not understand. So you cannot use this (binary) rpm on
distributions that have binutils before version 2.26 (e.g. CentOS 7).
On these distributions you might want to rebuild a binary rpm from the
source rpm fpc-3.0.4-1.src.rpm to overcome this problem.
But this seems to be old news (see
https://bugs.freepascal.org/view.php?id=32251)


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