[schemepy] Ideas on dealing with the mzscheme's memory-moving GC?
Chiyuan Zhang pluskid at gmail.comMon Jun 2 21:17:20 EDT 2008
- Previous message: [schemepy] pyScheme and stuff
- Next message: [schemepy] Ideas on dealing with the mzscheme's memory-moving GC?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I'm porting the mzscheme backend to 3m model. The GC of mzscheme is
memory-moving. It may move object during garbage collecting. When
programming in C/C++, some macros needed to record the local pointers
so that the GC can update them when moving the objects:
{
Scheme_Object *tmp1 = NULL, *tmp2 = NULL, *result;
MZ_GC_DECL_REG(2);
MZ_GC_VAR_IN_REG(0, tmp1);
MZ_GC_VAR_IN_REG(1, tmp2);
MZ_GC_REG();
tmp1 = scheme_make_pair(scheme_true, scheme_false);
tmp2 = scheme_make_pair(scheme_true, scheme_false);
result = scheme_make_pair(tmp1, tmp2);
MZ_GC_UNREG();
return result;
}
I don't think this is possible in Python with ctypes. Firstly, C
macros are not available here. Secondly, even if you can managed to
expand the macro in some way (manually, for example), you shouldn't
force the user to write Python code in this way that every local
variable need to be declared and registered first and call something
like MZ_GC_UNREG before leaving a block.
There's function scheme_dont_gc_ptr that can prevent object from
collected, but it won't prevent the object from being moved. I'm also
asking in the mzscheme mailing list to see whether there's such a
function. However, I'm also asking: is there any way that we can
cooperate with the memory-moving GC?
--
pluskid
- Previous message: [schemepy] pyScheme and stuff
- Next message: [schemepy] Ideas on dealing with the mzscheme's memory-moving GC?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the schemepy mailing list
