Bug 851552: IonMonkey: Disable GetElement caches after failing multiple times to attach stubs, r=djvj

This commit is contained in:
Hannes Verschore 2013-03-19 11:12:17 +01:00
parent bac96cf5c1
commit b1ef7704f5
2 changed files with 30 additions and 5 deletions

View File

@ -1486,6 +1486,8 @@ SetPropertyIC::update(JSContext *cx, size_t cacheIndex, HandleObject obj,
return true;
}
const size_t GetElementIC::MAX_FAILED_UPDATES = 16;
bool
GetElementIC::attachGetProp(JSContext *cx, IonScript *ion, HandleObject obj,
const Value &idval, HandlePropertyName name)
@ -1725,10 +1727,16 @@ GetElementIC::update(JSContext *cx, size_t cacheIndex, HandleObject obj,
if (!GetElementOperation(cx, JSOp(*pc), &lval, idval, res))
return false;
// If no new attach was done, and we've reached maximum number of stubs, then
// disable the cache.
if (!attachedStub && !cache.canAttachStub())
cache.disable();
// Disable cache when we reach max stubs or update failed too much.
if (!attachedStub) {
cache.incFailedUpdates();
if (cache.shouldDisable()) {
IonSpew(IonSpew_InlineCaches, "Disable inline cache");
cache.disable();
}
} else {
cache.resetFailedUpdates();
}
types::TypeScript::Monitor(cx, script, pc, res);
return true;

View File

@ -411,9 +411,14 @@ class GetElementIC : public IonCache
Register object_;
ConstantOrRegister index_;
TypedOrValueRegister output_;
bool monitoredResult_ : 1;
bool hasDenseStub_ : 1;
size_t failedUpdates_;
static const size_t MAX_FAILED_UPDATES;
public:
GetElementIC(Register object, ConstantOrRegister index,
TypedOrValueRegister output, bool monitoredResult)
@ -421,7 +426,8 @@ class GetElementIC : public IonCache
index_(index),
output_(output),
monitoredResult_(monitoredResult),
hasDenseStub_(false)
hasDenseStub_(false),
failedUpdates_(0)
{
}
@ -454,6 +460,17 @@ class GetElementIC : public IonCache
static bool
update(JSContext *cx, size_t cacheIndex, HandleObject obj, HandleValue idval,
MutableHandleValue vp);
void incFailedUpdates() {
failedUpdates_++;
}
void resetFailedUpdates() {
failedUpdates_ = 0;
}
bool shouldDisable() const {
return !canAttachStub() ||
(stubCount_ == 0 && failedUpdates_ > MAX_FAILED_UPDATES);
}
};
class BindNameIC : public IonCache