Bug 1337763 - Factor out GeneratePrototypeHoleGuards
MozReview-Commit-ID: JvSj1dyEMnC
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -356,16 +356,45 @@ GeneratePrototypeGuards(CacheIRWriter& w
writer.guardGroup(protoId, pobj->group());
}
}
pobj = pobj->staticPrototype();
}
}
static void
+GeneratePrototypeHoleGuards(CacheIRWriter& writer, JSObject* obj, ObjOperandId objId)
+{
+ if (obj->hasUncacheableProto()) {
+ // If the shape does not imply the proto, emit an explicit proto guard.
+ writer.guardProto(objId, obj->staticPrototype());
+ }
+
+ JSObject* pobj = obj->staticPrototype();
+ while (pobj) {
+ ObjOperandId protoId = writer.loadObject(pobj);
+
+ // Non-singletons with uncacheable protos can change their proto
+ // without a shape change, so also guard on the group (which determines
+ // the proto) in this case.
+ if (pobj->hasUncacheableProto() && !pobj->isSingleton())
+ writer.guardGroup(protoId, pobj->group());
+
+ // Make sure the shape matches, to avoid non-dense elements or anything
+ // else that is being checked by CanAttachDenseElementHole.
+ writer.guardShape(protoId, pobj->as<NativeObject>().lastProperty());
+
+ // Also make sure there are no dense elements.
+ writer.guardNoDenseElements(protoId);
+
+ pobj = pobj->staticPrototype();
+ }
+}
+
+static void
TestMatchingReceiver(CacheIRWriter& writer, JSObject* obj, Shape* shape, ObjOperandId objId,
Maybe<ObjOperandId>* expandoId)
{
if (obj->is<UnboxedPlainObject>()) {
writer.guardGroup(objId, obj->group());
if (UnboxedExpandoObject* expando = obj->as<UnboxedPlainObject>().maybeExpando()) {
expandoId->emplace(writer.guardAndLoadUnboxedExpando(objId));
@@ -1333,41 +1362,17 @@ GetPropIRGenerator::tryAttachDenseElemen
return false;
if (!CanAttachDenseElementHole(obj))
return false;
// Guard on the shape, to prevent non-dense elements from appearing.
writer.guardShape(objId, obj->as<NativeObject>().lastProperty());
- if (obj->hasUncacheableProto()) {
- // If the shape does not imply the proto, emit an explicit proto guard.
- writer.guardProto(objId, obj->staticPrototype());
- }
-
- JSObject* pobj = obj->staticPrototype();
- while (pobj) {
- ObjOperandId protoId = writer.loadObject(pobj);
-
- // Non-singletons with uncacheable protos can change their proto
- // without a shape change, so also guard on the group (which determines
- // the proto) in this case.
- if (pobj->hasUncacheableProto() && !pobj->isSingleton())
- writer.guardGroup(protoId, pobj->group());
-
- // Make sure the shape matches, to avoid non-dense elements or anything
- // else that is being checked by CanAttachDenseElementHole.
- writer.guardShape(protoId, pobj->as<NativeObject>().lastProperty());
-
- // Also make sure there are no dense elements.
- writer.guardNoDenseElements(protoId);
-
- pobj = pobj->staticPrototype();
- }
-
+ GeneratePrototypeHoleGuards(writer, obj, objId);
writer.loadDenseElementHoleResult(objId, indexId);
writer.typeMonitorResult();
trackAttached("DenseElementHole");
return true;
}
bool