-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AssemblyScript] porting source from JS to AS #421
base: master
Are you sure you want to change the base?
Conversation
Final steps are:
Please comment here if you are interested to generously help. ⚡✨🚀 -- |
This will be neat for AS users to have! Is there a particular reason to commit the build artefacts to the repo? Those can be built during publish time when publishing to NPM for example. Why build Wasm modules? If people will import the JS code into their JS projects, or import the AS code into their AS projects, then the module builds would not be needed. The Wasm modules are needed only for JS users who would import the Wasm modules instead of the JS code. Wondering if that's it's worth building modules. Would the barrier between JS and Wasm allow this to be faster? It would be sweet to see what perf diff looks like in a JS example that makes many calls into the module, vs plain JS and vs plain AS. |
Hi @trusktr
Thanks! I hope we could see more WebGL frameworks emerge on the WebAssembly platform and this helps to train programming in Assemblyscript 🙂
I was unsure at first, but I decided to include this because of the AssemblyScript conventions and I suppose someone could just download the file to include it in an existing project, especially during this testing phase.
Yes, exactly. A default
I am looking forward to try both implementations from the browser 😃 |
- disable size optimization - disable assertions in production Co-authored-by: Max Graey <[email protected]>
I have a weird compiler output due to type declared inside modules yet.. But so far, it seems to go well. Edit:
|
production build achieved from assembly
esm and cjs are produced by tsc rollup build all wasm loaders
3a12ac0
to
8a56b64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This work finalizes the first build targeting Javascript and Webassembly.
must declare hypot3, hypot4, hypot7, ... each for function overloading moved namespace Math into maths.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rollup supports operation for both release and debug script allows to produce the exports for each loader files loader is compiled from JS using typescript but babel is supported
loader/index.js
Outdated
|
||
let modules; | ||
|
||
wasm({ ...imports }).then(instance => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary, before I implement a better solution for exporting WebAssembly modules. Solutions are either:
Making a WASM file for each module (curently max size for synchronous compilation is 4KB). Current WASM file is >100KB with-O3
optimization- Complying on @assemblyscript/loader using
loader.instantiateStreaming
- Develop a processor script to pass
<script>
to WebAssembly usingeval
or some callback and DOM for moving executed elements to<noscript>
- Accessing modules using Direct Memory Access https://www.assemblyscript.org/loader.html#direct-memory-access
- Make the synchronous Instantiation in a WebWorker or another Thread https://developer.mozilla.org/en-US/docs/Tools/Performance/Scenarios/Intensive_JavaScript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently experimenting with as-bind
global function min cannot be accessed inside class when overriden asconfig.json: tdsFiles, exportRuntime, runtime set to incremental
32 Bit SupportThis PR is great! I'm in the process of implementing the brach in my project now. //64
export type Float = f64
export type FloatArray = Float64Array
export const FloatMath = Math
//32
export type Float = f32
export type FloatArray = Float32Array
export const FloatMath = Mathf |
Hello @mrchantey, Please you are welcome for trying and sharing your proposition. |
I didn't make any advancement on this PR. I was waiting for |
Follows #420