From 3e6df2d7aa8a7995b54e3a49a73083c717e76a90 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 16 Sep 2013 23:17:34 -0700 Subject: [PATCH] Just save XMM0-XMM15 on x64. Not really sure why but seems like VS2010 expects XMM4 to be preserved. Fixes headless on x64. --- Common/ABI.cpp | 14 ++++++++------ headless/Headless.cpp | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Common/ABI.cpp b/Common/ABI.cpp index 75185cc7ab..7dc2bef94f 100644 --- a/Common/ABI.cpp +++ b/Common/ABI.cpp @@ -478,7 +478,9 @@ unsigned int XEmitter::ABI_GetAlignedFrameSize(unsigned int frameSize) { #ifdef _WIN32 // The Windows x64 ABI requires XMM6 - XMM15 to be callee saved. 10 regs. -const int XMM_STACK_SPACE = 10 * 16; +// But, not saving XMM4 and XMM5 breaks things in VS 2010, even though they are volatile regs. +// Let's just save all 16. +const int XMM_STACK_SPACE = 16 * 16; // Win64 Specific Code void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() { @@ -495,13 +497,13 @@ void XEmitter::ABI_PushAllCalleeSavedRegsAndAdjustStack() { // Do this after aligning, beacuse before it's offset by 8. SUB(64, R(RSP), Imm32(XMM_STACK_SPACE)); - for (int i = 0; i < 10; ++i) - MOVAPS(MDisp(RSP, i * 16), (X64Reg)(XMM6 + i)); + for (int i = 0; i < 16; ++i) + MOVAPS(MDisp(RSP, i * 16), (X64Reg)(XMM0 + i)); } void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() { - for (int i = 0; i < 10; ++i) - MOVAPS((X64Reg)(XMM6 + i), MDisp(RSP, i * 16)); + for (int i = 0; i < 16; ++i) + MOVAPS((X64Reg)(XMM0 + i), MDisp(RSP, i * 16)); ADD(64, R(RSP), Imm32(XMM_STACK_SPACE)); ABI_RestoreStack(0); @@ -525,7 +527,7 @@ void XEmitter::ABI_PushAllCallerSavedRegsAndAdjustStack() { PUSH(R9); PUSH(R10); PUSH(R11); - // Callers preserve XMM4-5 (XMM0-3 are args.) But we don't need them usually. + // TODO: Callers preserve XMM4-5 (XMM0-3 are args.) ABI_AlignStack(0); } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 4f4101ed0d..50f13f2860 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -138,7 +138,7 @@ int main(int argc, const char* argv[]) const char *mountIso = 0; const char *screenshotFilename = 0; bool readMount = false; - double timeout = -1.0; + float timeout = std::numeric_limits::infinity(); for (int i = 1; i < argc; i++) { @@ -304,7 +304,7 @@ int main(int argc, const char* argv[]) time_update(); bool doCompare = true; - double deadline = timeout < 0.0 ? std::numeric_limits::infinity() : time_now() + timeout; + double deadline = time_now() + timeout; coreState = CORE_RUNNING; while (coreState == CORE_RUNNING) @@ -318,7 +318,7 @@ int main(int argc, const char* argv[]) headlessHost->SwapBuffers(); } time_update(); - if (time_now() > deadline) { + if (time_now_d() > deadline) { // Don't compare, print the output at least up to this point, and bail. printf("%s", output.c_str()); doCompare = false;