From bc7728c156b75aff4e30086b530e95a80a020301 Mon Sep 17 00:00:00 2001 From: Max Wang Date: Thu, 19 Jan 2017 22:45:26 -0800 Subject: [PATCH] Don't do branch profiling for profiling translations Reviewed By: markw65 Differential Revision: D4435131 fbshipit-source-id: 0eff93f31119627615ecdbe7955fa5c2bfaeba4b --- hphp/runtime/vm/jit/types.h | 18 ++++++++++++++++++ hphp/runtime/vm/jit/vasm-x64.cpp | 11 ++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/hphp/runtime/vm/jit/types.h b/hphp/runtime/vm/jit/types.h index c39647de1c4..12854ac40d4 100644 --- a/hphp/runtime/vm/jit/types.h +++ b/hphp/runtime/vm/jit/types.h @@ -104,6 +104,24 @@ inline std::string show(TransKind k) { not_reached(); } +inline bool isProfiling(TransKind k) { + switch (k) { + case TransKind::Profile: + case TransKind::ProfPrologue: + return true; + + case TransKind::Anchor: + case TransKind::Interp: + case TransKind::Live: + case TransKind::LivePrologue: + case TransKind::Optimize: + case TransKind::OptPrologue: + case TransKind::Invalid: + return false; + } + always_assert(false); +} + inline bool isPrologue(TransKind k) { switch (k) { case TransKind::LivePrologue: diff --git a/hphp/runtime/vm/jit/vasm-x64.cpp b/hphp/runtime/vm/jit/vasm-x64.cpp index 1026e93cbca..301016054f4 100644 --- a/hphp/runtime/vm/jit/vasm-x64.cpp +++ b/hphp/runtime/vm/jit/vasm-x64.cpp @@ -1043,11 +1043,12 @@ void optimizeX64(Vunit& unit, const Abi& abi, bool regalloc) { assertx(checkWidths(unit)); - if (abi.canSpill && RuntimeOption::EvalProfBranchSampleFreq > 0) { - // Only profile branches if we're allowed to spill (and if branch profiling - // is on, of course). This is not only for the freedom to generate - // arbitrary code, but also because we don't want to profile unique stubs - // and such. + if (unit.context && isProfiling(unit.context->kind) && abi.canSpill && + RuntimeOption::EvalProfBranchSampleFreq > 0) { + // Even when branch profiling is on, we still only want to profile + // non-profiling translations of PHP functions. We also require that we + // can spill, so that we can generate arbitrary profiling code, and also to + // ensure we don't profile unique stubs and such. profile_branches(unit); } -- 2.11.4.GIT