Issue #2026 - Part 1 - Implement BigInt64 and BigUint64Array. https://bugzilla.mozilla.org/show_bug.cgi?id=1456569

This commit is contained in:
Brian Smith 2023-07-24 23:30:27 -05:00 committed by roytam1
commit b64643e410
36 changed files with 788 additions and 232 deletions

View file

@ -3204,6 +3204,9 @@ StoreToTypedArray(JSContext* cx, MacroAssembler& masm, Scalar::Type type, Addres
} else {
masm.jump(failure);
}
} else if (type == Scalar::BigInt64 || type == Scalar::BigUint64) {
// FIXME: https://bugzil.la/1536703
masm.jump(failure);
} else {
Label notInt32;
masm.branchTestInt32(Assembler::NotEqual, value, &notInt32);

View file

@ -724,34 +724,9 @@ ScalarTypeToMIRType(Scalar::Type type)
return MIRType::Int16x8;
case Scalar::Int32x4:
return MIRType::Int32x4;
case Scalar::MaxTypedArrayViewType:
break;
}
MOZ_CRASH("unexpected SIMD kind");
}
static inline unsigned
ScalarTypeToLength(Scalar::Type type)
{
switch (type) {
case Scalar::Int8:
case Scalar::Uint8:
case Scalar::Int16:
case Scalar::Uint16:
case Scalar::Int32:
case Scalar::Uint32:
case Scalar::Int64:
case Scalar::Float32:
case Scalar::Float64:
case Scalar::Uint8Clamped:
return 1;
case Scalar::Float32x4:
case Scalar::Int32x4:
return 4;
case Scalar::Int16x8:
return 8;
case Scalar::Int8x16:
return 16;
case Scalar::BigInt64:
case Scalar::BigUint64:
MOZ_CRASH("NYI");
case Scalar::MaxTypedArrayViewType:
break;
}

View file

@ -6005,7 +6005,14 @@ jit::ElementAccessIsTypedArray(CompilerConstraintList* constraints,
return false;
*arrayType = types->getTypedArrayType(constraints);
return *arrayType != Scalar::MaxTypedArrayViewType;
// FIXME: https://bugzil.la/1536699
if (*arrayType == Scalar::MaxTypedArrayViewType ||
Scalar::isBigIntType(*arrayType)) {
return false;
}
return true;
}
bool

View file

@ -14443,6 +14443,9 @@ MIRTypeForTypedArrayRead(Scalar::Type arrayType, bool observedDouble)
return MIRType::Float32;
case Scalar::Float64:
return MIRType::Double;
case Scalar::BigInt64:
case Scalar::BigUint64:
return MIRType::BigInt;
default:
break;
}

View file

@ -644,7 +644,7 @@ void
MacroAssembler::canonicalizeFloatIfDeterministic(FloatRegister reg)
{
#ifdef JS_MORE_DETERMINISTIC
// See the comment in TypedArrayObjectTemplate::getIndexValue.
// See the comment in TypedArrayObjectTemplate::getElement.
canonicalizeFloat(reg);
#endif // JS_MORE_DETERMINISTIC
}
@ -662,7 +662,7 @@ void
MacroAssembler::canonicalizeDoubleIfDeterministic(FloatRegister reg)
{
#ifdef JS_MORE_DETERMINISTIC
// See the comment in TypedArrayObjectTemplate::getIndexValue.
// See the comment in TypedArrayObjectTemplate::getElement.
canonicalizeDouble(reg);
#endif // JS_MORE_DETERMINISTIC
}

View file

@ -345,6 +345,11 @@ MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const T& src, AnyRegi
branchTest32(Assembler::Signed, dest.gpr(), dest.gpr(), fail);
}
break;
case Scalar::BigInt64:
case Scalar::BigUint64:
// FIXME: https://bugzil.la/1536702
jump(fail);
break;
case Scalar::Float32:
loadFloat32(src, dest.fpu());
canonicalizeFloat(dest.fpu());
@ -447,17 +452,25 @@ MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const T& src, const V
tagValue(JSVAL_TYPE_INT32, temp, dest);
}
break;
case Scalar::Float32:
case Scalar::Float32: {
loadFromTypedArray(arrayType, src, AnyRegister(ScratchFloat32Reg), dest.scratchReg(),
nullptr);
convertFloat32ToDouble(ScratchFloat32Reg, ScratchDoubleReg);
boxDouble(ScratchDoubleReg, dest);
break;
case Scalar::Float64:
}
case Scalar::Float64: {
loadFromTypedArray(arrayType, src, AnyRegister(ScratchDoubleReg), dest.scratchReg(),
nullptr);
boxDouble(ScratchDoubleReg, dest);
break;
}
// FIXME: https://bugzil.la/1536702
case Scalar::BigInt64:
case Scalar::BigUint64: {
jump(fail);
break;
}
default:
MOZ_CRASH("Invalid typed array type");
}

View file

@ -1780,6 +1780,8 @@ GetTypedArrayRange(TempAllocator& alloc, Scalar::Type type)
case Scalar::Int32:
return Range::NewInt32Range(alloc, INT32_MIN, INT32_MAX);
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Int64:
case Scalar::Float32:
case Scalar::Float64:

View file

@ -445,6 +445,8 @@ CodeGeneratorX64::wasmStore(const wasm::MemoryAccessDesc& access, const LAllocat
case Scalar::Int16x8:
case Scalar::Int32x4:
case Scalar::Uint8Clamped:
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");
}

View file

@ -239,6 +239,8 @@ LIRGeneratorX64::visitWasmStore(MWasmStore* ins)
case Scalar::Int32x4:
valueAlloc = useRegisterAtStart(value);
break;
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Uint8Clamped:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");

View file

@ -713,6 +713,8 @@ MacroAssembler::wasmLoad(const wasm::MemoryAccessDesc& access, Operand srcAddr,
break;
case Scalar::Int64:
MOZ_CRASH("int64 loads must use load64");
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Uint8Clamped:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");
@ -759,6 +761,8 @@ MacroAssembler::wasmLoadI64(const wasm::MemoryAccessDesc& access, Operand srcAdd
case Scalar::Int16x8:
case Scalar::Int32x4:
MOZ_CRASH("non-int64 loads should use load()");
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Uint8Clamped:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");
@ -822,6 +826,8 @@ MacroAssembler::wasmStore(const wasm::MemoryAccessDesc& access, AnyRegister valu
MOZ_ASSERT(access.numSimdElems() == 8, "unexpected partial store");
storeUnalignedSimd128Int(value.fpu(), dstAddr);
break;
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Uint8Clamped:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");

View file

@ -402,6 +402,8 @@ CodeGeneratorX86Shared::visitOutOfLineLoadTypedArrayOutOfBounds(OutOfLineLoadTyp
case Scalar::Int8x16:
case Scalar::Int16x8:
case Scalar::Int32x4:
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");
case Scalar::Float32:

View file

@ -326,6 +326,8 @@ LIRGeneratorX86::visitWasmStore(MWasmStore* ins)
add(lir, ins);
return;
}
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Uint8Clamped:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");

View file

@ -616,6 +616,8 @@ MacroAssembler::wasmLoad(const wasm::MemoryAccessDesc& access, Operand srcAddr,
vmovdquWithPatch(srcAddr, out.fpu());
break;
case Scalar::Int64:
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Uint8Clamped:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected type");
@ -727,6 +729,8 @@ MacroAssembler::wasmLoadI64(const wasm::MemoryAccessDesc& access, Operand srcAdd
case Scalar::Int16x8:
case Scalar::Int32x4:
MOZ_CRASH("non-int64 loads should use load()");
case Scalar::BigInt64:
case Scalar::BigUint64:
case Scalar::Uint8Clamped:
case Scalar::MaxTypedArrayViewType:
MOZ_CRASH("unexpected array type");
@ -790,6 +794,8 @@ MacroAssembler::wasmStore(const wasm::MemoryAccessDesc& access, AnyRegister valu
case Scalar::Int64:
MOZ_CRASH("Should be handled in storeI64.");
case Scalar::MaxTypedArrayViewType:
case Scalar::BigInt64:
case Scalar::BigUint64:
MOZ_CRASH("unexpected type");
}
append(wasm::MemoryPatch(size()));