bool StoreTypedArrayElementStaticPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins) { MStoreTypedArrayElementStatic *store = ins->toStoreTypedArrayElementStatic(); return ConvertToInt32Policy<0>::staticAdjustInputs(alloc, ins) && StoreUnboxedScalarPolicy::adjustValueInput(alloc, ins, store->accessType(), store->value(), 1); }
void CodeGeneratorX86::visitStoreTypedArrayElementStatic(LStoreTypedArrayElementStatic* ins) { MStoreTypedArrayElementStatic* mir = ins->mir(); Scalar::Type accessType = mir->accessType(); Register ptr = ToRegister(ins->ptr()); const LAllocation* value = ins->value(); canonicalizeIfDeterministic(accessType, value); uint32_t offset = mir->offset(); MOZ_ASSERT_IF(mir->needsBoundsCheck(), offset == 0); Label rejoin; if (mir->needsBoundsCheck()) { MOZ_ASSERT(offset == 0); masm.cmpPtr(ptr, ImmWord(mir->length())); masm.j(Assembler::AboveOrEqual, &rejoin); } Operand dstAddr(ptr, int32_t(mir->base().asValue()) + int32_t(offset)); switch (accessType) { case Scalar::Int8: case Scalar::Uint8Clamped: case Scalar::Uint8: masm.movbWithPatch(ToRegister(value), dstAddr); break; case Scalar::Int16: case Scalar::Uint16: masm.movwWithPatch(ToRegister(value), dstAddr); break; case Scalar::Int32: case Scalar::Uint32: masm.movlWithPatch(ToRegister(value), dstAddr); break; case Scalar::Float32: masm.vmovssWithPatch(ToFloatRegister(value), dstAddr); break; case Scalar::Float64: masm.vmovsdWithPatch(ToFloatRegister(value), dstAddr); break; default: MOZ_CRASH("unexpected type"); } if (rejoin.used()) masm.bind(&rejoin); }
void CodeGeneratorX86::visitStoreTypedArrayElementStatic(LStoreTypedArrayElementStatic* ins) { MStoreTypedArrayElementStatic* mir = ins->mir(); Scalar::Type accessType = mir->accessType(); Register ptr = ToRegister(ins->ptr()); const LAllocation* value = ins->value(); uint32_t offset = mir->offset(); if (!mir->needsBoundsCheck()) { Operand dstAddr(ptr, int32_t(mir->base().asValue()) + int32_t(offset)); store(accessType, value, dstAddr); return; } MOZ_ASSERT(offset == 0); masm.cmpPtr(ptr, ImmWord(mir->length())); Label rejoin; masm.j(Assembler::AboveOrEqual, &rejoin); Operand dstAddr(ptr, int32_t(mir->base().asValue())); store(accessType, value, dstAddr); masm.bind(&rejoin); }