Bug 1404636 - Special-case typed arrays in PropertyReadNeedsTypeBarrier. r=bhackett

This commit is contained in:
Jan de Mooij 2017-10-26 16:15:35 +02:00
parent e82be8f70e
commit ab7b5f6697
3 changed files with 31 additions and 26 deletions

View File

@ -7806,9 +7806,6 @@ IonBuilder::getElemTryTypedObject(bool* emitted, MDefinition* obj, MDefinition*
MOZ_CRASH("Bad kind");
}
static MIRType
MIRTypeForTypedArrayRead(Scalar::Type arrayType, bool observedDouble);
bool
IonBuilder::checkTypedObjectIndexInBounds(uint32_t elemSize,
MDefinition* obj,
@ -8764,29 +8761,6 @@ IonBuilder::convertShiftToMaskForStaticTypedArray(MDefinition* id,
return ptr;
}
static MIRType
MIRTypeForTypedArrayRead(Scalar::Type arrayType, bool observedDouble)
{
switch (arrayType) {
case Scalar::Int8:
case Scalar::Uint8:
case Scalar::Uint8Clamped:
case Scalar::Int16:
case Scalar::Uint16:
case Scalar::Int32:
return MIRType::Int32;
case Scalar::Uint32:
return observedDouble ? MIRType::Double : MIRType::Int32;
case Scalar::Float32:
return MIRType::Float32;
case Scalar::Float64:
return MIRType::Double;
default:
break;
}
MOZ_CRASH("Unknown typed array type");
}
AbortReasonOr<Ok>
IonBuilder::jsop_getelem_typed(MDefinition* obj, MDefinition* index,
Scalar::Type arrayType)

View File

@ -6193,6 +6193,14 @@ PropertyReadNeedsTypeBarrier(CompilerConstraintList* constraints,
return BarrierKind::TypeSet;
}
if (!name && IsTypedArrayClass(key->clasp())) {
Scalar::Type arrayType = Scalar::Type(key->clasp() - &TypedArrayObject::classes[0]);
MIRType type = MIRTypeForTypedArrayRead(arrayType, true);
if (observed->mightBeMIRType(type))
return BarrierKind::NoBarrier;
return BarrierKind::TypeSet;
}
jsid id = name ? NameToId(name) : JSID_VOID;
HeapTypeSetKey property = key->property(id);
if (property.maybeTypes()) {

View File

@ -15002,6 +15002,29 @@ ArrayPrototypeHasIndexedProperty(IonBuilder* builder, JSScript* script);
AbortReasonOr<bool>
TypeCanHaveExtraIndexedProperties(IonBuilder* builder, TemporaryTypeSet* types);
inline MIRType
MIRTypeForTypedArrayRead(Scalar::Type arrayType, bool observedDouble)
{
switch (arrayType) {
case Scalar::Int8:
case Scalar::Uint8:
case Scalar::Uint8Clamped:
case Scalar::Int16:
case Scalar::Uint16:
case Scalar::Int32:
return MIRType::Int32;
case Scalar::Uint32:
return observedDouble ? MIRType::Double : MIRType::Int32;
case Scalar::Float32:
return MIRType::Float32;
case Scalar::Float64:
return MIRType::Double;
default:
break;
}
MOZ_CRASH("Unknown typed array type");
}
} // namespace jit
} // namespace js