Commit 224e1ea7 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix bug around instancemethod vref counting

parent 20a52359
......@@ -43,10 +43,7 @@ std::string ValuedCompilerType<llvm::Value*>::debugName() {
struct RawInstanceMethod {
CompilerVariable* obj, *func;
RawInstanceMethod(CompilerVariable* obj, CompilerVariable* func) : obj(obj), func(func) {
obj->incvref();
func->incvref();
}
RawInstanceMethod(CompilerVariable* obj, CompilerVariable* func) : obj(obj), func(func) {}
};
class InstanceMethodType : public ValuedCompilerType<RawInstanceMethod*> {
......@@ -76,6 +73,8 @@ public:
static CompilerVariable* makeIM(CompilerVariable* obj, CompilerVariable* func) {
CompilerVariable* rtn = new ValuedCompilerVariable<RawInstanceMethod*>(
InstanceMethodType::get(obj->getType(), func->getType()), new RawInstanceMethod(obj, func), true);
obj->incvref();
func->incvref();
return rtn;
}
......@@ -141,6 +140,8 @@ public:
RawInstanceMethod* im = var->getValue();
RawInstanceMethod* new_im = new RawInstanceMethod(im->obj->dup(cache), im->func->dup(cache));
rtn = new VAR(this, new_im, var->isGrabbed());
while (rtn->getVrefs() < var->getVrefs())
rtn->incvref();
}
return rtn;
}
......
# Regressin test: internal tracking of non-instantiated instancemethods was incorrect
def f():
items = [1 for i in xrange(10)]
set = []
setappend = set.append
for item in range(5):
setappend(item)
print set
f()
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