mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-30 13:40:51 +00:00
!7056 [Bug] atomics方法Detach后未报异常
Merge pull request !7056 from liujia178/mjsunit_atomics
This commit is contained in:
commit
3e82cd0615
@ -113,10 +113,8 @@ JSTaggedValue AtomicHelper::AtomicStore(JSThread *thread, const JSHandle<JSTagge
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
bufferTag = JSHandle<JSTaggedValue>(thread, integerValue);
|
||||
}
|
||||
if (BuiltinsArrayBuffer::IsDetachedBuffer(buffer.GetTaggedValue())) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "The ArrayBuffer of this value is detached buffer.",
|
||||
JSTaggedValue::Exception());
|
||||
}
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(typedArray));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
BuiltinsArrayBuffer::SetValueInBuffer(thread, buffer.GetTaggedValue(), indexedPosition, type, bufferTag, true);
|
||||
return bufferTag.GetTaggedValue();
|
||||
}
|
||||
@ -129,10 +127,8 @@ JSTaggedValue AtomicHelper::AtomicLoad(JSThread *thread, const JSHandle<JSTagged
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
uint32_t indexedPosition = ValidateAtomicAccess(thread, typedArray, index);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (BuiltinsArrayBuffer::IsDetachedBuffer(buffer.GetTaggedValue())) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "The ArrayBuffer of this value is detached buffer.",
|
||||
JSTaggedValue::Exception());
|
||||
}
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(typedArray));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
JSHandle<JSTaggedValue> arrayTypeName(thread,
|
||||
JSTypedArray::Cast(typedArray->GetTaggedObject())->GetTypedArrayName());
|
||||
DataViewType elementType = JSTypedArray::GetTypeFromName(thread, arrayTypeName);
|
||||
|
@ -259,6 +259,14 @@ JSTaggedValue BuiltinsArrayBuffer::AllocateArrayBuffer(JSThread *thread, const J
|
||||
}
|
||||
|
||||
// 24.1.1.2 IsDetachedBuffer()
|
||||
void BuiltinsArrayBuffer::IsDetachedBuffer(JSThread *thread, const JSHandle<JSTypedArray> &arrayBuffer)
|
||||
{
|
||||
JSTaggedValue detachedBuffer = arrayBuffer->GetViewedArrayBufferOrByteArray();
|
||||
if (IsDetachedBuffer(detachedBuffer)) {
|
||||
THROW_TYPE_ERROR(thread, "The ArrayBuffer of this value is detached buffer.");
|
||||
}
|
||||
}
|
||||
|
||||
bool BuiltinsArrayBuffer::IsDetachedBuffer(JSTaggedValue arrayBuffer)
|
||||
{
|
||||
if (arrayBuffer.IsByteArray()) {
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
// 24.1.4.3 ArrayBuffer.prototype.slice()
|
||||
static JSTaggedValue Slice(EcmaRuntimeCallInfo *argv);
|
||||
// 24.1.1.2 IsDetachedBuffer(arrayBuffer)
|
||||
static void IsDetachedBuffer(JSThread *thread, const JSHandle<JSTypedArray> &arrayBuffer);
|
||||
static bool IsDetachedBuffer(JSTaggedValue arrayBuffer);
|
||||
// 24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type, isLittleEndian )
|
||||
static JSTaggedValue GetValueFromBuffer(JSThread *thread, JSTaggedValue arrBuf, uint32_t byteIndex,
|
||||
|
@ -292,10 +292,8 @@ JSTaggedValue BuiltinsAtomics::AtomicReadModifyWrite(JSThread *thread, const JSH
|
||||
// 3. Let arrayTypeName be typedArray.[[TypedArrayName]].
|
||||
JSHandle<JSTaggedValue> arrayTypeName(thread,
|
||||
JSTypedArray::Cast(typedArray->GetTaggedObject())->GetTypedArrayName());
|
||||
if (BuiltinsArrayBuffer::IsDetachedBuffer(buffer.GetTaggedValue())) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "The ArrayBuffer of this value is detached buffer.",
|
||||
JSTaggedValue::Exception());
|
||||
}
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(typedArray));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
// 7. NOTE: The above check is not redundant with the check in ValidateIntegerTypedArray because the call to
|
||||
// ToBigInt or ToIntegerOrInfinity on the preceding lines can have arbitrary side effects, which could cause the
|
||||
// buffer to become detached.
|
||||
@ -380,12 +378,16 @@ JSTaggedValue BuiltinsAtomics::HandleWithUint8(JSThread *thread, uint32_t size,
|
||||
EcmaRuntimeCallInfo *argv, const callbackfun &op, uint8_t &tag)
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithUint8);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op((block + indexedPosition), &tag);
|
||||
return BuiltinsBase::GetTaggedInt(result);
|
||||
}
|
||||
JSHandle<JSTaggedValue> newValue = BuiltinsBase::GetCallArg(argv, BuiltinsBase::ArgsPosition::FOURTH);
|
||||
uint8_t newTag = JSTaggedValue::ToUint8(thread, newValue);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
uint8_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newTag;
|
||||
@ -399,12 +401,16 @@ JSTaggedValue BuiltinsAtomics::HandleWithInt8(JSThread *thread, uint32_t size, u
|
||||
EcmaRuntimeCallInfo *argv, const callbackfun &op, int8_t &tag)
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithInt8);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op(reinterpret_cast<int8_t *>(block + indexedPosition), &tag);
|
||||
return BuiltinsBase::GetTaggedInt(result);
|
||||
}
|
||||
JSHandle<JSTaggedValue> newValue = BuiltinsBase::GetCallArg(argv, BuiltinsBase::ArgsPosition::FOURTH);
|
||||
int8_t newTag = JSTaggedValue::ToInt8(thread, newValue);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
int8_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newTag;
|
||||
@ -418,12 +424,16 @@ JSTaggedValue BuiltinsAtomics::HandleWithUint16(JSThread *thread, uint32_t size,
|
||||
EcmaRuntimeCallInfo *argv, const callbackfun &op, uint16_t &tag)
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithUint16);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op(reinterpret_cast<uint16_t *>(block + indexedPosition), &tag);
|
||||
return BuiltinsBase::GetTaggedInt(result);
|
||||
}
|
||||
JSHandle<JSTaggedValue> newValue = BuiltinsBase::GetCallArg(argv, BuiltinsBase::ArgsPosition::FOURTH);
|
||||
uint16_t newTag = JSTaggedValue::ToUint16(thread, newValue);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
uint16_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newTag;
|
||||
@ -437,12 +447,16 @@ JSTaggedValue BuiltinsAtomics::HandleWithInt16(JSThread *thread, uint32_t size,
|
||||
EcmaRuntimeCallInfo *argv, const callbackfun &op, int16_t &tag)
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithInt16);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op(reinterpret_cast<int16_t *>(block + indexedPosition), &tag);
|
||||
return BuiltinsBase::GetTaggedInt(result);
|
||||
}
|
||||
JSHandle<JSTaggedValue> newValue = BuiltinsBase::GetCallArg(argv, BuiltinsBase::ArgsPosition::FOURTH);
|
||||
int16_t newTag = JSTaggedValue::ToInt16(thread, newValue);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
int16_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newTag;
|
||||
@ -456,12 +470,16 @@ JSTaggedValue BuiltinsAtomics::HandleWithUint32(JSThread *thread, uint32_t size,
|
||||
EcmaRuntimeCallInfo *argv, const callbackfun &op, uint32_t &tag)
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithUint32);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op(reinterpret_cast<uint32_t *>(block + indexedPosition), &tag);
|
||||
return JSTaggedValue(result);
|
||||
}
|
||||
JSHandle<JSTaggedValue> newValue = BuiltinsBase::GetCallArg(argv, BuiltinsBase::ArgsPosition::FOURTH);
|
||||
uint32_t newTag = JSTaggedValue::ToUint32(thread, newValue);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
uint32_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newTag;
|
||||
@ -475,12 +493,16 @@ JSTaggedValue BuiltinsAtomics::HandleWithInt32(JSThread *thread, uint32_t size,
|
||||
EcmaRuntimeCallInfo *argv, const callbackfun &op, int32_t &tag)
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithInt32);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op(reinterpret_cast<int32_t *>(block + indexedPosition), &tag);
|
||||
return BuiltinsBase::GetTaggedInt(result);
|
||||
}
|
||||
JSHandle<JSTaggedValue> newValue = BuiltinsBase::GetCallArg(argv, BuiltinsBase::ArgsPosition::FOURTH);
|
||||
int32_t newTag = JSTaggedValue::ToInt32(thread, newValue);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
int32_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newTag;
|
||||
@ -496,6 +518,8 @@ JSTaggedValue BuiltinsAtomics::HandleWithBigInt64(JSThread *thread, uint32_t siz
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithBigInt64);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op(reinterpret_cast<int64_t *>(block + indexedPosition), &tag);
|
||||
return BigInt::Int64ToBigInt(thread, result).GetTaggedValue();
|
||||
@ -504,6 +528,8 @@ JSTaggedValue BuiltinsAtomics::HandleWithBigInt64(JSThread *thread, uint32_t siz
|
||||
int64_t newVal = 0;
|
||||
BigInt::BigIntToInt64(thread, newValue, &newVal, &lossless);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
int64_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newVal;
|
||||
@ -518,6 +544,9 @@ JSTaggedValue BuiltinsAtomics::HandleWithBigUint64(JSThread *thread, uint32_t si
|
||||
uint64_t &tag, bool &lossless)
|
||||
{
|
||||
BUILTINS_API_TRACE(thread, Atomics, HandleWithBigUint64);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (size == 3) { // the number of parameters is 3
|
||||
auto result = op(reinterpret_cast<uint64_t *>(block + indexedPosition), &tag);
|
||||
return BigInt::Uint64ToBigInt(thread, result).GetTaggedValue();
|
||||
@ -525,6 +554,9 @@ JSTaggedValue BuiltinsAtomics::HandleWithBigUint64(JSThread *thread, uint32_t si
|
||||
JSHandle<JSTaggedValue> newValue = BuiltinsBase::GetCallArg(argv, BuiltinsBase::ArgsPosition::FOURTH);
|
||||
uint64_t newVal = 0;
|
||||
BigInt::BigIntToUint64(thread, newValue, &newVal, &lossless);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
BuiltinsArrayBuffer::IsDetachedBuffer(thread, JSHandle<JSTypedArray>::Cast(GetCallArg(argv, 0)));
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
uint64_t arg[ARGS_NUMBER] = {0};
|
||||
arg[0] = tag;
|
||||
arg[1] = newVal;
|
||||
|
@ -619,6 +619,11 @@ void BigInt::BigIntToInt64(JSThread *thread, JSHandle<JSTaggedValue> bigint, int
|
||||
if (bigint->IsBoolean()) {
|
||||
bigint = JSHandle<JSTaggedValue>(thread, JSTaggedValue::ToBigInt(thread, bigint));
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
} else if (!bigint->IsBigInt()) {
|
||||
JSHandle<BigInt> bigInt64(thread, JSTaggedValue::ToBigInt64(thread, bigint));
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
*cValue = bigInt64->ToInt64();
|
||||
return;
|
||||
}
|
||||
JSHandle<BigInt> bigInt64(thread, JSTaggedValue::ToBigInt64(thread, bigint));
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -637,6 +642,11 @@ void BigInt::BigIntToUint64(JSThread *thread, JSHandle<JSTaggedValue> bigint, ui
|
||||
if (bigint->IsBoolean()) {
|
||||
bigint = JSHandle<JSTaggedValue>(thread, JSTaggedValue::ToBigInt(thread, bigint));
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
} else if (!bigint->IsBigInt()) {
|
||||
JSHandle<BigInt> bigInt64(thread, JSTaggedValue::ToBigUint64(thread, bigint));
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
*cValue = bigInt64->ToInt64();
|
||||
return;
|
||||
}
|
||||
JSHandle<BigInt> bigUint64(thread, JSTaggedValue::ToBigUint64(thread, bigint));
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
|
@ -2824,7 +2824,6 @@
|
||||
"mjsunit/harmony/regexp-property-exact-match.js",
|
||||
"mjsunit/harmony/private-fields-special-object.js",
|
||||
"mjsunit/harmony/array-to-spliced.js",
|
||||
"mjsunit/harmony/atomics-on-arraybuffer-detach.js",
|
||||
"mjsunit/harmony/sharedarraybuffer.js",
|
||||
"mjsunit/harmony/atomics-waitasync-1thread-wake-up-fifo.js",
|
||||
"mjsunit/harmony/modules-import-10.js",
|
||||
|
Loading…
Reference in New Issue
Block a user