Commit 6ee86476 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Minor: call this _doFree helper from this other path

parent afea84fc
......@@ -312,7 +312,19 @@ static void _freeLargeObj(LargeObj* lobj) {
assert(r == 0);
}
static void _doFree(GCAllocation* al) {
if (VERBOSITY() >= 2)
printf("Freeing %p\n", al->user_data);
if (al->kind_id == GCKind::PYTHON) {
Box* b = (Box*)al->user_data;
ASSERT(b->cls->tp_dealloc == NULL, "%s", getTypeName(b)->c_str());
}
}
void Heap::free(GCAllocation* al) {
_doFree(al);
if (large_arena.contains(al)) {
LargeObj* lobj = LargeObj::fromAllocation(al);
_freeLargeObj(lobj);
......@@ -394,16 +406,6 @@ GCAllocation* Heap::getAllocationFromInteriorPointer(void* ptr) {
return reinterpret_cast<GCAllocation*>(&b->atoms[atom_idx]);
}
static void _doFree(GCAllocation* al) {
if (VERBOSITY() >= 2)
printf("Freeing %p\n", al->user_data);
if (al->kind_id == GCKind::PYTHON) {
Box* b = (Box*)al->user_data;
ASSERT(b->cls->tp_dealloc == NULL, "%s", getTypeName(b)->c_str());
}
}
static Block** freeChain(Block** head) {
while (Block* b = *head) {
int num_objects = b->numObjects();
......
......@@ -671,6 +671,11 @@ Box* print(BoxedTuple* args, BoxedDict* kwargs) {
return None;
}
Box* pydump(void* p) {
dump(p);
return None;
}
void setupBuiltins() {
builtins_module = createModule("__builtin__", "__builtin__");
......@@ -749,6 +754,7 @@ void setupBuiltins() {
builtins_module->giveAttr("ord", ord_obj);
trap_obj = new BoxedFunction(boxRTFunction((void*)trap, UNKNOWN, 0));
builtins_module->giveAttr("trap", trap_obj);
builtins_module->giveAttr("dump", new BoxedFunction(boxRTFunction((void*)pydump, UNKNOWN, 1)));
builtins_module->giveAttr(
"getattr", new BoxedFunction(boxRTFunction((void*)getattrFunc, UNKNOWN, 3, 1, false, false), { NULL }));
......
......@@ -1821,6 +1821,7 @@ extern "C" i64 unboxedLen(Box* obj) {
extern "C" void dump(void* p) {
printf("\n");
printf("Raw address: %p\n", p);
bool is_gc = (gc::global_heap.getAllocationFromInteriorPointer(p) != NULL);
if (!is_gc) {
printf("non-gc memory\n");
......
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