the JavaScriptCore(JSContext) in iOS not support WebAssembly

i have the demand to use JSContext run the JavaScript with WebAssembly, but JSContext not support.

i test this on the iOS12.4, iPhone6s

let 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 print

Out of executable memory in function at index 0 (evaluating 'new WebAssembly.Instance(mod, {})')

Replies

Tested on iOS 14 and 15:

(lldb) po message
"ok"

I am running into the same situation with JavaScriptCore not allowing WebAssembly anymore.