Bug 786126 - part 2 - Skip IC generation for GetElems of int32 indexes on non-native objects. (r=dvander)

This commit is contained in:
Kannan Vijayan 2012-09-28 18:14:39 -04:00
parent 722b933229
commit 8a051e5212
3 changed files with 30 additions and 14 deletions

View File

@ -373,6 +373,16 @@ TypeInferenceOracle::elementReadGeneric(JSScript *script, jsbytecode *pc, bool *
*cacheable = (obj == MIRType_Object &&
(id == MIRType_Value || id == MIRType_Int32 || id == MIRType_String));
// Turn off cacheing if the element is int32 and we've seen non-native objects as the target
// of this getelem.
if (*cacheable) {
if (id == MIRType_Int32) {
if (script->analysis()->getCode(pc).nonNativeGetElement)
*cacheable = false;
}
}
if (*cacheable)
*monitorResult = (id == MIRType_String || script->analysis()->getCode(pc).getStringElement);
else

View File

@ -113,6 +113,7 @@ class Bytecode
*/
bool arrayWriteHole: 1; /* SETELEM which has written to an array hole. */
bool getStringElement:1; /* GETELEM which has accessed string properties. */
bool nonNativeGetElement:1; /* GETELEM on a non-native object. */
bool accessGetter: 1; /* Property read on a shape with a getter hook. */
bool notIdempotent: 1; /* Don't use an idempotent cache for this property read. */

View File

@ -686,6 +686,19 @@ GetObjectElementOperation(JSContext *cx, JSOp op, HandleObject obj, const Value
}
#endif
bool updateAnalysis = false;
RootedScript script(cx, NULL);
jsbytecode *pc = NULL;
if (!cx->fp()->beginsIonActivation()) {
// Don't call GetPcScript from inside Ion since it's expensive.
types::TypeScript::GetPcScript(cx, &script, &pc);
if (script->hasAnalysis())
updateAnalysis = true;
}
if (updateAnalysis && !obj->isNative())
script->analysis()->getCode(pc).nonNativeGetElement = true;
uint32_t index;
if (IsDefinitelyIndex(rref, &index)) {
do {
@ -703,16 +716,8 @@ GetObjectElementOperation(JSContext *cx, JSOp op, HandleObject obj, const Value
return false;
} while(0);
} else {
if (!cx->fp()->beginsIonActivation()) {
// Don't update getStringElement if called from Ion code, since
// ion::GetPcScript is expensive.
RootedScript script(cx);
jsbytecode *pc;
types::TypeScript::GetPcScript(cx, &script, &pc);
if (script->hasAnalysis())
if (updateAnalysis)
script->analysis()->getCode(pc).getStringElement = true;
}
SpecialId special;
res.set(rref);