Commit Graph

20 Commits

Author SHA1 Message Date
adam-rhebo 7fe6ef4e35 Add ARMv7 as CI test target (#186)
* Add ARMv7 as CI test target

* Avoid UB in conversions from floating point

When truncating floating point values to integer values, we need to
avoid undefined behavior if the argument does not fit into the target
type which is currently impossible using casts of primitive types.

Hence, this reimplements those conversions using arbitrary precision
integers and rationals from the num crate.
2019-06-18 15:06:16 +02:00
Elichai Turkel e88d5d32e5 Removed Byteorder now that rust supports it natively (#171)
* Removed byteorder now that from_le_bytes is stabilized

* Rust fmt
2019-02-26 11:37:14 +01:00
Jef 899cc32e45 rustfmt (#151) 2018-12-11 12:54:06 +01:00
Jef c7f9196df6 Export LittleEndianConvert (#148) 2018-11-28 14:01:51 +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
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
Jef 3854ecdad6 Remove some unsafety (#131)
* Remove unsafety

* Remove transmutes and pointer casts
2018-10-25 14:17:25 +02:00
Arkadiy Paronyan 9ed95e49c1 Avoid allocations on memory operations (#112) 2018-07-26 14:50:05 +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
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 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 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 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 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 a98852e62a Couple of fixes 2018-01-23 18:12:52 +03:00
Sergey Pepyakin ca6299ba53 Hide ValueType. 2018-01-18 17:13:56 +03:00
Sergey Pepyakin 49347a63ee Initial commit 2018-01-17 19:54:06 +03:00