From 975afed42798db9c91a49031bf7cca985659a8a3 Mon Sep 17 00:00:00 2001 From: Guilherme Ottoni Date: Thu, 23 May 2013 17:52:39 -0700 Subject: [PATCH] Use r15 instead of r13 in generic return dec-refs This avoids a bad interaction with LinearScan, which saves the return value in r13 and r14 around GenericRetDecRefs. Effectively, this diff ends up saving a push, a pop, and some stack adjustment in GenericRetDecRefs. --- hphp/runtime/vm/translator/hopt/codegen.cpp | 14 +++++++------- hphp/runtime/vm/translator/translator-x64.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hphp/runtime/vm/translator/hopt/codegen.cpp b/hphp/runtime/vm/translator/hopt/codegen.cpp index 3c7ba51a6..15d89b606 100644 --- a/hphp/runtime/vm/translator/hopt/codegen.cpp +++ b/hphp/runtime/vm/translator/hopt/codegen.cpp @@ -2706,13 +2706,13 @@ void CodeGenerator::cgGenericRetDecRefs(IRInstruction* inst) { if (numLocals == 0) return; - // The helpers called below use a special ABI, in which r13 is not saved. - // So save r13 on the stack if it's live. - bool saveR13 = m_state.liveRegs[inst].contains(r13); + // The helpers called below use a special ABI, in which r15 is not saved. + // So save r15 on the stack if it's live. + bool saveR15 = m_state.liveRegs[inst].contains(r15); int stackAdjust = 8; - if (saveR13) { - a.push(r13); + if (saveR15) { + a.push(r15); stackAdjust = 16; } @@ -2725,9 +2725,9 @@ void CodeGenerator::cgGenericRetDecRefs(IRInstruction* inst) { a.call(target); recordSyncPoint(a); - if (saveR13) { + if (saveR15) { a.addq(8, rsp); - a.pop(r13); + a.pop(r15); } } diff --git a/hphp/runtime/vm/translator/translator-x64.cpp b/hphp/runtime/vm/translator/translator-x64.cpp index 6008636ed..2aeb059df 100644 --- a/hphp/runtime/vm/translator/translator-x64.cpp +++ b/hphp/runtime/vm/translator/translator-x64.cpp @@ -11000,12 +11000,12 @@ void TranslatorX64::emitFreeLocalsHelpers() { Label loopHead; /* - * Note: the IR currently requires that we preserve r14/r15 across + * Note: the IR currently requires that we preserve r13/r14 across * calls to these free locals helpers. */ static_assert(rVmSp == rbx, ""); auto const rIter = rbx; - auto const rFinished = r13; + auto const rFinished = r15; auto const rType = esi; auto const rData = rdi;