Commit Graph

189 Commits

Author SHA1 Message Date
Sergey Pepyakin 7c88c6ad65
Fix br_table validation (#67)
Fixes #63

Fix is simple: all labels refered by the br_table instruction must have same value type (or NoResult in case if they don't have result). So we just take the default label and check other labels against it.
2018-02-23 18:00:16 +03:00
Sergey Pepyakin 8a96bc2649
Make it easier to work with spec testsuite (#68)
If module will failed to load, one could just check line number of the original script.
2018-02-23 17:57:35 +03:00
Nikolay Volf 5bb5b6809c Exclude test directory for package (#65)
* Exclude test directory for package

* Update Cargo.toml

* Also exclude fuzz and deexclude non-existant spec
2018-02-23 00:45:27 +03:00
Nikolay Volf f1a3f06d5e
remove stray println (#66) 2018-02-21 23:00:31 +03:00
Nikolay Volf 6b6961bcb6
Bump parity-wasm version (#64) 2018-02-21 18:00:32 +03:00
Sergey Pepyakin 73c1451a84 Bump parity-wasm version to 0.25 (#62) 2018-02-19 19:32:38 +03:00
Sergey Pepyakin 9140e869e2 Update spec testsuite; Fix instantiation bug (#61)
The bug was about instantiating a module with elements segment being out-of-bounds, however, it was with zero length. E.g.:

```
(module
  (table 0 anyfunc)
  (elem (i32.const 1))
)
```

In our impl there was no out-of-bounds, because there was no attempt to set any table entry.

This change adds early check for specifically this case.
2018-02-19 18:59:18 +03:00
Sergey Pepyakin d02b0f8527
Add plain load to fuzzer (#58) 2018-02-15 20:34:56 +03:00
Sergey Pepyakin d11dffcf51 Use memory_units from crates.io. 2018-02-14 18:44:11 +03:00
Sergey Pepyakin 6cf6a31970
Merge signature mismatch traps (#57) 2018-02-14 18:27:22 +03:00
Sergey Pepyakin 863f2247a3
Move spec testsuite into tests. (#56)
Move all spec testsuite into `/tests` directory.

So it means that several changes will happen:

- Compilation will share common dependencies in target directory. This should make CI builds faster. This also should reduce space requirements.
- Common Cargo.lock file
- `cargo test` will include spec tests.
- `cargo check --tests` will also include spec tests.
2018-02-14 18:03:39 +03:00
Sergey Pepyakin c99ee1d986
Use wabt spec module (#48)
Use wabt-rs script parser to parse official testsuite.
2018-02-14 13:40:31 +03:00
Sergey Pepyakin 07fbe31ec2
Add `instantiate` bin (#53)
This change adds a handy utility to test whether the given module deserializes, validates and instantiates successfully.
2018-02-14 13:36:27 +03:00
Sergey Pepyakin 435bae5898
Use wasmi ValueType for RuntimeValue instead pwasm (#52)
`RuntimeValue::default` takes `parity_wasm::elements::ValueType` as an input parameter. 

This change fixes it to be wasmi's `ValueType`.
2018-02-14 13:36:17 +03:00
Sergey Pepyakin 4e8d113f84
Remove old fixtures. (#54)
Remove all old test fixtures that migrated in this repo from the parity-wasm.

Also, use .wast files instead of compiled .wasm. I believe this is more convenient than testing a .wasm file and having a corresponding .wast file, which might go out of sync.
2018-02-14 13:33:24 +03:00
Sergey Pepyakin 93423d9393
Update wabt-rs version (#55) 2018-02-13 23:14:38 +03:00
Sergey Pepyakin e5056e7871 Add newline in compile_error!
This doesn't change the actual message.
2018-02-13 18:17:38 +03:00
Sergey Pepyakin e273b9e40a Just bump framestack limits. (#50)
These limits seems to be picked arbitrary, and I just made it arbitrary larger.

We need to reconsider these limits, ideally providing to user a way to customize the limits.

FWIW, When the last time I've tried to run gcc's torture testsuite with wasmi it also bumped into this limit.

Fixes #41.
2018-02-13 09:29:04 +03:00
Sergey Pepyakin 31a70aaa8d
Fuzz wasmparser (#47) 2018-02-09 22:41:02 +03:00
Sergey Pepyakin 483736b1bd
Memory units (#42)
* Initial implementation

* Not use grow as it is makes debug builds very slow

* Use Pages::BYTE_SIZE for LINEAR_MEMORY_PAGE_SIZE

* Tidy docs.

* Use memory_units from git.
2018-02-09 16:45:21 +03:00
Sergey Pepyakin a3ad4b0e49
Remove NATURAL_ALIGNMENT (#46) 2018-02-09 16:00:19 +03:00
Sergey Pepyakin 6e4bbb7490 Opt in for 32bit platforms (#44) 2018-02-09 11:20:21 +03:00
Sergey Pepyakin c0ed715b37
Update testsuite (#39)
* ok_or_else in stack + top_mut.

* Model polymorphic stack explicitly

* Upgrade wasm testsuite.

* Update fixtures.

* Validate duplicate exports.

* Fix and clean spec runner.

* with_capcity for HashSet
2018-02-08 17:52:16 +03:00
Sergey Pepyakin 528f468ef2 Minor fixes in docs (#38)
* Run nightly only if NIGHTLY_TOOLCHAIN is defined

* Minor fixes in docs.
2018-02-06 23:10:58 +03:00
Sergey Pepyakin 367f17989b Refine errors (#36)
* Get rid of Stack error

* Add UnexpectedSignature error and remove Value err

* Publish FuncInstance::invoke

* Rename Trap to TrapKind

* Replace Trap with struct. Enum is now TrapKind

* Fixes

* Update value.rs

* Avoid reversing parameter types iter.

* Add impl From<TrapKind> for Trap

* Remove redundant clone in prepare_function_args.

* Use .into() to convert TrapKind into Trap
2018-02-06 14:14:57 +03:00
Sergey Pepyakin eda488233f Fix fuzz (#35)
* Add checking for fuzz.

* Use wabt's validation instead of wasm2wat.

Fixes #16
Fixes #34

* Check fuzz with nightly.

* Install nightly toolchain

* Travis Driven Development #1

* Travis Driven Development #2
2018-02-05 17:36:53 +03:00
Sergey Pepyakin 106ac7afdb Fix memory max pages (#33)
* Fix memory max pages

* Get rid of calculate_memory_size.
2018-02-02 00:44:06 +03:00
Sergey Pepyakin fa82dee676 Add docs (#32) 2018-02-01 19:46:33 +03:00
Sergey Pepyakin c96735d6d6 Wasm function can only trap (#29)
* Introduce Trap struct.

* get_local can't fail.

* Add MemoryOutOfBounds trap.

* from_little_endian use slice instead of vec.

* MemoryAccessOutOfBounds for mem get and set.

* from_little_endian conversion can't fail.

* call_indirect traps.

* DivisionByZero and InvalidConversionToInt

* Use traps in value to convey an error

* select: int condition on stack top

* if: int condition on stack top

* Assert pops.

* Another protions of assert pops

* Introduce ValueStack

Also, hide FunctionContext and remove some stale code

* Traps in execution

* Make it compile.

* Check args before invoke.

* Document RuntimeArgs.

* Update host.rs

* Add rustdoc for Trap.
2018-02-01 14:59:21 +03:00
Sergey Pepyakin 1d87fb09dc
Publish LINEAR_MEMORY_PAGE_SIZE constant (#31) 2018-02-01 14:46:49 +03:00
Sergey Pepyakin 3ad9f07e93 Add handy scripts (#30)
* Extract test.sh and doc.sh from .travis.yml

* check.sh
2018-01-31 22:13:50 +03:00
Sergey Pepyakin 551c992730
4th iteration on documentation (#22)
* Rename LoadedModule to Module

* Hide TryInto

* Fix rustdoc tests.

* Rename from_parity_wasm_module and doc it.

* Document `Module::from_buffer`

* Tidy Module docs

* Some rustdoc headers.

* Document FuncInstance::{alloc_host, signature}

* Document descriptors.

* Doc NotStartedModuleRef

* Fix cargo-deadlinks
2018-01-26 19:24:40 +03:00
Nikolay Volf aa4c8fe3bb Update to most recent parity-wasm (#21)
* Update to most recent parity-wasm

* fix validation
2018-01-26 18:35:12 +03:00
Nikolay Volf c1f05c822b
Merge pull request #20 from pepyakin/check-deadlinks
Check for dead links in rustdoc
2018-01-26 18:20:24 +03:00
Nikolay Volf aa42ac9e70
Merge pull request #15 from pepyakin/fuzz-load
Fuzz loading/validation against wabt.
2018-01-26 16:54:07 +03:00
Sergey Pepyakin eb968766f5 Check with deadlinks 2018-01-26 16:47:30 +03:00
Sergey Pepyakin e1216f633f Fix indent 2018-01-26 16:28:36 +03:00
Sergey Pepyakin 500538099d Change version to 0.0.0 2018-01-26 11:57:32 +03:00
Sergey Pepyakin 1dbb678d34
Add issue number for TODO 2018-01-26 11:53:30 +03:00
Nikolay Volf 6f3ec93952
Merge pull request #17 from pepyakin/docs-3
Third iteration on documenation.
2018-01-25 23:05:45 +03:00
Sergey Pepyakin cc24d8a77a Fix idents 2018-01-25 19:56:52 +03:00
Sergey Pepyakin bc89a20b96 Third iteration on documenation. 2018-01-25 18:17:25 +03:00
Sergey Pepyakin d78677ef00 Fuzz loading/validation against wabt. 2018-01-24 21:32:46 +03:00
Nikolay Volf 51caaff556
Merge pull request #14 from pepyakin/docs-2
Second iteration on documenation.
2018-01-24 19:14:45 +03:00
Sergey Pepyakin 230abc6a91 Second iteration on documenation. 2018-01-24 18:58:22 +03:00
Nikolay Volf f6f23accdd
Merge pull request #13 from pepyakin/static-signatures
Allow static signatures
2018-01-24 14:28:31 +03:00
NikVolf 65f08eb44c allow static signatures 2018-01-24 14:14:24 +03:00
Sergey Pepyakin 9dc45eacbf Update README.md 2018-01-23 20:07:09 +03:00
Nikolay Volf 429aaa2a4e
Merge pull request #11 from pepyakin/docs-1
First iteration on documentation.
2018-01-23 20:00:29 +03:00
Nikolay Volf ab5e3e22f3
Merge pull request #9 from pepyakin/add-license
Migrate missing license files from parity-wasm
2018-01-23 20:00:13 +03:00