Bug 1128076 - Clean up naming around unboxed scalar MIR accesses, r=jandem.

This commit is contained in:
Brian Hackett 2015-03-12 10:25:44 -06:00
parent a123cb3613
commit 6057f8b61d
18 changed files with 183 additions and 203 deletions

View File

@ -14,7 +14,7 @@
MakeConstructible: false, DecompileArg: false,
RuntimeDefaultLocale: false,
ParallelDo: false, ParallelSlices: false, NewDenseArray: false,
UnsafePutElements: false, ShouldForceSequential: false,
UnsafePutElements: false,
ParallelTestsShouldPass: false,
Dump: false,
callFunction: false,

View File

@ -8662,15 +8662,14 @@ CodeGenerator::visitUnboxObjectOrNull(LUnboxObjectOrNull *lir)
}
void
CodeGenerator::visitLoadTypedArrayElement(LLoadTypedArrayElement *lir)
CodeGenerator::visitLoadUnboxedScalar(LLoadUnboxedScalar *lir)
{
Register elements = ToRegister(lir->elements());
Register temp = lir->temp()->isBogusTemp() ? InvalidReg : ToRegister(lir->temp());
AnyRegister out = ToAnyRegister(lir->output());
Scalar::Type arrayType = lir->mir()->arrayType();
Scalar::Type readType = lir->mir()->readType();
int width = Scalar::byteSize(arrayType);
int width = Scalar::byteSize(lir->mir()->indexType());
Label fail;
if (lir->index()->isConstant()) {
@ -8747,13 +8746,13 @@ StoreToTypedArray(MacroAssembler &masm, Scalar::Type writeType, const LAllocatio
}
void
CodeGenerator::visitStoreTypedArrayElement(LStoreTypedArrayElement *lir)
CodeGenerator::visitStoreUnboxedScalar(LStoreUnboxedScalar *lir)
{
Register elements = ToRegister(lir->elements());
const LAllocation *value = lir->value();
Scalar::Type writeType = lir->mir()->writeType();
int width = Scalar::byteSize(lir->mir()->arrayType());
int width = Scalar::byteSize(lir->mir()->indexType());
if (lir->index()->isConstant()) {
Address dest(elements, ToInt32(lir->index()) * width + lir->mir()->offsetAdjustment());

View File

@ -262,9 +262,9 @@ class CodeGenerator : public CodeGeneratorSpecific
void visitArrayPushT(LArrayPushT *lir);
void visitArrayConcat(LArrayConcat *lir);
void visitArrayJoin(LArrayJoin *lir);
void visitLoadTypedArrayElement(LLoadTypedArrayElement *lir);
void visitLoadUnboxedScalar(LLoadUnboxedScalar *lir);
void visitLoadTypedArrayElementHole(LLoadTypedArrayElementHole *lir);
void visitStoreTypedArrayElement(LStoreTypedArrayElement *lir);
void visitStoreUnboxedScalar(LStoreUnboxedScalar *lir);
void visitStoreTypedArrayElementHole(LStoreTypedArrayElementHole *lir);
void visitCompareExchangeTypedArrayElement(LCompareExchangeTypedArrayElement *lir);
void visitAtomicTypedArrayElementBinop(LAtomicTypedArrayElementBinop *lir);

View File

@ -7852,10 +7852,10 @@ IonBuilder::pushScalarLoadFromTypedObject(MDefinition *obj,
loadTypedObjectElements(obj, byteOffset, size, &elements, &scaledOffset, &adjustment);
// Load the element.
MLoadTypedArrayElement *load = MLoadTypedArrayElement::New(alloc(), elements, scaledOffset,
elemType,
DoesNotRequireMemoryBarrier,
adjustment);
MLoadUnboxedScalar *load = MLoadUnboxedScalar::New(alloc(), elements, scaledOffset,
elemType,
DoesNotRequireMemoryBarrier,
adjustment);
current->add(load);
current->push(load);
@ -8613,7 +8613,7 @@ IonBuilder::jsop_getelem_typed(MDefinition *obj, MDefinition *index,
addTypedArrayLengthAndData(obj, DoBoundsCheck, &index, &length, &elements);
// Load the element.
MLoadTypedArrayElement *load = MLoadTypedArrayElement::New(alloc(), elements, index, arrayType);
MLoadUnboxedScalar *load = MLoadUnboxedScalar::New(alloc(), elements, index, arrayType);
current->add(load);
current->push(load);
@ -8809,7 +8809,7 @@ IonBuilder::setElemTryScalarElemOfTypedObject(bool *emitted,
return true;
// Store the element
if (!storeScalarTypedObjectValue(obj, indexAsByteOffset, elemType, false, value))
if (!storeScalarTypedObjectValue(obj, indexAsByteOffset, elemType, value))
return false;
current->push(value);
@ -9100,9 +9100,6 @@ IonBuilder::jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion,
MStoreElement *ins = MStoreElement::New(alloc(), elements, id, newValue, needsHoleCheck);
store = ins;
if (safety == SetElem_Unsafe)
ins->setRacy();
current->add(ins);
if (safety == SetElem_Normal)
@ -9163,10 +9160,8 @@ IonBuilder::jsop_setelem_typed(Scalar::Type arrayType, SetElemSafety safety,
if (expectOOB) {
ins = MStoreTypedArrayElementHole::New(alloc(), elements, length, id, toWrite, arrayType);
} else {
MStoreTypedArrayElement *store =
MStoreTypedArrayElement::New(alloc(), elements, id, toWrite, arrayType);
if (safety == SetElem_Unsafe)
store->setRacy();
MStoreUnboxedScalar *store =
MStoreUnboxedScalar::New(alloc(), elements, id, toWrite, arrayType);
ins = store;
}
@ -9179,7 +9174,7 @@ IonBuilder::jsop_setelem_typed(Scalar::Type arrayType, SetElemSafety safety,
}
bool
IonBuilder::jsop_setelem_typed_object(Scalar::Type arrayType, SetElemSafety safety, bool racy,
IonBuilder::jsop_setelem_typed_object(Scalar::Type arrayType, SetElemSafety safety,
MDefinition *object, MDefinition *index, MDefinition *value)
{
MOZ_ASSERT(safety == SetElem_Unsafe); // Can be fixed, but there's been no reason to as of yet
@ -9193,7 +9188,7 @@ IonBuilder::jsop_setelem_typed_object(Scalar::Type arrayType, SetElemSafety safe
if (!byteOffset.add(intIndex, elemSize))
setForceAbort();
return storeScalarTypedObjectValue(object, byteOffset, arrayType, racy, value);
return storeScalarTypedObjectValue(object, byteOffset, arrayType, value);
}
bool
@ -10427,24 +10422,24 @@ IonBuilder::loadUnboxedProperty(MDefinition *obj, size_t offset, JSValueType unb
MInstruction *load;
switch (unboxedType) {
case JSVAL_TYPE_BOOLEAN:
load = MLoadTypedArrayElement::New(alloc(), obj, scaledOffset, Scalar::Uint8,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
load = MLoadUnboxedScalar::New(alloc(), obj, scaledOffset, Scalar::Uint8,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
load->setResultType(MIRType_Boolean);
break;
case JSVAL_TYPE_INT32:
load = MLoadTypedArrayElement::New(alloc(), obj, scaledOffset, Scalar::Int32,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
load = MLoadUnboxedScalar::New(alloc(), obj, scaledOffset, Scalar::Int32,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
load->setResultType(MIRType_Int32);
break;
case JSVAL_TYPE_DOUBLE:
load = MLoadTypedArrayElement::New(alloc(), obj, scaledOffset, Scalar::Float64,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData(),
/* canonicalizeDoubles = */ false);
load = MLoadUnboxedScalar::New(alloc(), obj, scaledOffset, Scalar::Float64,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData(),
/* canonicalizeDoubles = */ false);
load->setResultType(MIRType_Double);
break;
@ -11245,7 +11240,7 @@ IonBuilder::setPropTryScalarPropOfTypedObject(bool *emitted,
if (!byteOffset.add(fieldOffset))
setForceAbort();
if (!storeScalarTypedObjectValue(obj, byteOffset, fieldType, false, value))
if (!storeScalarTypedObjectValue(obj, byteOffset, fieldType, value))
return false;
current->push(value);
@ -11326,21 +11321,21 @@ IonBuilder::storeUnboxedProperty(MDefinition *obj, size_t offset, JSValueType un
MInstruction *store;
switch (unboxedType) {
case JSVAL_TYPE_BOOLEAN:
store = MStoreTypedArrayElement::New(alloc(), obj, scaledOffset, value, Scalar::Uint8,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
store = MStoreUnboxedScalar::New(alloc(), obj, scaledOffset, value, Scalar::Uint8,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
break;
case JSVAL_TYPE_INT32:
store = MStoreTypedArrayElement::New(alloc(), obj, scaledOffset, value, Scalar::Int32,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
store = MStoreUnboxedScalar::New(alloc(), obj, scaledOffset, value, Scalar::Int32,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
break;
case JSVAL_TYPE_DOUBLE:
store = MStoreTypedArrayElement::New(alloc(), obj, scaledOffset, value, Scalar::Float64,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
store = MStoreUnboxedScalar::New(alloc(), obj, scaledOffset, value, Scalar::Float64,
DoesNotRequireMemoryBarrier,
UnboxedPlainObject::offsetOfData());
break;
case JSVAL_TYPE_STRING:
@ -12653,7 +12648,6 @@ bool
IonBuilder::storeScalarTypedObjectValue(MDefinition *typedObj,
const LinearSum &byteOffset,
ScalarTypeDescr::Type type,
bool racy,
MDefinition *value)
{
// Find location within the owner object.
@ -12669,11 +12663,9 @@ IonBuilder::storeScalarTypedObjectValue(MDefinition *typedObj,
current->add(toWrite->toInstruction());
}
MStoreTypedArrayElement *store =
MStoreTypedArrayElement::New(alloc(), elements, scaledOffset, toWrite,
type, DoesNotRequireMemoryBarrier, adjustment);
if (racy)
store->setRacy();
MStoreUnboxedScalar *store =
MStoreUnboxedScalar::New(alloc(), elements, scaledOffset, toWrite,
type, DoesNotRequireMemoryBarrier, adjustment);
current->add(store);
return true;

View File

@ -518,7 +518,6 @@ class IonBuilder
bool storeScalarTypedObjectValue(MDefinition *typedObj,
const LinearSum &byteOffset,
ScalarTypeDescr::Type type,
bool racy,
MDefinition *value);
bool checkTypedObjectIndexInBounds(int32_t elemSize,
MDefinition *obj,
@ -667,7 +666,7 @@ class IonBuilder
SetElemSafety safety,
MDefinition *object, MDefinition *index, MDefinition *value);
bool jsop_setelem_typed_object(ScalarTypeDescr::Type arrayType,
SetElemSafety safety, bool racy,
SetElemSafety safety,
MDefinition *object, MDefinition *index, MDefinition *value);
bool jsop_length();
bool jsop_length_fastPath();

View File

@ -57,7 +57,7 @@ enum BailoutKind
Bailout_StringArgumentsEval,
// Bailout on overflow, but don't immediately invalidate.
// Used for abs, sub and LoadTypedArrayElement (when loading a uint32 that
// Used for abs, sub and LoadUnboxedScalar (when loading a uint32 that
// doesn't fit in an int32).
Bailout_Overflow,

View File

@ -4884,20 +4884,19 @@ class LArrayJoin : public LCallInstructionHelper<1, 2, 0>
}
};
// Load a typed value from a typed array's elements vector.
class LLoadTypedArrayElement : public LInstructionHelper<1, 2, 1>
class LLoadUnboxedScalar : public LInstructionHelper<1, 2, 1>
{
public:
LIR_HEADER(LoadTypedArrayElement)
LIR_HEADER(LoadUnboxedScalar)
LLoadTypedArrayElement(const LAllocation &elements, const LAllocation &index,
const LDefinition &temp) {
LLoadUnboxedScalar(const LAllocation &elements, const LAllocation &index,
const LDefinition &temp) {
setOperand(0, elements);
setOperand(1, index);
setTemp(0, temp);
}
const MLoadTypedArrayElement *mir() const {
return mir_->toLoadTypedArrayElement();
const MLoadUnboxedScalar *mir() const {
return mir_->toLoadUnboxedScalar();
}
const LAllocation *elements() {
return getOperand(0);
@ -4945,20 +4944,20 @@ class LLoadTypedArrayElementStatic : public LInstructionHelper<1, 1, 0>
}
};
class LStoreTypedArrayElement : public LInstructionHelper<0, 3, 0>
class LStoreUnboxedScalar : public LInstructionHelper<0, 3, 0>
{
public:
LIR_HEADER(StoreTypedArrayElement)
LIR_HEADER(StoreUnboxedScalar)
LStoreTypedArrayElement(const LAllocation &elements, const LAllocation &index,
const LAllocation &value) {
LStoreUnboxedScalar(const LAllocation &elements, const LAllocation &index,
const LAllocation &value) {
setOperand(0, elements);
setOperand(1, index);
setOperand(2, value);
}
const MStoreTypedArrayElement *mir() const {
return mir_->toStoreTypedArrayElement();
const MStoreUnboxedScalar *mir() const {
return mir_->toStoreUnboxedScalar();
}
const LAllocation *elements() {
return getOperand(0);

View File

@ -220,11 +220,13 @@
_(LoadElementV) \
_(LoadElementT) \
_(LoadElementHole) \
_(LoadUnboxedScalar) \
_(LoadUnboxedPointerV) \
_(LoadUnboxedPointerT) \
_(UnboxObjectOrNull) \
_(StoreElementV) \
_(StoreElementT) \
_(StoreUnboxedScalar) \
_(StoreUnboxedPointer) \
_(ConvertUnboxedObjectToNative) \
_(ArrayPopShiftV) \
@ -235,10 +237,8 @@
_(ArrayJoin) \
_(StoreElementHoleV) \
_(StoreElementHoleT) \
_(LoadTypedArrayElement) \
_(LoadTypedArrayElementHole) \
_(LoadTypedArrayElementStatic) \
_(StoreTypedArrayElement) \
_(StoreTypedArrayElementHole) \
_(StoreTypedArrayElementStatic) \
_(CompareExchangeTypedArrayElement) \

View File

@ -2880,7 +2880,7 @@ LIRGenerator::visitStringSplit(MStringSplit *ins)
}
void
LIRGenerator::visitLoadTypedArrayElement(MLoadTypedArrayElement *ins)
LIRGenerator::visitLoadUnboxedScalar(MLoadUnboxedScalar *ins)
{
MOZ_ASSERT(IsValidElementsType(ins->elements(), ins->offsetAdjustment()));
MOZ_ASSERT(ins->index()->type() == MIRType_Int32);
@ -2893,14 +2893,14 @@ LIRGenerator::visitLoadTypedArrayElement(MLoadTypedArrayElement *ins)
// We need a temp register for Uint32Array with known double result.
LDefinition tempDef = LDefinition::BogusTemp();
if (ins->arrayType() == Scalar::Uint32 && IsFloatingPointType(ins->type()))
if (ins->readType() == Scalar::Uint32 && IsFloatingPointType(ins->type()))
tempDef = temp();
if (ins->requiresMemoryBarrier()) {
LMemoryBarrier *fence = new(alloc()) LMemoryBarrier(MembarBeforeLoad);
add(fence, ins);
}
LLoadTypedArrayElement *lir = new(alloc()) LLoadTypedArrayElement(elements, index, tempDef);
LLoadUnboxedScalar *lir = new(alloc()) LLoadUnboxedScalar(elements, index, tempDef);
if (ins->fallible())
assignSnapshot(lir, Bailout_Overflow);
define(lir, ins);
@ -2976,7 +2976,7 @@ LIRGenerator::visitLoadTypedArrayElementStatic(MLoadTypedArrayElementStatic *ins
}
void
LIRGenerator::visitStoreTypedArrayElement(MStoreTypedArrayElement *ins)
LIRGenerator::visitStoreUnboxedScalar(MStoreUnboxedScalar *ins)
{
MOZ_ASSERT(IsValidElementsType(ins->elements(), ins->offsetAdjustment()));
MOZ_ASSERT(ins->index()->type() == MIRType_Int32);
@ -3009,7 +3009,7 @@ LIRGenerator::visitStoreTypedArrayElement(MStoreTypedArrayElement *ins)
LMemoryBarrier *fence = new(alloc()) LMemoryBarrier(MembarBeforeStore);
add(fence, ins);
}
add(new(alloc()) LStoreTypedArrayElement(elements, index, value), ins);
add(new(alloc()) LStoreUnboxedScalar(elements, index, value), ins);
if (ins->requiresMemoryBarrier()) {
LMemoryBarrier *fence = new(alloc()) LMemoryBarrier(MembarAfterStore);
add(fence, ins);

View File

@ -203,10 +203,10 @@ class LIRGenerator : public LIRGeneratorSpecific
void visitArrayPush(MArrayPush *ins);
void visitArrayConcat(MArrayConcat *ins);
void visitArrayJoin(MArrayJoin *ins);
void visitLoadTypedArrayElement(MLoadTypedArrayElement *ins);
void visitLoadUnboxedScalar(MLoadUnboxedScalar *ins);
void visitLoadTypedArrayElementHole(MLoadTypedArrayElementHole *ins);
void visitLoadTypedArrayElementStatic(MLoadTypedArrayElementStatic *ins);
void visitStoreTypedArrayElement(MStoreTypedArrayElement *ins);
void visitStoreUnboxedScalar(MStoreUnboxedScalar *ins);
void visitStoreTypedArrayElementHole(MStoreTypedArrayElementHole *ins);
void visitClampToUint8(MClampToUint8 *ins);
void visitLoadFixedSlot(MLoadFixedSlot *ins);

View File

@ -2122,7 +2122,7 @@ IonBuilder::inlineUnsafeSetTypedObjectArrayElement(CallInfo &callInfo,
MDefinition *id = callInfo.getArg(base + 1);
MDefinition *elem = callInfo.getArg(base + 2);
if (!jsop_setelem_typed_object(arrayType, SetElem_Unsafe, true, obj, id, elem))
if (!jsop_setelem_typed_object(arrayType, SetElem_Unsafe, obj, id, elem))
return false;
return true;
@ -2688,9 +2688,9 @@ IonBuilder::inlineAtomicsLoad(CallInfo &callInfo)
MDefinition *index;
atomicsCheckBounds(callInfo, &elements, &index);
MLoadTypedArrayElement *load =
MLoadTypedArrayElement::New(alloc(), elements, index, arrayType,
DoesRequireMemoryBarrier);
MLoadUnboxedScalar *load =
MLoadUnboxedScalar::New(alloc(), elements, index, arrayType,
DoesRequireMemoryBarrier);
load->setResultType(getInlineReturnType());
current->add(load);
current->push(load);
@ -2725,9 +2725,9 @@ IonBuilder::inlineAtomicsStore(CallInfo &callInfo)
toWrite = MTruncateToInt32::New(alloc(), value);
current->add(toWrite->toInstruction());
}
MStoreTypedArrayElement *store =
MStoreTypedArrayElement::New(alloc(), elements, index, toWrite, arrayType,
DoesRequireMemoryBarrier);
MStoreUnboxedScalar *store =
MStoreUnboxedScalar::New(alloc(), elements, index, toWrite, arrayType,
DoesRequireMemoryBarrier);
current->add(store);
current->push(value);
@ -3206,7 +3206,7 @@ IonBuilder::inlineSimdLoad(CallInfo &callInfo, JSNative native, SimdTypeDescr::T
if (!prepareForSimdLoadStore(callInfo, simdType, &elements, &index, &arrayType))
return InliningStatus_NotInlined;
MLoadTypedArrayElement *load = MLoadTypedArrayElement::New(alloc(), elements, index, arrayType);
MLoadUnboxedScalar *load = MLoadUnboxedScalar::New(alloc(), elements, index, arrayType);
load->setResultType(SimdTypeDescrToMIRType(type));
load->setReadType(simdType);
@ -3229,8 +3229,8 @@ IonBuilder::inlineSimdStore(CallInfo &callInfo, JSNative native, SimdTypeDescr::
return InliningStatus_NotInlined;
MDefinition *valueToWrite = callInfo.getArg(2);
MStoreTypedArrayElement *store = MStoreTypedArrayElement::New(alloc(), elements, index,
valueToWrite, arrayType);
MStoreUnboxedScalar *store = MStoreUnboxedScalar::New(alloc(), elements, index,
valueToWrite, arrayType);
store->setWriteType(simdType);
current->add(store);

View File

@ -1027,10 +1027,10 @@ MConstantElements::printOpcode(FILE *fp) const
}
void
MLoadTypedArrayElement::printOpcode(FILE *fp) const
MLoadUnboxedScalar::printOpcode(FILE *fp) const
{
MDefinition::printOpcode(fp);
fprintf(fp, " %s", ScalarTypeDescr::typeName(arrayType()));
fprintf(fp, " %s", ScalarTypeDescr::typeName(indexType()));
}
void
@ -2031,7 +2031,7 @@ NeedNegativeZeroCheck(MDefinition *def)
case MDefinition::Op_StoreElementHole:
case MDefinition::Op_LoadElement:
case MDefinition::Op_LoadElementHole:
case MDefinition::Op_LoadTypedArrayElement:
case MDefinition::Op_LoadUnboxedScalar:
case MDefinition::Op_LoadTypedArrayElementHole:
case MDefinition::Op_CharCodeAt:
case MDefinition::Op_Mod:

View File

@ -300,12 +300,13 @@ class AliasSet {
enum Flag {
None_ = 0,
ObjectFields = 1 << 0, // shape, class, slots, length etc.
Element = 1 << 1, // A member of obj->elements, or reference
// typed object field.
DynamicSlot = 1 << 2, // A member of obj->slots.
FixedSlot = 1 << 3, // A member of obj->fixedSlots().
TypedArrayElement = 1 << 4, // A typed array element, or scalar typed
// object field.
Element = 1 << 1, // A Value member of obj->elements or
// a typed object.
UnboxedElement = 1 << 2, // An unboxed scalar or reference member of
// a typed array, typed object, or unboxed
// object.
DynamicSlot = 1 << 3, // A Value member of obj->slots.
FixedSlot = 1 << 4, // A Value member of obj->fixedSlots().
DOMProperty = 1 << 5, // A DOM property
FrameArgument = 1 << 6, // An argument kept on the stack frame
AsmJSGlobalVar = 1 << 7, // An asm.js global var
@ -8319,7 +8320,7 @@ class MLoadUnboxedObjectOrNull
return congruentIfOperandsEqual(other);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Load(AliasSet::Element);
return AliasSet::Load(AliasSet::UnboxedElement);
}
ALLOW_CLONE(MLoadUnboxedObjectOrNull)
@ -8368,7 +8369,7 @@ class MLoadUnboxedString
return congruentIfOperandsEqual(ins);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Load(AliasSet::Element);
return AliasSet::Load(AliasSet::UnboxedElement);
}
ALLOW_CLONE(MLoadUnboxedString)
@ -8378,13 +8379,11 @@ class MStoreElementCommon
{
MIRType elementType_;
bool needsBarrier_;
bool racy_; // if true, exempted from normal data race req. during par. exec.
protected:
MStoreElementCommon()
: elementType_(MIRType_Value),
needsBarrier_(false),
racy_(false)
needsBarrier_(false)
{ }
public:
@ -8401,12 +8400,6 @@ class MStoreElementCommon
void setNeedsBarrier() {
needsBarrier_ = true;
}
bool racy() const {
return racy_;
}
void setRacy() {
racy_ = true;
}
};
// Store a value to a dense array slots vector.
@ -8557,8 +8550,7 @@ class MStoreUnboxedObjectOrNull
return offsetAdjustment_;
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
// Use AliasSet::Element for reference typed object fields.
return AliasSet::Store(AliasSet::Element);
return AliasSet::Store(AliasSet::UnboxedElement);
}
// For StoreUnboxedObjectOrNullPolicy.
@ -8608,8 +8600,7 @@ class MStoreUnboxedString
return offsetAdjustment_;
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
// Use AliasSet::Element for reference typed object fields.
return AliasSet::Store(AliasSet::Element);
return AliasSet::Store(AliasSet::UnboxedElement);
}
ALLOW_CLONE(MStoreUnboxedString)
@ -8834,22 +8825,23 @@ enum MemoryBarrierRequirement
// Also see comments above MMemoryBarrier, below.
class MLoadTypedArrayElement
// Load an unboxed scalar value from a typed array or other object.
class MLoadUnboxedScalar
: public MBinaryInstruction,
public SingleObjectPolicy::Data
{
Scalar::Type arrayType_;
Scalar::Type indexType_;
Scalar::Type readType_;
bool requiresBarrier_;
int32_t offsetAdjustment_;
bool canonicalizeDoubles_;
MLoadTypedArrayElement(MDefinition *elements, MDefinition *index,
Scalar::Type arrayType, MemoryBarrierRequirement requiresBarrier,
int32_t offsetAdjustment, bool canonicalizeDoubles)
MLoadUnboxedScalar(MDefinition *elements, MDefinition *index,
Scalar::Type indexType, MemoryBarrierRequirement requiresBarrier,
int32_t offsetAdjustment, bool canonicalizeDoubles)
: MBinaryInstruction(elements, index),
arrayType_(arrayType),
readType_(arrayType),
indexType_(indexType),
readType_(indexType),
requiresBarrier_(requiresBarrier == DoesRequireMemoryBarrier),
offsetAdjustment_(offsetAdjustment),
canonicalizeDoubles_(canonicalizeDoubles)
@ -8861,21 +8853,22 @@ class MLoadTypedArrayElement
setMovable();
MOZ_ASSERT(IsValidElementsType(elements, offsetAdjustment));
MOZ_ASSERT(index->type() == MIRType_Int32);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::MaxTypedArrayViewType);
MOZ_ASSERT(indexType >= 0 && indexType < Scalar::MaxTypedArrayViewType);
}
public:
INSTRUCTION_HEADER(LoadTypedArrayElement)
INSTRUCTION_HEADER(LoadUnboxedScalar)
static MLoadTypedArrayElement *New(TempAllocator &alloc, MDefinition *elements, MDefinition *index,
Scalar::Type arrayType,
MemoryBarrierRequirement requiresBarrier=DoesNotRequireMemoryBarrier,
int32_t offsetAdjustment = 0,
bool canonicalizeDoubles = true)
static MLoadUnboxedScalar *New(TempAllocator &alloc, MDefinition *elements, MDefinition *index,
Scalar::Type indexType,
MemoryBarrierRequirement requiresBarrier
= DoesNotRequireMemoryBarrier,
int32_t offsetAdjustment = 0,
bool canonicalizeDoubles = true)
{
return new(alloc) MLoadTypedArrayElement(elements, index, arrayType,
requiresBarrier, offsetAdjustment,
canonicalizeDoubles);
return new(alloc) MLoadUnboxedScalar(elements, index, indexType,
requiresBarrier, offsetAdjustment,
canonicalizeDoubles);
}
void setReadType(Scalar::Type type) {
@ -8885,12 +8878,12 @@ class MLoadTypedArrayElement
return readType_;
}
Scalar::Type arrayType() const {
return arrayType_;
Scalar::Type indexType() const {
return indexType_;
}
bool fallible() const {
// Bailout if the result does not fit in an int32.
return arrayType_ == Scalar::Uint32 && type() == MIRType_Int32;
return readType_ == Scalar::Uint32 && type() == MIRType_Int32;
}
bool requiresMemoryBarrier() const {
return requiresBarrier_;
@ -8911,17 +8904,17 @@ class MLoadTypedArrayElement
// When a barrier is needed make the instruction effectful by
// giving it a "store" effect.
if (requiresBarrier_)
return AliasSet::Store(AliasSet::TypedArrayElement);
return AliasSet::Load(AliasSet::TypedArrayElement);
return AliasSet::Store(AliasSet::UnboxedElement);
return AliasSet::Load(AliasSet::UnboxedElement);
}
bool congruentTo(const MDefinition *ins) const MOZ_OVERRIDE {
if (requiresBarrier_)
return false;
if (!ins->isLoadTypedArrayElement())
if (!ins->isLoadUnboxedScalar())
return false;
const MLoadTypedArrayElement *other = ins->toLoadTypedArrayElement();
if (arrayType_ != other->arrayType_)
const MLoadUnboxedScalar *other = ins->toLoadUnboxedScalar();
if (indexType_ != other->indexType_)
return false;
if (readType_ != other->readType_)
return false;
@ -8936,9 +8929,9 @@ class MLoadTypedArrayElement
void computeRange(TempAllocator &alloc) MOZ_OVERRIDE;
bool canProduceFloat32() const MOZ_OVERRIDE { return arrayType_ == Scalar::Float32; }
bool canProduceFloat32() const MOZ_OVERRIDE { return indexType_ == Scalar::Float32; }
ALLOW_CLONE(MLoadTypedArrayElement)
ALLOW_CLONE(MLoadUnboxedScalar)
};
// Load a value from a typed array. Out-of-bounds accesses are handled in-line.
@ -8993,7 +8986,7 @@ class MLoadTypedArrayElementHole
return congruentIfOperandsEqual(other);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Load(AliasSet::TypedArrayElement);
return AliasSet::Load(AliasSet::UnboxedElement);
}
bool canProduceFloat32() const MOZ_OVERRIDE { return arrayType_ == Scalar::Float32; }
@ -9049,7 +9042,7 @@ class MLoadTypedArrayElementStatic
void setOffset(int32_t offset) { offset_ = offset; }
bool congruentTo(const MDefinition *ins) const MOZ_OVERRIDE;
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Load(AliasSet::TypedArrayElement);
return AliasSet::Load(AliasSet::UnboxedElement);
}
bool needsBoundsCheck() const { return needsBoundsCheck_; }
@ -9069,13 +9062,13 @@ class MLoadTypedArrayElementStatic
void collectRangeInfoPreTrunc() MOZ_OVERRIDE;
};
// Base class for MIR ops that write to typed arrays.
class StoreTypedArrayBase
// Base class for MIR ops that write unboxed scalar values.
class StoreUnboxedScalarBase
{
Scalar::Type writeType_;
protected:
explicit StoreTypedArrayBase(Scalar::Type writeType)
explicit StoreUnboxedScalarBase(Scalar::Type writeType)
: writeType_(writeType)
{
MOZ_ASSERT(isIntegerWrite() || isFloatWrite() || isSimdWrite());
@ -9109,27 +9102,24 @@ class StoreTypedArrayBase
}
};
class MStoreTypedArrayElement
// Store an unboxed scalar value to a typed array or other object.
class MStoreUnboxedScalar
: public MTernaryInstruction,
public StoreTypedArrayBase,
public StoreTypedArrayPolicy::Data
public StoreUnboxedScalarBase,
public StoreUnboxedScalarPolicy::Data
{
Scalar::Type arrayType_;
Scalar::Type indexType_;
bool requiresBarrier_;
int32_t offsetAdjustment_;
// See note in MStoreElementCommon.
bool racy_;
MStoreTypedArrayElement(MDefinition *elements, MDefinition *index, MDefinition *value,
Scalar::Type arrayType, MemoryBarrierRequirement requiresBarrier,
int32_t offsetAdjustment)
MStoreUnboxedScalar(MDefinition *elements, MDefinition *index, MDefinition *value,
Scalar::Type indexType, MemoryBarrierRequirement requiresBarrier,
int32_t offsetAdjustment)
: MTernaryInstruction(elements, index, value),
StoreTypedArrayBase(arrayType),
arrayType_(arrayType),
StoreUnboxedScalarBase(indexType),
indexType_(indexType),
requiresBarrier_(requiresBarrier == DoesRequireMemoryBarrier),
offsetAdjustment_(offsetAdjustment),
racy_(false)
offsetAdjustment_(offsetAdjustment)
{
if (requiresBarrier_)
setGuard(); // Not removable or movable
@ -9137,23 +9127,25 @@ class MStoreTypedArrayElement
setMovable();
MOZ_ASSERT(IsValidElementsType(elements, offsetAdjustment));
MOZ_ASSERT(index->type() == MIRType_Int32);
MOZ_ASSERT(arrayType >= 0 && arrayType < Scalar::MaxTypedArrayViewType);
MOZ_ASSERT(indexType >= 0 && indexType < Scalar::MaxTypedArrayViewType);
}
public:
INSTRUCTION_HEADER(StoreTypedArrayElement)
INSTRUCTION_HEADER(StoreUnboxedScalar)
static MStoreTypedArrayElement *New(TempAllocator &alloc, MDefinition *elements, MDefinition *index,
MDefinition *value, Scalar::Type arrayType,
MemoryBarrierRequirement requiresBarrier = DoesNotRequireMemoryBarrier,
int32_t offsetAdjustment = 0)
static MStoreUnboxedScalar *New(TempAllocator &alloc,
MDefinition *elements, MDefinition *index,
MDefinition *value, Scalar::Type indexType,
MemoryBarrierRequirement requiresBarrier =
DoesNotRequireMemoryBarrier,
int32_t offsetAdjustment = 0)
{
return new(alloc) MStoreTypedArrayElement(elements, index, value, arrayType,
requiresBarrier, offsetAdjustment);
return new(alloc) MStoreUnboxedScalar(elements, index, value, indexType,
requiresBarrier, offsetAdjustment);
}
Scalar::Type arrayType() const {
return arrayType_;
Scalar::Type indexType() const {
return indexType_;
}
MDefinition *elements() const {
return getOperand(0);
@ -9165,7 +9157,7 @@ class MStoreTypedArrayElement
return getOperand(2);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Store(AliasSet::TypedArrayElement);
return AliasSet::Store(AliasSet::UnboxedElement);
}
bool requiresMemoryBarrier() const {
return requiresBarrier_;
@ -9173,30 +9165,24 @@ class MStoreTypedArrayElement
int32_t offsetAdjustment() const {
return offsetAdjustment_;
}
bool racy() const {
return racy_;
}
void setRacy() {
racy_ = true;
}
TruncateKind operandTruncateKind(size_t index) const MOZ_OVERRIDE;
bool canConsumeFloat32(MUse *use) const MOZ_OVERRIDE {
return use == getUseFor(2) && arrayType_ == Scalar::Float32;
return use == getUseFor(2) && writeType() == Scalar::Float32;
}
ALLOW_CLONE(MStoreTypedArrayElement)
ALLOW_CLONE(MStoreUnboxedScalar)
};
class MStoreTypedArrayElementHole
: public MAryInstruction<4>,
public StoreTypedArrayBase,
public StoreUnboxedScalarBase,
public StoreTypedArrayHolePolicy::Data
{
MStoreTypedArrayElementHole(MDefinition *elements, MDefinition *length, MDefinition *index,
MDefinition *value, Scalar::Type arrayType)
: MAryInstruction<4>(),
StoreTypedArrayBase(arrayType)
StoreUnboxedScalarBase(arrayType)
{
initOperand(0, elements);
initOperand(1, length);
@ -9237,7 +9223,7 @@ class MStoreTypedArrayElementHole
return getOperand(3);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Store(AliasSet::TypedArrayElement);
return AliasSet::Store(AliasSet::UnboxedElement);
}
TruncateKind operandTruncateKind(size_t index) const MOZ_OVERRIDE;
@ -9251,13 +9237,13 @@ class MStoreTypedArrayElementHole
// Store a value infallibly to a statically known typed array.
class MStoreTypedArrayElementStatic :
public MBinaryInstruction,
public StoreTypedArrayBase,
public StoreUnboxedScalarBase,
public StoreTypedArrayElementStaticPolicy::Data
{
MStoreTypedArrayElementStatic(JSObject *someTypedArray, MDefinition *ptr, MDefinition *v,
int32_t offset, bool needsBoundsCheck)
: MBinaryInstruction(ptr, v),
StoreTypedArrayBase(AnyTypedArrayType(someTypedArray)),
StoreUnboxedScalarBase(AnyTypedArrayType(someTypedArray)),
someTypedArray_(someTypedArray),
offset_(offset), needsBoundsCheck_(needsBoundsCheck)
{}
@ -9296,7 +9282,7 @@ class MStoreTypedArrayElementStatic :
int32_t offset() const { return offset_; }
void setOffset(int32_t offset) { offset_ = offset; }
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Store(AliasSet::TypedArrayElement);
return AliasSet::Store(AliasSet::UnboxedElement);
}
TruncateKind operandTruncateKind(size_t index) const MOZ_OVERRIDE;
@ -9723,8 +9709,10 @@ class MGetPropertyPolymorphic
return getOperand(0);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Load(AliasSet::ObjectFields | AliasSet::FixedSlot | AliasSet::DynamicSlot |
(unboxedGroups_.empty() ? 0 : (AliasSet::TypedArrayElement | AliasSet::Element)));
return AliasSet::Load(AliasSet::ObjectFields |
AliasSet::FixedSlot |
AliasSet::DynamicSlot |
(!unboxedGroups_.empty() ? AliasSet::UnboxedElement : 0));
}
bool mightAlias(const MDefinition *store) const MOZ_OVERRIDE;
@ -9807,8 +9795,10 @@ class MSetPropertyPolymorphic
needsBarrier_ = true;
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Store(AliasSet::ObjectFields | AliasSet::FixedSlot | AliasSet::DynamicSlot |
(unboxedGroups_.empty() ? 0 : (AliasSet::TypedArrayElement | AliasSet::Element)));
return AliasSet::Store(AliasSet::ObjectFields |
AliasSet::FixedSlot |
AliasSet::DynamicSlot |
(!unboxedGroups_.empty() ? AliasSet::UnboxedElement : 0));
}
};
@ -12228,8 +12218,8 @@ class MRecompileCheck : public MNullaryInstruction
};
// All barriered operations - MMemoryBarrier, MCompareExchangeTypedArrayElement,
// and MAtomicTypedArrayElementBinop, as well as MLoadTypedArrayElement and
// MStoreTypedArrayElement when they are marked as requiring a memory barrer - have
// and MAtomicTypedArrayElementBinop, as well as MLoadUnboxedScalar and
// MStoreUnboxedSclaar when they are marked as requiring a memory barrer - have
// the following attributes:
//
// - Not movable
@ -12266,7 +12256,7 @@ class MMemoryBarrier
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Store(AliasSet::TypedArrayElement);
return AliasSet::Store(AliasSet::UnboxedElement);
}
};
@ -12321,7 +12311,7 @@ class MCompareExchangeTypedArrayElement
return arrayType_;
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Store(AliasSet::TypedArrayElement);
return AliasSet::Store(AliasSet::UnboxedElement);
}
};
@ -12376,7 +12366,7 @@ class MAtomicTypedArrayElementBinop
return getOperand(2);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {
return AliasSet::Store(AliasSet::TypedArrayElement);
return AliasSet::Store(AliasSet::UnboxedElement);
}
};

View File

@ -179,10 +179,12 @@ namespace jit {
_(InArray) \
_(LoadElement) \
_(LoadElementHole) \
_(LoadUnboxedScalar) \
_(LoadUnboxedObjectOrNull) \
_(LoadUnboxedString) \
_(StoreElement) \
_(StoreElementHole) \
_(StoreUnboxedScalar) \
_(StoreUnboxedObjectOrNull) \
_(StoreUnboxedString) \
_(ConvertUnboxedObjectToNative) \
@ -190,10 +192,8 @@ namespace jit {
_(ArrayPush) \
_(ArrayConcat) \
_(ArrayJoin) \
_(LoadTypedArrayElement) \
_(LoadTypedArrayElementHole) \
_(LoadTypedArrayElementStatic) \
_(StoreTypedArrayElement) \
_(StoreTypedArrayElementHole) \
_(StoreTypedArrayElementStatic) \
_(CompareExchangeTypedArrayElement) \

View File

@ -347,7 +347,7 @@ MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const T &src, AnyRegi
load32(src, dest.gpr());
// Bail out if the value doesn't fit into a signed int32 value. This
// is what allows MLoadTypedArrayElement to have a type() of
// is what allows MLoadUnboxedScalar to have a type() of
// MIRType_Int32 for UInt32 array loads.
branchTest32(Assembler::Signed, dest.gpr(), dest.gpr(), fail);
}

View File

@ -1678,7 +1678,7 @@ GetTypedArrayRange(TempAllocator &alloc, Scalar::Type type)
}
void
MLoadTypedArrayElement::computeRange(TempAllocator &alloc)
MLoadUnboxedScalar::computeRange(TempAllocator &alloc)
{
// We have an Int32 type and if this is a UInt32 load it may produce a value
// outside of our range, but we have a bailout to handle those cases.
@ -2642,7 +2642,7 @@ MToDouble::operandTruncateKind(size_t index) const
}
MDefinition::TruncateKind
MStoreTypedArrayElement::operandTruncateKind(size_t index) const
MStoreUnboxedScalar::operandTruncateKind(size_t index) const
{
// An integer store truncates the stored value.
return index == 2 && isIntegerWrite() ? Truncate : NoTruncate;

View File

@ -876,8 +876,9 @@ InstanceOfPolicy::adjustInputs(TempAllocator &alloc, MInstruction *def)
}
bool
StoreTypedArrayPolicy::adjustValueInput(TempAllocator &alloc, MInstruction *ins,
Scalar::Type writeType, MDefinition *value, int valueOperand)
StoreUnboxedScalarPolicy::adjustValueInput(TempAllocator &alloc, MInstruction *ins,
Scalar::Type writeType, MDefinition *value,
int valueOperand)
{
// Storing a SIMD value just implies that we might need a SimdUnbox.
if (Scalar::isSimdType(writeType))
@ -962,11 +963,11 @@ StoreTypedArrayPolicy::adjustValueInput(TempAllocator &alloc, MInstruction *ins,
}
bool
StoreTypedArrayPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
StoreUnboxedScalarPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
{
SingleObjectPolicy::staticAdjustInputs(alloc, ins);
MStoreTypedArrayElement *store = ins->toStoreTypedArrayElement();
MStoreUnboxedScalar *store = ins->toStoreUnboxedScalar();
MOZ_ASSERT(IsValidElementsType(store->elements(), store->offsetAdjustment()));
MOZ_ASSERT(store->index()->type() == MIRType_Int32);
@ -981,7 +982,7 @@ StoreTypedArrayHolePolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
MOZ_ASSERT(store->index()->type() == MIRType_Int32);
MOZ_ASSERT(store->length()->type() == MIRType_Int32);
return StoreTypedArrayPolicy::adjustValueInput(alloc, ins, store->arrayType(), store->value(), 3);
return StoreUnboxedScalarPolicy::adjustValueInput(alloc, ins, store->arrayType(), store->value(), 3);
}
bool
@ -990,7 +991,7 @@ StoreTypedArrayElementStaticPolicy::adjustInputs(TempAllocator &alloc, MInstruct
MStoreTypedArrayElementStatic *store = ins->toStoreTypedArrayElementStatic();
return ConvertToInt32Policy<0>::staticAdjustInputs(alloc, ins) &&
StoreTypedArrayPolicy::adjustValueInput(alloc, ins, store->accessType(), store->value(), 1);
StoreUnboxedScalarPolicy::adjustValueInput(alloc, ins, store->accessType(), store->value(), 1);
}
bool
@ -1117,7 +1118,7 @@ FilterTypeSetPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
_(SimdSwizzlePolicy) \
_(StoreTypedArrayElementStaticPolicy) \
_(StoreTypedArrayHolePolicy) \
_(StoreTypedArrayPolicy) \
_(StoreUnboxedScalarPolicy) \
_(StoreUnboxedObjectOrNullPolicy) \
_(TestPolicy) \
_(AllDoublePolicy) \

View File

@ -439,7 +439,7 @@ class InstanceOfPolicy MOZ_FINAL : public TypePolicy
class StoreTypedArrayHolePolicy;
class StoreTypedArrayElementStaticPolicy;
class StoreTypedArrayPolicy : public TypePolicy
class StoreUnboxedScalarPolicy : public TypePolicy
{
private:
static bool adjustValueInput(TempAllocator &alloc, MInstruction *ins, Scalar::Type arrayType,
@ -453,14 +453,14 @@ class StoreTypedArrayPolicy : public TypePolicy
virtual bool adjustInputs(TempAllocator &alloc, MInstruction *ins) MOZ_OVERRIDE;
};
class StoreTypedArrayHolePolicy MOZ_FINAL : public StoreTypedArrayPolicy
class StoreTypedArrayHolePolicy MOZ_FINAL : public StoreUnboxedScalarPolicy
{
public:
EMPTY_DATA_;
virtual bool adjustInputs(TempAllocator &alloc, MInstruction *ins) MOZ_OVERRIDE;
};
class StoreTypedArrayElementStaticPolicy MOZ_FINAL : public StoreTypedArrayPolicy
class StoreTypedArrayElementStaticPolicy MOZ_FINAL : public StoreUnboxedScalarPolicy
{
public:
EMPTY_DATA_;