Commit 8732a586 authored by Lars T Hansen's avatar Lars T Hansen
Browse files

Bug 1669179 - Clean up predicate for unaligned FP accesses. r=nbp

Several interlinked changes here:

- the predicate SupportsFastUnalignedAccesses is renamed as SupportsFastUnalignedFPAccesses,
  as this is the sense that is needed - we already assume that unaligned integer accesses
  are supported.
- DataView accessors that use this predicate are rewritten to test that the access type
  is an FP access before using this predicate
- In Wasm, the uses of this predicate only pertain to when FP accesses are used to
  implement inlined/unrolled memory.copy and memory.fill, so move the predicate so
  that it guards this case only, not all cases.

Differential Revision: https://phabricator.services.mozilla.com/D123356
parent 30e0a7da
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -125,6 +125,29 @@ static inline bool isBigIntType(Type atype) {
  MOZ_CRASH("invalid scalar type");
}

static inline bool isFloatingType(Type atype) {
  switch (atype) {
    case Int8:
    case Uint8:
    case Uint8Clamped:
    case Int16:
    case Uint16:
    case Int32:
    case Uint32:
    case Int64:
    case BigInt64:
    case BigUint64:
      return false;
    case Float32:
    case Float64:
    case Simd128:
      return true;
    case MaxTypedArrayViewType:
      break;
  }
  MOZ_CRASH("invalid scalar type");
}

static inline const char* name(Type atype) {
  switch (atype) {
    case Int8:
+7 −4
Original line number Diff line number Diff line
@@ -12696,8 +12696,9 @@ void CodeGenerator::visitLoadDataViewElement(LLoadDataViewElement* lir) {
                ToBoolean(littleEndian) == MOZ_LITTLE_ENDIAN();
  // Directly load if no byte swap is needed and the platform supports unaligned
  // accesses for floating point registers.
  if (noSwap && MacroAssembler::SupportsFastUnalignedAccesses()) {
  // accesses for the access.  (Such support is assumed for integer types.)
  if (noSwap && (!Scalar::isFloatingType(storageType) ||
                 MacroAssembler::SupportsFastUnalignedFPAccesses())) {
    if (!Scalar::isBigIntType(storageType)) {
      Label fail;
      masm.loadFromTypedArray(storageType, source, out, temp, &fail);
@@ -13077,8 +13078,10 @@ void CodeGenerator::visitStoreDataViewElement(LStoreDataViewElement* lir) {
                ToBoolean(littleEndian) == MOZ_LITTLE_ENDIAN();
  // Directly store if no byte swap is needed and the platform supports
  // unaligned accesses for floating point registers.
  if (noSwap && MacroAssembler::SupportsFastUnalignedAccesses()) {
  // unaligned accesses for the access.  (Such support is assumed for integer
  // types.)
  if (noSwap && (!Scalar::isFloatingType(writeType) ||
                 MacroAssembler::SupportsFastUnalignedFPAccesses())) {
    if (!Scalar::isBigIntType(writeType)) {
      StoreToTypedArray(masm, writeType, value, dest);
    } else {
+4 −1
Original line number Diff line number Diff line
@@ -1686,7 +1686,10 @@ class Assembler : public AssemblerShared {

  static bool SupportsFloatingPoint() { return HasVFP(); }
  static bool SupportsUnalignedAccesses() { return HasARMv7(); }
  static bool SupportsFastUnalignedAccesses() { return false; }
  // Note, returning false here is technically wrong, but one has to go via the
  // as_vldr_unaligned and as_vstr_unaligned instructions to get proper behavior
  // and those are NEON-specific and have to be asked for specifically.
  static bool SupportsFastUnalignedFPAccesses() { return false; }

  static bool HasRoundInstruction(RoundingMode mode) { return false; }

+1 −1
Original line number Diff line number Diff line
@@ -537,7 +537,7 @@ class Assembler : public vixl::Assembler {

  static bool SupportsFloatingPoint() { return true; }
  static bool SupportsUnalignedAccesses() { return true; }
  static bool SupportsFastUnalignedAccesses() { return true; }
  static bool SupportsFastUnalignedFPAccesses() { return true; }
  static bool SupportsWasmSimd() { return true; }

  static bool HasRoundInstruction(RoundingMode mode) {
+1 −1
Original line number Diff line number Diff line
@@ -1229,7 +1229,7 @@ class AssemblerMIPSShared : public AssemblerShared {
#endif
  }
  static bool SupportsUnalignedAccesses() { return true; }
  static bool SupportsFastUnalignedAccesses() { return false; }
  static bool SupportsFastUnalignedFPAccesses() { return false; }

  static bool HasRoundInstruction(RoundingMode mode) { return false; }

Loading