Commit 60706fc8 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Refcount tuple unpacking

parent bf582fb6
...@@ -518,14 +518,17 @@ void ASTInterpreter::doStore(AST_expr* node, STOLEN(Value) value) { ...@@ -518,14 +518,17 @@ void ASTInterpreter::doStore(AST_expr* node, STOLEN(Value) value) {
Box** array = unpackIntoArray(value.o, tuple->elts.size()); Box** array = unpackIntoArray(value.o, tuple->elts.size());
RewriterVar* array_var = NULL; RewriterVar* array_var = NULL;
if (jit) if (jit) {
assert(0 && "check refcounting");
array_var = jit->emitUnpackIntoArray(value, tuple->elts.size()); array_var = jit->emitUnpackIntoArray(value, tuple->elts.size());
}
unsigned i = 0; unsigned i = 0;
for (AST_expr* e : tuple->elts) { for (AST_expr* e : tuple->elts) {
doStore(e, Value(array[i], jit ? array_var->getAttr(i * sizeof(void*)) : NULL)); doStore(e, Value(array[i], jit ? array_var->getAttr(i * sizeof(void*)) : NULL));
++i; ++i;
} }
Py_DECREF(value.o);
} else if (node->type == AST_TYPE::List) { } else if (node->type == AST_TYPE::List) {
AST_List* list = (AST_List*)node; AST_List* list = (AST_List*)node;
Box** array = unpackIntoArray(value.o, list->elts.size()); Box** array = unpackIntoArray(value.o, list->elts.size());
...@@ -956,6 +959,9 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) { ...@@ -956,6 +959,9 @@ Value ASTInterpreter::visit_langPrimitive(AST_LangPrimitive* node) {
if (jit) if (jit)
jit->emitSetExcInfo(type, value, traceback); jit->emitSetExcInfo(type, value, traceback);
getFrameInfo()->exc = ExcInfo(type.o, value.o, traceback.o); getFrameInfo()->exc = ExcInfo(type.o, value.o, traceback.o);
Py_DECREF(type.o);
Py_DECREF(value.o);
Py_DECREF(traceback.o);
v = getNone(); v = getNone();
} else if (node->opcode == AST_LangPrimitive::UNCACHE_EXC_INFO) { } else if (node->opcode == AST_LangPrimitive::UNCACHE_EXC_INFO) {
assert(node->args.empty()); assert(node->args.empty());
......
...@@ -320,12 +320,16 @@ extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size) { ...@@ -320,12 +320,16 @@ extern "C" Box** unpackIntoArray(Box* obj, int64_t expected_size) {
if (obj->cls == tuple_cls) { if (obj->cls == tuple_cls) {
BoxedTuple* t = static_cast<BoxedTuple*>(obj); BoxedTuple* t = static_cast<BoxedTuple*>(obj);
_checkUnpackingLength(expected_size, t->size()); _checkUnpackingLength(expected_size, t->size());
for (auto e : *t)
Py_INCREF(e);
return &t->elts[0]; return &t->elts[0];
} }
if (obj->cls == list_cls) { if (obj->cls == list_cls) {
BoxedList* l = static_cast<BoxedList*>(obj); BoxedList* l = static_cast<BoxedList*>(obj);
_checkUnpackingLength(expected_size, l->size); _checkUnpackingLength(expected_size, l->size);
for (size_t i = 0; i < l->size; i++)
Py_INCREF(l->elts->elts[i]);
return &l->elts->elts[0]; return &l->elts->elts[0];
} }
......
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