WebAssembly JS API: throw when a promise can't be created
authorjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Nov 2017 21:57:09 +0000 (21:57 +0000)
committerjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Nov 2017 21:57:09 +0000 (21:57 +0000)
commitae98a4b4a1d04bc38c45130a4393e93e281bdbcb
tree05b347e9bdca6f118c63b21292b2bbd507100cf9
parent54b58454490d3cc043eae1cb0d74f9feb2aeba28
WebAssembly JS API: throw when a promise can't be created
https://bugs.webkit.org/show_bug.cgi?id=179826
<rdar://problem/35455813>

Reviewed by Mark Lam.

JSTests:

Test WebAssembly.{compile,instantiate} where promise creation
fails because of a stack overflow.

* wasm/js-api/promise-stack-overflow.js: Added.
(const.runNearStackLimit.f.const.t):
(async.testCompile):
(async.testInstantiate):

Source/JavaScriptCore:

Failure *in* a promise causes rejection, but failure to create a
promise (because of stack overflow) isn't really spec'd (as all
stack things JS). This applies to WebAssembly.compile and
WebAssembly.instantiate.

Dan's current proposal says:

    https://littledan.github.io/spec/document/js-api/index.html#stack-overflow

    Whenever a stack overflow occurs in WebAssembly code, the same
    class of exception is thrown as for a stack overflow in
    JavaScript. The particular exception here is
    implementation-defined in both cases.

    Note: ECMAScript doesn’t specify any sort of behavior on stack
    overflow; implementations have been observed to throw RangeError,
    InternalError or Error. Any is valid here.

This is for general stack overflow within WebAssembly, not
specifically for promise creation within JavaScript, but it seems
like a stack overflow in promise creation should follow the same
rule instead of, say, swallowing the overflow and returning
undefined.

* wasm/js/WebAssemblyPrototype.cpp:
(JSC::webAssemblyCompileFunc):
(JSC::webAssemblyInstantiateFunc):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224985 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/wasm/js-api/promise-stack-overflow.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp