Commit 6f10acc7 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix a 'can't get constant value in reg' assertion

I guess it's good that we have that since it was firing to tell us
that we were generating bad assembly.
parent b5c6f215
......@@ -545,12 +545,19 @@ void Rewriter::_incref(RewriterVar* var, int num_refs) {
for (int i = 0; i < num_refs; ++i)
assembler->incq(assembler::Immediate(&_Py_RefTotal));
#endif
auto reg = var->getInReg();
if (num_refs == 1)
assembler->incq(assembler::Indirect(reg, offsetof(Box, ob_refcnt)));
else
assembler->add(assembler::Immediate(num_refs), assembler::Indirect(reg, offsetof(Box, ob_refcnt)));
if (var->isConstant() && !Rewriter::isLargeConstant(var->constant_value)) {
for (int i = 0; i < num_refs; i++) {
assembler->incq(assembler::Immediate(var->constant_value));
}
} else {
auto reg = var->getInReg();
if (num_refs == 1)
assembler->incq(assembler::Indirect(reg, offsetof(Box, ob_refcnt)));
else
assembler->add(assembler::Immediate(num_refs), assembler::Indirect(reg, offsetof(Box, ob_refcnt)));
}
// Doesn't call bumpUse, since this function is designed to be callable from other emitting functions.
// (ie the caller should call bumpUse)
......
# expected: reffail
# Simple datetime test
# Doesn't test much of the functionality, but even importing the module is tough:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment