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-30 15:18:47 -04:00
parent a31ae24743
commit ad138984ba
3 changed files with 30 additions and 10 deletions

View File

@ -373,6 +373,12 @@ 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 && id == MIRType_Int32 && script->analysis()->getCode(pc).nonNativeGetElement)
*cacheable = false;
if (*cacheable)
*monitorResult = (id == MIRType_String || script->analysis()->getCode(pc).getStringElement);
else

View File

@ -111,10 +111,11 @@ class Bytecode
* Dynamically observed state about the execution of this opcode. These are
* hints about the script for use during compilation.
*/
bool arrayWriteHole: 1; /* SETELEM which has written to an array hole. */
bool getStringElement:1; /* GETELEM which has accessed string properties. */
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. */
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, non-array 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. */
/* Stack depth before this opcode. */
uint32_t stackDepth;

View File

@ -685,9 +685,20 @@ GetObjectElementOperation(JSContext *cx, JSOp op, HandleObject obj, const Value
return js_GetXMLMethod(cx, obj, id, res);
}
#endif
// Don't call GetPcScript (needed for analysis) from inside Ion since it's expensive.
bool analyze = !cx->fp()->beginsIonActivation();
uint32_t index;
if (IsDefinitelyIndex(rref, &index)) {
if (analyze && !obj->isNative() && !obj->isArray()) {
RootedScript script(cx, NULL);
jsbytecode *pc = NULL;
types::TypeScript::GetPcScript(cx, &script, &pc);
if (script->hasAnalysis())
script->analysis()->getCode(pc).nonNativeGetElement = true;
}
do {
if (obj->isDenseArray()) {
if (index < obj->getDenseArrayInitializedLength()) {
@ -703,15 +714,17 @@ 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;
if (analyze) {
RootedScript script(cx, NULL);
jsbytecode *pc = NULL;
types::TypeScript::GetPcScript(cx, &script, &pc);
if (script->hasAnalysis())
if (script->hasAnalysis()) {
script->analysis()->getCode(pc).getStringElement = true;
if (!obj->isArray() && !obj->isNative())
script->analysis()->getCode(pc).nonNativeGetElement = true;
}
}
SpecialId special;