Bug 639858 - Bias the profiler toward tracing scripted getters (r=dmandelin)

This commit is contained in:
Bill McCloskey 2011-03-11 10:21:33 -08:00
parent 4aa7aa5390
commit 274e0534d2
2 changed files with 37 additions and 1 deletions

View File

@ -17179,6 +17179,37 @@ LoopProfile::profileOperation(JSContext* cx, JSOp op)
increment(OP_ARRAY_READ);
}
if (op == JSOP_GETPROP || op == JSOP_CALLPROP ||
op == JSOP_GETARGPROP || op == JSOP_GETLOCALPROP)
{
/* Try to see if it's a scripted getter, which is faster in the tracer. */
Value v;
if (op == JSOP_GETPROP || op == JSOP_CALLPROP) {
v = cx->regs->sp[-1];
} if (op == JSOP_GETARGPROP) {
uint32 slot = GET_ARGNO(pc);
JS_ASSERT(slot < fp->numFormalArgs());
v = fp->formalArg(slot);
} else if (op == JSOP_GETLOCALPROP) {
uint32 slot = GET_SLOTNO(pc);
JS_ASSERT(slot < script->nslots);
v = fp->slots()[slot];
}
if (v.isObject()) {
JSObject *aobj = js_GetProtoIfDenseArray(&v.toObject());
PropertyCacheEntry *entry;
JSObject *obj2;
JSAtom *atom;
JS_PROPERTY_CACHE(cx).test(cx, pc, aobj, obj2, entry, atom);
if (!atom && entry->vword.isShape()) {
const Shape *shape = entry->vword.toShape();
if (shape->hasGetterValue())
increment(OP_SCRIPTED_GETTER);
}
}
}
if (op == JSOP_CALL) {
increment(OP_CALL);
@ -17373,6 +17404,7 @@ LoopProfile::decide(JSContext *cx)
debug_only_printf(LC_TMProfiler, "FEATURE call %d\n", allOps[OP_CALL]);
debug_only_printf(LC_TMProfiler, "FEATURE arrayread %d\n", allOps[OP_ARRAY_READ]);
debug_only_printf(LC_TMProfiler, "FEATURE typedarray %d\n", allOps[OP_TYPED_ARRAY]);
debug_only_printf(LC_TMProfiler, "FEATURE scriptedgetter %d\n", allOps[OP_SCRIPTED_GETTER]);
debug_only_printf(LC_TMProfiler, "FEATURE fwdjump %d\n", allOps[OP_FWDJUMP]);
debug_only_printf(LC_TMProfiler, "FEATURE recursive %d\n", allOps[OP_RECURSIVE]);
debug_only_printf(LC_TMProfiler, "FEATURE shortLoop %d\n", shortLoop);
@ -17408,9 +17440,12 @@ LoopProfile::decide(JSContext *cx)
/* The tracer handles these ops well because of inlining. */
goodOps += (count(OP_CALL) + count(OP_NEW))*20;
/* The tracer specialized typed array access. */
/* The tracer specializes typed array access. */
goodOps += count(OP_TYPED_ARRAY)*10;
/* The tracer traces scripted getters. */
goodOps += count(OP_SCRIPTED_GETTER)*40;
/* The methodjit is faster at array writes, but the tracer is faster for reads. */
goodOps += count(OP_ARRAY_READ)*15;

View File

@ -639,6 +639,7 @@ public:
OP_RECURSIVE, // Recursive calls
OP_ARRAY_READ, // Reads from dense arrays
OP_TYPED_ARRAY, // Accesses to typed arrays
OP_SCRIPTED_GETTER, // Getters defined in JS
OP_LIMIT
};