Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows fprs preservation #1216

Merged
merged 41 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4543e23
initial brush at preserving SIMD registers in Windows fastcall functions
iximeow Feb 6, 2020
218ff4f
remove outdated comment and align CSR space if any SIMD registers are…
iximeow Feb 6, 2020
dd558cb
x86: preserve/restore callee-save xmm registers
iximeow Feb 6, 2020
0537418
rustfmt
iximeow Feb 6, 2020
6147df3
i do not understand why these are being rejected now
iximeow Feb 6, 2020
ad96c5a
rcx is used as a return value register, but r11 is free at return
iximeow Feb 6, 2020
59d23fa
use rbp instead of r11 to work around missing fstDisp8/fldDisp8 encod…
iximeow Feb 6, 2020
bee0989
avoid growing callee-save space when already 16-byte aligned
iximeow Feb 10, 2020
8f33538
fix merge confict with EBB rename
iximeow Feb 11, 2020
eefa4fc
tests are real too
iximeow Feb 11, 2020
2e632bd
also record xmm preservation in Windows fastcall unwind info
iximeow Feb 12, 2020
3de41fa
turns out f64x2 tries to use the nonexistent fstDisp8 encoding for f6…
iximeow Feb 12, 2020
aa5d68e
trusty rustfmt
iximeow Feb 12, 2020
3ce7acf
clarify that Windows only requires the low 128 bits of floating point…
iximeow Feb 13, 2020
cc99f14
fix FPR preservation overlapping with GPR stack area
iximeow Feb 21, 2020
597c994
rustfmt
iximeow Feb 21, 2020
d22ec8a
specify that ss0 should be a 32-byte spill slot, sufficient for two x…
iximeow Feb 21, 2020
9489c05
almost fix offset calculations kind of sort of
iximeow Mar 3, 2020
cc2975a
maybe it works now
iximeow Mar 6, 2020
403ebb2
maaaybe get Windows FPR unwind info right?
iximeow Mar 10, 2020
eeca3f4
running rustfmt in the wrong directory does nothing
iximeow Mar 10, 2020
b86234b
ci speak to me of windows woes
iximeow Mar 10, 2020
eeea0dd
only check for aligned frame allocation when we need it to be aligned
iximeow Mar 11, 2020
74d4ab8
print the whole prologue that caused issues in unwind
iximeow Mar 11, 2020
f0f2394
add a comment explaining the seemingly-trunctaed test
iximeow Mar 13, 2020
7bcff83
Revert "ci speak to me of windows woes"
iximeow Mar 13, 2020
56e45cf
preserve FPRs in an ExplicitSlot rather than SpillSlot
iximeow Mar 13, 2020
84da124
remove helper function that only existed due to a bad rebase
iximeow Mar 13, 2020
ceb48bf
temporarily disable the panic-reaching multi-return spectest
iximeow Mar 13, 2020
291d09b
rust ... format ...
iximeow Mar 14, 2020
0a418a2
ignore more windows-unfriendly tests?
iximeow Apr 2, 2020
a7e23a9
try different names for the testsuites?
iximeow Apr 2, 2020
52425ef
rustfmt
iximeow Apr 2, 2020
3060c8c
update panic message with reference to implementation limit
iximeow Apr 6, 2020
42d129b
review feedback
iximeow Apr 7, 2020
c7547ed
fix date
iximeow Apr 7, 2020
c3530e6
try making unwind info fallible
iximeow Apr 9, 2020
f403c0a
pass errors in generating unwind info back up through CompiledFunctio…
iximeow Apr 9, 2020
750507a
forgot to rustfmt
iximeow Apr 9, 2020
4e1b10e
make emit_fde Result-y as well
iximeow Apr 9, 2020
89af7e1
Update cranelift/codegen/src/isa/mod.rs
iximeow Apr 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
("reference_types", "table_copy_on_imported_tables") => return false,
("reference_types", _) => return true,

("misc_testsuite", "export_large_signature")
| ("spec_testsuite", "call")
| ("multi_value", "call")
| ("multi_value", "func") => {
// FIXME These involves functions with very large stack frames that Cranelift currently
// cannot compile using the fastcall (Windows) calling convention.
// See https://github.com/bytecodealliance/wasmtime/pull/1216.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create a new issue to track the stack layout for CSRs problem and link here instead of the PR? My concern is only that it's hard to make out what's relevant of a complex PR like this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. That's the third item in my to-do list which I've been waiting for even a preliminary ✔️ to actually file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder to update this to https://github.com/bytecodealliance/wasmtime/issues/1475.

#[cfg(windows)]
return true;
}

_ => {}
},
_ => panic!("unrecognized strategy"),
Expand Down
4 changes: 2 additions & 2 deletions cranelift/codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ impl Context {
isa: &dyn TargetIsa,
kind: FrameUnwindKind,
sink: &mut dyn FrameUnwindSink,
) {
isa.emit_unwind_info(&self.func, kind, sink);
) -> CodegenResult<()> {
isa.emit_unwind_info(&self.func, kind, sink)
}

/// Run the verifier on the function.
Expand Down
3 changes: 2 additions & 1 deletion cranelift/codegen/src/isa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,9 @@ pub trait TargetIsa: fmt::Display + Send + Sync {
_func: &ir::Function,
_kind: binemit::FrameUnwindKind,
_sink: &mut dyn binemit::FrameUnwindSink,
) {
) -> CodegenResult<()> {
// No-op by default
Ok(())
}
}

Expand Down
241 changes: 220 additions & 21 deletions cranelift/codegen/src/isa/x86/abi.rs

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions cranelift/codegen/src/isa/x86/fde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::binemit::{FrameUnwindOffset, FrameUnwindSink, Reloc};
use crate::ir::{FrameLayoutChange, Function};
use crate::isa::fde::RegisterMappingError;
use crate::isa::{CallConv, RegUnit, TargetIsa};
use crate::result::CodegenResult;
use alloc::vec::Vec;
use core::convert::TryInto;
use gimli::write::{
Expand Down Expand Up @@ -178,7 +179,11 @@ fn to_cfi(
}

/// Creates FDE structure from FrameLayout.
pub fn emit_fde(func: &Function, isa: &dyn TargetIsa, sink: &mut dyn FrameUnwindSink) {
pub fn emit_fde(
func: &Function,
isa: &dyn TargetIsa,
sink: &mut dyn FrameUnwindSink,
) -> CodegenResult<()> {
assert!(isa.name() == "x86");

// Expecting function with System V prologue
Expand Down Expand Up @@ -266,6 +271,8 @@ pub fn emit_fde(func: &Function, isa: &dyn TargetIsa, sink: &mut dyn FrameUnwind

// Need 0 marker for GCC unwind to end FDE "list".
sink.bytes(&[0, 0, 0, 0]);

Ok(())
}

#[cfg(test)]
Expand Down Expand Up @@ -314,7 +321,7 @@ mod tests {
context.compile(&*isa).expect("expected compilation");

let mut sink = SimpleUnwindSink(Vec::new(), 0, Vec::new());
emit_fde(&context.func, &*isa, &mut sink);
emit_fde(&context.func, &*isa, &mut sink).expect("can emit fde");

assert_eq!(
sink.0,
Expand Down Expand Up @@ -376,7 +383,7 @@ mod tests {
context.compile(&*isa).expect("expected compilation");

let mut sink = SimpleUnwindSink(Vec::new(), 0, Vec::new());
emit_fde(&context.func, &*isa, &mut sink);
emit_fde(&context.func, &*isa, &mut sink).expect("can emit fde");

assert_eq!(
sink.0,
Expand Down
4 changes: 2 additions & 2 deletions cranelift/codegen/src/isa/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ impl TargetIsa for Isa {
func: &ir::Function,
kind: FrameUnwindKind,
sink: &mut dyn FrameUnwindSink,
) {
abi::emit_unwind_info(func, self, kind, sink);
) -> CodegenResult<()> {
abi::emit_unwind_info(func, self, kind, sink)
}
}

Expand Down
Loading