当前位置: 首页>>代码示例>>C++>>正文


C++ X64Assembler类代码示例

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


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


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