Extend WebAssembly with rounded floating-point instructions
The goal is to create new instruction in WebAssembly reference interpreter, which will demonstrate your understanding and implementation of the f64.add_all_zeros operation. This operation is somewhat senseless itself, but you will be able to extend the
Download and build WASM reference implementation
git clone git@github.com:WebAssembly/wabt.git ls rm -r build/ cd wabt/ ls mkdir build cd build/ cmake .. git clone https://github.com/whirlicote/rounding-mode-control.git cd rounding-mode-control/intepreter git checkout origin/rounding-testcases You should now be in detached head state. Create new branch (optional): git checkout origin/rounding-testcases git checkout -b rounding-testcases
We will now create a new test case for our new assembly instruction, because we follow test driven development.
At this point you should see that make test should give at least 1 failure:
[superuser@valhalla:~/rounding-mode-control/interpreter]$ make test dune build smallint.exe dune exec ./smallint.exe ../test/core/run.py --wasm `pwd`/wasm .............................F..................................................................................................................... ====================================================================== FAIL: test float_misc.wast (__main__.RunTests.test float_misc.wast) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/galt/rounding-mode-control/interpreter/../test/core/run.py", line 118, insetattr(RunTests, testName, lambda self, file=fileName: self._runTestFile(file)) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/galt/rounding-mode-control/interpreter/../test/core/run.py", line 72, in _runTestFile self._runCommand(('%s -d "%s" -o "%s"') % (wasmCommand, inputPath, jsPath), logPath) File "/home/galt/rounding-mode-control/interpreter/../test/core/run.py", line 50, in _runCommand self.assertEqual(expectedExitCode, exitCode, "failed with exit code %i (expected %i) for %s" % (exitCode, expectedExitCode, command)) AssertionError: 0 != 1 : failed with exit code 1 (expected 0) for /home/galt/rounding-mode-control/interpreter/wasm -d "/home/galt/da/rounding-mode-control/test/core/float_misc.wast" -o "/home/galt/rounding-mode-control/test/core/_output/float_misc.js" ---------------------------------------------------------------------- Ran 147 tests in 26.508s FAILED (failures=1) make: *** [Makefile:71: test] Error 1
Bonus chatter
make test does not always overwrite wasm binary. So I usually remove it myself: rm -f wasm; make test.