News for hackers. Stuff that matters.
Re:AssemblyScript: A Subset of TypeScript That Compiles to W... by trgv on Wednesday September 06, 2017 @10:21PM (#15188698)
Right now, one of the projects I'm working on calls a wasm function which returns a pointer. I then do a lookup in the wasm buffer at the address specified by the pointer and pull out a few numbers with a float64array constructor. Is that an expensive operation?
Re:AssemblyScript: A Subset of TypeScript That Compiles to W... by kannanvijayan on Wednesday September 06, 2017 @10:52PM (#15188835)
It's probably best to keep a Float64Array view into the ArrayBuffer around, and use that repeatedly instead of constructing a fresh one each time.

The interpreters and baseline JITs will always construct the object because they can't inline and they don't do whole-method analysis.. and the heavyweight JITs _probably would_ inline the constructor, then notice that the constructed array does not escape, then scalarize the whole thing down to a single read...

but hey, why work the optimizer so hard when you can just make life easy for it and do a single allocation up front, and it runs fast in all performance tiers, and performance isn't predicated on a particular optimization strategy being utilized.

Re:AssemblyScript: A Subset of TypeScript That Compiles to W... by trgv on Wednesday September 06, 2017 @11:52PM (#15189030)
Thanks for the advice, very helpful.
Re:AssemblyScript: A Subset of TypeScript That Compiles to W... by jononor on Thursday September 07, 2017 @07:41AM (#15190857)
You should ask the profiler.