When running miniparrot I receive the following error:
Assertion failed: (PTR2UINTVAL(mmd_table[i].func_ptr) & 3) == 0, file
src\mmd.c, line 1709
Here's some context:
-snip-
/*
* register default mmds for this type
*/
for (i = 0; i < n; ++i) {
assert((PTR2UINTVAL(mmd_table[i].func_ptr) & 3) == 0);
mmd_register(interp,
mmd_table[i].func_nr, type,
mmd_table[i].right, mmd_table[i].func_ptr);
mmd_create_builtin_multi_meth(interp, ns, type, mmd_table + i);
}
-snip-
Now, when I run miniparrot through the debugger C<mmd_table[0].func_ptr>
is 0x100036e3, which is C<Parrot_UnManagedStruct_is_equal>.
My questions are:
- Is anyone else smoking / running Parrot with assertions enabled?
- The assertion seems to check that the lowest two bits of a function
pointer are zero. Why's that?
Thanks,
Ron
> - The assertion seems to check that the lowest two bits of a function
> pointer are zero. Why's that?
Presumably because pointers need a specific alignment, so those two bits will
always be zero on a raw pointer -- and thus, they're available as flags,
because when you dereference the pointer as a pointer, the compiler will
ignore the flags.
-- c
Your hint about the flags is perfect, didn't think about that. It seems
like PMC information (searching for C<is_pmc> and C<fake>) is put there.
Not sure about the details, though on Windows the function pointer is
not the address of the function but to an entry of an Import Lookup
Table. The functions themselves seem to be aligned at nibble
boundaries, but the table entries don't seem to be.
Hope I got things right.
I have heard rumors that in prehistoric times only 24 bits of the
available 32 bits were used for addressing, and some people used the
remaining bits for their own flags. Hope we're not going back to those
days. ;-)
Ron
That's a bigger hack to discern function from PMC pointers in that table. That
hack and the whole table needs to be replaced by a more densly packed infix
MMD cache representation (that was mmd_table actually is).
leo
Thanks for your explanations!
Ron