12015-09-17 Sukolsak Sakshuwong <sukolsak@gmail.com>
2
3 Convert return values from JavaScript functions to the expected types in WebAssembly
4 https://bugs.webkit.org/show_bug.cgi?id=149200
5
6 Reviewed by NOBODY (OOPS!).
7
8 When a WebAssembly function calls a JavaScript function, there is no
9 guarantee that the JavaScript function will always return values of the
10 type we expect. This patch converts the return values to the expected
11 types.
12
13 (The reverse is also true: When a WebAssembly function is called from a
14 JavaScript function, there is no guarantee that the arguments to the
15 WebAssembly function will always be of the types we expect. We have
16 fixed this in Bug 149033.)
17
18 We don't need to type check the return values if the callee is a
19 WebAssembly function. We don't need to type check the arguments if the
20 caller is a WebAssembly function. This optimization will be
21 implemented in the future.
22
23 * tests/stress/wasm-type-conversion.js:
24 * tests/stress/wasm/type-conversion.wasm:
25 * wasm/WASMFunctionCompiler.h:
26 (JSC::WASMFunctionCompiler::startFunction):
27 (JSC::WASMFunctionCompiler::buildReturn):
28 (JSC::WASMFunctionCompiler::boxArgumentsAndAdjustStackPointer):
29 (JSC::WASMFunctionCompiler::callAndUnboxResult):
30 (JSC::WASMFunctionCompiler::convertValueToInt32):
31 (JSC::WASMFunctionCompiler::convertValueToDouble):
32 (JSC::WASMFunctionCompiler::convertDoubleToValue):
33 (JSC::WASMFunctionCompiler::loadValueAndConvertToInt32): Deleted.
34 (JSC::WASMFunctionCompiler::loadValueAndConvertToDouble): Deleted.
35 * wasm/WASMFunctionParser.cpp:
36 (JSC::WASMFunctionParser::parseExpressionI32):
37 (JSC::WASMFunctionParser::parseExpressionF32):
38 (JSC::WASMFunctionParser::parseExpressionF64):
39 (JSC::WASMFunctionParser::parseCallInternalExpressionI32): Deleted.
40 * wasm/WASMFunctionParser.h:
41