void BoxedMethodDescriptor::gcHandler(GCVisitor* v, Box* _o) { assert(_o->cls == method_cls); BoxedMethodDescriptor* o = static_cast<BoxedMethodDescriptor*>(_o); boxGCHandler(v, o); v->visit(o->type); }
void BoxedWrapperObject::gcHandler(GCVisitor* v, Box* _o) { assert(_o->cls == wrapperobject_cls); BoxedWrapperObject* o = static_cast<BoxedWrapperObject*>(_o); boxGCHandler(v, o); v->visit(o->obj); }
extern "C" void setIteratorGCHandler(GCVisitor* v, Box* b) { boxGCHandler(v, b); BoxedSetIterator* it = (BoxedSetIterator*)b; v->visit(it->s); }
void BoxedLong::gchandler(GCVisitor* v, Box* b) { boxGCHandler(v, b); BoxedLong* l = (BoxedLong*)b; v->visitPotentialRange((void**)&l->n, (void**)((&l->n) + 1)); }
void BoxedWrapperDescriptor::gcHandler(GCVisitor* v, Box* _o) { assert(_o->cls == wrapperdescr_cls); BoxedWrapperDescriptor* o = static_cast<BoxedWrapperDescriptor*>(_o); boxGCHandler(v, o); v->visit(o->type); }
static void iterwrapperGCVisit(GCVisitor* v, Box* b) { assert(b->cls == iterwrapper_cls); boxGCHandler(v, b); BoxedIterWrapper* iw = static_cast<BoxedIterWrapper*>(b); v->visit(iw->iter); if (iw->next) v->visit(iw->next); }
static void seqiterGCVisit(GCVisitor* v, Box* b) { assert(b->cls == seqiter_cls || b->cls == seqreviter_cls); boxGCHandler(v, b); BoxedSeqIter* si = static_cast<BoxedSeqIter*>(b); v->visit(si->b); if (si->next) v->visit(si->next); }
// This probably belongs in tuple.cpp? extern "C" void tupleGCHandler(GCVisitor *v, void* p) { boxGCHandler(v, p); BoxedTuple *t = (BoxedTuple*)p; int size = t->elts.size(); for (int i = 0; i < size; i++) { v->visit(t->elts[i]); } }
extern "C" void sliceGCHandler(GCVisitor* v, void* p) { boxGCHandler(v, p); BoxedSlice* sl = static_cast<BoxedSlice*>(p); assert(sl->cls == slice_cls); v->visit(sl->start); v->visit(sl->stop); v->visit(sl->step); }
static void gcHandler(GCVisitor* v, Box* _o) { assert(_o->cls == super_cls); BoxedSuper* o = static_cast<BoxedSuper*>(_o); boxGCHandler(v, o); if (o->type) v->visit(o->type); if (o->obj) v->visit(o->obj); if (o->obj_type) v->visit(o->obj_type); }
// This probably belongs in list.cpp? extern "C" void listGCHandler(GCVisitor *v, void* p) { boxGCHandler(v, p); BoxedList *l = (BoxedList*)p; int size = l->size; if (size) { v->visit(l->elts); v->visitRange((void**)&l->elts->elts[0], (void**)&l->elts->elts[size]); } static StatCounter sc("gc_listelts_visited"); sc.log(size); }
// This probably belongs in dict.cpp? extern "C" void dictGCHandler(GCVisitor* v, void* p) { boxGCHandler(v, p); BoxedDict* d = (BoxedDict*)p; // This feels like a cludge, but we need to find anything that // the unordered_map might have allocated. // Another way to handle this would be to rt_alloc the unordered_map // as well, though that incurs extra memory dereferences which would // be nice to avoid. void** start = (void**)&d->d; void** end = start + (sizeof(d->d) / 8); v->visitPotentialRange(start, end); }
extern "C" void hcBoxGCHandler(GCVisitor *v, void* p) { boxGCHandler(v, p); HCBox* b = (HCBox*)p; v->visit(b->hcls); int nattrs = b->hcls->attr_offsets.size(); if (nattrs) { HCBox::AttrList *attr_list = b->attr_list; assert(attr_list); v->visit(attr_list); for (int i = 0; i < nattrs; i++) { v->visit(attr_list->attrs[i]); } } }
// This probably belongs in dict.cpp? extern "C" void functionGCHandler(GCVisitor* v, void* p) { boxGCHandler(v, p); BoxedFunction* f = (BoxedFunction*)p; // It's ok for f->defaults to be NULL here even if f->ndefaults isn't, // since we could be collecting from inside a BoxedFunction constructor if (f->ndefaults) { assert(f->defaults); v->visit(f->defaults); // do a conservative scan since there can be NULLs in there: v->visitPotentialRange(reinterpret_cast<void* const*>(&f->defaults[0]), reinterpret_cast<void* const*>(&f->defaults[f->ndefaults])); } }
extern "C" void generatorGCHandler(GCVisitor* v, Box* b) { boxGCHandler(v, b); BoxedGenerator* g = (BoxedGenerator*)b; v->visit(g->function); int num_args = g->function->f->numReceivedArgs(); if (num_args >= 1) v->visit(g->arg1); if (num_args >= 2) v->visit(g->arg2); if (num_args >= 3) v->visit(g->arg3); if (g->args) v->visit(g->args); if (num_args > 3) v->visitPotentialRange(reinterpret_cast<void* const*>(&g->args->elts[0]), reinterpret_cast<void* const*>(&g->args->elts[num_args - 3])); if (g->returnValue) v->visit(g->returnValue); if (g->exception.type) v->visit(g->exception.type); if (g->exception.value) v->visit(g->exception.value); if (g->exception.traceback) v->visit(g->exception.traceback); if (g->running) { v->visitPotentialRange((void**)&g->returnContext, ((void**)&g->returnContext) + sizeof(g->returnContext) / sizeof(void*)); } else { // g->context is always set for a running generator, but we can trigger a GC while constructing // a generator in which case we can see a NULL context if (g->context) { #if STACK_GROWS_DOWN v->visitPotentialRange((void**)g->context, (void**)g->stack_begin); #endif } } }
// This probably belongs in tuple.cpp? extern "C" void tupleGCHandler(GCVisitor* v, void* p) { boxGCHandler(v, p); BoxedTuple* t = (BoxedTuple*)p; v->visitPotentialRange((void* const*)&t->elts, (void* const*)(&t->elts + 1)); }
extern "C" void dictIteratorGCHandler(GCVisitor* v, void* p) { boxGCHandler(v, p); BoxedDictIterator* it = (BoxedDictIterator*)p; v->visit(it->d); }
extern "C" void listIteratorGCHandler(GCVisitor* v, void* p) { boxGCHandler(v, p); BoxedListIterator* it = (BoxedListIterator*)p; v->visit(it->l); }
extern "C" void typeGCHandler(GCVisitor* v, void* p) { boxGCHandler(v, p); BoxedClass* b = (BoxedClass*)p; }
extern "C" void tupleIteratorGCHandler(GCVisitor* v, Box* b) { boxGCHandler(v, b); BoxedTupleIterator* it = (BoxedTupleIterator*)b; v->visit(it->t); }
extern "C" void listIteratorGCHandler(GCVisitor* v, Box* b) { boxGCHandler(v, b); BoxedListIterator* it = (BoxedListIterator*)b; v->visit(it->l); }
static void gcHandler(GCVisitor* v, Box* b) { assert(b->cls == code_cls); boxGCHandler(v, b); }