MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / dynamic_cmpxchg_lock

Method dynamic_cmpxchg_lock

source/emulation/cpu/armv8/jitArmV8CodeGen.cpp:5670–5748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5668}
5669
5670void JitArmV8CodeGen::dynamic_cmpxchg_lock(JitWidth width, DecodedOp* op) {
5671 JitCodeGen::write(JitWidth::b16, calculateEaa(op), nullptr, [width, op, this](MemPtr mem) {
5672 LazyFlagType flagType;
5673
5674 if (width == JitWidth::b32) {
5675 flagType = FLAGS_CMP32;
5676 } else if (width == JitWidth::b16) {
5677 flagType = FLAGS_CMP16;
5678 } else if (width == JitWidth::b8) {
5679 flagType = FLAGS_CMP8;
5680 } else {
5681 kpanic("JitArmV8CodeGen::dynamic_cmpxchg_lock");
5682 flagType = FLAGS_NONE;
5683 }
5684
5685 RegPtr tmp = getTmpReg();
5686 RegPtr tmp2 = getTmpReg();
5687 RegPtr reg = getReadOnlyRegInLower(width, op->reg);
5688 RegPtr eax = getReg(0);
5689
5690
5691 RegPtr address = calculateAddress(mem);
5692
5693 RegPtr tmpEax = eax;
5694 bool needToCopyEaxBack = false;
5695 JitFlags jitFlags(this, cpu, op, flagType, eax, nullptr, false);
5696 jitFlags.copyDest(eax);
5697
5698 if (width != JitWidth::b32 || (jitFlags.flags && (jitFlags.flags->usesSrc(jitFlags.needsToSetFlags) || jitFlags.flags->usesResult(jitFlags.needsToSetFlags)))) {
5699 tmpEax = getTmpReg();
5700 movzx(JitWidth::b32, tmpEax, width, eax);
5701 needToCopyEaxBack = true;
5702 }
5703
5704 if (rt.cpu_features().has(asmjit::CpuFeatures::ARM::kLSE)) {
5705 if (width == JitWidth::b32) {
5706 compiler.casal(R32(tmpEax), R32(reg), Mem(R64(address)));
5707 } else if (width == JitWidth::b16) {
5708 compiler.casalh(R32(tmpEax), R32(reg), Mem(R64(address)));
5709 } else if (width == JitWidth::b8) {
5710 compiler.casalb(R32(tmpEax), R32(reg), Mem(R64(address)));
5711 }
5712 if (jitFlags.flags && jitFlags.flags->usesResult(jitFlags.needsToSetFlags)) {
5713 compiler.sub(R32(tmp2), wEAX, R32(tmpEax));
5714 }
5715 if (needToCopyEaxBack) {
5716 mov(width, eax, tmpEax);
5717 }
5718 } else {
5719 Label label = compiler.new_label();
5720 compiler.bind(label);
5721 if (width == JitWidth::b32) {
5722 compiler.ldaxr(R32(tmp), Mem(R64(address)));
5723 } else if (width == JitWidth::b16) {
5724 compiler.ldaxrh(R32(tmp), Mem(R64(address)));
5725 } else if (width == JitWidth::b8) {
5726 compiler.ldaxrb(R32(tmp), Mem(R64(address)));
5727 }

Callers

nothing calls this directly

Calls 15

writeFunction · 0.85
kpanicFunction · 0.85
copyDestMethod · 0.80
casalMethod · 0.80
ldaxrMethod · 0.80
stlxrMethod · 0.80
R32Function · 0.70
R64Function · 0.70
movFunction · 0.70
MemClass · 0.50
usesSrcMethod · 0.45
usesResultMethod · 0.45

Tested by

no test coverage detected