Bug 1439336 - Make guards consistent for TypedObjects. r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Tue, 20 Feb 2018 23:33:42 -0500
changeset 404647 6de1bb4f3df3c039c109cbbcbf0e95e24e6ee218
parent 404646 d3fbff4246c3239ab5771f288702f7b820e83612
child 404648 c6b9c2cb220d504dd68263f8d7291d4cdaa0f54c
push id100055
push usertcampbell@mozilla.com
push dateWed, 21 Feb 2018 15:26:44 +0000
treeherdermozilla-inbound@6de1bb4f3df3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1439336
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439336 - Make guards consistent for TypedObjects. r=jandem MozReview-Commit-ID: CmOMoFq5DgP
js/src/jit/CacheIR.cpp
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -1458,45 +1458,43 @@ GetTypedThingLayout(const Class* clasp)
     if (IsInlineTypedObjectClass(clasp))
         return Layout_InlineTypedObject;
     MOZ_CRASH("Bad object class");
 }
 
 bool
 GetPropIRGenerator::tryAttachTypedObject(HandleObject obj, ObjOperandId objId, HandleId id)
 {
-    if (!obj->is<TypedObject>() ||
-        !cx_->runtime()->jitSupportsFloatingPoint ||
-        cx_->compartment()->detachedTypedObjects)
-    {
-        return false;
-    }
+    if (!obj->is<TypedObject>())
+        return false;
+
+    if (!cx_->runtime()->jitSupportsFloatingPoint || cx_->compartment()->detachedTypedObjects)
+        return false;
 
     TypedObject* typedObj = &obj->as<TypedObject>();
     if (!typedObj->typeDescr().is<StructTypeDescr>())
         return false;
 
     StructTypeDescr* structDescr = &typedObj->typeDescr().as<StructTypeDescr>();
     size_t fieldIndex;
     if (!structDescr->fieldIndex(id, &fieldIndex))
         return false;
 
     TypeDescr* fieldDescr = &structDescr->fieldDescr(fieldIndex);
     if (!fieldDescr->is<SimpleTypeDescr>())
         return false;
 
-    Shape* shape = typedObj->maybeShape();
-    TypedThingLayout layout = GetTypedThingLayout(shape->getObjectClass());
+    TypedThingLayout layout = GetTypedThingLayout(obj->getClass());
 
     uint32_t fieldOffset = structDescr->fieldOffset(fieldIndex);
     uint32_t typeDescr = SimpleTypeDescrKey(&fieldDescr->as<SimpleTypeDescr>());
 
     maybeEmitIdGuard(id);
     writer.guardNoDetachedTypedObjects();
-    writer.guardShape(objId, shape);
+    writer.guardGroupForLayout(objId, obj->group());
     writer.loadTypedObjectResult(objId, fieldOffset, layout, typeDescr);
 
     // Only monitor the result if the type produced by this stub might vary.
     bool monitorLoad = false;
     if (SimpleTypeDescrKeyIsScalar(typeDescr)) {
         Scalar::Type type = ScalarTypeFromSimpleTypeDescrKey(typeDescr);
         monitorLoad = type == Scalar::Uint32;
     } else {
@@ -1933,20 +1931,23 @@ GetPropIRGenerator::tryAttachTypedElemen
         return false;
 
     // Don't attach typed object stubs if the underlying storage could be
     // detached, as the stub will always bail out.
     if (IsPrimitiveArrayTypedObject(obj) && cx_->compartment()->detachedTypedObjects)
         return false;
 
     TypedThingLayout layout = GetTypedThingLayout(obj->getClass());
-    if (layout != Layout_TypedArray)
+
+    if (IsPrimitiveArrayTypedObject(obj)) {
         writer.guardNoDetachedTypedObjects();
-
-    writer.guardShape(objId, obj->as<ShapedObject>().shape());
+        writer.guardGroupForLayout(objId, obj->group());
+    } else {
+        writer.guardShape(objId, obj->as<TypedArrayObject>().shape());
+    }
 
     writer.loadTypedElementResult(objId, indexId, layout, TypedThingElementType(obj));
 
     // Reading from Uint32Array may produce an int32 now but a double value
     // later, so ensure we monitor the result.
     if (TypedThingElementType(obj) == Scalar::Type::Uint32)
         writer.typeMonitorResult();
     else
@@ -2639,23 +2640,22 @@ HasPropIRGenerator::tryAttachUnboxedExpa
 
 bool
 HasPropIRGenerator::tryAttachTypedArray(HandleObject obj, ObjOperandId objId,
                                         uint32_t index, Int32OperandId indexId)
 {
     if (!obj->is<TypedArrayObject>() && !IsPrimitiveArrayTypedObject(obj))
         return false;
 
-    // Don't attach typed object stubs if the underlying storage could be
-    // detached, as the stub will always bail out.
-    if (IsPrimitiveArrayTypedObject(obj) && cx_->compartment()->detachedTypedObjects)
-        return false;
-
     TypedThingLayout layout = GetTypedThingLayout(obj->getClass());
-    writer.guardShape(objId, obj->as<ShapedObject>().shape());
+
+    if (IsPrimitiveArrayTypedObject(obj))
+        writer.guardGroupForLayout(objId, obj->group());
+    else
+        writer.guardShape(objId, obj->as<TypedArrayObject>().shape());
 
     writer.loadTypedElementExistsResult(objId, indexId, layout);
 
     writer.returnFromIC();
 
     trackAttached("TypedArrayObject");
     return true;
 }
@@ -3078,17 +3078,20 @@ EmitGuardUnboxedPropertyType(CacheIRWrit
         writer.guardType(valId, propType);
     }
 }
 
 bool
 SetPropIRGenerator::tryAttachUnboxedProperty(HandleObject obj, ObjOperandId objId, HandleId id,
                                              ValOperandId rhsId)
 {
-    if (!obj->is<UnboxedPlainObject>() || !cx_->runtime()->jitSupportsFloatingPoint)
+    if (!obj->is<UnboxedPlainObject>())
+        return false;
+
+    if (!cx_->runtime()->jitSupportsFloatingPoint)
         return false;
 
     const UnboxedLayout::Property* property = obj->as<UnboxedPlainObject>().layout().lookup(id);
     if (!property)
         return false;
 
     maybeEmitIdGuard(id);
     writer.guardGroupForLayout(objId, obj->group());
@@ -3104,20 +3107,20 @@ SetPropIRGenerator::tryAttachUnboxedProp
     trackAttached("Unboxed");
     return true;
 }
 
 bool
 SetPropIRGenerator::tryAttachTypedObjectProperty(HandleObject obj, ObjOperandId objId, HandleId id,
                                                  ValOperandId rhsId)
 {
-    if (!obj->is<TypedObject>() || !cx_->runtime()->jitSupportsFloatingPoint)
-        return false;
-
-    if (cx_->compartment()->detachedTypedObjects)
+    if (!obj->is<TypedObject>())
+        return false;
+
+    if (!cx_->runtime()->jitSupportsFloatingPoint || cx_->compartment()->detachedTypedObjects)
         return false;
 
     if (!obj->as<TypedObject>().typeDescr().is<StructTypeDescr>())
         return false;
 
     StructTypeDescr* structDescr = &obj->as<TypedObject>().typeDescr().as<StructTypeDescr>();
     size_t fieldIndex;
     if (!structDescr->fieldIndex(id, &fieldIndex))
@@ -3127,17 +3130,16 @@ SetPropIRGenerator::tryAttachTypedObject
     if (!fieldDescr->is<SimpleTypeDescr>())
         return false;
 
     uint32_t fieldOffset = structDescr->fieldOffset(fieldIndex);
     TypedThingLayout layout = GetTypedThingLayout(obj->getClass());
 
     maybeEmitIdGuard(id);
     writer.guardNoDetachedTypedObjects();
-    writer.guardShape(objId, obj->as<TypedObject>().shape());
     writer.guardGroupForLayout(objId, obj->group());
 
     typeCheckInfo_.set(obj->group(), id);
 
     // Scalar types can always be stored without a type update stub.
     if (fieldDescr->is<ScalarTypeDescr>()) {
         Scalar::Type type = fieldDescr->as<ScalarTypeDescr>().type();
         writer.storeTypedObjectScalarProperty(objId, fieldOffset, layout, type, rhsId);
@@ -3518,20 +3520,23 @@ SetPropIRGenerator::tryAttachSetTypedEle
         // bail out.
         if (cx_->compartment()->detachedTypedObjects)
             return false;
     }
 
     Scalar::Type elementType = TypedThingElementType(obj);
     TypedThingLayout layout = GetTypedThingLayout(obj->getClass());
 
-    if (!obj->is<TypedArrayObject>())
+    if (IsPrimitiveArrayTypedObject(obj)) {
         writer.guardNoDetachedTypedObjects();
-
-    writer.guardShape(objId, obj->as<ShapedObject>().shape());
+        writer.guardGroupForLayout(objId, obj->group());
+    } else {
+        writer.guardShape(objId, obj->as<TypedArrayObject>().shape());
+    }
+
     writer.storeTypedElement(objId, indexId, rhsId, layout, elementType, handleOutOfBounds);
     writer.returnFromIC();
 
     if (handleOutOfBounds)
         attachedTypedArrayOOBStub_ = true;
 
     trackAttached(handleOutOfBounds ? "SetTypedElementOOB" : "SetTypedElement");
     return true;