by Steven Myers
This is an example of a monomorhpic stub.
function arraySum(arr){
var sum = 0;
for (var i = 0; i < arr.length; i++) {
//if arr[i] is always int then compiler
//will stub and run as int addition
sum += arr[i];
}
}
example via Lin Clark
"main problem that wasm is aiming to solve... quickly start large applications"-- Alon Zakai
const importObject = {
imports: { imported_func: arg => alert(arg) }
};
fetch('assets/simple.wasm')
.then(response => response.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, importObject))
.then(results => results.instance.exports.exported_func())
resources
resources continued