Skip to content

Commit

Permalink
Improve side exits from HHIR to tx64-generated translations
Browse files Browse the repository at this point in the history
When a side exit from an HHIR-generated translation was taken, a
BIND_JMP service request was being used, which would make it create a
new HHIR translation at the exiting bytecode. This translation would
then generate a REQ_RETRANSLATE_NO_IR to produce a tx64 translation.

This diff avoids the useless HHIR translation generated for the
exiting bytecode in case no translation for this bytecode exists when
the service request is made.  This is done through a new
BIND_JMP_NO_IR request that directly generates a translation for the
exiting bytecode without HHIR if no translation for the SrcKey exists.
  • Loading branch information
ottoni authored and sgolemon committed Oct 5, 2012
1 parent 3e818b9 commit fcd706c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
13 changes: 12 additions & 1 deletion src/runtime/vm/translator/abi-x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ const PhysReg serviceReqArgRegs[] = {
REQ(BIND_JMPCC_SECOND) \
REQ(BIND_REQUIRE) \
\
/*
* BIND_JMP_NO_IR is similar to BIND_JMP except that, if a new translation
* needs to be generated, it'll force that HHIR is not used.
* This is only used when HHIR is turned on.
*/ \
REQ(BIND_JMP_NO_IR) \
\
/*
* When all translations don't support the incoming types, a
* retranslate request is made.
Expand Down Expand Up @@ -195,7 +202,11 @@ const PhysReg serviceReqArgRegs[] = {
REQ(STACK_OVERFLOW) \
\
/*
* TODO: explain this
* When HHIR is in use, this requests a retranslation that does not use HHIR.
* This is only used when HHIR is turned on.
*
* Note that, when EvalJitUseIR is enabled, RETRANSLATE requests will attempt
* to use HHIR.
*/ \
REQ(RETRANSLATE_NO_IR) \
/*
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/vm/translator/hopt/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,9 +1640,11 @@ Address CodeGenerator::cgExitTrace(IRInstruction* inst) {

switch(exitType) {
case TraceExitType::Normal:
case TraceExitType::Slow:
m_tx64->emitBindJmp(outputAsm, destSK);
break;
case TraceExitType::Slow:
m_tx64->emitBindJmp(outputAsm, destSK, REQ_BIND_JMP_NO_IR);
break;
case TraceExitType::SlowNoProgress:
m_tx64->emitReqRetransNoIR(outputAsm, destSK);
break;
Expand Down
17 changes: 11 additions & 6 deletions src/runtime/vm/translator/translator-x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,8 @@ reqName(int req) {
* a translation.
*/
TCA
TranslatorX64::getTranslation(const SrcKey *sk, bool align) {
TranslatorX64::getTranslation(const SrcKey *sk, bool align,
bool forceNoHHIR /* = false */) {
curFunc()->validate();
SKTRACE(2, *sk, "getTranslation: curUnit %s funcId %llx offset %d\n",
curUnit()->filepath()->data(),
Expand Down Expand Up @@ -1222,7 +1223,8 @@ TranslatorX64::getTranslation(const SrcKey *sk, bool align) {
// Since we are holding the write lease, we know that sk is properly
// initialized, except that it has no translations (due to
// replaceOldTranslations)
return retranslate(*sk, align, RuntimeOption::EvalJitUseIR);
return retranslate(*sk, align,
RuntimeOption::EvalJitUseIR && !forceNoHHIR);
}
}

Expand All @@ -1241,7 +1243,7 @@ TranslatorX64::getTranslation(const SrcKey *sk, bool align) {

ASSERT(getTransRec(start)->kind == TransAnchor);

return retranslate(*sk, align, RuntimeOption::EvalJitUseIR);
return retranslate(*sk, align, RuntimeOption::EvalJitUseIR && !forceNoHHIR);
}

TCA
Expand Down Expand Up @@ -2251,8 +2253,9 @@ void TranslatorX64::drawCFG(std::ofstream& out) const {
* u:dest from toSmash.
*/
TCA
TranslatorX64::bindJmp(TCA toSmash, SrcKey destSk, bool isAddr) {
TCA tDest = getTranslation(&destSk, false);
TranslatorX64::bindJmp(TCA toSmash, SrcKey destSk, bool isAddr,
bool forceNoHHIR /* = false */) {
TCA tDest = getTranslation(&destSk, false, forceNoHHIR);
if (!tDest) return NULL;
LeaseHolder writer(s_writeLease);
if (!writer) return tDest;
Expand Down Expand Up @@ -2869,14 +2872,16 @@ TranslatorX64::enterTC(SrcKey sk) {

case REQ_BIND_SIDE_EXIT:
case REQ_BIND_JMP:
case REQ_BIND_JMP_NO_IR:
case REQ_BIND_ADDR: {
TCA toSmash = (TCA)args[0];
Offset off = args[1];
sk = SrcKey(curFunc(), off);
if (requestNum == REQ_BIND_SIDE_EXIT) {
SKTRACE(3, sk, "side exit taken!\n");
}
start = bindJmp(toSmash, sk, requestNum == REQ_BIND_ADDR);
start = bindJmp(toSmash, sk, requestNum == REQ_BIND_ADDR,
requestNum == REQ_BIND_JMP_NO_IR);
} break;

case REQ_BIND_JMPCC_FIRST: {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/vm/translator/translator-x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,13 +701,13 @@ PSEUDOINSTRS
static bool isSmashable(Asm &a, int nBytes);
static void smash(Asm &a, TCA src, TCA dest);

TCA getTranslation(const SrcKey *sk, bool align);
TCA getTranslation(const SrcKey *sk, bool align, bool forceNoHHIR = false);
TCA retranslate(SrcKey sk, bool align, bool useHHIR);
TCA retranslateOpt(TransID transId, bool align);
TCA retranslateAndPatchNoIR(SrcKey sk,
bool align,
TCA toSmash);
TCA bindJmp(TCA toSmash, SrcKey dest, bool isAddr = false);
TCA bindJmp(TCA toSmash, SrcKey dest, bool isAddr, bool forceNoHHIR = false);
TCA bindJmpccFirst(TCA toSmash,
Offset offTrue, Offset offFalse,
bool toTake,
Expand Down

0 comments on commit fcd706c

Please sign in to comment.