Skip to content

Factor out i32 and i64 from arithmetic.ml; implement wasm-compatible semantics #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ml-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You'll get an executable named `src/wasm`.
Alternatively, you can also say (in `src`):

```
ocamlbuild -Is "given, spec, host" -libs "bigarray, nums, str" main.native
ocamlbuild -Is "given, spec, host" -libs "bigarray, str" main.native
```

and get an executable named `src/main.native`.
Expand Down
15 changes: 8 additions & 7 deletions ml-proto/TestingTodo.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ Misc semantics:

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

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

Function pointer semantics:
- test that function pointers work [correctly](https://github.com/WebAssembly/design/issues/89)
Expand Down
2 changes: 1 addition & 1 deletion ml-proto/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def find_interpreter(path):
def rebuild_interpreter(path):
print("// building %s" % path)
sys.stdout.flush()
exitCode = subprocess.call(["ocamlbuild", "-libs", "bigarray, nums, str", "-Is", "given, spec, host", "-cflags", "-g", "host/main.native"], cwd=os.path.abspath("src"))
exitCode = subprocess.call(["ocamlbuild", "-libs", "bigarray, str", "-Is", "given, spec, host", "-cflags", "-g", "host/main.native"], cwd=os.path.abspath("src"))
if (exitCode != 0):
raise Exception("ocamlbuild failed with exit code %i" % exitCode)
if not os.path.exists(path):
Expand Down
4 changes: 2 additions & 2 deletions ml-proto/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Makefile = Makefile
OCB_FLAGS += # -use-ocamlfind
OCB_FLAGS += # -cflags -w
OCB_FLAGS += # -cflags +a-4-41-42-44-45
OCB_FLAGS += -libs nums,str,bigarray
OCB_FLAGS += -libs str,bigarray
OCB_FLAGS += -I host -I given -I spec
OCB = ocamlbuild $(OCB_FLAGS)

Expand All @@ -34,7 +34,7 @@ clean:
check:
# check that we can find all relevant libraries
# when using ocamlfind
ocamlfind query str num bigarray
ocamlfind query str bigarray

zip:
git archive --format=zip --prefix=$(NAME)/ \
Expand Down
8 changes: 4 additions & 4 deletions ml-proto/src/host/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ let parse_error s = Error.error Source.no_region s
let literal at s t =
try
match t with
| Types.Int32Type -> Values.Int32 (Int32.of_string s) @@ at
| Types.Int64Type -> Values.Int64 (Int64.of_string s) @@ at
| Types.Float32Type -> Values.Float32 (Float32.of_string s) @@ at
| Types.Float64Type -> Values.Float64 (Float64.of_string s) @@ at
| Types.Int32Type -> Values.Int32 (I32.of_string s) @@ at
| Types.Int64Type -> Values.Int64 (I64.of_string s) @@ at
| Types.Float32Type -> Values.Float32 (F32.of_string s) @@ at
| Types.Float64Type -> Values.Float64 (F64.of_string s) @@ at
with _ -> Error.error at "constant out of range"


Expand Down
Loading