Commit Graph

129 Commits

Author SHA1 Message Date
Nick Lewycky
c02cd76623 Refactor trampoline generation to use load_object_file. 2020-05-21 13:53:48 -07:00
Nick Lewycky
3764e7b9f8 Change load_object_file to take a RelocationTarget instead of a LocalFunctionIndex.
This removes its last connection to the implementation details of having a wasm_module, which we don't want to have to rely on when building trampolines.

There currently isn't a RelocationTarget for a trampoline function that refers to itself (none of been observed to done so yet), so we make the RelocationTarget optional.
2020-05-21 13:40:08 -07:00
Nick Lewycky
02f7e58c01 Change load_object_file to take a callback that converts symbol names into relocation targets.
This change means that load_object_file no longer needs a ModuleInfo, which trampoline generation doesn't have.
2020-05-21 13:32:03 -07:00
Nick Lewycky
a3a4a74596 Plain refactor the ELF loading to its own file. NFC. 2020-05-21 12:18:22 -07:00
Nick Lewycky
11cfe08919 Factor common string out to a constant. 2020-05-20 17:42:30 -07:00
Nick Lewycky
a47a3068f4 Remove #![allow(unused_imports, dead_code)] and fix resulting issues.
Fix nearly-all issues found by clippy too.
2020-05-20 17:18:23 -07:00
Nick Lewycky
dde6bc5269 Remove the C++ code.
This is replaced in reborn by the engines.
2020-05-20 15:41:11 -07:00
nlewycky
2c9ba69767 Merge pull request #40 from wasmerio/llvm-fcg-methods
Turn free functions into methods on LLVMFunctionCodeGenerator.
2020-05-20 14:45:09 -07:00
Nick Lewycky
c522e01165 Remove redundant close-and-reopen of impl block.
Move trap_if_misaligned up so it can join the impl block above it.
2020-05-20 14:18:34 -07:00
Nick Lewycky
1a22b5414e The 'name' parameter was always "". Remove them. 2020-05-20 14:15:24 -07:00
Nick Lewycky
f2c781b3b2 Turn splat_vector into a method. 2020-05-20 14:12:00 -07:00
Nick Lewycky
9eb1392988 Turn apply_pending_canonicalization into a method. 2020-05-20 14:05:14 -07:00
Nick Lewycky
df527f2cf1 Turn trap_if_misaligned into a method. 2020-05-20 13:57:51 -07:00
Nick Lewycky
159b2938b9 Turn three trap_if_* functions into methods. 2020-05-20 13:52:12 -07:00
Nick Lewycky
7ea973f6a8 Turn v128_into_* into methods. 2020-05-20 13:43:42 -07:00
Nick Lewycky
ac5a6ce3f9 Rename the use of inkwell::targets::Target from LLVMTarget to InkwellTarget.
Makes it consistent with other renamed inkwell imports that are prefaced with 'Inkwell'.
2020-05-20 12:40:39 -07:00
losfair
32461a6938 Resolve review comments. 2020-05-21 00:53:41 +08:00
Syrus
3e76e2d1f1 Fixed comments 2020-05-19 22:08:48 -07:00
Syrus
bdb58903c0 Merge branch 'master' into simplify-vmctx 2020-05-19 22:05:08 -07:00
Syrus
c76a3d83db Make LLVM work with one-vmctx imported functions 2020-05-19 21:38:10 -07:00
Nick Lewycky
fbd716374d Make trunc_sat_scalar() a member of LLVMFunctionCodeGenerator. 2020-05-19 21:37:35 -07:00
Nick Lewycky
093f32c4b9 Make trunc_sat() a member of LLVMFunctionCodeGenerator. 2020-05-19 21:35:29 -07:00
Syrus
09e057338a Renamed Module to ModuleInfo 2020-05-19 18:47:50 -07:00
Syrus Akbary
e7386373ff Merge pull request #16 from wasmerio/native-engine
Native engine
2020-05-19 18:13:37 -07:00
Syrus
ae8dcfcb27 Make PIC optional for compilers 2020-05-19 16:56:56 -07:00
Nick Lewycky
c5696101f8 Simplify TBAA label to a string. If the caller wants to construct a complex one, they can do so. NFC. 2020-05-19 15:13:24 -07:00
Nick Lewycky
f8af586a6d Remove dead code. 2020-05-19 15:02:04 -07:00
Nick Lewycky
063863eb87 Add a trap code for misaligned atomic accesses. Called "unaligned" because that's what the thread proposal spectest uses. Use it in LLVM. 2020-05-19 12:36:27 -07:00
Nick Lewycky
88bc330761 Remove commented-out code. 2020-05-19 11:52:34 -07:00
Nick Lewycky
808cf9eb0d Remove obsolete comment and variables.
Expound upon comment. Fix typo.
2020-05-19 11:23:53 -07:00
Nick Lewycky
ae6f0dadb2 Stop naming instructions with numbered names.
LLVM will number instructions if you don't provide a name, so we get %7 instead of %s7 from calling state.var_name(). LLVM doesn't assign the numbers until printing out the LLVM IR as text, which we never do in a normal run of wasmer.

