handle methods ending with large blocks properly when generating constant pools

We can only omit the jump past a constant pool if it's placed at the
end of a method, which is only true if the pool belongs to the last
block of that method and that block is not so large that the pool must
be placed inside the block instead of after it.
This commit is contained in:
Joel Dice 2011-05-11 19:56:29 -06:00
parent b76cbbfa56
commit fa7d46c322

View File

@ -664,13 +664,19 @@ appendPoolEvent(Context* c, MyBlock* b, unsigned offset, PoolOffset* head,
b->poolEventTail = e;
}
bool
needJump(MyBlock* b)
{
return b->next or b->size != (b->size & PoolOffsetMask);
}
unsigned
padding(MyBlock* b, unsigned offset)
{
unsigned total = 0;
for (PoolEvent* e = b->poolEventHead; e; e = e->next) {
if (e->offset <= offset) {
if (b->next) {
if (needJump(b)) {
total += BytesPerWord;
}
for (PoolOffset* o = e->poolOffsetHead; o; o = o->next) {
@ -2363,7 +2369,7 @@ class MyAssembler: public Assembler {
unsigned entry = dstOffset + poolSize;
if (b->next) {
if (needJump(b)) {
entry += BytesPerWord;
}
@ -2381,7 +2387,7 @@ class MyAssembler: public Assembler {
poolSize += BytesPerWord;
}
if (b->next) {
if (needJump(b)) {
write4(dst + dstOffset, ::b((poolSize + BytesPerWord - 8) >> 2));
}