From 731a3fcd23ae3908ff22381e22d058a14b5f169f Mon Sep 17 00:00:00 2001 From: mwilliams Date: Wed, 13 Mar 2013 17:33:45 -0700 Subject: [PATCH] Fix emitInterceptProlog When the compare was rewritten for the new assembler syntax it was accidently changed from being a compare of the byte pointed to by rax, to a compare of the low byte of rax. I also noticed that by loading the Func* into rax, and doing a compare against rax[Func::maybeInterceptedOff()] we can skip a subsequent mov of the Func* into rax. The code was only slightly broken because we set everything to be interceptable up front, (if EnableRenameFunction is on) because we had too many issues with the invalidation code. The bug was that if the Func happened to be allocated at a multiple of 256 bytes, it wasnt interceptable. Also, the existing code looked silly, mov $abcdef45, $eax cmp 0, $al and the new code is smaller. --- hphp/runtime/vm/translator/translator-x64.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hphp/runtime/vm/translator/translator-x64.cpp b/hphp/runtime/vm/translator/translator-x64.cpp index ee5bf2e21..1f82ae8ab 100644 --- a/hphp/runtime/vm/translator/translator-x64.cpp +++ b/hphp/runtime/vm/translator/translator-x64.cpp @@ -2173,13 +2173,11 @@ TranslatorX64::funcPrologue(Func* func, int nPassed) { TCA TranslatorX64::emitInterceptPrologue(Func* func) { TCA start = a.code.frontier; - emitImmReg(a, int64_t(&func->maybeIntercepted()), rax); - a. cmpb (0, al); + emitImmReg(a, int64_t(func), rax); + a. cmpb (0, rax[Func::maybeInterceptedOff()]); semiLikelyIfBlock(CC_NE, a, [&]{ // Prologues are not really sites for function entry yet; we can get // here via an optimistic bindCall. Check that the func is as expected. - - emitImmReg(a, int64_t(func), rax); a. cmpq (rax, rStashedAR[AROFF(m_func)]); { JccBlock skip(a);