[fpc-devel] First pas2js public release

Benito van der Zander benito at benibela.de
Mon Dec 18 14:55:53 CET 2017


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<100000;i++) x++;

and

var x = [1];
for (var i=0;i<100000;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 <benito at 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 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 at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20171218/76920266/attachment.html>


More information about the fpc-devel mailing list