Open tshort opened 6 years ago
@sjorn3, I remember you had a blog post with an array example. Is that link still available?
Yep all of my blog stuff is still up at seaninn.es/gsoc_blog. I think the one you want is: http://seaninn.es/gsoc_blog/gsoc/2018/06/25/array-example.html
If these changes are just fixing the docos tests and updating to julia 0.7 then this looks fine to me though I haven't had a chance to test them locally. Just need to delete the comment saying it doesn't work.
While tests pass, there's still breakage on these branches. For arrays, I started to try to replicate Sean's array example in his blog entry. I can create both "wasm" and "wast" files, but both seem broken. The binary file just errors. The text file has bad entries. Here are some examples:
(local i32) (local i32)
(get_local 0)
(WebAssembly.GetGlobal(13))
(i32.gt_u)
(if
(then
(WebAssembly.MemoryUtility(:current_memory, false)) ;; BAD
...
(i32.sub)
(WebAssembly.MemoryUtility(:grow_memory, false)) ;; BAD
(i32.const 0)
(i32.lt_s)
(if
(then
(i32.const 0)
(return)))
(get_local 2)
(i32.const 16)
(i32.shl)
(WebAssembly.SetGlobal(13)))) ;; BAD
I'm not sure what would be wrong with the binary off the top of my head, but definitely the issue with wast is that I never added a show instance for most of the new stuff I added, so it's just printing out the data structure. This should be simple enough to fix.
The translations should all be straight forward, for the examples you gave:
WebAssembly.GetGlobal(13) -> get_global 13
WebAssembly.SetGlobal(13) -> set_global 13
WebAssembly.MemoryUtility(:current_memory, false) -> current_memory
WebAssembly.MemoryUtility(:grow_memory, false) -> grow_memory
IIRC the bool in the memory commands was a quirk of the binary format that currently isn't used for anything.
Thanks, Sean. I'll work on getting text to work. It still might be good to go ahead and merge this and the julia-0.7-optimise branch in WebAssembly.
I think the wasm files are working. I must have just goofed my first attempt. @sjorn3, in trying to recreate your blog post above, I'm missing getn
and setn
. How do I define those, or where do I get them from?
I can replicate your blog example up to the point where it calls setn
. I tried assigning it to setindex!
, but that didn't work.
Ok to merge this and its WebAssembly counterpart?
Great – @sjorn3 want to take a look over it?