[fpc-devel] First pas2js public release

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Dec 18 17:19:21 CET 2017

On Mon, 18 Dec 2017 14:55:53 +0100
Benito van der Zander <benito at 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<100000;i++) x++;
> and
> var x = [1];
> for (var i=0;i<100000;i++) x[0]++;
> in Firefox.

Of course not. First of all 100000 is ridiculously small and second
the above example is probably optimized by the engine.
For example under V8 with 100000000 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.


More information about the fpc-devel mailing list