Implement some arithmetic instructions in WebAssembly
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Sep 2015 22:45:03 +0000 (22:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Sep 2015 22:45:03 +0000 (22:45 +0000)
commit9891a843a7dca1ca0821cd3db7ab9334296d605c
tree3d294392efc4aae035159c810a98b9986a17a7bc
parent2ff47cdaf5b1489fb8bdbb899da1a41fe3e9e90d
Implement some arithmetic instructions in WebAssembly
https://bugs.webkit.org/show_bug.cgi?id=148737

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

This patch implements the addition and subtraction instructions in
WebAssembly using a stack-based approach: each instruction reads its
operands from the top of the 'temporary' stack, pops them, and
optionally pushes a return value to the stack. Since operands are passed
on the stack, we don't use the arguments that are passed to the methods
of WASMFunctionCompiler, and we don't use the return values from these
methods. (We will use them when we implement LLVM IR generation for
WebAssembly, where each expression is an LLVMValueRef.)

* tests/stress/wasm-arithmetic.js: Added.
* tests/stress/wasm-arithmetic.wasm: Added.
* wasm/WASMFunctionCompiler.h:
(JSC::WASMFunctionCompiler::endFunction):
(JSC::WASMFunctionCompiler::buildReturn):
(JSC::WASMFunctionCompiler::buildImmediateI32):
(JSC::WASMFunctionCompiler::buildBinaryI32):
(JSC::WASMFunctionCompiler::temporaryAddress):
* wasm/WASMFunctionParser.cpp:
(JSC::WASMFunctionParser::parseReturnStatement):
(JSC::WASMFunctionParser::parseExpressionI32):
(JSC::WASMFunctionParser::parseImmediateExpressionI32):
(JSC::WASMFunctionParser::parseBinaryExpressionI32):
* wasm/WASMFunctionParser.h:
* wasm/WASMFunctionSyntaxChecker.h:
(JSC::WASMFunctionSyntaxChecker::startFunction):
(JSC::WASMFunctionSyntaxChecker::endFunction):
(JSC::WASMFunctionSyntaxChecker::buildReturn):
(JSC::WASMFunctionSyntaxChecker::buildImmediateI32):
(JSC::WASMFunctionSyntaxChecker::buildBinaryI32):
(JSC::WASMFunctionSyntaxChecker::stackHeight):
(JSC::WASMFunctionSyntaxChecker::updateTempStackHeight):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/tests/stress/wasm-arithmetic.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/wasm-arithmetic.wasm [new file with mode: 0644]
Source/JavaScriptCore/wasm/WASMFunctionCompiler.h
Source/JavaScriptCore/wasm/WASMFunctionParser.cpp
Source/JavaScriptCore/wasm/WASMFunctionParser.h
Source/JavaScriptCore/wasm/WASMFunctionSyntaxChecker.h