Commit Graph

5963 Commits

Author SHA1 Message Date
Marcin Mielniczuk
f07392c175 Quick fix for path_filestat_set_times. Closes #95. 2019-09-11 15:01:01 -07:00
Nicolas B. Pierron
e8dc9ad8c9 Fix x86/br-i128 test case to use basic blocks. 2019-09-11 20:24:48 +02:00
Dan Gohman
e85376ec07 Add doc comments to WasiCtxBuilder's methods. 2019-09-11 11:33:37 +02:00
Dan Gohman
c1c74ca54b Add a method for inhering the command-line arguments from the host. 2019-09-11 11:05:29 +02:00
Jef
31a75a2a84 Merge pull request #24 from sstangl/patch-1
Correctly capitalize Firefox in the README
2019-09-11 11:03:02 +02:00
Dan Gohman
aea2f11f06 Mark WasiCtx's internals as pub(crate). 2019-09-11 10:39:02 +02:00
Artur Jamro
633dfa17ee Cache config as a file 2019-09-11 00:12:25 -07:00
Wander Lairson Costa
35c6d869f5 Replace region::protect by make_exec in cranelift-filetests 2019-09-10 18:53:02 -07:00
Nicolas B. Pierron
abb157315b Basic Blocks: Fix frontend::sample_function test case. (#1007) 2019-09-10 15:02:11 -06:00
Benjamin Bouvier
cad2074587 [codegen] Don't simplify an operation if it would result in unnecessary legalization;
Converting something like iadd.i64 on a 32-bits architecture into a
iadd_imm.i64 will result in the instruction being legalized back to an
iadd.i64 later on, creating unnecessary churn.

This commit implements avoid doing so, and changes the target ISA to a
64-bits platform for tests than ran into this, as well as making sure
this won't happen on 32-bits platforms.
2019-09-10 19:50:34 +02:00
Benjamin Bouvier
3aa76b558c Legalize i64.const by breaking it into two i32.const, on 32-bits platforms; 2019-09-10 19:50:34 +02:00
Andrew Brown
6f1ed94e82 Fix documentation 2019-09-10 10:45:12 -07:00
Andrew Brown
295b2ef614 Avoid extra register movement when lowering an x86 insertlane to a float vector 2019-09-10 10:45:12 -07:00
Andrew Brown
3dfc68afb1 Avoid extra register movement when lowering the x86 scalar_to_vector of a float value 2019-09-10 10:45:12 -07:00
Andrew Brown
00bedca274 Avoid extra register movement when lowering the x86 extractlane of a float vector
This commit is based on the assumption that floats are already stored in XMM registers in x86. When extracting a lane, cranelift was moving the float to a regular register and back to an XMM register; this change avoids this by shuffling the float value to the lowest bits of the XMM register. It also assumes that the upper bits can be left as is (instead of zeroing them out).
2019-09-10 10:45:12 -07:00
Andrew Brown
f1363168a9 Translate the sign-extended and zero-extended versions of extract_lane 2019-09-10 10:45:12 -07:00
Andrew Brown
ebc783e49b Use raw_bitcast when legalizing splat
raw_bitcast matches the intent of this legalization more clearly (to simply change the CLIF type without changing any bits) and the additional null encodings added are necessary for later instructions
2019-09-10 10:45:12 -07:00
Andrew Brown
8a6686ec45 Enable SSSE3 setting when detected on CPU 2019-09-10 10:45:12 -07:00
Andrew Brown
7f152611a4 Log compiled and legalized functions 2019-09-10 10:45:12 -07:00
dependabot-preview[bot]
c42698dc85 Update pyo3 requirement from 0.7.0-alpha.1 to 0.8.0 (#324)
* Update pyo3 requirement from 0.7.0-alpha.1 to 0.8.0

Updates the requirements on [pyo3](https://github.com/pyo3/pyo3) to permit the latest version.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/master/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.7.0-alpha.1...v0.8.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Change into_object() -> into_py()
2019-09-10 10:04:24 -05:00
Sean Stangl
4b085b9cf7 Avoid unnecessary reallocations in domtree::with_function() (#1011) 2019-09-10 08:18:06 -06:00
julian-seward1
63367d205c Fix #975 (Structure of cranelift-wasm/src/translation_utils.rs causes many pointless heap allocations) (#1010)
This patch restricts the `Err(..)` return from `blocktype_to_type` to be
`Err(..)` only in the case where it really is an error to continue.  The three
use points of `blocktype_to_type` are changed to check for an `Err(..)` rather
than silently ignoring it.  There are also cosmetic changes to `type_to_type`
and `tabletype_to_type`.

When compiling wasm_lua_binarytrees, this reduces the number of blocks
allocated by CL by 1.9%.  Instruction count falls by 0.1%.

Details:

* `type_to_type` and `tabletype_to_type`:

   - Added the function name in the failure message

   - No functional change for non-error cases

   - Push the `Ok(..)` to expression leaves, where it really applies.  This
     corrects the misleading impression that, in the case of an unsupported
     type, the function returns `Ok` wrapped around whatever
     `wasm_unsupported` returns.  It doesn't do that, but it certainly reads
     like that.  This assumes that the LLVM backend will do tail merging, so
     the generated code will be unchanged.

* `blocktype_to_type`:

  - Change return type from `WasmResult<ir::Type>` to `WasmResult<Option<ir::Type>>`

  - Manually inline the call to `type_to_type`, to make this function easier
    to read.

  - For the non-error case: map `TypeOrFuncType::Type(Type::EmptyBlockType)`
    to `Ok(None)` rather than `Err(..)`, since that's what all the call sites
    expect - For the error cases, add the function name in the failure
    messages

* cranelift-wasm/src/code_translator.rs

  - For the three uses of `blocktype_to_type`, use `?` to detect failures and
    drop out immediately, meaning that the code will no longer silently ignore
    errors.
2019-09-10 15:06:10 +02:00
Nicolas B. Pierron
81fa5e7696 Add equivalent safepoint test cases for basic blocks. 2019-09-10 14:53:13 +02:00
Ujjwal Sharma
345b2dc0cc [codegen] add new recipe "rout" (#1014)
* [codegen] add new recipe "rout"

Add a new recipe "rout" intended to be used by arithematic operations
that output flags, currently being used for `iadd_cout` and `isub_bout`.

Fixes: https://github.com/CraneStation/cranelift/issues/1009
2019-09-10 12:55:24 +02:00
data-pup
ac2ca6116b allow module environment to parse name section 2019-09-10 11:30:54 +02:00
Philip Craig
3293ca6b69 Add cranelift-object 2019-09-09 21:54:20 -07:00
Dan Gohman
52b69c21cf Miscellaneous clippy fixes. 2019-09-09 18:07:39 +02:00
Dan Gohman
39161d020f Clippy: use from functions rather than as casts.
`as` is a many-faceted conversion operator, while `from` functions only do
lossless conversions.
2019-09-09 18:07:39 +02:00
Dan Gohman
09ace35295 Clippy: use ptr::add rather than ptr::offset. 2019-09-09 18:07:39 +02:00
Dan Gohman
34db7f0150 Update to syn 1 and quote 1. 2019-09-09 16:33:32 +02:00
Nicolas B. Pierron
90b0b86f5c Simplify isa_builder macro 2019-09-09 13:30:02 +02:00
Julian Seward
d2443a75f3 legalizer/split.rs: simplify_branch_arguments: use SmallVec instead of Vec
This function is responsible for 8.5% of all heap allocation (calls) in CL.
This change avoids almost all of them by using a SmallVec::<[Value; 32]>
instead.  Dynamic instruction count falls by 0.25%.  The fixed size of 32 was
arrived at after profiling with fixed sizes of 1, 2, 4, 8, 16, 32, 64 and 128.
32 is as high as I can push it without the instruction count starting to creep
up again, and gets almost all the block-reduction win of 64 and 128.
2019-09-09 12:58:21 +02:00
Julian Seward
c6a4c60a0f EbbHeaderBlockData::predecessors: use SmallVec instead of Vec
Allocations associated with pushes to EbbHeaderBlockData::predecessors account
for 4.9% of all heap allocation (calls) in CL.  This change avoids almost all
of them by changing it to be a SmallVec<[PredBlock; 4]>.  Dynamic instruction
count falls by 0.15%.
2019-09-09 11:37:04 +02:00
Julian Seward
955cdd5f83 VirtRegs::find: use SmallVec instead of Vec for val_stack.
Pushing on the `val_stack` vector is CL's biggest source of calls to
malloc/realloc/free, by some margin.  It accounts for about 27.7% of all heap
blocks allocated when compiling wasm_lua_binarytrees.  This change removes
pretty much all dynamic allocation by changing to a SmallVec<[Value; 8]>
instead.  A fixed size of 4 gets all the gains to be had, in testing, so 8
gives some safety margin and is harmless from a stack-use perspective: 8
Values will occupy 32 bytes.

As a bonus, this change also reduces the compiler's dynamic instruction count
by about 0.5%.
2019-09-09 11:30:59 +02:00
Jakub Konka
33c78e2e5b Fix formatting 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
612617b0ba reuse the host::* consts in enum Error 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
c5339d01cf refactor errno_from_ioerror 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
ae836df42d reformat 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
57c19cf073 fixes 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
438c693508 Impl Fail 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
b812304d86 Remove .vscode 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
3fd0cdcc12 Cleanup 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
b09f7e860f Refactor try_from and try_into error handing. 2019-09-09 11:26:06 +02:00
Marcin Mielniczuk
14aaffd46f Initial error refactor 2019-09-09 11:26:06 +02:00
Alex Crichton
705bfacf10 rustfmt 2019-09-07 16:20:23 -07:00
Alex Crichton
dfda794f55 Add a custom section hook to ModuleEnvironment
This commit adds a hook to the `ModuleEnvironment` trait to learn when a
custom section in a wasm file is read. This hook can in theory be used
to parse and handle custom sections as they appear in the wasm file
without having to re-iterate over the wasm file after cranelift has
already parsed the wasm file.

The `translate_module` function is now less strict in that it doesn't
require sections to be in a particular order, but it's figured that the
wasm file is already validated elsewhere to verify the section order.
2019-09-07 16:20:23 -07:00
Aaron Power
8fd1128990 Remove FunctionBuilderContext from API, and change FunctionBuilder API 2019-09-07 14:43:07 -07:00
bjorn3
0273eb84e0 Fix rebase 2019-09-07 09:55:09 -07:00
bjorn3
e8d4ef7c3d Fix review comments 2019-09-07 09:55:09 -07:00
bjorn3
e2b2b520eb Fix compilation 2019-09-07 09:55:09 -07:00