Commit 772200b7 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Get rid of the now-unused has_safe_tp_dealloc

parent 6be5e446
......@@ -230,7 +230,6 @@ void setupThread() {
thread_lock_cls = BoxedClass::create(type_cls, object_cls, 0, 0, sizeof(BoxedThreadLock), false, "lock",
true, BoxedThreadLock::dealloc, NULL, false);
thread_lock_cls->tp_dealloc = BoxedThreadLock::threadLockDestructor;
thread_lock_cls->has_safe_tp_dealloc = true;
thread_lock_cls->instances_are_nonzero = true;
thread_lock_cls->giveAttr("__module__", boxString("thread"));
......
......@@ -1912,6 +1912,5 @@ void setupClassobj() {
instance_cls->tp_as_number->nb_index = instance_index;
instance_cls->tp_as_number->nb_power = instance_pow;
instance_cls->tp_as_number->nb_inplace_power = instance_ipow;
instance_cls->has_safe_tp_dealloc = false;
}
}
......@@ -866,8 +866,6 @@ void setupDict() {
dictiterkey_cls->instances_are_nonzero = dictitervalue_cls->instances_are_nonzero
= dictiteritem_cls->instances_are_nonzero = true;
dict_cls->has_safe_tp_dealloc = true;
dict_cls->giveAttr("__len__", new BoxedFunction(FunctionMetadata::create((void*)dictLen, BOXED_INT, 1)));
dict_cls->giveAttr("__new__", new BoxedFunction(FunctionMetadata::create((void*)dictNew, UNKNOWN, 1, true, true)));
dict_cls->giveAttr("__init__", new BoxedFunction(FunctionMetadata::create((void*)dictInit, NONE, 1, true, true)));
......
......@@ -1856,8 +1856,6 @@ void file_dealloc(Box* b) noexcept {
}
void setupFile() {
file_cls->has_safe_tp_dealloc = true;
file_cls->giveAttr("read", new BoxedFunction(FunctionMetadata::create((void*)fileRead, STR, 2, false, false),
{ autoDecref(boxInt(-1)) }));
......
......@@ -519,7 +519,6 @@ void setupGenerator() {
generator_cls = BoxedClass::create(type_cls, object_cls, 0, offsetof(BoxedGenerator, weakreflist),
sizeof(BoxedGenerator), false, "generator", false, (destructor)generator_dealloc,
NULL, true, (traverseproc)generator_traverse, NOCLEAR);
generator_cls->has_safe_tp_dealloc = true;
generator_cls->giveAttr(
"__iter__", new BoxedFunction(FunctionMetadata::create((void*)generatorIter, typeFromClass(generator_cls), 1)));
......
......@@ -6524,27 +6524,6 @@ Box* _typeNew(BoxedClass* metatype, BoxedString* name, BoxedTuple* bases, BoxedD
made->tp_alloc = PyType_GenericAlloc;
// On some occasions, Python-implemented classes inherit from C-implement classes. For
// example, KeyedRef inherits from weakref, and needs to have it's finalizer called
// whenever weakref would. So we inherit the property that a class has a safe tp_dealloc
// too. However, we must be careful to do that only when nothing else invalidates that
// property, such as the presence of a __del__ (tp_del) method.
assert(!made->has_safe_tp_dealloc);
if (!made->tp_del) {
for (auto b : *bases) {
BoxedClass* base = static_cast<BoxedClass*>(b);
if (!PyType_Check(base))
continue;
if (base->tp_del) {
break;
}
if (base->has_safe_tp_dealloc) {
made->has_safe_tp_dealloc = true;
break;
}
}
}
return made;
}
......
......@@ -862,7 +862,6 @@ void setupSet() {
frozenset_cls->tp_as_number = &frozenset_as_number;
set_cls->tp_dealloc = frozenset_cls->tp_dealloc = BoxedSet::dealloc;
set_cls->has_safe_tp_dealloc = frozenset_cls->has_safe_tp_dealloc = true;
set_iterator_cls = BoxedClass::create(type_cls, object_cls, 0, 0, sizeof(BoxedSetIterator), false, "setiterator",
false, (destructor)BoxedSetIterator::dealloc, NULL, true,
......
......@@ -3762,7 +3762,6 @@ void setupRuntime() {
_PyObject_GC_TRACK(type_cls);
type_cls->tp_is_gc = (inquiry)type_is_gc;
type_cls->has_safe_tp_dealloc = false;
type_cls->tp_flags |= Py_TPFLAGS_TYPE_SUBCLASS;
type_cls->tp_itemsize = sizeof(BoxedHeapClass::SlotOffset);
......@@ -3840,7 +3839,6 @@ void setupRuntime() {
builtin_function_or_method_cls = new (0) BoxedClass(
object_cls, 0, offsetof(BoxedBuiltinFunctionOrMethod, weakreflist), sizeof(BoxedBuiltinFunctionOrMethod), false,
"builtin_function_or_method", false, functionDtor, NULL, true, (traverseproc)builtin_func_traverse, NOCLEAR);
function_cls->has_safe_tp_dealloc = builtin_function_or_method_cls->has_safe_tp_dealloc = true;
module_cls = new (0) BoxedClass(object_cls, offsetof(BoxedModule, attrs), 0, sizeof(BoxedModule), false, "module",
true, BoxedModule::dealloc, NULL, true, BoxedModule::traverse, BoxedModule::clear);
......
......@@ -204,19 +204,6 @@ public:
bool instancesHaveHCAttrs() { return attrs_offset != 0; }
bool instancesHaveDictAttrs() { return tp_dictoffset != 0; }
// A "safe" tp_dealloc destructor/finalizer is one we believe:
// 1) Can be called at any point after the object is dead.
// (implies it's references could be finalized already, including its class)
// 2) Won't take a lot of time to run.
// 3) Won't take up a lot of memory (requiring another GC run).
// 4) Won't resurrect itself.
//
// We specify that such destructors are safe for optimization purposes (in our GC, we try to
// emulate the order of destructor calls and support resurrection by calling them in topological
// order through multiple GC passes, which is potentially quite expensive). We call the tp_dealloc
// as the object gets freed rather than put it in a pending finalizer list.
bool has_safe_tp_dealloc;
// Whether this class object is constant or not, ie whether or not class-level
// attributes can be changed or added.
// Does not necessarily imply that the instances of this class are constant,
......
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