Commit Graph

151 Commits

Author SHA1 Message Date
Sergei Pepyakin d52ba8849a
Run rustfmt check on CI (#154)
* Run rustfmt check on CI

* Reformat.
2019-01-02 23:50:38 +01:00
Arkadiy Paronyan e047f508fa Track memory usage (#153)
* Track memory usage

* Track lowest_used in copy, etc.

* Extra comment for used_size
2019-01-02 22:13:21 +01:00
Jef 617be0198d Check type when resuming function (#152)
* Check type when resuming function

* Remove pub(crate)

* Update lib.rs
2019-01-02 12:18:24 +01:00
Jef 899cc32e45 rustfmt (#151) 2018-12-11 12:54:06 +01:00
Ivan Enderlin da558c7ce7 doc(host) Fix the `Externals` example (#149)
* doc(host) Fix the `Externals` example

The example is missing two things:

  * `index` is computed but not used,
  * `check_signature` is never used.

This patch tries to fix that.

* doc(host) Fix `check_signature` example
2018-11-28 14:03:03 +01:00
Jef c7f9196df6 Export LittleEndianConvert (#148) 2018-11-28 14:01:51 +01:00
Sergey Pepyakin 7191998216
Bump version to 0.4.2 (#144) 2018-11-15 13:19:53 +01:00
Sergey Pepyakin 15e9461bae
Allow failures on nightly (#143) 2018-11-15 13:11:10 +01:00
Jef e11ba15373 Remove `Box<[Target]>` from `Instruction` (#141)
This also allows `Instruction` to be `Copy`, which massively speeds
up `<Instructions as Clone>::clone` since it can now just `memcpy`
the bytes using SIMD instead of having to switch on every single
element. I haven't looked at the disassembly of `InstructionIter::next`
yet, it could be that there are even more improvements yet to be gained
from either:

* Only doing work on `BrTable` (this might already be the case depending
  on the whims of the optimiser)
* Using `unsafe` to make it a noop (we really don't want to do this,
  obviously, since it means that `Instructions` has to be immovable)
2018-11-15 12:18:47 +01:00
Eric Findlay 7b4c648acb Minor edits to documentation. (#140) 2018-11-09 15:39:40 +01:00
Jef c877d64508 Remove tag from RuntimeValue (#133)
* Remove tag from runtime value

* Add explanation of `RuntimeValueInternal`, move it so I don't need to do `pub(crate)`
2018-10-31 16:01:20 +01:00
Wei Tang 1c04be64f8 Remove redundent check_function_args (#135)
* Remove redundent check_function_args

* Remove unused format convertion in check_function_args

* Remove unnecessary alloc
2018-10-29 18:29:46 +01:00
Julius Rakow 20154c5e24 Add no_std support (#122)
* add default-enabled std feature

* use parity-wasm/std feature only if std is enabled

* drop dependency on std::io

* use hashmap_core instead of std::collections::HashMap

* disable std::error in no_std

* core and alloc all the things

* mention no_std in readme

* add no_std feature and use hashmap_core only on no_std

* rename the no_std feature to core

* drop dependency on byteorder/std

* simplify float impl macro

* remove some trailing whitespace

* use libm for float math in no_std

* add note about no_std panics of libm to readme

* Embed nan-preserving-float crate.

* Add no_std check to the Travis CI config

* add missing dev-dependency
2018-10-29 11:16:55 +01:00
Sergey Pepyakin 2f7505d120
Travis maintenance (#132)
*  Use gcc-8 for builds

* Don't run cargo-deadlinks

* Update wabt to 0.6.
2018-10-26 15:03:01 +02:00
Jef 3854ecdad6 Remove some unsafety (#131)
* Remove unsafety

* Remove transmutes and pointer casts
2018-10-25 14:17:25 +02:00
Sergey Pepyakin ad4236263a
Don't update PC on every instruction (#130) 2018-10-19 16:55:07 +02:00
Will Glynn 7509477a61 Hide instruction storage details (#129)
* Hide Instructions implementation behind an iterator

* Hide instruction encoding behind isa::Instructions::push()

* Consistently use u32 for program counter storage

* Refer to instructions by position rather than index
2018-10-10 19:02:27 +02:00
Sergey Pepyakin 9170303aad Bump wasmi to 0.4.1 2018-10-02 11:36:23 +01:00
Sergey Pepyakin 36582c32b6
Transfer function (#128) 2018-10-02 11:01:18 +01:00
Sergey Pepyakin 438eab9ada
Don't run cargo deadlinks for nightly (#121) 2018-08-27 11:11:21 +03:00
Tobias Bucher 167e4845ef Proofread the library-level docs (#123)
* Proofread the library-level docs

* Fix extra word, remove mention of linear memory "space"
2018-08-27 11:10:45 +03:00
Guanqun Lu 0409913a26 Typo fixes (#119)
* typo fixes

* more typo fixes
2018-08-03 16:05:10 +03:00
Guanqun Lu 929ac564a5 we don't need this TODO anymore (#120) 2018-08-03 16:04:33 +03:00
Guanqun Lu 8ca6b4b860 Add a section in README to show how to build and test (#117) 2018-08-01 12:21:50 +03:00
Sergey Pepyakin 0a34f1d0f6
Bump version to 0.4.0 (#116) 2018-07-31 17:05:21 +03:00
Arkadiy Paronyan 118396851a Allocate memory on demand (#115)
* Allocate mem on demand

* More control in with_direct_access_mut
2018-07-31 16:25:46 +03:00
Guanqun Lu 5c86c1c753 Bump wabt's version to 0.4 and add two more test cases (#114)
* bump wabt version to 0.4

It has some interface changes.

* bump up testsuite and add two more test cases

* use the same expect string
2018-07-30 19:43:18 +03:00
Guanqun Lu 43b8d52bca typo fixes in lib.rs (#113) 2018-07-30 15:16:17 +03: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