Previously, i8 and i16 was careless w.r.t. the top bits,
because they were only used by v128, which uses Bytes.get/set that
appropriate masks the top bits when storing into the byte array.
With this change, i8 and i16 are self contained small integers
implemented using int32. They are always stored signed-extended, e.g.
INT8_MIN (-128) is stored as 0xffffff80.
This requires adding sign-extension operation (Rep.sx) in a couple of
places, that will make sure to extend the sign bit to the rest of the
int32.
Also add a small, non-exhaustive test for these small integers in a new
file test/smallint.ml. This is the first ml test we are adding (all
previous tests are wasm/wast tests that we run using the interpreter),
so there are some modifications to the Makefile to build and run this
test (make smallinttest, make test will also run it).
Previously, i8 and i16 was careless w.r.t. the top bits, because they were only used by v128, which uses Bytes.get/set that appropriate masks the top bits when storing into the byte array.
With this change, i8 and i16 are self contained small integers implemented using int32. They are always stored signed-extended, e.g. INT8_MIN (-128) is stored as 0xffffff80.
This requires adding sign-extension operation (Rep.sx) in a couple of places, that will make sure to extend the sign bit to the rest of the int32.
Also add a small, non-exhaustive test for these small integers in a new file test/smallint.ml. This is the first ml test we are adding (all previous tests are wasm/wast tests that we run using the interpreter), so there are some modifications to the Makefile to build and run this test (make smallinttest, make test will also run it).