Skip to content

Commit fdf44d6

Browse files
committed
Merge pull request #82 from WebAssembly/numerics
Factor out i32 and i64 from arithmetic.ml; implement wasm-compatible semantics
2 parents df77a0a + 628af67 commit fdf44d6

32 files changed

+1589
-355
lines changed

ml-proto/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ You'll get an executable named `src/wasm`.
2828
Alternatively, you can also say (in `src`):
2929

3030
```
31-
ocamlbuild -Is "given, spec, host" -libs "bigarray, nums, str" main.native
31+
ocamlbuild -Is "given, spec, host" -libs "bigarray, str" main.native
3232
```
3333

3434
and get an executable named `src/main.native`.

ml-proto/TestingTodo.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ Misc semantics:
1515

1616
Operator semantics:
1717
- test that promote/demote, sext/trunc, zext/trunc is bit-preserving if not NaN
18-
- test that clz/ctz handle zero
18+
- ~~test that clz/ctz handle zero~~
1919
- test that numbers slightly outside of the int32 range round into the int32 range in floating-to-int32 conversion
2020
- test that neg, abs, copysign, reinterpretcast, store+load, set+get, preserve the sign bit and significand bits of NaN and don't canonicalize
21-
- test that shifts don't mask their shift count. 32 is particularly nice to test.
21+
- ~~test that shifts don't mask their shift count. 32 is particularly nice to test.~~
2222
- test that `page_size` returns something sane [(power of 2?)](https://github.com/WebAssembly/design/pull/296)
2323
- test that arithmetic operands are evaluated left-to-right
24-
- test that add/sub/mul/wrap/wrapping-store silently wrap on overflow
25-
- test that sdiv/udiv/srem/urem trap on divide-by-zero
26-
- test that sdiv traps on overflow
27-
- test that srem doesn't trap when the corresponding sdiv would overflow
24+
- ~~test that add/sub/mul/wrap/wrapping-store silently wrap on overflow~~
25+
- ~~test that sdiv/udiv/srem/urem trap on divide-by-zero~~
26+
- ~~test that sdiv traps on overflow~~
27+
- ~~test that srem doesn't trap when the corresponding sdiv would overflow~~
2828
- test that float-to-integer conversion traps on overflow and invalid
29-
- test that unsigned operations are properly unsigned
29+
- ~~test that unsigned operations are properly unsigned~~
3030

3131
Floating point semantics:
3232
- test for round-to-nearest rounding
@@ -49,6 +49,7 @@ Linear memory semantics:
4949
- test loading "uninitialized" things from aliased stack frames return what's there
5050
- test that loadwithoffset traps in overflow cases
5151
- test that newly allocated memory is zeroed
52+
- test that resize_memory does a full 32-bit unsigned check for page_size divisibility
5253

5354
Function pointer semantics:
5455
- test that function pointers work [correctly](https://github.com/WebAssembly/design/issues/89)

ml-proto/runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def find_interpreter(path):
5151
def rebuild_interpreter(path):
5252
print("// building %s" % path)
5353
sys.stdout.flush()
54-
exitCode = subprocess.call(["ocamlbuild", "-libs", "bigarray, nums, str", "-Is", "given, spec, host", "-cflags", "-g", "host/main.native"], cwd=os.path.abspath("src"))
54+
exitCode = subprocess.call(["ocamlbuild", "-libs", "bigarray, str", "-Is", "given, spec, host", "-cflags", "-g", "host/main.native"], cwd=os.path.abspath("src"))
5555
if (exitCode != 0):
5656
raise Exception("ocamlbuild failed with exit code %i" % exitCode)
5757
if not os.path.exists(path):

ml-proto/src/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Makefile = Makefile
1010
OCB_FLAGS += # -use-ocamlfind
1111
OCB_FLAGS += # -cflags -w
1212
OCB_FLAGS += # -cflags +a-4-41-42-44-45
13-
OCB_FLAGS += -libs nums,str,bigarray
13+
OCB_FLAGS += -libs str,bigarray
1414
OCB_FLAGS += -I host -I given -I spec
1515
OCB = ocamlbuild $(OCB_FLAGS)
1616

@@ -34,7 +34,7 @@ clean:
3434
check:
3535
# check that we can find all relevant libraries
3636
# when using ocamlfind
37-
ocamlfind query str num bigarray
37+
ocamlfind query str bigarray
3838

3939
zip:
4040
git archive --format=zip --prefix=$(NAME)/ \

ml-proto/src/host/parser.mly

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ let parse_error s = Error.error Source.no_region s
3434
let literal at s t =
3535
try
3636
match t with
37-
| Types.Int32Type -> Values.Int32 (Int32.of_string s) @@ at
38-
| Types.Int64Type -> Values.Int64 (Int64.of_string s) @@ at
39-
| Types.Float32Type -> Values.Float32 (Float32.of_string s) @@ at
40-
| Types.Float64Type -> Values.Float64 (Float64.of_string s) @@ at
37+
| Types.Int32Type -> Values.Int32 (I32.of_string s) @@ at
38+
| Types.Int64Type -> Values.Int64 (I64.of_string s) @@ at
39+
| Types.Float32Type -> Values.Float32 (F32.of_string s) @@ at
40+
| Types.Float64Type -> Values.Float64 (F64.of_string s) @@ at
4141
with _ -> Error.error at "constant out of range"
4242

4343

0 commit comments

Comments
 (0)