Skip to content

Commit

Permalink
Remove Translator::m_mode
Browse files Browse the repository at this point in the history
Summary:
The TransKind is per-translation state and shouldn't be global like
this. Move it to function arguments/state structs as needed.

Reviewed By: ottoni

Differential Revision: D2903472

fb-gh-sync-id: cd0177df77b11c04e07c044466f8f2dbb7a94a68
  • Loading branch information
swtaarrs authored and hhvm-bot committed Feb 8, 2016
1 parent f1bce25 commit ea43e34
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 156 deletions.
2 changes: 1 addition & 1 deletion hphp/runtime/test/test-context.h
Expand Up @@ -24,7 +24,7 @@ namespace HPHP { namespace jit {

// A TransContext for use in tests.
const auto test_context =
TransContext { kInvalidTransID, SrcKey{}, FPInvOffset{0} };
TransContext { kInvalidTransID, TransKind::Live, SrcKey{}, FPInvOffset{0} };

//////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/vm/jit/code-gen-x64.cpp
Expand Up @@ -2134,7 +2134,7 @@ void CodeGenerator::cgGenericRetDecRefs(IRInstruction* inst) {
float CodeGenerator::decRefDestroyRate(const IRInstruction* inst,
OptDecRefProfile& profile,
Type type) {
auto const kind = mcg->tx().mode();
auto const kind = m_state.unit.context().kind;
// Without profiling data, we assume destroy is unlikely.
if (kind != TransKind::Profile && kind != TransKind::Optimize) return 0.0;

Expand Down
9 changes: 6 additions & 3 deletions hphp/runtime/vm/jit/func-prologue.cpp
Expand Up @@ -50,10 +50,12 @@ namespace {
///////////////////////////////////////////////////////////////////////////////

TransContext prologue_context(TransID transID,
TransKind kind,
const Func* func,
Offset entry) {
return TransContext(
transID,
kind,
SrcKey{func, entry, SrcKey::PrologueTag{}},
FPInvOffset{func->numSlotsInFrame()}
);
Expand All @@ -65,8 +67,8 @@ TransContext prologue_context(TransID transID,

///////////////////////////////////////////////////////////////////////////////

TCA genFuncPrologue(TransID transID, Func* func, int argc) {
auto context = prologue_context(transID, func,
TCA genFuncPrologue(TransID transID, TransKind kind, Func* func, int argc) {
auto context = prologue_context(transID, kind, func,
func->getEntryForNumArgs(argc));
IRGS env{context, TransFlags{}};

Expand All @@ -85,7 +87,8 @@ TCA genFuncPrologue(TransID transID, Func* func, int argc) {
}

TCA genFuncBodyDispatch(Func* func, const DVFuncletsVec& dvs) {
auto context = prologue_context(kInvalidTransID, func, func->base());
auto context = prologue_context(kInvalidTransID, TransKind::Live,
func, func->base());
IRGS env{context, TransFlags{}};

assertx(mcg->cgFixups().empty());
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/vm/jit/func-prologue.h
Expand Up @@ -47,7 +47,7 @@ namespace jit {
* A func prologue does a large portion of the work of an interpreted FCall;
* the rest of it is handled by the Call instruction.
*/
TCA genFuncPrologue(TransID transID, Func* func, int argc);
TCA genFuncPrologue(TransID transID, TransKind kind, Func* func, int argc);

/*
* Emit a func body dispatch entry point to the TC.
Expand Down
3 changes: 1 addition & 2 deletions hphp/runtime/vm/jit/inlining-decider.cpp
Expand Up @@ -489,8 +489,7 @@ RegionDescPtr selectCalleeTracelet(const Func* callee,
}

// Produce a tracelet for the callee.
return selectTracelet(ctx, maxBCInstrs, false /* profiling */,
true /* inlining */);
return selectTracelet(ctx, TransKind::Live, maxBCInstrs, true /* inlining */);
}

TransID findTransIDForCallee(const Func* callee, const int numArgs,
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/vm/jit/ir-builder.cpp
Expand Up @@ -117,7 +117,7 @@ IRBuilder::IRBuilder(IRUnit& unit, BCMarker initMarker)
, m_curMarker(initMarker)
, m_state(initMarker)
, m_curBlock(m_unit.entry())
, m_constrainGuards(mcg->tx().mode() != TransKind::Optimize)
, m_constrainGuards(unit.context().kind != TransKind::Optimize)
{
m_state.setBuilding();
if (RuntimeOption::EvalHHIRGenOpts) {
Expand Down
2 changes: 1 addition & 1 deletion hphp/runtime/vm/jit/irgen-func-prologue.cpp
Expand Up @@ -270,7 +270,7 @@ void emitPrologueBody(IRGS& env, uint32_t argc, TransID transID) {
auto const func = env.context.func;

// Increment profiling counter.
if (mcg->tx().mode() == TransKind::Proflogue) {
if (env.context.kind == TransKind::Proflogue) {
assertx(shouldPGOFunc(*func));
auto profData = mcg->tx().profData();

Expand Down
1 change: 1 addition & 0 deletions hphp/runtime/vm/jit/irlower.cpp
Expand Up @@ -375,6 +375,7 @@ void genCodeImpl(IRUnit& unit, CodeKind kind, AsmInfo* ai) {

Vasm vasm;
auto& vunit = vasm.unit();
vunit.transKind = unit.context().kind;
SCOPE_ASSERT_DETAIL("vasm unit") { return show(vunit); };

IRLS env(unit);
Expand Down

0 comments on commit ea43e34

Please sign in to comment.