TCA emitSmashableMovq(CodeBlock& cb, uint64_t imm, PhysReg d) {
  auto const start = EMIT_BODY(cb, movq, Movq, 0xdeadbeeffeedface, d);

  auto immp = reinterpret_cast<uint64_t*>(
    cb.frontier() - smashableMovqLen() + kSmashMovqImmOff
  );
  *immp = imm;

  return start;
}
Exemple #2
0
TCA funcGuardFromPrologue(TCA prologue, const Func* /*func*/) {
  if (!isPrologueStub(prologue)) {
    // Typically a func guard is a smashable movq followed by an ldr, cmp, b.eq,
    // ldr, br, and a 32 bit target. However, relocation can shorten the sequence,
    // so search backwards until the smashable movq is found.
    for (int length = 0; length <= (5 * 4) + 4; length += 4) {
      TCA inst = prologue - (smashableMovqLen() + length);
      if (isSmashableMovq(inst)) return inst;
    }
    always_assert(false);
  }
  return prologue;
}