If you're editing a .ll text by hand and you're worried about messing up the numbering, use `opt --instnamer` to assign autogenerated names to all numbered instructions.
2020-05-19 09:54:20 -07:00
nlewycky
976493c756 Merge pull request #31 from wasmerio/llvm-memorydefinition-cache
Cache lookup of VMMemoryDefinition.
2020-05-18 20:03:48 -07:00
Nick Lewycky
0df99b5dbc Cache lookup of VMMemoryDefinition.
To add to the cache, mutability is required, so now `resolve_memory_ptr` must be `&mut self` which means that `translate_operator` may not hold those convenient immutable references across the whole function.

The search and replace to implement the above changes affected some commented out code, that code is removed.

MemoryStyle grows PartialEq and Eq so that we can check what the memory style is without a match expression.
2020-05-18 19:59:50 -07:00
Syrus
363dbb3b08 Fixed lint issues 2020-05-18 14:55:55 -07:00
Nick Lewycky
dff7cf28c9 Fix invalid LLVM IR for global.get/set of imported globals.
In passing, refactor global accesses and cache the address computations and values of const globals.

Also includes some cargo fmt fixes.
2020-05-18 14:35:23 -07:00
Syrus
f20d09fb2d Fixed LLVM compilation 2020-05-18 13:23:19 -07:00
Nick Lewycky
f666a394c5 Fix LLVM type of load of table entry. 2020-05-18 13:17:44 -07:00
Syrus Akbary
9981a51f8f Merge pull request #23 from wasmerio/host-trampolines
Improved trampolines adding support for Dynamic functions
2020-05-18 13:12:37 -07:00
Nick Lewycky
7783879ae2 Improve comment. 2020-05-18 12:44:49 -07:00
Nick Lewycky
be1754766e Fix issue with GOT relocations being emitted on Mac. 2020-05-18 12:30:49 -07:00
Nick Lewycky
288cb46715 Give the main loop a big comment explaining it.
Remove some commented out duplicate code.
2020-05-18 11:08:33 -07:00
Nick Lewycky
cac3246b2e Improve error handling around ElfSectionIndex a little. 2020-05-18 10:56:44 -07:00
Nick Lewycky
7e1f19eafe Add an ElfSectionIndex type for type safety and code clarity. 2020-05-18 09:51:00 -07:00
Nick Lewycky
7e62e1f59b Factor out building and pushing the Relocation. This if-else just computes the relocation target. 2020-05-18 09:21:09 -07:00
Nick Lewycky
a79a9b19f7 Remove name for unused variable. 2020-05-18 09:13:51 -07:00
Nick Lewycky
aa4aa65d0c Remove some calls to clone() by using into_iter(). 2020-05-18 09:08:33 -07:00
Nick Lewycky
fce8e32cf6 Don't make SectionBody's internal Vec public.
Add a new method to create a new section body. Remove unused methods. Improve implementation of is_empty().
2020-05-18 09:08:33 -07:00
Nick Lewycky
1ee5f27a3a Simplify sort expression. 2020-05-18 09:08:33 -07:00
Nick Lewycky
ea05e16b6d Parse relocations that apply to custom relocations.
This rewrites the whole relocation parsing to work properly.
  * we no longer use LocalRelocation and simply assign a new SectionIndex as new sections are encountered.
  * we no longer use string matching to determine what function applies relocations to what, instead we use the field in the elf section header that tells us
  * we no longer merge sections, each section from every function is preserved as an independent custom section in the module.
  * we now discover any new sections that need to be pulled in recursively as we parse each section
  * many error cases are either handled, or report CompileErrors.
2020-05-18 09:08:33 -07:00
Syrus
5dfa9faafb Improve compiler names for trampoline functions 2020-05-17 20:32:42 -07:00