Patrick R. Michaud wrote:
Another update on current GC failures affecting Rakudo.
Ok, after many iterations and rumbling around I want to apply next patch
to Parrot.
1. PARROT_ASSERT in hash.c enforce contract about "constant" PMC usage.
Because for "constant" PMC *all* contents _including_ keys must be
allocated from constant pool.
2. Changing HLL_info from constant_pmc_new to pmc_new for same reason.
OrderedHash.push_pmc creates new keys. And those keys are not allocated
from _constant_ pool. And this is likely main problem of "Method 'succ'
not found".
3. Clearing constant flag on PMC thawing. Comment in packfile.c:3999
/*
* TODO use thaw_constants
* current issue: a constant Sub with attached properties
* doesn't GC mark the properties
* for a constant PMC *all* contents have to be in the constant pools
*/
pmc = Parrot_thaw(interp, image);
Which means when we unpack PackFile_Constant we actually allocate from
non-constant pool. But for aggregate PMCs (such Hash) we preserve
freezed flags including PObj_constant_FLAG. Which lead us to hash_visit
where we create new non-constant keys.
Honestly, I wish to eliminate constant_pool totally. It's very-very
premature optimisation. And complexity of using it is similar to
refcountig.
--
Bacek
diff --git a/src/hash.c b/src/hash.c
index 9949e40..4695f60 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -1303,6 +1303,14 @@ parrot_hash_put(PARROT_INTERP, ARGMOD(Hash *hash), ARGIN(void *key), ARGIN_NULLO
const UINTVAL hashval = (hash->hash_val)(interp, key, hash->seed);
HashBucket *bucket = hash->bi[hashval & hash->mask];
+ PARROT_ASSERT(
+ PMC_IS_NULL(hash->container)
+ || !(hash->key_type == Hash_key_type_STRING)
+ || !(PObj_constant_TEST(hash->container))
+ || PObj_constant_TEST((PObj *)key)
+ || !"Use non-constant key in constant hash"
+ );
+
while (bucket) {
/* store hash_val or not */
if ((hash->compare)(interp, key, bucket->key) == 0)
diff --git a/src/hll.c b/src/hll.c
index a0863a1..ea0bae3 100644
--- a/src/hll.c
+++ b/src/hll.c
@@ -133,7 +133,7 @@ Parrot_init_HLL(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_init_HLL)
interp->HLL_info =
- constant_pmc_new(interp, enum_class_OrderedHash);
+ pmc_new(interp, enum_class_OrderedHash);
interp->HLL_namespace =
constant_pmc_new(interp, enum_class_ResizablePMCArray);
diff --git a/src/pmc_freeze.c b/src/pmc_freeze.c
index a46d8b3..7d4f87c 100644
--- a/src/pmc_freeze.c
+++ b/src/pmc_freeze.c
@@ -1661,6 +1661,11 @@ again:
PARROT_ASSERT(current->vtable);
+ /* Workaround for thawing constants. Clear constant flag */
+ /* See src/packfile.c:3999 */
+ if (thawing)
+ PObj_constant_CLEAR(current);
+
VTABLE_visit(interp, current, info);
if (thawing) {
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev