Commit Graph

575 Commits

Author SHA1 Message Date
Ivan Enderlin
5744f6896f fix(clif-backend) Module::new does not use its argument.
The `Module::new` method requires an argument (`wasm: &[u8]`) that is
never used.

This patch removes the argument, and updates the code accordingly.
2019-03-04 14:03:07 +01:00
Ivan Enderlin
42c9bdf8c2 fix(clif-backend) Remove an unused variable declaration.
The `compiled_functions` variable is declared twice. The first
declaration is never used. This patch removes it.
2019-03-04 13:59:37 +01:00
Ivan Enderlin
d9073c03c6 fix(runtime-core) hasher does not need to be mutable.
This patch updates the `hasher` variable. It is declared as mutable,
but it's never mutated.
2019-03-04 13:53:41 +01:00
Ivan Enderlin
ec4e476cc6 fix(runtime-core) Remove an unused import.
This patch removes an unused import, namely `crate::sys::Memory`.
2019-03-04 13:51:13 +01:00
Lachlan Sneff
3f9dbca17f List specific supported features for validator. 2019-03-03 22:47:34 -08:00
Lachlan Sneff
ab550f46fc Fix bug resulting from comparing the memory base instead of the memory offset to the memory bounds. 2019-03-03 22:11:40 -08:00
Lachlan Sneff
ae3b2b2a42 Add bounds checking for memory accesses on dynamic memories 2019-03-03 21:56:30 -08:00
Lachlan Sneff
87c453a0ec Add check for table bounds on call_indirect. 2019-03-03 21:38:35 -08:00
Lachlan Sneff
801979c40d Add dynamic sigindices to the vm context. 2019-03-03 21:26:34 -08:00
Lachlan Sneff
51cf9dde05 Move SSA value caches to the entry block.
The supporting framework around LLVM will make sure to only compute values once if they
are known to never change. Previously, these values were attempted to be reused from places where
the users may not dominate the creation of the value. To avoid that, they are always created
in the entry block now.
2019-03-03 21:13:37 -08:00
Brandon Fish
c07298e58e Make capstone optional with a feature 2019-03-03 16:02:20 -06:00
Brandon Fish
aae256b407 Add tag to fix cast ptr lint error 2019-03-03 15:34:20 -06:00
Brandon Fish
3f345b41c2 Fix emscripten lib compilation 2019-03-03 15:18:16 -06:00
Brandon Fish
97a70327d0 Fix compilation of test example 2019-03-03 15:13:20 -06:00
Brandon Fish
2c765c87c5 Update locals reading to use count 2019-03-03 12:55:29 -06:00
Lachlan Sneff
e362b56b07 Turns out we can just throw an exception from the signal handler
without any fancy tricks.

This has been tested on macos, hopefully it works on linux too.
2019-03-03 02:15:53 -08:00
Brandon Fish
2077fb448a Fix C API table/global/memory imports 2019-03-02 22:28:00 -06:00
Lachlan Sneff
9cfda6800f Try to return an error from call_protected when an exception occurs.
Something breaks pretty drastically sometimes, not sure why.
2019-03-02 19:08:15 -08:00
Lachlan Sneff
caf2205936 Add a signal handler for macos and linux.
Implementation Notes:
- To avoid setjmp, longjmp, and the mess that those create, we instead set the interrupting
    context of the signal handler to return into the `throw_trap` routine. To my surprise,
    this actually works. The stack ends up getting unwound normally and the memory-oob error
    is caught by the trampoline.
