mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
...
This commit is contained in:
parent
ba25fd4710
commit
f2be5cf0f4
3
.gitignore
vendored
3
.gitignore
vendored
@ -37,3 +37,6 @@ tests/00_tmp.py
|
||||
docs/C-API/functions.md
|
||||
|
||||
*.log
|
||||
|
||||
|
||||
cmake-build-*
|
||||
|
@ -25,4 +25,4 @@ void ModuleDict__dtor(ModuleDict* self);
|
||||
void ModuleDict__set(ModuleDict* self, const char* key, py_TValue val);
|
||||
py_TValue* ModuleDict__try_get(ModuleDict* self, const char* path);
|
||||
bool ModuleDict__contains(ModuleDict* self, const char* path);
|
||||
void ModuleDict__apply_mark(ModuleDict* self, void (*marker)(PyObject*));
|
||||
void ModuleDict__apply_mark(ModuleDict* self, void (*marker)(py_TValue*));
|
||||
|
@ -588,7 +588,9 @@ void PyObject__dtor(PyObject* self) {
|
||||
static void mark_object(PyObject* obj);
|
||||
|
||||
void pk__mark_value(py_TValue* val) {
|
||||
if(val->is_ptr) mark_object(val->_obj);
|
||||
if(val->is_ptr && !val->_obj->gc_marked) {
|
||||
mark_object(val->_obj);
|
||||
}
|
||||
}
|
||||
|
||||
void pk__mark_namedict(NameDict* dict) {
|
||||
@ -605,7 +607,8 @@ void pk__tp_set_marker(py_Type type, void (*gc_mark)(void*)) {
|
||||
}
|
||||
|
||||
static void mark_object(PyObject* obj) {
|
||||
if(obj->gc_marked) return;
|
||||
assert(!obj->gc_marked);
|
||||
|
||||
obj->gc_marked = true;
|
||||
|
||||
if(obj->slots > 0) {
|
||||
@ -651,7 +654,7 @@ void ManagedHeap__mark(ManagedHeap* self) {
|
||||
pk__mark_value(&vm->ascii_literals[i]);
|
||||
}
|
||||
// mark modules
|
||||
ModuleDict__apply_mark(&vm->modules, mark_object);
|
||||
ModuleDict__apply_mark(&vm->modules, pk__mark_value);
|
||||
// mark types
|
||||
int types_length = vm->types.length;
|
||||
// 0-th type is placeholder
|
||||
|
@ -74,8 +74,8 @@ bool ModuleDict__contains(ModuleDict* self, const char* path) {
|
||||
return ModuleDict__try_get(self, path) != NULL;
|
||||
}
|
||||
|
||||
void ModuleDict__apply_mark(ModuleDict *self, void (*marker)(PyObject*)) {
|
||||
void ModuleDict__apply_mark(ModuleDict *self, void (*marker)(py_TValue*)) {
|
||||
if(self->left) ModuleDict__apply_mark(self->left, marker);
|
||||
if(self->right) ModuleDict__apply_mark(self->right, marker);
|
||||
marker(self->module._obj);
|
||||
marker(&self->module);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user