Charlotte.jl icon indicating copy to clipboard operation
Charlotte.jl copied to clipboard

Updates for Julia 1.0

Open tshort opened this issue 7 years ago • 9 comments

tshort avatar Oct 13 '18 16:10 tshort

Great – @sjorn3 want to take a look over it?

MikeInnes avatar Oct 15 '18 12:10 MikeInnes

@sjorn3, I remember you had a blog post with an array example. Is that link still available?

tshort avatar Oct 27 '18 19:10 tshort

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.

sjorn3 avatar Oct 29 '18 12:10 sjorn3

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

tshort avatar Dec 01 '18 00:12 tshort

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.

sjorn3 avatar Dec 01 '18 10:12 sjorn3

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.

tshort avatar Dec 01 '18 11:12 tshort

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?

tshort avatar Dec 01 '18 23:12 tshort

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.

tshort avatar Dec 01 '18 23:12 tshort

Ok to merge this and its WebAssembly counterpart?

tshort avatar Dec 03 '18 23:12 tshort