Commit Graph

124 Commits

Author SHA1 Message Date
Guanqun Lu 94f9f84362 typo fixes in lib.rs 2018-07-29 22:42:36 +08:00
Arkadiy Paronyan 9ed95e49c1 Avoid allocations on memory operations (#112) 2018-07-26 14:50:05 +03:00
Wei Tang a605175abe Resumable function invocation (#110)
* Move call_stack to Interpreter struct

* Accept func and args when creating the Interpreter

* Create a RunState to indicate whether the current interpreter is recoverable

* Add functionality to resume execution in Interpreter level

* Implement resumable execution in func

* Expose FuncInvocation and ResumableError

* Fix missing docs for FuncInvocation

* Add test for resumable invoke and move external parameter passing to start/resume_invocation

* Add comments why assert is always true

* Add note why value stack is always empty after execution

* Use as_func

* Document `resume_execution` on conditions for `is_resumable` and `resumable_value_type`

* Document conditions where NotResumable and AlreadyStarted error is returned

* Warn user that invoke_resumable is experimental
2018-07-09 19:06:44 +03:00
Sergey Pepyakin df0e3ddd46
Bump version to 0.3.0 (#107) 2018-07-04 12:22:08 +03:00
Sergey Pepyakin dc5052aadb
Export nan_preserving_float (#109) 2018-07-04 12:13:57 +03:00
Sergey Pepyakin 5d99077e17
Bump limits arbitrary (#108) 2018-07-04 11:18:54 +03:00
Sergey Pepyakin f6657bace4
Flat Stack (#98)
* Define Instruction Set.

* WIP

* WIP 2

* Tests

* Working

* Bunch of other tests.

* WIP

* WIP

* Use Vec instead of VecDeque.

* Calibrate the limits.

* Clean

* Clean

* Another round of cleaning.

* Ignore traces.

* Optimize value stack

* Optimize a bit more.

* Cache memory index.

* Inline always instruction dispatch function.

* Comments.

* Clean

* Clean

* Use vector to keep unresolved references.

* Estimate resulting size.

* do refactoring

* Validate the locals count in the begging

* Introduce Keep and DropKeep structs in isa

* Rename/Split Validator into Reader

* Document stack layout

* Remove println!

* Fix typo.

* Use .last / .last_mut in stack

* Update docs for BrTable.

* Review fixes.

* Merge.

* Add an assert that stack is empty after the exec
2018-07-04 10:08:45 +03:00
Sergey Pepyakin 3a96a8399f
Bump version to 0.2.1 (#106) 2018-07-02 13:17:36 +03:00
Wei Tang f91dc92119 Update parity-wasm dependency to 0.31 (#105)
* Update parity-wasm dependency to 0.31
* Fix tests
2018-06-29 14:10:04 +03:00
Sergey Pepyakin 2fb793c8b8
Add hfuzz into repo (#103)
* Add fuzzing against spec interpreter.

* Redirect output of spec to /dev/null

* Also stderr

* Refactor

* Oops. Revert to temp file creation.

* Version of libfuzzer pinned

* Add honggfuzz.

* Impl hfuzz

* Update parity-wasm.

* Update honggfuzz to 0.5.9.

* Update parity-wasm

* Stack hash.

* Update script a bit.

* Unpin parity-wasm version

* Indentation
2018-06-25 17:46:13 +03:00
Leonardo Yvens 9db7896e48 implement from and into RuntimeValue for i8, u8, i16 and u16 (#104)
This works under the assumption that these values
are represented as an `I32` in WASM, which seems
reasonable.
2018-06-25 16:59:30 +03:00
Leonardo Yvens 75406dd8ff Use transmute instead of casts In RuntimeValue conversion. (#102)
Casts have arithmetic semantics, and under some build configurations
Rust will panic when encountering an arithmetic overflow.
Use a transmute instead since it's what we mean.
The previous code worked, but still I added a test for good measure.
2018-06-21 15:47:49 +03:00
Sergey Pepyakin 94b797de44
Add some more benches (#97)
* Add rev_complement test

# Conflicts:
#	benches/src/lib.rs
#	benches/wasm-kernel/src/lib.rs

* Add redux_regex test.

# Conflicts:
#	benches/wasm-kernel/Cargo.toml

* Fmt and return an original header

* Use ManuallyDrop

* Really initialize lazy static.
2018-06-19 16:29:33 +03:00
Sergey Pepyakin f305b3cd1f
Fix wasm benches on nightly (#93) 2018-06-12 14:00:57 +03:00
Sergey Pepyakin 724a32ad60
Provide direct access to the underlying buffer (#91)
This allows zero-copy access to the linear memory.
2018-05-31 16:01:15 +02:00
Sergey Pepyakin 6cf0ebc79e
Add a simple bench (#90)
* Add first bench

* Refactor travis.yml

* Use assert_matches!

* sha3_256 → keccak256
2018-05-24 16:31:15 +03:00
Sergey Pepyakin d926993c6c Bump wabt version to 0.3 2018-04-25 18:00:11 +03:00
Sergey Pepyakin 89c3a9286f Bump version 0.2.0 2018-04-25 10:25:33 +03:00
Jef 3890dd379f Preserve signalling bit in NaNs (#87)
* Preserve signalling bit in NaNs

* Fix warnings
2018-04-25 10:18:14 +03:00
Sergey Pepyakin b95e11c414 Bump version to 0.1.3. 2018-04-20 17:59:16 +03:00
Sergey Pepyakin 730c918a80
Don't expand locals. (#86) 2018-04-20 17:55:07 +03:00
Sergey Pepyakin 5cda9a05da Check the signature of host function. (#84) 2018-04-18 17:44:10 +03:00
Jef 22b260a3b9 Optionally deny floating point operations (#83)
* Optionally deny floating point operations

* Deny floating-point parameters and fix docs/indentation

* Test denial of floating-point parameters
2018-04-18 15:09:09 +03:00
Sergey Pepyakin a2aa3ddb25 Update README.md 2018-04-17 09:41:26 +03:00
Sergey Pepyakin 7aecc55173 Bump version to 0.1.2 2018-04-05 13:12:39 +03:00
Pierre Krieger 4c2995ca98 Fix the name of the 32bits feature (#82)
So that it matches the Cargo.toml
2018-04-04 18:14:43 +03:00
Sergey Pepyakin d12a04f8ff
Publish with externvals (#81)
* Publish with_externvals constructor.
* Add examples to Signature::new.
* Use Iterators for ExternVal imports
2018-03-29 18:43:44 +03:00
NikVolf a6b5574704 bump version 2018-03-24 17:57:28 +03:00
Sergey Pepyakin 86bbd96a33
Require func_type (not func) for func import. (#79) 2018-03-22 17:49:30 +03:00
Sergey Pepyakin 654426b147 Rename feature opt-in-32bit 2018-03-21 11:01:13 +03:00
Sergey Pepyakin 527b9e0cbc Prepare for 0.1.0 (#77) 2018-03-21 10:51:51 +03:00
Sergey Pepyakin 522fa20983
Fix br_if and then tee_local validation. (#76) 2018-03-20 13:09:51 +03:00
Sergey Pepyakin 6253dd6fdf Args refactor (#71)
* Refactor TryInto → FromRuntimeValue.

Replace `TryInto<T, E>` with `FromRuntimeValue`.

The main difference is that `FromRuntimeValue` is implemented for the concrete type of the value we create, rather than on `RuntimeValue`. This makes more sense to me and seems more clear.

The `try_into` method is now implemented on `RuntimeValue` itself.

And finally, `FromRuntimeValue` has been made public.

* Impl AsRef<[RuntimeValue]> for RuntimeArgs

This impl can be used as an escape hatch if the user wants to use the inner slice.

* Little doc fixes for RuntimeArgs.
2018-03-14 01:23:12 +03:00
Sergey Pepyakin 9fa933ccd6
Use f32/f64::from_bits. (#72)
And also enable:

- "conversions",
- "float_exprs",
- "float_literals",
- "float_memory",

tests.
2018-03-12 12:37:43 +01:00
Sergey Pepyakin 0c277abacb
Implement Error for Trap (#73) 2018-03-12 12:37:12 +01:00
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