On Fri, 2004-08-13 at 09:23, Dan Sugalski wrote:
This hash should either be allocated from constant PMCs that don't get GC'd, or put in the root set, then.
Just to be specific then, the steps would be:
- allocate a new PMC
- mark it as constant (PMC_constant_FLAG)
That would be too late. Constant PMCs are living in the constant_pmc_pool. *But* constant PerlHashes have non-constant buffer-like headers and are unusable as constants currently.
See e.g. constant_pmc_new_nonit() in src/pmc.c
When that's fixed (or hash's memory is malloced) then the keys have to be declared with CONST_STRING() or - as these are C strings in the first place, you create a custom hash with C-string keys. See the API in hash.c:new_hash_x() or just new_cstring_hash()
... or call the register op on the PMC (though does this have interpreter-specific meaning?)
dod_register_pmc() would work but is a bit inefficient. The long term solution is for sure to keep such Parrot internal structures that live forever out of the root set and make these really constant. For now that's a simple and working solution.
- store it somewhere that other interpreters and other trips through the function can access it (don't know how to do this)
interpreter->iglobals e.g. where BTW the entry #3 "Env" is history and unused ;)
leo