Skip to content

Commit

Permalink
Use structured LIR for kInvokeStaticFunction
Browse files Browse the repository at this point in the history
Summary: Converts `kInvokeStaticFunction` to using structured LIR.  Pretty straight forward, just using the same move to temp and pass the instruction in.

Reviewed By: alexmalyshev

Differential Revision: D52048251

fbshipit-source-id: 27d0263d08837b0b9614d8bd5175207490c6442d
  • Loading branch information
DinoV authored and facebook-github-bot committed Jan 3, 2024
1 parent 5e852e8 commit b94cd5f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions CinderX/Jit/lir/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1850,29 +1850,26 @@ LIRGenerator::TranslatedBlock LIRGenerator::TranslateOneBasicBlock(
PyFunctionObject* func = instr->func();

std::stringstream ss;

Instruction* lir;
if (_PyJIT_IsCompiled((PyObject*)func)) {
ss << fmt::format(
"Call {}, {}",
instr->dst(),
reinterpret_cast<uint64_t>(
JITRT_GET_STATIC_ENTRY(func->vectorcall)));
lir = bbb.appendInstr(
instr->dst(),
Instruction::kCall,
Imm{reinterpret_cast<uint64_t>(JITRT_GET_STATIC_ENTRY(func->vectorcall))});
} else {
void** indir = env_->rt->findFunctionEntryCache(func);
env_->function_indirections.emplace(func, indir);
std::string tmp_id = GetSafeTempName();
bbb.AppendCode(
"Load {}, {:#x}", tmp_id, reinterpret_cast<uint64_t>(indir));
ss << "Call " << instr->dst()->name() << ":" << instr->dst()->type()
<< ", " << tmp_id;
Instruction* move = bbb.appendInstr(
Instruction::kMove,
OutVReg{OperandBase::k64bit},
MemImm{indir});

lir = bbb.appendInstr(instr->dst(), Instruction::kCall, move);
}

for (size_t i = 0; i < nargs; i++) {
ss << ", " << instr->GetOperand(i)->name();
lir->addOperands(VReg{bbb.getDefInstr(instr->GetOperand(i))});
}

bbb.AppendCode(ss.str());

// functions that return primitives will signal error via edx/xmm1
auto kind = InstrGuardKind::kNotZero;
Type ret_type = instr->ret_type();
Expand Down

0 comments on commit b94cd5f

Please sign in to comment.