mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
f2be5cf0f4
commit
cd81927380
@ -55,7 +55,7 @@ void VM__pop_frame(VM* self);
|
||||
bool pk__parse_int_slice(py_Ref slice, int length, int* start, int* stop, int* step);
|
||||
bool pk__normalize_index(int* index, int length);
|
||||
|
||||
void pk__mark_value(py_TValue*);
|
||||
#define pk__mark_value(val) if((val)->is_ptr && !(val)->_obj->gc_marked) PyObject__mark((val)->_obj)
|
||||
void pk__mark_namedict(NameDict*);
|
||||
void pk__tp_set_marker(py_Type type, void (*gc_mark)(void*));
|
||||
bool pk__object_new(int argc, py_Ref argv);
|
||||
|
@ -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)(py_TValue*));
|
||||
void ModuleDict__apply_mark(ModuleDict* self);
|
||||
|
@ -24,3 +24,4 @@ void* PyObject__userdata(PyObject* self);
|
||||
#define PK_OBJ_SLOTS_SIZE(slots) ((slots) >= 0 ? sizeof(py_TValue) * (slots) : sizeof(NameDict))
|
||||
|
||||
void PyObject__dtor(PyObject* self);
|
||||
void PyObject__mark(PyObject* self);
|
||||
|
@ -585,14 +585,6 @@ void PyObject__dtor(PyObject* self) {
|
||||
if(self->slots == -1) NameDict__dtor(PyObject__dict(self));
|
||||
}
|
||||
|
||||
static void mark_object(PyObject* obj);
|
||||
|
||||
void pk__mark_value(py_TValue* val) {
|
||||
if(val->is_ptr && !val->_obj->gc_marked) {
|
||||
mark_object(val->_obj);
|
||||
}
|
||||
}
|
||||
|
||||
void pk__mark_namedict(NameDict* dict) {
|
||||
for(int i = 0; i < dict->length; i++) {
|
||||
NameDict_KV* kv = c11__at(NameDict_KV, dict, i);
|
||||
@ -606,7 +598,7 @@ void pk__tp_set_marker(py_Type type, void (*gc_mark)(void*)) {
|
||||
ti->gc_mark = gc_mark;
|
||||
}
|
||||
|
||||
static void mark_object(PyObject* obj) {
|
||||
void PyObject__mark(PyObject* obj) {
|
||||
assert(!obj->gc_marked);
|
||||
|
||||
obj->gc_marked = true;
|
||||
@ -654,7 +646,7 @@ void ManagedHeap__mark(ManagedHeap* self) {
|
||||
pk__mark_value(&vm->ascii_literals[i]);
|
||||
}
|
||||
// mark modules
|
||||
ModuleDict__apply_mark(&vm->modules, pk__mark_value);
|
||||
ModuleDict__apply_mark(&vm->modules);
|
||||
// mark types
|
||||
int types_length = vm->types.length;
|
||||
// 0-th type is placeholder
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "pocketpy/objects/namedict.h"
|
||||
#include "pocketpy/objects/object.h"
|
||||
|
||||
#define SMALLMAP_T__SOURCE
|
||||
#define K uint16_t
|
||||
@ -74,8 +75,8 @@ bool ModuleDict__contains(ModuleDict* self, const char* path) {
|
||||
return ModuleDict__try_get(self, path) != NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
void ModuleDict__apply_mark(ModuleDict *self) {
|
||||
PyObject__mark(self->module._obj);
|
||||
if(self->left) ModuleDict__apply_mark(self->left);
|
||||
if(self->right) ModuleDict__apply_mark(self->right);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user