Menu

#31 Alignment Traps Galore

open
nobody
None
5
2008-04-23
2008-04-23
Aric Blumer
No

This problem occurs when running with jamvm 1.5.0 compiled as part of angstrom 2007.12 on an ARM processor (PXA320 to be exact). I see the same problem in the 1.5.1 code, so I don't think it has been fixed yet.

The problem has to do with the 'J' and 'D' types. In class.c, the 'J' and 'D' types use casts like this:

if((*fb->type == 'J') || (*fb->type == 'D'))
*(long long *)&fb->static_value = 0;
else
fb->static_value = 0;

fb->static_value is an unsigned long int (32-bits), so the address of fb->static_value is cast in the second line above to a (long long *) for 'J' and 'D'. The problem is that in the struct of fb, static_value is at a non-8-byte boundary, thus causing oodles of alignment traps. In my kernel, a trap message is printed for each which brings performance to a crawl. I removed the printk() and that helps significantly, but this code appears to be wrong. Casting to a 32-bit access to a 64-bit access will clobber the next element in the structure. This code really should use a union so that the compiler can do the right thing.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.