mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-13 15:10:19 +00:00
Compare commits
No commits in common. "cd8192738018577c1b13b2d7b39854a083a4aafc" and "ba25fd471042064aeed69018cf5f523118172d4a" have entirely different histories.
cd81927380
...
ba25fd4710
3
.gitignore
vendored
3
.gitignore
vendored
@ -37,6 +37,3 @@ tests/00_tmp.py
|
||||
docs/C-API/functions.md
|
||||
|
||||
*.log
|
||||
|
||||
|
||||
cmake-build-*
|
||||
|
||||
@ -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);
|
||||
|
||||
#define pk__mark_value(val) if((val)->is_ptr && !(val)->_obj->gc_marked) PyObject__mark((val)->_obj)
|
||||
void pk__mark_value(py_TValue*);
|
||||
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 ModuleDict__apply_mark(ModuleDict* self, void (*marker)(PyObject*));
|
||||
|
||||
@ -24,4 +24,3 @@ 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,6 +585,12 @@ 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) 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);
|
||||
@ -598,9 +604,8 @@ void pk__tp_set_marker(py_Type type, void (*gc_mark)(void*)) {
|
||||
ti->gc_mark = gc_mark;
|
||||
}
|
||||
|
||||
void PyObject__mark(PyObject* obj) {
|
||||
assert(!obj->gc_marked);
|
||||
|
||||
static void mark_object(PyObject* obj) {
|
||||
if(obj->gc_marked) return;
|
||||
obj->gc_marked = true;
|
||||
|
||||
if(obj->slots > 0) {
|
||||
@ -646,7 +651,7 @@ void ManagedHeap__mark(ManagedHeap* self) {
|
||||
pk__mark_value(&vm->ascii_literals[i]);
|
||||
}
|
||||
// mark modules
|
||||
ModuleDict__apply_mark(&vm->modules);
|
||||
ModuleDict__apply_mark(&vm->modules, mark_object);
|
||||
// mark types
|
||||
int types_length = vm->types.length;
|
||||
// 0-th type is placeholder
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "pocketpy/objects/namedict.h"
|
||||
#include "pocketpy/objects/object.h"
|
||||
|
||||
#define SMALLMAP_T__SOURCE
|
||||
#define K uint16_t
|
||||
@ -75,8 +74,8 @@ bool ModuleDict__contains(ModuleDict* self, const char* path) {
|
||||
return ModuleDict__try_get(self, path) != NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
void ModuleDict__apply_mark(ModuleDict *self, void (*marker)(PyObject*)) {
|
||||
if(self->left) ModuleDict__apply_mark(self->left, marker);
|
||||
if(self->right) ModuleDict__apply_mark(self->right, marker);
|
||||
marker(self->module._obj);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user