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() { ...@@ -43,10 +43,7 @@ std::string ValuedCompilerType<llvm::Value*>::debugName() {
struct RawInstanceMethod { struct RawInstanceMethod {
CompilerVariable* obj, *func; CompilerVariable* obj, *func;
RawInstanceMethod(CompilerVariable* obj, CompilerVariable* func) : obj(obj), func(func) { RawInstanceMethod(CompilerVariable* obj, CompilerVariable* func) : obj(obj), func(func) {}
obj->incvref();
func->incvref();
}
}; };
class InstanceMethodType : public ValuedCompilerType<RawInstanceMethod*> { class InstanceMethodType : public ValuedCompilerType<RawInstanceMethod*> {
...@@ -76,6 +73,8 @@ public: ...@@ -76,6 +73,8 @@ public:
static CompilerVariable* makeIM(CompilerVariable* obj, CompilerVariable* func) { static CompilerVariable* makeIM(CompilerVariable* obj, CompilerVariable* func) {
CompilerVariable* rtn = new ValuedCompilerVariable<RawInstanceMethod*>( CompilerVariable* rtn = new ValuedCompilerVariable<RawInstanceMethod*>(
InstanceMethodType::get(obj->getType(), func->getType()), new RawInstanceMethod(obj, func), true); InstanceMethodType::get(obj->getType(), func->getType()), new RawInstanceMethod(obj, func), true);
obj->incvref();
func->incvref();
return rtn; return rtn;
} }
...@@ -141,6 +140,8 @@ public: ...@@ -141,6 +140,8 @@ public:
RawInstanceMethod* im = var->getValue(); RawInstanceMethod* im = var->getValue();
RawInstanceMethod* new_im = new RawInstanceMethod(im->obj->dup(cache), im->func->dup(cache)); RawInstanceMethod* new_im = new RawInstanceMethod(im->obj->dup(cache), im->func->dup(cache));
rtn = new VAR(this, new_im, var->isGrabbed()); rtn = new VAR(this, new_im, var->isGrabbed());
while (rtn->getVrefs() < var->getVrefs())
rtn->incvref();
} }
return rtn; 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