Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Assertions and MMD (on Windows XP)

9 views
Skip to first unread message

Ron Blaschke

unread,
Dec 20, 2006, 2:24:01 PM12/20/06
to perl6-i...@perl.org
Sorry to bring this up again, but I hope someone can help me with this.
I'm trying to compile Parrot on Windows XP / Visual C++ with assertions
enabled, that is, without C<NDEBUG>.

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

chromatic

unread,
Dec 20, 2006, 2:42:17 PM12/20/06
to perl6-i...@perl.org, r...@rblasch.org
On Wednesday 20 December 2006 11:24, Ron Blaschke wrote:

> - 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

Ron Blaschke

unread,
Dec 20, 2006, 4:10:57 PM12/20/06
to chromatic, perl6-i...@perl.org

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

Leopold Toetsch

unread,
Dec 20, 2006, 5:28:07 PM12/20/06
to perl6-i...@perl.org, r...@rblasch.org
Am Mittwoch, 20. Dezember 2006 20:24 schrieb Ron Blaschke:
> - The assertion seems to check that the lowest two bits of a function
> pointer are zero.  Why's that?

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

Ron Blaschke

unread,
Dec 22, 2006, 1:07:05 PM12/22/06
to Leopold Toetsch, chromatic, perl6-i...@perl.org

Thanks for your explanations!

Ron

0 new messages