2019-03-02 17:00:05 -08:00
Lachlan Sneff
57bfa9b0a4 Remove multiple throwing functions, just use one. 2019-03-02 14:16:02 -08:00
Lachlan Sneff
9a90689b93 Add preliminary support for throwing and catching uncatchable exceptions.
Additional info:
- WebAssembly "traps" are uncatchable, but are still caught by the trampoline caller.
2019-03-02 12:57:35 -08:00
Lachlan Sneff
5760f6006a Start implementing exception handling by adding frame descriptor entry processing.
- Soon, we should be able basic exceptions.
2019-03-02 10:56:02 -08:00
Lachlan Sneff
87ddf4f855 Add personality function.
- This is part of supporting exceptions in the future.
2019-03-02 10:20:18 -08:00
Lachlan Sneff
a6fc06c908 Fix more compiling issues
Specifically:
- Don't truncate the list of local parameters.
- If the default destination in a br_table instruction is a loop, don't pop any results.
2019-03-02 10:04:44 -08:00
Lachlan Sneff
362e5aa160 Fix issue caused by dangling instruction.
- Come on inkwell, I thought you were better than this.
2019-03-01 20:28:27 -08:00
Lachlan Sneff
f0ac76517a Start running spectests
Additional info:
- Execution is turned off, this is just to make sure the backend can compile the entire specsuite.
- That being said, trampolines are implemented and protected call works (just doesn't protect).
2019-03-01 17:11:20 -08:00
Lachlan Sneff
3717c5720d Get control flow (at least according to the llvm verifier) working.
Next up:
- Importing vm intrinsics.
2019-03-01 15:48:43 -08:00
Mackenzie Clark
bde2022b58
fix appveyor installer and build (#224)
* remove exception handler when function returns or throws

* revert to only reserving and not committing memory due to issues

* appveyor builds for release, caches more, only publish artifact once
2019-03-01 13:16:32 -08:00
Brandon Fish
adfdf4d85d Merge branch 'master' into feature/add-c-api-module-import-descriptors 2019-03-01 12:50:35 -06:00
Brandon Fish
0792cc7018 Merge branch 'master' into feature/c-api-call-an-exported-func 2019-03-01 12:14:56 -06:00
losfair
aa75994e2f Add memory opcodes and test. 2019-03-02 01:41:31 +08:00
Brandon Fish
b80252e165 Setup the spectests lib to use llvm-backend 2019-02-28 23:02:03 -06:00
Lachlan Sneff
51c9091fc5 Start work on generating trampolines 2019-02-28 18:26:47 -08:00
Lachlan Sneff
6a20676fa9 Actually unmap the code after it's done being used 2019-02-28 17:20:18 -08:00
Lachlan Sneff
359ac5abec Connect part of the llvm backend to the runtime 2019-02-28 13:18:00 -08:00
Lachlan Sneff
d4ae5cdd40 Get function addresses from llvm-compiled code 2019-02-28 12:31:39 -08:00
losfair
e026adf33e Initial work on linear memory. 2019-02-28 23:58:02 +08:00
losfair
64142c4cb8 Reserve R15. 2019-02-28 23:22:21 +08:00
losfair
b7ca5e46ed Add Select opcode. 2019-02-28 23:12:42 +08:00
Brandon Fish
358d653b18
Merge branch 'master' into feature/add-c-api-module-export-descriptors 2019-02-27 23:21:23 -06:00
Brandon Fish
889fc3f432
Merge branch 'master' into feature/add-c-api-module-import-descriptors 2019-02-27 23:21:01 -06:00
Brandon Fish
02eac589f4 Merge branch 'master' into feature/c-api-call-an-exported-func 2019-02-27 23:19:50 -06:00
Lachlan Sneff
5d77769381 Hopefully finish the memory manager implementation for llvm RuntimeDyLd 2019-02-27 17:21:20 -08:00
Syrus
60f8f15db3 Updated version to 0.2.1 2019-02-27 17:20:49 -08:00
Mackenzie Clark
95062d524a
commit virtual memory before copying (#212) 2019-02-27 14:20:53 -08:00
Mackenzie Clark
ff5e1320da
Fix casting errors cause io issues (#222) 2019-02-27 13:54:28 -08:00
Mackenzie Clark
2a7a8c0069
newline in test-module-imports.c 2019-02-27 10:41:22 -08:00
Mackenzie Clark
c4566f0b39
Merge branch 'master' into feature/add-c-api-module-export-descriptors 2019-02-27 10:28:18 -08:00
losfair
d50f1cc95f If/Else. 2019-02-27 23:38:45 +08:00
Syrus Akbary
c7f3666354
Merge pull request #220 from wasmerio/feature/better-debug
Added debug build
2019-02-26 15:42:29 -08:00
Syrus
f7197bf456 Added debug build 2019-02-26 15:39:54 -08:00
losfair
3c3c5db2e1 Native trampolines. 2019-02-26 20:56:10 +08:00
Syrus
e6d0f91832 Use blake2b SIMD version for increased performance 2019-02-26 01:12:34 -08:00
Lachlan Sneff
4f833876e0 Start work on object loader using llvm's RuntimeDyld api. 2019-02-25 18:08:06 -08:00
Syrus
2d49d58665 Use blake2b (simd) version instead of blake2 2019-02-25 17:43:25 -08:00
Syrus
e7d08712b5 Use blake2 hashing algorithm 2019-02-25 17:37:33 -08:00
Syrus
53c8603464 Updated crates version to 0.2.0 2019-02-25 13:33:33 -08:00
Syrus Akbary
09fe82862e
Merge pull request #211 from wasmerio/fix/error-display
Fix/error display
2019-02-25 12:35:16 -08:00
Syrus
f9c0e0c078 Fix formatting 2019-02-25 12:25:28 -08:00
Mackenzie Clark
3cfdaf3891
Merge branch 'master' into feature/emscripten-getcwd 2019-02-25 12:18:30 -08:00
Syrus Akbary
c5c967da00 Added parallel compilation (#209) 2019-02-25 12:03:48 -08:00
losfair
9d8c5a5c70 Add a note on incorrect code generation. 2019-02-25 23:57:12 +08:00
losfair
530294922a Allow more registers to be used. 2019-02-25 23:55:27 +08:00
losfair
78fd995ad3 Fix argument passing at entry. 2019-02-25 23:38:33 +08:00
losfair
80812e3809 Implement native call & fix stack alignment. 2019-02-25 23:29:18 +08:00
losfair
2432a6c9b3 Fix function calls. 2019-02-25 22:47:27 +08:00
Brandon Fish
b008a054de Fix C API to allow calling an exported func 2019-02-24 12:22:24 -06:00
losfair
dbebdf937f Code generation for br_table. 2019-02-24 12:00:35 +08:00
Brandon Fish
1dfa106850 Add C API module import descriptors 2019-02-23 18:25:51 -06:00
Brandon Fish
17fe7bdaea Add C API module export descriptors 2019-02-23 15:41:38 -06:00
losfair
09cbd4aeb0 Changed to using custom calling conventions; Implemented direct calls. 2019-02-24 00:52:32 +08:00
losfair
e9c0325784 Update dependencies 2019-02-24 00:51:47 +08:00
Andrew Cann
ed706133c4 fix stack overflow in Error's Display impl 2019-02-23 17:00:03 +08:00
Mackenzie Clark
82eef13f41
Create a grow error and refactor grow impl to return result (#191) 2019-02-22 22:18:59 -08:00
Lachlan Sneff
2a913f5663 Implement table, partial call_indirect 2019-02-22 17:34:55 -08:00
Mackenzie Clark
0c4aea2d84
Merge branch 'master' into feature/emscripten-getcwd 2019-02-22 16:54:19 -08:00
Lachlan Sneff
07c8975304 Fix clif backend 2019-02-22 16:20:26 -08:00
Mackenzie Clark
7fb7529b48 cargo fmt 2019-02-22 15:16:07 -08:00
Mackenzie Clark
70e0b8cee1
Merge branch 'master' into feature/emscripten-getcwd 2019-02-22 15:15:26 -08:00
Mackenzie Clark
b5056d676a update wasm file 2019-02-22 15:07:55 -08:00
Mackenzie Clark
966be3ee8f right to the out buffer that was passed in syscall183 2019-02-22 14:54:01 -08:00
Lachlan Sneff
df03d00e74 Merge upstream/master into feature/llvm-feature 2019-02-22 14:14:46 -08:00
Lachlan Sneff
0c19824425 Fix after merge 2019-02-22 14:07:03 -08:00
Lachlan Sneff
d9506ca5d5
Merge branch 'master' into feature/benchmarks 2019-02-22 13:32:09 -08:00
Lachlan Sneff
4042cff914 Change hashing algorithm from sha1 to meowhash 2019-02-22 13:02:28 -08:00
Mackenzie Clark
0f9369c67d cargo fmt and better error message 2019-02-22 12:39:19 -08:00
Mackenzie Clark
ad3d361f76 add the syscall and create a test 2019-02-22 12:32:14 -08:00
Lachlan Sneff
687f70df89 Add validation benchmark 2019-02-22 12:31:41 -08:00
Syrus
16d62ace52 Fixed cache example (again) 2019-02-22 12:17:49 -08:00
Mackenzie Clark
70ba4ec466
Merge branch 'master' into feature/benchmarks 2019-02-22 12:14:11 -08:00
Lachlan Sneff
6d092dc121 Fix lint 2019-02-22 12:08:56 -08:00
Lachlan Sneff
17901f992a Add benchmark runner and nginx compile vs. load bench 2019-02-22 12:07:07 -08:00
Syrus
b3dd47bce8 Fixed runtime example 2019-02-22 12:06:22 -08:00
Syrus
84042cecb3 Fixed wrong syntax 2019-02-22 12:00:30 -08:00
Syrus
fdb2a67579 Added cache into standalone app 2019-02-22 11:42:36 -08:00
Brandon Fish
c9969f269c Use minimum limit as initial table size (#196) 2019-02-22 11:16:15 -08:00
Mackenzie Clark
a6d72bdec9
more emscripten stubs and urandom hack (#199) 2019-02-22 10:42:38 -08:00
Syrus Akbary
e9d72740c0
Merge pull request #197 from wasmerio/feature/c-api-module-instantiate
Add C API module_instantiate function
2019-02-22 09:58:49 -08:00
losfair
08a2ec82b3 Unary operators, comparison opcodes, loops, etc. 2019-02-23 01:54:16 +08:00
Lachlan Sneff
f1b190743b Change file.write to file.write_all 2019-02-21 17:11:28 -08:00
Lachlan Sneff
199cabd0af Add comment about serde feature 2019-02-21 17:09:32 -08:00
Lachlan Sneff
696fd8fce3 Update api again and change SerializedCache to Artifact 2019-02-21 17:07:04 -08:00
Lachlan Sneff
64eadad7fa Fix review comments 2019-02-21 15:31:20 -08:00
Lachlan Sneff
244308374c Fix formatting 2019-02-21 15:27:20 -08:00
Lachlan Sneff
f9d7d56195 Add documentation and make load safe 2019-02-21 14:00:33 -08:00
Lachlan Sneff
c78d4a8674 Fix test compilation 2 2019-02-21 12:55:03 -08:00
Lachlan Sneff
2234f357b7
Merge branch 'master' into feature/cache-rework 2019-02-21 11:54:57 -08:00
Lachlan Sneff
f18da0690e Fix test compilation 2019-02-21 11:54:39 -08:00
Lachlan Sneff
7fa818ea06 Finalize new cache api 2019-02-21 11:47:28 -08:00
losfair
7c439932f1 Block and conditional branch. 2019-02-21 22:04:43 +08:00
losfair
63b3f41f05 Handle unreachable and fix return. 2019-02-21 21:14:10 +08:00
losfair
6f97ebd5f7 Remove a hack in parser. 2019-02-21 21:12:58 +08:00
Brandon Fish
ac57a1bc71 Add C API module_instantiate function 2019-02-20 23:08:23 -06:00
Lachlan Sneff
336c1d9c5f Fix lint 2019-02-20 17:00:48 -08:00
Lachlan Sneff
9f40eedba8 Get caching working again 2019-02-20 16:41:41 -08:00
Mackenzie Clark
1a951a9abf
stub wasm32-unknown-emscripten target imports (#193) 2019-02-20 14:05:12 -08:00
Syrus Akbary
a418595f2f
Merge pull request #135 from wasmerio/feature/c-api
C API
2019-02-20 11:51:45 -08:00
Brandon Fish
b073145dbb Clone import in instantiate to prevent import move 2019-02-20 09:52:42 -06:00
losfair
aaabbf169c Operator::Br and control stack fixes 2019-02-20 23:21:33 +08:00
losfair
61c83507a4 Control frames, jumps & stack unwinding. 2019-02-20 22:56:32 +08:00
Jordan Danford
64519b1581 Fix formatting and grammar in documentation 2019-02-19 17:01:44 -07:00
Lachlan Sneff
82eea00a02 Saved 2019-02-19 15:36:22 -08:00
Lachlan Sneff
3c7dc200fa close to working 2019-02-19 09:58:01 -08:00
losfair
93d2713bde Operators. 2019-02-19 20:25:09 +08:00
losfair
5583e96d96 Mitigate a bug that causes incorrect code generation.
Still need to figure out why R8 and higher registers don't work.
2019-02-19 19:19:40 +08:00
Brandon Fish
d2f3023191 Allow specifying optional max value in limits 2019-02-19 00:05:08 -06:00
Brandon Fish
380d766943 Convert from Box into/from raw to pointer ref-deref to fix free issue 2019-02-18 23:30:08 -06:00
Lachlan Sneff
e381bbd07b Use ModuleInfo instead of ModuleInner when possible 2019-02-18 11:56:20 -08:00
Brandon Fish
2ed6e82354 Merge branch 'master' into feature/c-api 2019-02-17 17:20:47 -06:00
Brandon Fish
123d55cb4a Remove commented out code, cleanup build warnings 2019-02-17 17:10:15 -06:00
Brandon Fish
ee81560e06 Cleanup tests 2019-02-17 16:51:59 -06:00
Brandon Fish
a77d1be983 Remove unused API functions 2019-02-17 14:48:30 -06:00
Brandon Fish
36767e0bd6 Move ctx pointer to first parameter to fix test 2019-02-17 14:39:26 -06:00
Brandon Fish
7bb947aba7 Add func signature lookup functions 2019-02-17 14:12:05 -06:00
David McNeil
a9b1c6c85e Fix emscripten environment (#172)
Dynamically determine abortOnCannotGrowMemory and add
_emscripten_get_heap_size and _emscripten_resize_heap
2019-02-16 15:01:01 -07:00
Brandon Fish
56079ad589 Add compile Module function 2019-02-15 19:47:00 -06:00
Brandon Fish
9ee86138b9 Impl Error for CallError 2019-02-15 19:16:19 -06:00
Brandon Fish
768a2fae18 Merge branch 'master' into feature/c-api 2019-02-15 19:12:30 -06:00
Lachlan Sneff
108973dabe Start producing object files with llvm 2019-02-15 16:02:20 -08:00
Christopher Serr
cb29261ec7 Use repr(transparent) for single element structs (#187)
The ABI of aggregates such as single element structs is not required to
be the same as the single elements themselves. This is especially true
for f64 vs. #[repr(c)] struct F(f64); on Windows. Therefore the macro
has been tweaked so S1 uses repr(transparent) which is made for exactly
for this use case.

Closes #183
2019-02-15 15:11:06 -08:00
Mackenzie Clark
2d2d708500
Validate descriptor max on creating new table or memory (#186) 2019-02-15 13:14:42 -08:00
Mackenzie Clark
b68b109b7d
Implement error for remaining errors and the amalgamation error (#184) 2019-02-15 08:15:57 -08:00
Brandon Fish
3ebb80e50e Update imports and add func_new 2019-02-15 09:40:28 -06:00
Mackenzie Clark
39ef47ebb1
Implement Error for CompilerError (#181) 2019-02-14 21:08:35 -08:00
Mackenzie Clark
09ba27390c
Implement Error for Creation Error (#180) 2019-02-14 19:22:19 -08:00
Mackenzie Clark
6e87676160
Impl error for link error (#182) 2019-02-14 18:40:52 -08:00
Mackenzie Clark
24d028e2a2
impl error trait for ResolveError (#179) 2019-02-14 18:19:18 -08:00
Lachlan Sneff
73b4f7d337 Implement memory and global operations 2019-02-14 18:08:20 -08:00
Lachlan Sneff
2d87f64f82 Merge master into feature/llvm-backend 2019-02-14 15:47:28 -08:00
Lachlan Sneff
8827830aba implement load* and store* instructions 2019-02-14 15:13:58 -08:00