Jump to page: 1 2
Thread overview
WebAssembly + Custom Runtime + Associative Arrays
Nov 10, 2020
Remi
Nov 10, 2020
Ferhat Kurtulmuş
Nov 10, 2020
Ferhat Kurtulmuş
Nov 10, 2020
Johan
Nov 10, 2020
Adam D. Ruppe
Nov 10, 2020
Ferhat Kurtulmuş
Nov 10, 2020
Remi
Nov 10, 2020
Adam D. Ruppe
Nov 10, 2020
Remi
Nov 10, 2020
Remi
Nov 11, 2020
Ferhat Kurtulmuş
Nov 11, 2020
Remi
Nov 11, 2020
kinke
Nov 11, 2020
kinke
Nov 11, 2020
Remi
Nov 11, 2020
Ferhat Kurtulmuş
November 10, 2020
Hi all,

I've been trying to compile a game project to WebAssembly for a while. It had been going quite well but I'm hitting an issue with associative arrays now and I don't know if it's a compiler bug or something on my side.

I uploaded some code with a broken example here: https://github.com/speps/dwasmaa

If you clone it then run a HTTP server and navigate to index.htm, it will output the wrong message as described in the README.

If you compile+run it with `dub --arch=x86` it displays the correct message (sorry that arch only works in Windows for now as I'm not using the runtime and only hooked up Win32 API console output).

Anyway, where am I going wrong? Thanks.

- Remi Gillig.
November 10, 2020
On Tuesday, 10 November 2020 at 18:24:03 UTC, Remi wrote:
> Hi all,
>
> I've been trying to compile a game project to WebAssembly for a while. It had been going quite well but I'm hitting an issue with associative arrays now and I don't know if it's a compiler bug or something on my side.
>
> I uploaded some code with a broken example here: https://github.com/speps/dwasmaa
>
> If you clone it then run a HTTP server and navigate to index.htm, it will output the wrong message as described in the README.
>
> If you compile+run it with `dub --arch=x86` it displays the correct message (sorry that arch only works in Windows for now as I'm not using the runtime and only hooked up Win32 API console output).
>
> Anyway, where am I going wrong? Thanks.
>
> - Remi Gillig.

AA needs druntime. Adam's repo does not include a custom AA implementation.
November 10, 2020
On Tuesday, 10 November 2020 at 19:20:42 UTC, Ferhat Kurtulmuş wrote:
> On Tuesday, 10 November 2020 at 18:24:03 UTC, Remi wrote:
>> [...]
>
> AA needs druntime. Adam's repo does not include a custom AA implementation.

Uhh you did it in your repo. Sorry.
November 10, 2020
On Tuesday, 10 November 2020 at 18:24:03 UTC, Remi wrote:
> Hi all,
>
> I've been trying to compile a game project to WebAssembly for a while. It had been going quite well but I'm hitting an issue with associative arrays now and I don't know if it's a compiler bug or something on my side.

I know almost nothing about webassembly, but I think 0 (`null`) is a valid memory address. Could that be the reason for the troubles? (some object allocated on address 0?)

-Johan

November 10, 2020
On Tuesday, 10 November 2020 at 18:24:03 UTC, Remi wrote:
> Anyway, where am I going wrong? Thanks.

Looks like you fixed the array append function but the one in my repo was broken af until... well right now, I just pushed. The way that function works is bizarre.

But I think you did it right here... just like... that's where I'd focus attention first to confirm it actually works before digging much deeper.
November 10, 2020
On Tuesday, 10 November 2020 at 18:24:03 UTC, Remi wrote:
> Hi all,
>
> I've been trying to compile a game project to WebAssembly for a while. It had been going quite well but I'm hitting an issue with associative arrays now and I don't know if it's a compiler bug or something on my side.
>
> I uploaded some code with a broken example here: https://github.com/speps/dwasmaa
>
> If you clone it then run a HTTP server and navigate to index.htm, it will output the wrong message as described in the README.
>
> If you compile+run it with `dub --arch=x86` it displays the correct message (sorry that arch only works in Windows for now as I'm not using the runtime and only hooked up Win32 API console output).
>
> Anyway, where am I going wrong? Thanks.
>
> - Remi Gillig.

It is weird, but if you pass pointer aa as ref it works.

extern (C) void* _aaGetY(ref AA* aa, const TypeInfo_AssociativeArray aati, in size_t valuesize, in void* pkey)
November 10, 2020
On Tuesday, 10 November 2020 at 21:23:07 UTC, Ferhat Kurtulmuş wrote:
> On Tuesday, 10 November 2020 at 18:24:03 UTC, Remi wrote:
>> [...]
>
> It is weird, but if you pass pointer aa as ref it works.
>
> extern (C) void* _aaGetY(ref AA* aa, const TypeInfo_AssociativeArray aati, in size_t valuesize, in void* pkey)

Wow thanks! Can't believe I didn't think of that. Seems to work indeed.
November 10, 2020
On Tuesday, 10 November 2020 at 22:36:40 UTC, Remi wrote:
> Wow thanks! Can't believe I didn't think of that. Seems to work indeed.

I don't understand why that would work though..

you don't change aa itself, just the aa.impl which should go through the pointer already.....
November 10, 2020
On Tuesday, 10 November 2020 at 22:38:30 UTC, Adam D. Ruppe wrote:
> On Tuesday, 10 November 2020 at 22:36:40 UTC, Remi wrote:
>> Wow thanks! Can't believe I didn't think of that. Seems to work indeed.
>
> I don't understand why that would work though..
>
> you don't change aa itself, just the aa.impl which should go through the pointer already.....

Well, it seems my troubles aren't finished though. I'm having another _aaGetY crash to figure out by using the WASM debugger in Firefox...
November 10, 2020
On Tuesday, 10 November 2020 at 22:53:59 UTC, Remi wrote:
> On Tuesday, 10 November 2020 at 22:38:30 UTC, Adam D. Ruppe wrote:
>> On Tuesday, 10 November 2020 at 22:36:40 UTC, Remi wrote:
>>> Wow thanks! Can't believe I didn't think of that. Seems to work indeed.
>>
>> I don't understand why that would work though..
>>
>> you don't change aa itself, just the aa.impl which should go through the pointer already.....
>
> Well, it seems my troubles aren't finished though. I'm having another _aaGetY crash to figure out by using the WASM debugger in Firefox...

Also that fixes makes it crash in the x86 build now. So yeah Adam you might be right, it doesn't really fix it in the right way. I'm still not sure why it's doing that.
« First   ‹ Prev
1 2