Commit a79385d6 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Improve tear-down process slightly

Since we are putting more things in the IC gc references,
call GC again after clearing them.
parent 3d9a8393
......@@ -1435,8 +1435,7 @@ void Rewriter::commit() {
for (auto p : gc_references) {
if (Py_REFCNT(p) == 1) {
// we hold the only ref to this object
assert(0 && "untested");
// we hold the only ref to this object, there's no way this could succeed in the future
this->abort();
return;
......
......@@ -3955,6 +3955,10 @@ static int type_traverse(PyTypeObject* type, visitproc visit, void* arg) {
Py_VISIT(type->tp_bases);
Py_VISIT(type->tp_base);
// TODO: should have something like this to traverse GC references in the type runtime ICs:
// if (type->hasnext_ic)
// Py_TRAVERSE(*type->hasnext_ic);
/* There's no need to visit type->tp_subclasses or
((PyHeapTypeObject *)type)->ht_slots, because they can't be involved
in cycles; tp_subclasses is a list of weak references,
......@@ -4719,6 +4723,8 @@ extern "C" void Py_Finalize() noexcept {
// May need to run multiple collections to collect everything:
while (true) {
clearAllICs();
int freed = 0;
freed += PyGC_Collect();
......@@ -4738,7 +4744,6 @@ extern "C" void Py_Finalize() noexcept {
}
constant_locations.clear();
clearAllICs();
PyType_ClearCache();
PyOS_FiniInterrupts();
_PyCodecRegistry_Deinit();
......@@ -4752,6 +4757,7 @@ extern "C" void Py_Finalize() noexcept {
constants.clear();
clearAllICs();
PyGC_Collect();
for (auto b : late_constants) {
Py_DECREF(b);
......
......@@ -251,7 +251,7 @@ extern "C" void dumpEx(void* p, int levels) {
FunctionMetadata* md = f->md;
if (md->source) {
printf("User-defined function '%s'\n", md->source->getName()->c_str());
printf("Defined at %s:%d\n", md->source->getFn()->c_str(), md->source->getBody()[0]->lineno);
printf("Defined at %s:%d\n", md->source->getFn()->c_str(), md->source->ast->lineno);
if (md->source->cfg && levels > 0) {
md->source->cfg->print();
......
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