Skip to content

Commit

Permalink
jsc/wasm32/wasm32.jsc: revert
Browse files Browse the repository at this point in the history
  • Loading branch information
pipcet committed Feb 3, 2021
1 parent 1cfbe31 commit 836ca19
Showing 1 changed file with 68 additions and 31 deletions.
99 changes: 68 additions & 31 deletions jsc/wasm32/wasm32.jsc
Original file line number Diff line number Diff line change
Expand Up @@ -5706,36 +5706,6 @@ var module;
var gRetrigger;
var gExitStatus = 0;

async function run() {
let process = new Wasm32Process(system);
module = await process.modules.module(path);
process.modules.push(module);
module.sizes = sizes;

system.instantiate(module, vm, args, environment_variables()).then(() => {
try {
run = () => {
try {
if (!system.step())
Promise.resolve().then(run);
} catch (e) {
console.log(e);
console.log(e.stack);
}
};
run();
gRetrigger = run;
} catch (e) {
console.log("exception");
console.log(e);
console.log(e.stack);
}
}).catch((e) => {
console.log("caught");
console.log(e);
});
}

if (remote) {
fetch(path).then(response => {
if (response.ok)
Expand Down Expand Up @@ -5777,6 +5747,73 @@ if (remote) {
console.log("e2:" + e + "\n" + e.stack);
});
} else if (typeof os !== "undefined") {
run();
module = new Wasm32Module(new Wasm32Process(system), os.file.readFile(path, "binary"));
module.sizes = sizes;

system.instantiate(module, vm, args, environment_variables()).then(() => {
try {
run = () => {
try {
if (!system.step())
Promise.resolve().then(run);
} catch (e) {
console.log(e);
console.log(e.stack);
}
};
run();
gRetrigger = run;
} catch (e) {
console.log("exception");
console.log(e);
console.log(e.stack);
}
}).catch((e) => {
console.log("caught");
console.log(e);
});
} else if (typeof fetch !== "undefined") {
caches.open("v3").then((cache) => {
var req = new Request(path);

return cache.match(req).then((response) => {
if (response === undefined)
return fetch(path);

return response;
}).then(response => {
cache.put(path, response.clone());

if (response.ok)
return response.arrayBuffer();

return Promise.reject(response);
});
}).then((ab) => {
module = new Wasm32Module(ab);

return system.instantiate(module, vm, args, []);
}).then(() => {
try {
run = () => {
try {
system.step();
Promise.resolve().then(run);
} catch (e) {
console.log(e);
console.log(e.stack);
}
};
run();
} catch (e) {
console.log("exception");
console.log(e);
console.log(e.stack);
}
}).catch((e) => {
console.log("caught");
console.log(e);
console.log(e.stack);
});
}

0 comments on commit 836ca19

Please sign in to comment.