Skip to content

Commit c975d7b

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Fix memory leak on ARM
Summary: We have a memory leak on ARM. When we have an inlined function we're using kBitTest but it sets different flags than x64 does. So we need an architecture specific check to see which flag to check. Reviewed By: mpage Differential Revision: D103768786 fbshipit-source-id: 702a5525b6780f4b5ae92ae4c2ed15d82a909016
1 parent f52d3a1 commit c975d7b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cinderx/Jit/lir/generator.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4036,14 +4036,24 @@ LIRGenerator::TranslatedBlock LIRGenerator::TranslateOneBasicBlock(
40364036
Ind{callee_frame,
40374037
(Py_ssize_t)offsetof(FrameHeader, func) -
40384038
(Py_ssize_t)sizeof(FrameHeader)});
4039+
40394040
JIT_DCHECK(
40404041
JIT_FRAME_INITIALIZED == 2,
40414042
"JIT_FRAME_INITIALIZED changed"); // this is the bit we're testing
40424043
// below
40434044
bbb.appendInstr(Instruction::kBitTest, rtfs_reg, Imm{1});
40444045
auto done_block = bbb.allocateBlock();
40454046
auto not_materialized_block = bbb.allocateBlock();
4046-
bbb.appendBranch(Instruction::kBranchNC, not_materialized_block);
4047+
// kBitTest lowers differently per architecture:
4048+
// - x86: BT sets the Carry flag to the tested bit value, so
4049+
// kBranchNC (jnc) branches when the bit is NOT set.
4050+
// - ARM64: BT is lowered to TST which sets the Zero flag, so
4051+
// kBranchE (b.eq) branches when the bit is NOT set.
4052+
bbb.appendBranch(
4053+
codegen::arch::kBuildArch == codegen::arch::Arch::kAarch64
4054+
? Instruction::kBranchE
4055+
: Instruction::kBranchNC,
4056+
not_materialized_block);
40474057
bbb.appendBlock(bbb.allocateBlock());
40484058

40494059
// The frame was materialized, let's use the unlink helper to clean

0 commit comments

Comments
 (0)