Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - redretroking

Pages: [1]
Help / strlen in wast
« on: October 15, 2017, 03:02:23 pm »
Last night I was working on something and needed strlen, I wrote the following, but I am curious if someone knows of a better way. For example would it be worth unrolling offset 1,2,3? Is there a different op code I can use that would be better?

Code: [Select]
(func $strlen (param $s i32) (result i32)
    (local $head i32)
    (set_local $head (get_local $s))
    (loop $done $loop
      (br_if $done (i32.eq (i32.const 0) (i32.load8_u offset=0 (get_local $head))))
      (set_local $head (i32.add (get_local $head) (i32.const 1)))
      (br $loop)
    (return (i32.sub (get_local $head) (get_local $s)))

Make it so I can write a program for the 2011 ant AI challenge in a webpage and then see it run right there in the webpage

Port this C code (don't just use llvm to compile it resulting in a bloated binary) https://github.com/icefox/genesys
So you can it inside of this webpage: http://icefox.github.io/genesys/
Full background: http://benjamin-meyer.blogspot.com/2015/03/a-connection-machine-in-your-pocket.html

Discussions / Why is the speed of web assembly comparable to native code?
« on: October 01, 2017, 07:50:23 pm »
My understanding is that wasm is very similar to direct memory manipulation thus it is very fast. But isn't this memory manipulation on top of javascript interpreter, thus should be magnitude slower since we are not directly manipulating memory but rather treating javascript primitives as memory?

Am I getting anything wrong?

Pages: [1]