Bug 1063918 - IonMonkey: Replace untyped loads by boxed value of the store. r=h4writer

This commit is contained in:
Nicolas B. Pierron 2014-09-12 16:19:24 +02:00
parent ba261ce2e3
commit 26b8a4ad86
2 changed files with 30 additions and 12 deletions

View File

@ -222,6 +222,26 @@ MDefinition::foldsTo(TempAllocator &alloc)
return this;
}
MDefinition *
MInstruction::foldsToStoredValue(TempAllocator &alloc, MDefinition *loaded)
{
// If the type are matching then we return the value which is used as
// argument of the store.
if (loaded->type() != type()) {
// If we expect to read a type which is more generic than the type seen
// by the store, then we box the value used by the store.
if (type() != MIRType_Value)
return this;
MOZ_ASSERT(loaded->type() < MIRType_Value);
MBox *box = MBox::New(alloc, loaded);
block()->insertBefore(this, box);
loaded = box;
}
return loaded;
}
void
MDefinition::analyzeEdgeCasesForward()
{
@ -3066,10 +3086,7 @@ MLoadFixedSlot::foldsTo(TempAllocator &alloc)
if (store->slot() != slot())
return this;
if (store->value()->type() != type())
return this;
return store->value();
return foldsToStoredValue(alloc, store->value());
}
bool
@ -3208,10 +3225,7 @@ MLoadSlot::foldsTo(TempAllocator &alloc)
if (store->slots() != slots())
return this;
if (store->value()->type() != type())
return this;
return store->value();
return foldsToStoredValue(alloc, store->value());
}
MDefinition *
@ -3230,10 +3244,7 @@ MLoadElement::foldsTo(TempAllocator &alloc)
if (store->index() != index())
return this;
if (store->value()->type() != type())
return this;
return store->value();
return foldsToStoredValue(alloc, store->value());
}
bool

View File

@ -831,6 +831,13 @@ class MInstruction
resumePoint_(nullptr)
{ }
// Convenient function used for replacing a load by the value of the store
// if the types are match, and boxing the value if they do not match.
//
// Note: There is no need for such function in AsmJS functions as they do
// not use any MIRType_Value.
MDefinition *foldsToStoredValue(TempAllocator &alloc, MDefinition *loaded);
void setResumePoint(MResumePoint *resumePoint);
// Used to transfer the resume point to the rewritten instruction.