TurboScript icon indicating copy to clipboard operation
TurboScript copied to clipboard

Standard libs like Math and polyfills (charCodeAt, fromCharCode, etc)

Open MaxGraey opened this issue 7 years ago • 8 comments

According to this: https://github.com/WebAssembly/design/blob/master/FAQ.md we need manually implement all sets of js enviroment. This is big job. I could help with this

UPD I see some stdlib already implement with direct binding to Wasm opcodes.

MaxGraey avatar Mar 24 '17 19:03 MaxGraey

How you bind Math library to Wasm right now? It seems just import from js according this: https://github.com/01alchemist/TurboScript/blob/master/tests/math-wasm.html.

~~One more thing. In declared set of WasmOpcodes are missing f32_fma and f64_fma commands: https://github.com/01alchemist/TurboScript/blob/master/src/wasm/opcode.ts~~

Sorry, this post MVP feature. Not implement yet.

MaxGraey avatar Mar 25 '17 00:03 MaxGraey

Right now importing from JavaScript built-in. I need to implement method overload to use same functions for different signatures like in JavaScript. It's a big task to implement all built-ins manually. We need to wait for WASM 2 Specification to be finalized before implementing this manually. For now, for compatibility we can import slow Math library from JS and gradually add fast implementations in WASM.

nidin avatar Mar 25 '17 08:03 nidin

That's right we definitely need fma command for IEEE-754 (2008) compatible sin, cos, log and etc, but min, max, sqrt, rounding and abs we already has direct equivalents in wasm, so we can use them now

MaxGraey avatar Mar 25 '17 19:03 MaxGraey

Sure we can implement direct equalents right away. right now built-in classes and functions are located inside library folder.

nidin avatar Mar 25 '17 20:03 nidin

Be sure there are no associated costs for modules that don't use these features.

winksaville avatar Apr 12 '17 14:04 winksaville

Tree shaking should remove unused functions. So there will be no extra cost.

On Wed 12. Apr 2017 at 4:32 PM, Wink Saville [email protected] wrote:

Be sure there are no associated costs for modules that don't use these features.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/01alchemist/TurboScript/issues/14#issuecomment-293596150, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMGZq9tB3h_EE-GiNmmTsGBwi1ONUnIks5rvOBegaJpZM4MorMz .

nidin avatar Apr 12 '17 15:04 nidin

@nidin Is it possible use wasm's sqrt, clz, ctz, popcount, copysign and etc now?

MaxGraey avatar Apr 12 '17 15:04 MaxGraey

Not yet. No work done in that direction. You are free to investigate.

On Wed 12. Apr 2017 at 5:55 PM, Max Graey [email protected] wrote:

@nidin https://github.com/nidin Is it possible use wasm's sqrt, clz, ctz, popcount, copysign and etc now?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/01alchemist/TurboScript/issues/14#issuecomment-293623992, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMGZkyvyTS8mo_YLFfkXEHAvIRcb0bBks5rvPPcgaJpZM4MorMz .

nidin avatar Apr 12 '17 16:04 nidin