Skip to content

Commit

Permalink
Merge branch 'master' into singlepass_aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Jan 26, 2022
2 parents 74779f5 + 67be3ea commit bff3c09
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 38 deletions.
66 changes: 33 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -149,7 +149,7 @@ languages**, so you can use WebAssembly _anywhere_.
[c logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/c.svg
[c integration]: https://github.com/wasmerio/wasmer/tree/master/lib/c-api
[`wasmer.h` header]: https://github.com/wasmerio/wasmer/blob/master/lib/c-api/wasmer.h
[c docs]: https://docs.rs/wasmer-c-api/*/wasmer_c_api/wasm_c_api/index.html
[c docs]: https://docs.rs/wasmer-c-api/*/wasmer/wasm_c_api/index.html

[c# logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/csharp.svg
[c# integration]: https://github.com/migueldeicaza/WasmerSharp
Expand All @@ -164,7 +164,7 @@ languages**, so you can use WebAssembly _anywhere_.
[python logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/python.svg
[python integration]: https://github.com/wasmerio/wasmer-python
[`wasmer` pypi package]: https://pypi.org/project/wasmer/
[python docs]: https://wasmerio.github.io/wasmer-python/api/wasmer/
[python docs]: https://wasmerio.github.io/wasmer-python/api/wasmer

[go logo]: https://raw.githubusercontent.com/wasmerio/wasmer/master/assets/languages/go.svg
[go integration]: https://github.com/wasmerio/wasmer-go
Expand Down
12 changes: 9 additions & 3 deletions lib/compiler-singlepass/src/machine_x64.rs
Expand Up @@ -1809,16 +1809,22 @@ impl Machine for MachineX86_64 {
fn push_location_for_native(&mut self, loc: Location) {
match loc {
Location::Imm64(_) => {
// Push R9 value slot to be exchange with `mov`.
// x86_64 does not support `mov imm64, mem`. We must first place the immdiate value
// into a register and then write the register to the memory. Now the problem is
// that there might not be any registers available to clobber. In order to make
// this work out we spill a register thus retaining both the original value of the
// register and producing the required data at the top of the stack.
//
// FIXME(#2723): figure out how to not require spilling a register here. It should
// definitely be possible to `pick_gpr`/`pick_temp_gpr` to grab an otherwise unused
// register and just clobber its value here.
self.assembler.emit_push(Size::S64, Location::GPR(GPR::R9));
self.reserve_unused_temp_gpr(GPR::R9);
self.move_location(Size::S64, loc, Location::GPR(GPR::R9));
self.assembler.emit_xchg(
Size::S64,
Location::GPR(GPR::R9),
Location::Memory(GPR::RSP, 0),
);
self.release_gpr(GPR::R9);
}
Location::SIMD(_) => {
// Dummy value slot to be filled with `mov`.
Expand Down
39 changes: 39 additions & 0 deletions tests/compilers/issues.rs
Expand Up @@ -225,3 +225,42 @@ fn call_with_static_data_pointers(mut config: crate::Config) -> Result<()> {
instance.exports.get_function("repro")?.call(&[])?;
Ok(())
}

/// Exhaustion of GPRs when calling a function with many floating point arguments
///
/// Note: this one is specific to Singlepass, but we want to test in all
/// available compilers.
#[compiler_test(issues)]
fn regression_gpr_exhaustion_for_calls(mut config: crate::Config) -> Result<()> {
let store = config.store();
let wat = r#"
(module
(type (;0;) (func (param f64) (result i32)))
(type (;1;) (func (param f64 f64 f64 f64 f64 f64)))
(func (;0;) (type 0) (param f64) (result i32)
local.get 0
local.get 0
local.get 0
local.get 0
f64.const 0
f64.const 0
f64.const 0
f64.const 0
f64.const 0
f64.const 0
f64.const 0
i32.const 0
call_indirect (type 0)
call_indirect (type 1)
drop
drop
drop
drop
i32.const 0)
(table (;0;) 1 1 funcref))
"#;
let module = Module::new(&store, wat)?;
let imports: ImportObject = imports! {};
let instance = Instance::new(&module, &imports)?;
Ok(())
}

0 comments on commit bff3c09

Please sign in to comment.