• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ X64Assembler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中X64Assembler的典型用法代码示例。如果您正苦于以下问题:C++ X64Assembler类的具体用法?C++ X64Assembler怎么用?C++ X64Assembler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了X64Assembler类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: reclaimTranslation

void reclaimTranslation(TransLoc loc) {
  BlockingLeaseHolder writer(Translator::WriteLease());

  ITRACE(1, "Reclaiming translation M[{}, {}] C[{}, {}] F[{}, {}]\n",
         loc.mainStart(), loc.mainEnd(), loc.coldStart(), loc.coldEnd(),
         loc.frozenStart(), loc.frozenEnd());

  Trace::Indent _i;

  auto& cache = mcg->code();
  cache.blockFor(loc.mainStart()).free(loc.mainStart(), loc.mainSize());
  cache.blockFor(loc.coldStart()).free(loc.coldStart(), loc.coldSize());
  if (loc.coldStart() != loc.frozenStart()) {
    cache.blockFor(loc.frozenStart()).free(loc.frozenStart(), loc.frozenSize());
  }

  for (auto it = s_smashedBranches.begin(); it != s_smashedBranches.end();) {
    auto br = it++;
    if (loc.contains(br->first)) {
      ITRACE(1, "Erasing smashed branch @ {} from SrcRec addr={}\n",
             br->first, (void*)br->second);
      br->second->removeIncomingBranch(br->first);
      s_smashedBranches.erase(br);
    }
  }

  // Erase meta-data about these regions of the TC
  {
    ITRACE(1, "Clearing translation meta-data\n");
    Trace::Indent _i;
    clearTCMaps(loc.mainStart(), loc.mainEnd());
    clearTCMaps(loc.coldCodeStart(), loc.coldEnd());
    clearTCMaps(loc.frozenCodeStart(), loc.frozenEnd());
  }

  if (debug) {
    // Ensure no one calls into the function
    ITRACE(1, "Overwriting function\n");
    auto clearBlock = [] (CodeBlock& cb) {
      X64Assembler a {cb};
      while (cb.available() >= 2) a.ud2();
      if (cb.available() > 0) a.int3();
      always_assert(!cb.available());
    };

    CodeBlock main, cold, frozen;
    main.init(loc.mainStart(), loc.mainSize(), "Dead Main");
    cold.init(loc.coldStart(), loc.coldSize(), "Dead Cold");
    frozen.init(loc.frozenStart(), loc.frozenSize(), "Dead Frozen");

    clearBlock(main);
    clearBlock(cold);
    clearBlock(frozen);
  }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:hhvm,代码行数:55,代码来源:recycle-tc.cpp


示例2: smashJcc

void smashJcc(TCA inst, TCA target, ConditionCode cc) {
  always_assert(is_aligned(inst, Alignment::SmashJcc));

  if (cc == CC_None) {
    X64Assembler::patchJcc(inst, target);
  } else {
    auto& cb = mcg->code().blockFor(inst);
    CodeCursor cursor { cb, inst };
    X64Assembler a { cb };
    a.jcc(cc, target);
  }
}
开发者ID:archibaldhaddock,项目名称:hhvm,代码行数:12,代码来源:smashable-instr-x64.cpp


示例3: smashJmp

void smashJmp(TCA inst, TCA target) {
  always_assert(is_aligned(inst, Alignment::SmashJmp));

  auto& cb = mcg->code().blockFor(inst);
  CodeCursor cursor { cb, inst };
  X64Assembler a { cb };

  if (target > inst && target - inst <= smashableJmpLen()) {
    a.emitNop(target - inst);
  } else {
    a.jmp(target);
  }
}
开发者ID:archibaldhaddock,项目名称:hhvm,代码行数:13,代码来源:smashable-instr-x64.cpp


示例4: deltaFits

StoreImmPatcher::StoreImmPatcher(X64Assembler& as, uint64_t initial,
                                 register_name_t reg,
                                 int32_t offset, register_name_t base) {
  is32 = deltaFits(initial, sz::dword);
  if (is32) {
    as.store_imm64_disp_reg64(initial, offset, base);
  } else {
    as.mov_imm64_reg(initial, reg);
    as.store_reg64_disp_reg64(reg, offset, base);
  }
  m_addr = as.code.frontier - (is32 ? 4 : 8);
  ASSERT((is32 ? (uint64_t)*(int32_t*)m_addr : *(uint64_t*)m_addr) == initial);
}
开发者ID:huasanyelao,项目名称:hiphop-php,代码行数:13,代码来源:asm-x64.cpp


示例5: operator

  void operator()() {
    auto codeLock = mcg->lockCode();

    for (auto& e : entries) {
      CodeBlock cb;
      cb.init(e.first, e.second - e.first, "relocated");
      X64Assembler a { cb };
      while (a.canEmit(2)) {
        a.ud2();
      }
      if (a.canEmit(1)) a.int3();
    }
    okToRelocate = true;
  }
开发者ID:292388900,项目名称:hhvm,代码行数:14,代码来源:relocation.cpp


示例6: emitSmashableJccAndJmp

std::pair<TCA,TCA>
emitSmashableJccAndJmp(CodeBlock& cb, TCA target, ConditionCode cc) {
  assertx(cc != CC_None);

  align(cb, Alignment::SmashJccAndJmp, AlignContext::Live);

  X64Assembler a { cb };
  auto const jcc = cb.frontier();
  a.jcc(cc, target);
  auto const jmp = cb.frontier();
  a.jmp(target);

  return std::make_pair(jcc, jmp);
}
开发者ID:archibaldhaddock,项目名称:hhvm,代码行数:14,代码来源:smashable-instr-x64.cpp


示例7: moveToAlign

/*
 * Satisfy an alignment constraint. Bridge the gap with int3's.
 */
void moveToAlign(CodeBlock& cb,
                 const size_t align /* =kJmpTargetAlign */) {
  X64Assembler a { cb };
  assertx(folly::isPowTwo(align));
  size_t leftInBlock = align - ((align - 1) & uintptr_t(cb.frontier()));
  if (leftInBlock == align) return;
  if (leftInBlock > 2) {
    a.ud2();
    leftInBlock -= 2;
  }
  if (leftInBlock > 0) {
    a.emitInt3s(leftInBlock);
  }
}
开发者ID:runt18,项目名称:hhvm,代码行数:17,代码来源:code-gen-helpers-x64.cpp


示例8: smashCall

void smashCall(TCA inst, TCA target) {
  always_assert(is_aligned(inst, Alignment::SmashCall));
  /*
   * TODO(#7889486): We'd like this just to be:
   *
   *    X64Assembler::patchCall(inst, target);
   *
   * but presently this causes asserts to fire in MCGenerator because of a bug
   * with PGO and relocation.
   */
  auto& cb = mcg->code().blockFor(inst);
  CodeCursor cursor { cb, inst };
  X64Assembler a { cb };
  a.call(target);
}
开发者ID:archibaldhaddock,项目名称:hhvm,代码行数:15,代码来源:smashable-instr-x64.cpp


示例9: deltaFits

StoreImmPatcher::StoreImmPatcher(CodeBlock& cb, uint64_t initial,
                                 RegNumber reg,
                                 int32_t offset, RegNumber base) {
  X64Assembler as { cb };
  m_is32 = deltaFits(initial, sz::dword);
  if (m_is32) {
    as.store_imm64_disp_reg64(initial, offset, base);
    m_addr = cb.frontier() - 4;
  } else {
    as.mov_imm64_reg(initial, reg);
    m_addr = cb.frontier() - 8;
    as.store_reg64_disp_reg64(reg, offset, base);
  }
  assert((m_is32 ?  (uint64_t)*(int32_t*)m_addr : *(uint64_t*)m_addr)
         == initial);
}
开发者ID:360buyliulei,项目名称:hiphop-php,代码行数:16,代码来源:asm-x64.cpp


示例10: operator

  void operator()() {
    LeaseHolder writer(Translator::WriteLease());
    if (!writer) {
      Treadmill::enqueue(std::move(*this));
      return;
    }

    for (auto& e : entries) {
      CodeBlock cb;
      cb.init(e.first, e.second - e.first, "relocated");
      X64Assembler a { cb };
      while (a.canEmit(2)) {
        a.ud2();
      }
      if (a.canEmit(1)) a.int3();
    }
    okToRelocate = true;
  }
开发者ID:anthonyattard,项目名称:hhvm,代码行数:18,代码来源:relocation.cpp


示例11: moveToAlign

/*
 * Satisfy an alignment constraint. Bridge the gap with int3's.
 */
void moveToAlign(CodeBlock& cb,
                 const size_t align /* =kJmpTargetAlign */) {
  // TODO(2967396) implement properly, move function
  if (arch() == Arch::ARM) return;

  using namespace HPHP::Util;
  X64Assembler a { cb };
  assert(isPowerOfTwo(align));
  size_t leftInBlock = align - ((align - 1) & uintptr_t(cb.frontier()));
  if (leftInBlock == align) return;
  if (leftInBlock > 2) {
    a.ud2();
    leftInBlock -= 2;
  }
  if (leftInBlock > 0) {
    a.emitInt3s(leftInBlock);
  }
}
开发者ID:Dx3webs,项目名称:hhvm,代码行数:21,代码来源:code-gen-helpers-x64.cpp


示例12: emitFuncGuard

void emitFuncGuard(const Func* func, CodeBlock& cb) {
  using namespace reg;
  X64Assembler a { cb };

  assertx(x64::abi(CodeKind::CrossTrace).gpUnreserved.contains(rax));

  TCA start DEBUG_ONLY = a.frontier();

  auto const funcImm = Immed64(func);

  if (funcImm.fits(sz::dword)) {
    emitSmashableCmpq(a.code(), funcImm.l(), rVmFp,
                      safe_cast<int8_t>(AROFF(m_func)));
  } else {
    // Although func doesn't fit in a signed 32-bit immediate, it may still fit
    // in an unsigned one.  Rather than deal with yet another case (which only
    // happens when we disable jemalloc), just emit a smashable mov followed by
    // a register cmp.
    emitSmashableMovq(a.code(), uint64_t(func), rax);
    a.  cmpq   (rax, rVmFp[AROFF(m_func)]);
  }
  a.    jnz    (mcg->tx().uniqueStubs.funcPrologueRedispatch);

  assertx(funcPrologueToGuard(a.frontier(), func) == start);
  assertx(funcPrologueHasGuard(a.frontier(), func));
}
开发者ID:sunnygkp10,项目名称:hhvm,代码行数:26,代码来源:func-guard.cpp


示例13: emitFuncGuard

void emitFuncGuard(const Func* func, CodeBlock& cb, CGMeta& fixups) {
  using namespace reg;
  X64Assembler a { cb };

  assertx(x64::abi(CodeKind::CrossTrace).gpUnreserved.contains(rax));

  auto const funcImm = Immed64(func);

  if (funcImm.fits(sz::dword)) {
    emitSmashableCmpq(a.code(), fixups, funcImm.l(), rvmfp(),
                      safe_cast<int8_t>(AROFF(m_func)));
  } else {
    // Although func doesn't fit in a signed 32-bit immediate, it may still fit
    // in an unsigned one.  Rather than deal with yet another case (which only
    // happens when we disable jemalloc), just emit a smashable mov followed by
    // a register cmp.
    emitSmashableMovq(a.code(), fixups, uint64_t(func), rax);
    a.  cmpq   (rax, rvmfp()[AROFF(m_func)]);
  }
  a.    jnz    (tc::ustubs().funcPrologueRedispatch);

  DEBUG_ONLY auto guard = funcGuardFromPrologue(a.frontier(), func);
  assertx(funcGuardMatches(guard, func));
}
开发者ID:MatmaRex,项目名称:hhvm,代码行数:24,代码来源:func-guard-x64.cpp


示例14: emitFuncGuard

void emitFuncGuard(const Func* func, CodeBlock& cb) {
  using namespace reg;
  X64Assembler a { cb };

  assertx(cross_trace_abi.gpUnreserved.contains(rax));

  auto const funcImm = Immed64(func);
  int nbytes, offset;

  if (!funcImm.fits(sz::dword)) {
    nbytes = kFuncGuardSmash;
    offset = kFuncGuardImm;
  } else {
    nbytes = kFuncGuardShortSmash;
    offset = kFuncGuardShortImm;
  }
  mcg->backEnd().prepareForSmash(a.code(), nbytes, offset);

  TCA start DEBUG_ONLY = a.frontier();

  if (!funcImm.fits(sz::dword)) {
    // Although func doesnt fit in a signed 32-bit immediate, it may still fit
    // in an unsigned one.  Rather than deal with yet another case (which only
    // happens when we disable jemalloc), just force it to be an 8-byte
    // immediate, and patch it up afterwards.
    a.  movq   (0xdeadbeeffeedface, rax);

    auto immptr = reinterpret_cast<uintptr_t*>(a.frontier()) - 1;
    assertx(*immptr == 0xdeadbeeffeedface);
    *immptr = uintptr_t(func);

    a.  cmpq   (rax, rVmFp[AROFF(m_func)]);
  } else {
    a.  cmpq   (funcImm.l(), rVmFp[AROFF(m_func)]);
  }
  a.    jnz    (mcg->tx().uniqueStubs.funcPrologueRedispatch);

  assertx(funcPrologueToGuard(a.frontier(), func) == start);
  assertx(funcPrologueHasGuard(a.frontier(), func));
}
开发者ID:nurulimamnotes,项目名称:hhvm,代码行数:40,代码来源:func-guard.cpp


示例15: deltaFits

MovImmPatcher::MovImmPatcher(X64Assembler& as, uint64_t initial,
                             register_name_t reg) {
  is32 = deltaFits(initial, sz::dword);
  as.mov_imm64_reg(initial, reg);
  m_addr = as.code.frontier - (is32 ? 4 : 8);
}
开发者ID:arktisklada,项目名称:hiphop-php,代码行数:6,代码来源:asm-x64.cpp


示例16: emitCallToExit

TCA emitCallToExit(CodeBlock& cb) {
  X64Assembler a { cb };

  // Emit a byte of padding. This is a kind of hacky way to avoid
  // hitting an assert in recordGdbStub when we call it with stub - 1
  // as the start address.
  a.emitNop(1);
  auto const start = a.frontier();
  if (RuntimeOption::EvalHHIRGenerateAsserts) {
    Label ok;
    a.emitImmReg(uintptr_t(enterTCExit), reg::rax);
    a.cmpq(reg::rax, *rsp());
    a.je8 (ok);
    a.ud2();
  asm_label(a, ok);
  }

  // Emulate a ret to enterTCExit without actually doing one to avoid
  // unbalancing the return stack buffer. The call from enterTCHelper() that
  // got us into the TC was popped off the RSB by the ret that got us to this
  // stub.
  a.addq(8, rsp());
  if (a.jmpDeltaFits(TCA(enterTCExit))) {
    a.jmp(TCA(enterTCExit));
  } else {
    // can't do a near jmp and a rip-relative load/jmp would require threading
    // through extra state to allocate a literal. use an indirect jump through
    // a register
    a.emitImmReg(uintptr_t(enterTCExit), reg::rax);
    a.jmp(reg::rax);
  }

  // On a backtrace, gdb tries to locate the calling frame at address
  // returnRIP-1. However, for the first VM frame, there is no code at
  // returnRIP-1, since the AR was set up manually. For this frame,
  // record the tracelet address as starting from this callToExit-1,
  // so gdb does not barf.
  return start;
}
开发者ID:SecureCloud-biz,项目名称:hhvm,代码行数:39,代码来源:unique-stubs-x64.cpp


示例17: emitPops

void PhysRegSaverParity::emitPops(X64Assembler& as, RegSet regs) {
  emitPops(Vauto(as.code()).main(), regs);
}
开发者ID:AmineCherrai,项目名称:hhvm,代码行数:3,代码来源:phys-reg.cpp


示例18: Vauto

PhysRegSaverParity::PhysRegSaverParity(int parity, X64Assembler& as,
                                       RegSet regs)
  : PhysRegSaverParity{parity, Vauto(as.code()).main(), regs} {
  m_v = nullptr;
  m_as = &as;
}
开发者ID:AmineCherrai,项目名称:hhvm,代码行数:6,代码来源:phys-reg.cpp


示例19: testEmitMethods

void testEmitMethods() {
  X64Assembler e;
  e.init(10 << 20);

  using namespace HPHP::VM::Transl::reg;

  int n = sizeof(instr_list) / sizeof(instr_list[0]);
  for (int i = 0; i < n; ++i) {

    X64Instr op = instr_list[i];
    printf("%s:\n", instr_names[i]);

    if (supported_AM[i] & MASK_none) {
      printf("  Address mode: none\n");
      e.emit(op);
    }

    if (supported_AM[i] & MASK_R) {
      printf("  Address mode: R\n");
      e.emitR(op, rax);
      e.emitR(op, rsi);
      e.emitR(op, rbp);
      e.emitR(op, rsp);
      e.emitR(op, r8);
      e.emitR(op, r15);
      e.emitR(op, r13);
      e.emitR(op, r12);
    }

    if (supported_AM[i] & MASK_RR) {
      printf("  Address mode: RR\n");
      e.emitRR(op, rsi, rax);
      e.emitRR(op, rax, rdi);
      e.emitRR(op, rsi, rdi);
      e.emitRR(op, rbp, rsp);
      e.emitRR(op, rsp, rbp);
      e.emitRR(op, rsi, r8);
      e.emitRR(op, rax, r15);
      e.emitRR(op, rsi, r15);
      e.emitRR(op, rbp, r12);
      e.emitRR(op, rsp, r13);
      e.emitRR(op, r14, rax);
      e.emitRR(op, r8,  rdi);
      e.emitRR(op, r14, rdi);
      e.emitRR(op, r13, rsp);
      e.emitRR(op, r12, rbp);
      e.emitRR(op, r14, r8);
      e.emitRR(op, r8,  r15);
      e.emitRR(op, r14, r15);
      e.emitRR(op, r13, r12);
      e.emitRR(op, r12, r13);
      e.emitRR(op, rax, rax);
      e.emitRR(op, rax, r8);
      e.emitRR(op, r8, rax);
      e.emitRR(op, r8, r8);
    }

    if (supported_AM[i] & MASK_I) {
      printf("  Address mode: I\n");
      e.emitI(op, -128);
      e.emitI(op, 127);
      e.emitI(op, 0xF1);
      e.emitI(op, 1);
    }

    if (supported_AM[i] & MASK_IR) {
      printf("  Address mode: IR\n");
      e.emitIR(op, rbx, 1);
      e.emitIR(op, rax, -128);
      e.emitIR(op, rsi, -128);
      e.emitIR(op, rbp, 127);
      e.emitIR(op, rsp, 0xF1);
      e.emitIR(op, rsp, 1);
      e.emitIR(op, r11, 1);
      e.emitIR(op, r8, -128);
      e.emitIR(op, r14, -128);
      e.emitIR(op, r13, 127);
      e.emitIR(op, r12, 0xF1);
      e.emitIR(op, r12, 1);
      if (i == 13 /*instr_mov*/) {
        e.emitIR(op, rax, (ssize_t)0x1234123412341234);
        e.emitIR(op, r8, (ssize_t)0x1234123412341234);
      }
    }

    if (supported_AM[i] & MASK_IRR) {
      printf("  Address mode: IRR\n");
      e.emitIRR(op, rsi, rax, -128);
      e.emitIRR(op, rax, rdi, -128);
      e.emitIRR(op, rbp, rsp, 127);
      e.emitIRR(op, rsp, rbp, 0xF1);
      e.emitIRR(op, rsp, rbp, 1);
      e.emitIRR(op, r14, rax, -128);
      e.emitIRR(op, r8, rdi, -128);
      e.emitIRR(op, r13, rsp, 127);
      e.emitIRR(op, r12, rbp, 0xF1);
      e.emitIRR(op, r12, rbp, 1);
      e.emitIRR(op, rsi, r8, -128);
      e.emitIRR(op, rax, r15, -128);
      e.emitIRR(op, rbp, r12, 127);
//.........这里部分代码省略.........
开发者ID:7755373049,项目名称:hiphop-php,代码行数:101,代码来源:asm-x64-test.cpp



注:本文中的X64Assembler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ X86AsmPrinter类代码示例发布时间:2022-05-31
下一篇:
C++ X509_Certificate类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap