Implement the signed division instruction in WebAssembly
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 22:47:23 +0000 (22:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 22:47:23 +0000 (22:47 +0000)
commit53d2ecb8e2ef340a5a07b363b93326ae18c22b69
treedc0f2ecd11892c2360540add240793345d627946
parente36a59f72de2336d9494c3fc3431527be5bf1727
Implement the signed division instruction in WebAssembly
https://bugs.webkit.org/show_bug.cgi?id=148772

Patch by Sukolsak Sakshuwong <sukolsak@gmail.com> on 2015-09-04
Reviewed by Geoffrey Garen.

This patch implements the signed division instruction in WebAssembly
for 32-bit integers. We use the IDIV instruction on x86 and x86-64 and
use a C function on all other platforms. We throw an exception if
- the denominator is zero, or
- the numerator is -2^31 and the denominator is -1.

* jit/JITOperations.cpp:
* jit/JITOperations.h:
* tests/stress/wasm-arithmetic.js:
(shouldBe):
(shouldThrow):
* tests/stress/wasm-arithmetic.wasm:
* wasm/WASMFunctionCompiler.h:
(JSC::operationDiv):
(JSC::WASMFunctionCompiler::endFunction):
(JSC::WASMFunctionCompiler::buildBinaryI32):
(JSC::WASMFunctionCompiler::appendCall):
(JSC::WASMFunctionCompiler::appendCallWithExceptionCheck):
(JSC::WASMFunctionCompiler::callOperation):
(JSC::WASMFunctionCompiler::throwStackOverflowError): Deleted.
* wasm/WASMFunctionParser.cpp:
(JSC::WASMFunctionParser::parseExpressionI32):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189396 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/jit/JITOperations.h
Source/JavaScriptCore/tests/stress/wasm-arithmetic.js
Source/JavaScriptCore/tests/stress/wasm-arithmetic.wasm
Source/JavaScriptCore/wasm/WASMFunctionCompiler.h
Source/JavaScriptCore/wasm/WASMFunctionParser.cpp