Posts

Post not yet marked as solved
2 Replies
2k Views
i have the demand to use JSContext run the JavaScript with WebAssembly, but JSContext not support.i test this on the iOS12.4, iPhone6slet script = """ (()=>{ function testSafariWebAssemblyBug() { var bin = new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]); var mod = new WebAssembly.Module(bin); var inst = new WebAssembly.Instance(mod, {}); // test storing to and loading from a non-zero location via a parameter. // Safari on iOS 11.2.5 returns 0 unexpectedly at non-zero locations // console.log(inst.exports.test(4)); return (inst.exports.test(4) !== 0); } if (testSafariWebAssemblyBug()) { // ok, we stored a value. return 'ok'; } else { return 'fail'; } })(); """ var context = JSContext( context?.exceptionHandler = { [weak self] _, error in if let error = error { let message = String(describing: error) print(message) } } let value = context?.evaluateScript(script) if let value = value { let message = String(describing: value) print(message) }the console printOut of executable memory in function at index 0 (evaluating 'new WebAssembly.Instance(mod, {})')
Posted
by doom_sil.
Last updated
.