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) { ...@@ -545,12 +545,19 @@ void Rewriter::_incref(RewriterVar* var, int num_refs) {
for (int i = 0; i < num_refs; ++i) for (int i = 0; i < num_refs; ++i)
assembler->incq(assembler::Immediate(&_Py_RefTotal)); assembler->incq(assembler::Immediate(&_Py_RefTotal));
#endif #endif
auto reg = var->getInReg();
if (num_refs == 1) if (var->isConstant() && !Rewriter::isLargeConstant(var->constant_value)) {
assembler->incq(assembler::Indirect(reg, offsetof(Box, ob_refcnt))); for (int i = 0; i < num_refs; i++) {
else assembler->incq(assembler::Immediate(var->constant_value));
assembler->add(assembler::Immediate(num_refs), assembler::Indirect(reg, offsetof(Box, ob_refcnt))); }
} 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. // Doesn't call bumpUse, since this function is designed to be callable from other emitting functions.
// (ie the caller should call bumpUse) // (ie the caller should call bumpUse)
......
# expected: reffail
# Simple datetime test # Simple datetime test
# Doesn't test much of the functionality, but even importing the module is tough: # 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