Skip to content
Snippets Groups Projects
Commit ce17edb0 authored by Nadav Har'El's avatar Nadav Har'El
Browse files

Unfortunately, while in theory it should not be necessary to save

the FPU on a context switch caused by a function call (as opposed
to a preemption during interrupt), in practice this makes the
"sunflow" benchmark from SpecJVM fail, producing wrong results.

This patch saves the FPU on any context switch and makes "sunflow"
work correctly, at the price of slower context switches and an
unsolved puzzle on why the heck this is needed in the first place :(
parent 2c1eb668
No related branches found
No related tags found
No related merge requests found
......@@ -81,13 +81,23 @@ void cpu::reschedule_from_interrupt(bool preempt)
n->_status.store(thread::status::running);
if (n != thread::current()) {
if (preempt) {
asm volatile("clts");
p->_fpu.save();
} else {
// FIXME: In this case, in theory, we do not need to save the FPU
// state (perhaps just mxcsr and cw) because we got here through a
// function call and the calling conventions guarantee the caller
// clears the FPU state. Unfortunately, in practice, the SPECjvm
// "sunflow" benchmark breaks (gets wrong results) if we don't
// save the SSE registers here. We don't know why.
p->_fpu.save();
}
trace_switch(n);
n->switch_to();
if (preempt) {
p->_fpu.restore();
} else {
// FIXME: This shouldn't be here! See comment above.
p->_fpu.restore();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment