Commit b34237fb authored by Rudi Chen's avatar Rudi Chen

Rename boxGCHandler to Box::gcHandler.

parent 03cd0cbc
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
assert(_o->cls == capifunc_cls); assert(_o->cls == capifunc_cls);
BoxedCApiFunction* o = static_cast<BoxedCApiFunction*>(_o); BoxedCApiFunction* o = static_cast<BoxedCApiFunction*>(_o);
boxGCHandler(v, o); Box::gcHandler(v, o);
v->visit(o->passthrough); v->visit(o->passthrough);
v->visit(o->module); v->visit(o->module);
} }
......
...@@ -603,6 +603,8 @@ public: ...@@ -603,6 +603,8 @@ public:
Box* hasnextOrNullIC(); Box* hasnextOrNullIC();
friend class AttrWrapper; friend class AttrWrapper;
static void gcHandler(GCVisitor* v, Box* b);
}; };
static_assert(offsetof(Box, cls) == offsetof(struct _object, ob_type), ""); static_assert(offsetof(Box, cls) == offsetof(struct _object, ob_type), "");
......
...@@ -1013,7 +1013,7 @@ public: ...@@ -1013,7 +1013,7 @@ public:
} }
static void gcHandler(GCVisitor* v, Box* b) { static void gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedEnumerate* it = (BoxedEnumerate*)b; BoxedEnumerate* it = (BoxedEnumerate*)b;
it->iterator.gcHandler(v); it->iterator.gcHandler(v);
......
...@@ -228,7 +228,7 @@ public: ...@@ -228,7 +228,7 @@ public:
static void gcHandler(GCVisitor* v, Box* _b) { static void gcHandler(GCVisitor* v, Box* _b) {
assert(_b->cls == sys_flags_cls); assert(_b->cls == sys_flags_cls);
boxGCHandler(v, _b); Box::gcHandler(v, _b);
BoxedSysFlags* self = static_cast<BoxedSysFlags*>(_b); BoxedSysFlags* self = static_cast<BoxedSysFlags*>(_b);
v->visit(self->division_warning); v->visit(self->division_warning);
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
assert(_o->cls == classobj_cls); assert(_o->cls == classobj_cls);
BoxedClassobj* o = static_cast<BoxedClassobj*>(_o); BoxedClassobj* o = static_cast<BoxedClassobj*>(_o);
boxGCHandler(v, o); Box::gcHandler(v, o);
if (o->bases) if (o->bases)
v->visit(o->bases); v->visit(o->bases);
if (o->name) if (o->name)
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
assert(_o->cls == instance_cls); assert(_o->cls == instance_cls);
BoxedInstance* o = static_cast<BoxedInstance*>(_o); BoxedInstance* o = static_cast<BoxedInstance*>(_o);
boxGCHandler(v, o); Box::gcHandler(v, o);
if (o->inst_cls) if (o->inst_cls)
v->visit(o->inst_cls); v->visit(o->inst_cls);
} }
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
static void gcHandler(GCVisitor* v, Box* b) { static void gcHandler(GCVisitor* v, Box* b) {
assert(b->cls == code_cls); assert(b->cls == code_cls);
boxGCHandler(v, b); Box::gcHandler(v, b);
} }
static Box* name(Box* b, void*) { static Box* name(Box* b, void*) {
......
...@@ -413,7 +413,7 @@ void BoxedMethodDescriptor::gcHandler(GCVisitor* v, Box* _o) { ...@@ -413,7 +413,7 @@ void BoxedMethodDescriptor::gcHandler(GCVisitor* v, Box* _o) {
assert(_o->cls == method_cls); assert(_o->cls == method_cls);
BoxedMethodDescriptor* o = static_cast<BoxedMethodDescriptor*>(_o); BoxedMethodDescriptor* o = static_cast<BoxedMethodDescriptor*>(_o);
boxGCHandler(v, o); Box::gcHandler(v, o);
v->visit(o->type); v->visit(o->type);
} }
...@@ -452,7 +452,7 @@ void BoxedWrapperDescriptor::gcHandler(GCVisitor* v, Box* _o) { ...@@ -452,7 +452,7 @@ void BoxedWrapperDescriptor::gcHandler(GCVisitor* v, Box* _o) {
assert(_o->cls == wrapperdescr_cls); assert(_o->cls == wrapperdescr_cls);
BoxedWrapperDescriptor* o = static_cast<BoxedWrapperDescriptor*>(_o); BoxedWrapperDescriptor* o = static_cast<BoxedWrapperDescriptor*>(_o);
boxGCHandler(v, o); Box::gcHandler(v, o);
v->visit(o->type); v->visit(o->type);
} }
...@@ -570,7 +570,7 @@ void BoxedWrapperObject::gcHandler(GCVisitor* v, Box* _o) { ...@@ -570,7 +570,7 @@ void BoxedWrapperObject::gcHandler(GCVisitor* v, Box* _o) {
assert(_o->cls == wrapperobject_cls); assert(_o->cls == wrapperobject_cls);
BoxedWrapperObject* o = static_cast<BoxedWrapperObject*>(_o); BoxedWrapperObject* o = static_cast<BoxedWrapperObject*>(_o);
boxGCHandler(v, o); Box::gcHandler(v, o);
v->visit(o->obj); v->visit(o->obj);
} }
......
...@@ -685,7 +685,7 @@ extern "C" Box* dictInit(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) { ...@@ -685,7 +685,7 @@ extern "C" Box* dictInit(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) {
void BoxedDict::gcHandler(GCVisitor* v, Box* b) { void BoxedDict::gcHandler(GCVisitor* v, Box* b) {
assert(isSubclass(b->cls, dict_cls)); assert(isSubclass(b->cls, dict_cls));
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedDict* d = (BoxedDict*)b; BoxedDict* d = (BoxedDict*)b;
...@@ -701,7 +701,7 @@ void BoxedDict::gcHandler(GCVisitor* v, Box* b) { ...@@ -701,7 +701,7 @@ void BoxedDict::gcHandler(GCVisitor* v, Box* b) {
void BoxedDictIterator::gcHandler(GCVisitor* v, Box* b) { void BoxedDictIterator::gcHandler(GCVisitor* v, Box* b) {
assert(b->cls == dict_iterator_cls); assert(b->cls == dict_iterator_cls);
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedDictIterator* it = static_cast<BoxedDictIterator*>(b); BoxedDictIterator* it = static_cast<BoxedDictIterator*>(b);
v->visit(it->d); v->visit(it->d);
...@@ -709,7 +709,7 @@ void BoxedDictIterator::gcHandler(GCVisitor* v, Box* b) { ...@@ -709,7 +709,7 @@ void BoxedDictIterator::gcHandler(GCVisitor* v, Box* b) {
void BoxedDictView::gcHandler(GCVisitor* v, Box* b) { void BoxedDictView::gcHandler(GCVisitor* v, Box* b) {
assert(b->cls == dict_items_cls); assert(b->cls == dict_items_cls);
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedDictView* view = static_cast<BoxedDictView*>(b); BoxedDictView* view = static_cast<BoxedDictView*>(b);
v->visit(view->d); v->visit(view->d);
......
...@@ -1744,7 +1744,7 @@ void fileDestructor(Box* b) { ...@@ -1744,7 +1744,7 @@ void fileDestructor(Box* b) {
} }
void BoxedFile::gcHandler(GCVisitor* v, Box* b) { void BoxedFile::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
assert(isSubclass(b->cls, file_cls)); assert(isSubclass(b->cls, file_cls));
BoxedFile* f = static_cast<BoxedFile*>(b); BoxedFile* f = static_cast<BoxedFile*>(b);
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
// ** = getter supported, but setter unsupported // ** = getter supported, but setter unsupported
static void gchandler(GCVisitor* v, Box* b) { static void gchandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
auto f = static_cast<BoxedFrame*>(b); auto f = static_cast<BoxedFrame*>(b);
......
...@@ -379,7 +379,7 @@ extern "C" BoxedGenerator::BoxedGenerator(BoxedFunctionBase* function, Box* arg1 ...@@ -379,7 +379,7 @@ extern "C" BoxedGenerator::BoxedGenerator(BoxedFunctionBase* function, Box* arg1
} }
void BoxedGenerator::gcHandler(GCVisitor* v, Box* b) { void BoxedGenerator::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedGenerator* g = (BoxedGenerator*)b; BoxedGenerator* g = (BoxedGenerator*)b;
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
} }
static void gcHandler(GCVisitor* v, Box* b) { static void gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedXrangeIterator* it = (BoxedXrangeIterator*)b; BoxedXrangeIterator* it = (BoxedXrangeIterator*)b;
v->visit(it->xrange); v->visit(it->xrange);
......
...@@ -114,7 +114,7 @@ Box* seqiterNext(Box* s) { ...@@ -114,7 +114,7 @@ Box* seqiterNext(Box* s) {
void BoxedSeqIter::gcHandler(GCVisitor* v, Box* b) { void BoxedSeqIter::gcHandler(GCVisitor* v, Box* b) {
assert(b->cls == seqiter_cls || b->cls == seqreviter_cls); assert(b->cls == seqiter_cls || b->cls == seqreviter_cls);
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedSeqIter* si = static_cast<BoxedSeqIter*>(b); BoxedSeqIter* si = static_cast<BoxedSeqIter*>(b);
v->visit(si->b); v->visit(si->b);
...@@ -124,7 +124,7 @@ void BoxedSeqIter::gcHandler(GCVisitor* v, Box* b) { ...@@ -124,7 +124,7 @@ void BoxedSeqIter::gcHandler(GCVisitor* v, Box* b) {
void BoxedIterWrapper::gcHandler(GCVisitor* v, Box* b) { void BoxedIterWrapper::gcHandler(GCVisitor* v, Box* b) {
assert(b->cls == iterwrapper_cls); assert(b->cls == iterwrapper_cls);
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedIterWrapper* iw = static_cast<BoxedIterWrapper*>(b); BoxedIterWrapper* iw = static_cast<BoxedIterWrapper*>(b);
v->visit(iw->iter); v->visit(iw->iter);
......
...@@ -1092,7 +1092,7 @@ extern "C" int PyList_SetSlice(PyObject* a, Py_ssize_t ilow, Py_ssize_t ihigh, P ...@@ -1092,7 +1092,7 @@ extern "C" int PyList_SetSlice(PyObject* a, Py_ssize_t ilow, Py_ssize_t ihigh, P
} }
void BoxedListIterator::gcHandler(GCVisitor* v, Box* b) { void BoxedListIterator::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedListIterator* it = (BoxedListIterator*)b; BoxedListIterator* it = (BoxedListIterator*)b;
v->visit(it->l); v->visit(it->l);
} }
...@@ -1100,7 +1100,7 @@ void BoxedListIterator::gcHandler(GCVisitor* v, Box* b) { ...@@ -1100,7 +1100,7 @@ void BoxedListIterator::gcHandler(GCVisitor* v, Box* b) {
void BoxedList::gcHandler(GCVisitor* v, Box* b) { void BoxedList::gcHandler(GCVisitor* v, Box* b) {
assert(isSubclass(b->cls, list_cls)); assert(isSubclass(b->cls, list_cls));
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedList* l = (BoxedList*)b; BoxedList* l = (BoxedList*)b;
int size = l->size; int size = l->size;
......
...@@ -62,7 +62,7 @@ int _PyLong_DigitValue[256] = { ...@@ -62,7 +62,7 @@ int _PyLong_DigitValue[256] = {
#define PY_ABS_LLONG_MIN (0 - (unsigned PY_LONG_LONG)PY_LLONG_MIN) #define PY_ABS_LLONG_MIN (0 - (unsigned PY_LONG_LONG)PY_LLONG_MIN)
void BoxedLong::gchandler(GCVisitor* v, Box* b) { void BoxedLong::gchandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedLong* l = (BoxedLong*)b; BoxedLong* l = (BoxedLong*)b;
......
...@@ -26,7 +26,7 @@ extern "C" Box* createSet() { ...@@ -26,7 +26,7 @@ extern "C" Box* createSet() {
} }
void BoxedSet::gcHandler(GCVisitor* v, Box* b) { void BoxedSet::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedSet* s = (BoxedSet*)b; BoxedSet* s = (BoxedSet*)b;
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
} }
static void gcHandler(GCVisitor* v, Box* b) { static void gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedSetIterator* it = (BoxedSetIterator*)b; BoxedSetIterator* it = (BoxedSetIterator*)b;
......
...@@ -2313,7 +2313,7 @@ public: ...@@ -2313,7 +2313,7 @@ public:
} }
static void gcHandler(GCVisitor* v, Box* b) { static void gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedStringIterator* it = (BoxedStringIterator*)b; BoxedStringIterator* it = (BoxedStringIterator*)b;
v->visit(it->s); v->visit(it->s);
} }
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
assert(_o->cls == super_cls); assert(_o->cls == super_cls);
BoxedSuper* o = static_cast<BoxedSuper*>(_o); BoxedSuper* o = static_cast<BoxedSuper*>(_o);
boxGCHandler(v, o); Box::gcHandler(v, o);
if (o->type) if (o->type)
v->visit(o->type); v->visit(o->type);
if (o->obj) if (o->obj)
......
...@@ -45,7 +45,7 @@ void BoxedTraceback::gcHandler(GCVisitor* v, Box* b) { ...@@ -45,7 +45,7 @@ void BoxedTraceback::gcHandler(GCVisitor* v, Box* b) {
if (self->tb_next) if (self->tb_next)
v->visit(self->tb_next); v->visit(self->tb_next);
boxGCHandler(v, b); Box::gcHandler(v, b);
} }
void printTraceback(Box* b) { void printTraceback(Box* b) {
......
...@@ -559,14 +559,14 @@ static Py_ssize_t tuplelength(PyTupleObject* a) { ...@@ -559,14 +559,14 @@ static Py_ssize_t tuplelength(PyTupleObject* a) {
} }
void BoxedTuple::gcHandler(GCVisitor* v, Box* b) { void BoxedTuple::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedTuple* t = (BoxedTuple*)b; BoxedTuple* t = (BoxedTuple*)b;
v->visitRange((void* const*)&t->elts[0], (void* const*)&t->elts[t->size()]); v->visitRange((void* const*)&t->elts[0], (void* const*)&t->elts[t->size()]);
} }
extern "C" void BoxedTupleIterator::gcHandler(GCVisitor* v, Box* b) { extern "C" void BoxedTupleIterator::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedTupleIterator* it = (BoxedTupleIterator*)b; BoxedTupleIterator* it = (BoxedTupleIterator*)b;
v->visit(it->t); v->visit(it->t);
} }
......
...@@ -332,6 +332,34 @@ Box* Box::hasnextOrNullIC() { ...@@ -332,6 +332,34 @@ Box* Box::hasnextOrNullIC() {
return this->cls->callHasnextIC(this, true); return this->cls->callHasnextIC(this, true);
} }
void Box::gcHandler(GCVisitor* v, Box* b) {
if (b->cls) {
v->visit(b->cls);
if (b->cls->instancesHaveHCAttrs()) {
HCAttrs* attrs = b->getHCAttrsPtr();
v->visit(attrs->hcls);
if (attrs->attr_list)
v->visit(attrs->attr_list);
}
if (b->cls->instancesHaveDictAttrs()) {
RELEASE_ASSERT(0, "Shouldn't all of these objects be conservatively scanned?");
}
if (b->cls->tp_flags & Py_TPFLAGS_HEAPTYPE) {
BoxedHeapClass* heap_cls = static_cast<BoxedHeapClass*>(b->cls);
BoxedHeapClass::SlotOffset* slotOffsets = heap_cls->slotOffsets();
for (int i = 0; i < heap_cls->nslots(); i++) {
v->visit(*((Box**)((char*)b + slotOffsets[i])));
}
}
} else {
assert(type_cls == NULL || b == type_cls);
}
}
extern "C" BoxedFunctionBase::BoxedFunctionBase(CLFunction* f) extern "C" BoxedFunctionBase::BoxedFunctionBase(CLFunction* f)
: in_weakreflist(NULL), f(f), closure(NULL), ndefaults(0), defaults(NULL), modname(NULL), name(NULL), doc(NULL) { : in_weakreflist(NULL), f(f), closure(NULL), ndefaults(0), defaults(NULL), modname(NULL), name(NULL), doc(NULL) {
if (f->source) { if (f->source) {
...@@ -409,7 +437,7 @@ BoxedFunction::BoxedFunction(CLFunction* f, std::initializer_list<Box*> defaults ...@@ -409,7 +437,7 @@ BoxedFunction::BoxedFunction(CLFunction* f, std::initializer_list<Box*> defaults
} }
void BoxedFunction::gcHandler(GCVisitor* v, Box* b) { void BoxedFunction::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedFunction* f = (BoxedFunction*)b; BoxedFunction* f = (BoxedFunction*)b;
...@@ -541,7 +569,7 @@ template <typename A, typename B, typename C> void visitContiguousMap(GCVisitor* ...@@ -541,7 +569,7 @@ template <typename A, typename B, typename C> void visitContiguousMap(GCVisitor*
} }
void BoxedModule::gcHandler(GCVisitor* v, Box* b) { void BoxedModule::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedModule* d = (BoxedModule*)b; BoxedModule* d = (BoxedModule*)b;
...@@ -571,34 +599,6 @@ extern "C" CLFunction* unboxCLFunction(Box* b) { ...@@ -571,34 +599,6 @@ extern "C" CLFunction* unboxCLFunction(Box* b) {
return static_cast<BoxedFunction*>(b)->f; return static_cast<BoxedFunction*>(b)->f;
} }
extern "C" void boxGCHandler(GCVisitor* v, Box* b) {
if (b->cls) {
v->visit(b->cls);
if (b->cls->instancesHaveHCAttrs()) {
HCAttrs* attrs = b->getHCAttrsPtr();
v->visit(attrs->hcls);
if (attrs->attr_list)
v->visit(attrs->attr_list);
}
if (b->cls->instancesHaveDictAttrs()) {
RELEASE_ASSERT(0, "Shouldn't all of these objects be conservatively scanned?");
}
if (b->cls->tp_flags & Py_TPFLAGS_HEAPTYPE) {
BoxedHeapClass* heap_cls = static_cast<BoxedHeapClass*>(b->cls);
BoxedHeapClass::SlotOffset* slotOffsets = heap_cls->slotOffsets();
for (int i = 0; i < heap_cls->nslots(); i++) {
v->visit(*((Box**)((char*)b + slotOffsets[i])));
}
}
} else {
assert(type_cls == NULL || b == type_cls);
}
}
static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3, static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3,
Box** args, const std::vector<BoxedString*>* keyword_names); Box** args, const std::vector<BoxedString*>* keyword_names);
...@@ -1132,7 +1132,7 @@ Box* typeCall(Box* obj, BoxedTuple* vararg, BoxedDict* kwargs) { ...@@ -1132,7 +1132,7 @@ Box* typeCall(Box* obj, BoxedTuple* vararg, BoxedDict* kwargs) {
} }
void BoxedHeapClass::gcHandler(GCVisitor* v, Box* b) { void BoxedHeapClass::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedClass* cls = (BoxedClass*)b; BoxedClass* cls = (BoxedClass*)b;
...@@ -1196,7 +1196,7 @@ static void typeSubSetDict(Box* obj, Box* val, void* context) { ...@@ -1196,7 +1196,7 @@ static void typeSubSetDict(Box* obj, Box* val, void* context) {
Box* dict_descr = NULL; Box* dict_descr = NULL;
void BoxedInstanceMethod::gcHandler(GCVisitor* v, Box* b) { void BoxedInstanceMethod::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedInstanceMethod* im = (BoxedInstanceMethod*)b; BoxedInstanceMethod* im = (BoxedInstanceMethod*)b;
...@@ -1206,7 +1206,7 @@ void BoxedInstanceMethod::gcHandler(GCVisitor* v, Box* b) { ...@@ -1206,7 +1206,7 @@ void BoxedInstanceMethod::gcHandler(GCVisitor* v, Box* b) {
} }
void BoxedProperty::gcHandler(GCVisitor* v, Box* b) { void BoxedProperty::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedProperty* prop = (BoxedProperty*)b; BoxedProperty* prop = (BoxedProperty*)b;
...@@ -1221,7 +1221,7 @@ void BoxedProperty::gcHandler(GCVisitor* v, Box* b) { ...@@ -1221,7 +1221,7 @@ void BoxedProperty::gcHandler(GCVisitor* v, Box* b) {
} }
void BoxedStaticmethod::gcHandler(GCVisitor* v, Box* b) { void BoxedStaticmethod::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedStaticmethod* sm = (BoxedStaticmethod*)b; BoxedStaticmethod* sm = (BoxedStaticmethod*)b;
...@@ -1230,7 +1230,7 @@ void BoxedStaticmethod::gcHandler(GCVisitor* v, Box* b) { ...@@ -1230,7 +1230,7 @@ void BoxedStaticmethod::gcHandler(GCVisitor* v, Box* b) {
} }
void BoxedClassmethod::gcHandler(GCVisitor* v, Box* b) { void BoxedClassmethod::gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedClassmethod* cm = (BoxedClassmethod*)b; BoxedClassmethod* cm = (BoxedClassmethod*)b;
...@@ -1241,7 +1241,7 @@ void BoxedClassmethod::gcHandler(GCVisitor* v, Box* b) { ...@@ -1241,7 +1241,7 @@ void BoxedClassmethod::gcHandler(GCVisitor* v, Box* b) {
void BoxedSlice::gcHandler(GCVisitor* v, Box* b) { void BoxedSlice::gcHandler(GCVisitor* v, Box* b) {
assert(b->cls == slice_cls); assert(b->cls == slice_cls);
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedSlice* sl = static_cast<BoxedSlice*>(b); BoxedSlice* sl = static_cast<BoxedSlice*>(b);
...@@ -1259,7 +1259,7 @@ static int call_gc_visit(PyObject* val, void* arg) { ...@@ -1259,7 +1259,7 @@ static int call_gc_visit(PyObject* val, void* arg) {
} }
static void proxy_to_tp_traverse(GCVisitor* v, Box* b) { static void proxy_to_tp_traverse(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
assert(b->cls->tp_traverse); assert(b->cls->tp_traverse);
b->cls->tp_traverse(b, call_gc_visit, v); b->cls->tp_traverse(b, call_gc_visit, v);
...@@ -1268,7 +1268,7 @@ static void proxy_to_tp_traverse(GCVisitor* v, Box* b) { ...@@ -1268,7 +1268,7 @@ static void proxy_to_tp_traverse(GCVisitor* v, Box* b) {
void BoxedClosure::gcHandler(GCVisitor* v, Box* b) { void BoxedClosure::gcHandler(GCVisitor* v, Box* b) {
assert(isSubclass(b->cls, closure_cls)); assert(isSubclass(b->cls, closure_cls));
boxGCHandler(v, b); Box::gcHandler(v, b);
BoxedClosure* c = (BoxedClosure*)b; BoxedClosure* c = (BoxedClosure*)b;
if (c->parent) if (c->parent)
...@@ -1981,7 +1981,7 @@ public: ...@@ -1981,7 +1981,7 @@ public:
DEFAULT_CLASS(attrwrapperiter_cls); DEFAULT_CLASS(attrwrapperiter_cls);
static void gcHandler(GCVisitor* v, Box* b) { static void gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
AttrWrapperIter* self = (AttrWrapperIter*)b; AttrWrapperIter* self = (AttrWrapperIter*)b;
v->visit(self->hcls); v->visit(self->hcls);
...@@ -2016,7 +2016,7 @@ public: ...@@ -2016,7 +2016,7 @@ public:
Box* getUnderlying() { return b; } Box* getUnderlying() { return b; }
static void gcHandler(GCVisitor* v, Box* b) { static void gcHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
AttrWrapper* aw = (AttrWrapper*)b; AttrWrapper* aw = (AttrWrapper*)b;
v->visit(aw->b); v->visit(aw->b);
...@@ -3026,7 +3026,7 @@ out: ...@@ -3026,7 +3026,7 @@ out:
} }
void unicode_visit(GCVisitor* v, Box* b) { void unicode_visit(GCVisitor* v, Box* b) {
boxGCHandler(v, b); Box::gcHandler(v, b);
PyUnicodeObject* u = (PyUnicodeObject*)b; PyUnicodeObject* u = (PyUnicodeObject*)b;
v->visit(u->str); v->visit(u->str);
...@@ -3193,7 +3193,7 @@ void setupRuntime() { ...@@ -3193,7 +3193,7 @@ void setupRuntime() {
// We have to do a little dance to get object_cls and type_cls set up, since the normal // We have to do a little dance to get object_cls and type_cls set up, since the normal
// object-creation routines look at the class to see the allocation size. // object-creation routines look at the class to see the allocation size.
void* mem = gc_alloc(sizeof(BoxedClass), gc::GCKind::PYTHON); void* mem = gc_alloc(sizeof(BoxedClass), gc::GCKind::PYTHON);
object_cls = ::new (mem) BoxedClass(NULL, &boxGCHandler, 0, 0, sizeof(Box), false); object_cls = ::new (mem) BoxedClass(NULL, &Box::gcHandler, 0, 0, sizeof(Box), false);
mem = gc_alloc(sizeof(BoxedHeapClass), gc::GCKind::PYTHON); mem = gc_alloc(sizeof(BoxedHeapClass), gc::GCKind::PYTHON);
type_cls = ::new (mem) BoxedHeapClass(object_cls, &BoxedHeapClass::gcHandler, offsetof(BoxedClass, attrs), type_cls = ::new (mem) BoxedHeapClass(object_cls, &BoxedHeapClass::gcHandler, offsetof(BoxedClass, attrs),
offsetof(BoxedClass, tp_weaklist), sizeof(BoxedHeapClass), false, NULL); offsetof(BoxedClass, tp_weaklist), sizeof(BoxedHeapClass), false, NULL);
......
...@@ -1006,8 +1006,6 @@ public: ...@@ -1006,8 +1006,6 @@ public:
static void gcHandler(GCVisitor* v, Box* _o); static void gcHandler(GCVisitor* v, Box* _o);
}; };
extern "C" void boxGCHandler(GCVisitor* v, Box* b);
Box* objectNewNoArgs(BoxedClass* cls); Box* objectNewNoArgs(BoxedClass* cls);
Box* objectSetattr(Box* obj, Box* attr, Box* value); Box* objectSetattr(Box* obj, Box* attr, Box* value);
......
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