Merge pull request !4913 from 李晨帅/OpenHarmony-4.0-Release
This commit is contained in:
openharmony_ci 2023-09-25 11:26:28 +00:00 committed by Gitee
commit e85c3fbb75
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
47 changed files with 706 additions and 106 deletions

View File

@ -56,12 +56,12 @@ JSTaggedValue TypedArrayHelper::TypedArrayConstructor(EcmaRuntimeCallInfo *argv,
JSHandle<JSTaggedValue> firstArg = BuiltinsBase::GetCallArg(argv, 0);
if (!firstArg->IsECMAObject()) {
// es11 22.2.4.1 TypedArray ( )
int32_t elementLength = 0;
uint32_t elementLength = 0;
// es11 22.2.4.2 TypedArray ( length )
if (!firstArg->IsUndefined()) {
JSTaggedNumber index = JSTaggedValue::ToIndex(thread, firstArg);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
elementLength = static_cast<int32_t>(index.GetNumber());
elementLength = static_cast<uint32_t>(index.GetNumber());
}
JSHandle<JSObject> obj = TypedArrayHelper::AllocateTypedArray(thread, constructorName, newTarget,
elementLength, arrayType);
@ -415,7 +415,7 @@ JSHandle<JSObject> TypedArrayHelper::AllocateTypedArray(JSThread *thread,
// es11 22.2.4.2.1 Runtime Semantics: AllocateTypedArray ( constructorName, newTarget, defaultProto, length )
JSHandle<JSObject> TypedArrayHelper::AllocateTypedArray(JSThread *thread,
const JSHandle<JSTaggedValue> &constructorName,
const JSHandle<JSTaggedValue> &newTarget, int32_t length,
const JSHandle<JSTaggedValue> &newTarget, uint32_t length,
const DataViewType arrayType)
{
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();

View File

@ -35,7 +35,7 @@ public:
const DataViewType arrayType);
static JSHandle<JSObject> AllocateTypedArray(JSThread *thread,
const JSHandle<JSTaggedValue> &constructorName,
const JSHandle<JSTaggedValue> &newTarget, int32_t length,
const JSHandle<JSTaggedValue> &newTarget, uint32_t length,
const DataViewType arrayType);
static JSHandle<JSObject> TypedArraySpeciesCreate(JSThread *thread, const JSHandle<JSTypedArray> &obj,
uint32_t argc, JSTaggedType argv[]);

View File

@ -2999,8 +2999,8 @@ JSTaggedValue BuiltinsArray::With(EcmaRuntimeCallInfo *argv)
// ReturnIfAbrupt(A).
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newArray);
if (thisObjVal->IsStableJSArray(thread)) {
return JSStableArray::With(thread, thisObjHandle, newArrayHandle, len, actualIndex, value);
if (thisHandle->IsStableJSArray(thread) && !thisObjHandle->GetJSHClass()->HasConstructor()) {
return JSStableArray::With(thread, JSHandle<JSArray>::Cast(thisHandle), len, actualIndex, value);
}
// 8. Let k be 0.
int64_t k = 0;
@ -3144,8 +3144,8 @@ JSTaggedValue BuiltinsArray::ToSpliced(EcmaRuntimeCallInfo *argv)
if (newLen > base::MAX_SAFE_INTEGER) {
THROW_TYPE_ERROR_AND_RETURN(thread, "out of range.", JSTaggedValue::Exception());
}
if (thisHandle->IsStableJSArray(thread)) {
return JSStableArray::ToSpliced(thread, thisObjHandle, argv, argc, actualStart,
if (thisHandle->IsStableJSArray(thread) && !thisObjHandle->GetJSHClass()->HasConstructor()) {
return JSStableArray::ToSpliced(JSHandle<JSArray>::Cast(thisHandle), argv, argc, actualStart,
actualSkipCount, newLen);
}
// 13. Let A be ? ArrayCreate(newLen).
@ -3361,8 +3361,8 @@ JSTaggedValue BuiltinsArray::ToReversed(EcmaRuntimeCallInfo *argv)
int64_t len = ArrayHelper::GetLength(thread, thisObjVal);
// ReturnIfAbrupt(len).
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (thisHandle->IsStableJSArray(thread)) {
return JSStableArray::ToReversed(thread, thisObjHandle, len);
if (thisHandle->IsStableJSArray(thread) && !thisObjHandle->GetJSHClass()->HasConstructor()) {
return JSStableArray::ToReversed(thread, JSHandle<JSArray>::Cast(thisHandle), len);
}
// 3. Let A be ? ArrayCreate(len).
JSTaggedValue newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(len))).GetTaggedValue();

View File

@ -494,7 +494,11 @@ JSTaggedValue BuiltinsArrayBuffer::GetValueFromBufferForFloat(uint8_t *block, ui
if constexpr (std::is_same_v<T, float>) {
unionValue.uValue = *reinterpret_cast<uint32_t *>(block + byteIndex);
if (std::isnan(unionValue.value)) {
return GetTaggedDouble(unionValue.value);
if (!JSTaggedValue::IsImpureNaN(unionValue.value)) {
return GetTaggedDouble(unionValue.value);
} else {
return GetTaggedDouble(base::NAN_VALUE);
}
}
if (!littleEndian) {
uint32_t res = LittleEndianToBigEndian(unionValue.uValue);
@ -512,6 +516,10 @@ JSTaggedValue BuiltinsArrayBuffer::GetValueFromBufferForFloat(uint8_t *block, ui
return GetTaggedDouble(base::bit_cast<T>(base::pureNaN));
}
return GetTaggedDouble(d);
} else {
if (JSTaggedValue::IsImpureNaN(unionValue.value)) {
return GetTaggedDouble(base::NAN_VALUE);
}
}
}

View File

@ -1293,7 +1293,7 @@ GateRef StubBuilder::StringToElementIndex(GateRef glue, GateRef string)
Label entry(env);
env->SubCfgEntry(&entry);
Label exit(env);
DEFVARIABLE(result, VariableType::INT32(), Int32(-1));
DEFVARIABLE(result, VariableType::INT64(), Int64(-1));
Label greatThanZero(env);
Label inRange(env);
auto len = GetLengthFromString(string);
@ -1319,7 +1319,7 @@ GateRef StubBuilder::StringToElementIndex(GateRef glue, GateRef string)
Branch(Int32Equal(len, Int32(1)), &lengthIsOne, &exit);
Bind(&lengthIsOne);
{
result = Int32(0);
result = Int64(0);
Jump(&exit);
}
}
@ -1327,7 +1327,7 @@ GateRef StubBuilder::StringToElementIndex(GateRef glue, GateRef string)
{
Label isDigit(env);
DEFVARIABLE(i, VariableType::INT32(), Int32(1));
DEFVARIABLE(n, VariableType::INT32(), Int32Sub(*c, Int32('0')));
DEFVARIABLE(n, VariableType::INT64(), Int64Sub(ZExtInt32ToInt64(*c), Int64('0')));
Branch(IsDigit(*c), &isDigit, &exit);
Label loopHead(env);
Label loopEnd(env);
@ -1343,7 +1343,7 @@ GateRef StubBuilder::StringToElementIndex(GateRef glue, GateRef string)
Bind(&isDigit2);
{
// 10 means the base of digit is 10.
n = Int32Add(Int32Mul(*n, Int32(10)), Int32Sub(*c, Int32('0')));
n = Int64Add(Int64Mul(*n, Int64(10)), Int64Sub(ZExtInt32ToInt64(*c), Int64('0')));
i = Int32Add(*i, Int32(1));
Branch(Int32UnsignedLessThan(*i, len), &loopEnd, &afterLoop);
}
@ -1355,7 +1355,7 @@ GateRef StubBuilder::StringToElementIndex(GateRef glue, GateRef string)
Bind(&afterLoop);
{
Label lessThanMaxIndex(env);
Branch(Int32UnsignedLessThan(*n, Int32(JSObject::MAX_ELEMENT_INDEX)),
Branch(Int64LessThan(*n, Int64(JSObject::MAX_ELEMENT_INDEX)),
&lessThanMaxIndex, &exit);
Bind(&lessThanMaxIndex);
{
@ -1381,11 +1381,11 @@ GateRef StubBuilder::TryToElementsIndex(GateRef glue, GateRef key)
Label isKeyInt(env);
Label notKeyInt(env);
DEFVARIABLE(resultKey, VariableType::INT32(), Int32(-1));
DEFVARIABLE(resultKey, VariableType::INT64(), Int64(-1));
Branch(TaggedIsInt(key), &isKeyInt, &notKeyInt);
Bind(&isKeyInt);
{
resultKey = GetInt32OfTInt(key);
resultKey = GetInt64OfTInt(key);
Jump(&exit);
}
Bind(&notKeyInt);
@ -1410,7 +1410,7 @@ GateRef StubBuilder::TryToElementsIndex(GateRef glue, GateRef key)
Branch(DoubleEqual(number, ChangeInt32ToFloat64(integer)), &isEqual, &exit);
Bind(&isEqual);
{
resultKey = integer;
resultKey = SExtInt32ToInt64(integer);
Jump(&exit);
}
}
@ -1647,8 +1647,17 @@ GateRef StubBuilder::LoadElement(GateRef glue, GateRef receiver, GateRef key, Pr
Label indexNotLessZero(env);
Label lengthLessIndex(env);
Label lengthNotLessIndex(env);
Label greaterThanInt32Max(env);
Label notGreaterThanInt32Max(env);
DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
GateRef index = TryToElementsIndex(glue, key);
GateRef index64 = TryToElementsIndex(glue, key);
Branch(Int64GreaterThanOrEqual(index64, Int64(INT32_MAX)), &greaterThanInt32Max, &notGreaterThanInt32Max);
Bind(&greaterThanInt32Max);
{
Jump(&exit);
}
Bind(&notGreaterThanInt32Max);
GateRef index = TruncInt64ToInt32(index64);
Branch(Int32LessThan(index, Int32(0)), &indexLessZero, &indexNotLessZero);
Bind(&indexLessZero);
{
@ -1695,9 +1704,18 @@ GateRef StubBuilder::ICStoreElement(
Label cellHasNotChanged(env);
Label loopHead(env);
Label loopEnd(env);
Label greaterThanInt32Max(env);
Label notGreaterThanInt32Max(env);
DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
DEFVARIABLE(varHandler, VariableType::JS_ANY(), handler);
GateRef index = TryToElementsIndex(glue, key);
GateRef index64 = TryToElementsIndex(glue, key);
Branch(Int64GreaterThanOrEqual(index64, Int64(INT32_MAX)), &greaterThanInt32Max, &notGreaterThanInt32Max);
Bind(&greaterThanInt32Max);
{
Jump(&exit);
}
Bind(&notGreaterThanInt32Max);
GateRef index = TruncInt64ToInt32(index64);
Branch(Int32LessThan(index, Int32(0)), &indexLessZero, &indexNotLessZero);
Bind(&indexLessZero);
{
@ -2163,7 +2181,6 @@ GateRef StubBuilder::GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef
env->SubCfgEntry(&entry);
DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
DEFVARIABLE(holder, VariableType::JS_ANY(), receiver);
DEFVARIABLE(proto, VariableType::JS_ANY(), Hole());
Label exit(env);
Label loopHead(env);
Label loopEnd(env);
@ -2182,13 +2199,12 @@ GateRef StubBuilder::GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef
// TypeArray
Label isFastTypeArray(env);
Label notFastTypeArray(env);
Label notTypedArrayProto(env);
Branch(Int32Equal(jsType, Int32(static_cast<int32_t>(JSType::JS_TYPED_ARRAY))), &exit, &notTypedArrayProto);
Bind(&notTypedArrayProto);
Branch(IsFastTypeArray(jsType), &isFastTypeArray, &notFastTypeArray);
Bind(&isFastTypeArray);
{
proto = GetPrototypeFromHClass(LoadHClass(receiver));
Label notOnProtoChain(env);
Branch(Int64NotEqual(*proto, *holder), &exit, &notOnProtoChain);
Bind(&notOnProtoChain);
TypedArrayStubBuilder typedArrayStubBuilder(this);
result = typedArrayStubBuilder.FastGetPropertyByIndex(glue, *holder, index, jsType);
Jump(&exit);
@ -2317,9 +2333,18 @@ GateRef StubBuilder::GetPropertyByValue(GateRef glue, GateRef receiver, GateRef
}
Bind(&isNumberOrStringSymbol);
{
GateRef index = TryToElementsIndex(glue, *key);
GateRef index64 = TryToElementsIndex(glue, *key);
Label validIndex(env);
Label notValidIndex(env);
Label greaterThanInt32Max(env);
Label notGreaterThanInt32Max(env);
Branch(Int64GreaterThanOrEqual(index64, Int64(INT32_MAX)), &greaterThanInt32Max, &notGreaterThanInt32Max);
Bind(&greaterThanInt32Max);
{
Jump(&exit);
}
Bind(&notGreaterThanInt32Max);
GateRef index = TruncInt64ToInt32(index64);
Branch(Int32GreaterThanOrEqual(index, Int32(0)), &validIndex, &notValidIndex);
Bind(&validIndex);
{
@ -3159,9 +3184,18 @@ GateRef StubBuilder::SetPropertyByValue(GateRef glue, GateRef receiver, GateRef
}
Bind(&isNumberOrStringSymbol);
{
GateRef index = TryToElementsIndex(glue, *varKey);
GateRef index64 = TryToElementsIndex(glue, *varKey);
Label validIndex(env);
Label notValidIndex(env);
Label greaterThanInt32Max(env);
Label notGreaterThanInt32Max(env);
Branch(Int64GreaterThanOrEqual(index64, Int64(INT32_MAX)), &greaterThanInt32Max, &notGreaterThanInt32Max);
Bind(&greaterThanInt32Max);
{
Jump(&exit);
}
Bind(&notGreaterThanInt32Max);
GateRef index = TruncInt64ToInt32(index64);
Branch(Int32GreaterThanOrEqual(index, Int32(0)), &validIndex, &notValidIndex);
Bind(&validIndex);
{

View File

@ -104,7 +104,7 @@ GateRef TypedArrayStubBuilder::FastGetPropertyByIndex(GateRef glue, GateRef arra
{
GateRef offset = GetByteOffset(array);
result = GetValueFromBuffer(buffer, index, offset, jsType);
Jump(&exit);
Branch(TaggedIsNumber(*result), &exit, &slowPath);
}
}
Bind(&slowPath);

View File

@ -149,7 +149,9 @@ JSTaggedValue LoadICRuntime::LoadMiss(JSHandle<JSTaggedValue> receiver, JSHandle
{
if (!receiver->IsJSObject() || receiver->HasOrdinaryGet()) {
icAccessor_.SetAsMega();
return JSTaggedValue::GetProperty(thread_, receiver, key).GetValue().GetTaggedValue();
JSHandle<JSTaggedValue> propKey = JSTaggedValue::ToPropertyKey(thread_, key);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread_);
return JSTaggedValue::GetProperty(thread_, receiver, propKey).GetValue().GetTaggedValue();
}
ICKind kind = GetICKind();

View File

@ -488,7 +488,7 @@ JSTaggedValue ICRuntimeStub::StoreElement(JSThread *thread, JSObject *receiver,
return JSTaggedValue::Undefined();
}
ARK_INLINE int32_t ICRuntimeStub::TryToElementsIndex(JSTaggedValue key)
ARK_INLINE int64_t ICRuntimeStub::TryToElementsIndex(JSTaggedValue key)
{
if (LIKELY(key.IsInt())) {
return key.GetInt();
@ -497,7 +497,7 @@ ARK_INLINE int32_t ICRuntimeStub::TryToElementsIndex(JSTaggedValue key)
if (key.IsString()) {
uint32_t index = 0;
if (JSTaggedValue::StringToElementIndex(key, &index)) {
return static_cast<int32_t>(index);
return static_cast<int64_t>(index);
}
}

View File

@ -71,7 +71,7 @@ public:
static inline JSTaggedValue LoadElement(JSObject *receiver, JSTaggedValue key);
static inline JSTaggedValue StoreElement(JSThread *thread, JSObject *receiver, JSTaggedValue key,
JSTaggedValue value, JSTaggedValue handlerInfo);
static inline int32_t TryToElementsIndex(JSTaggedValue key);
static inline int64_t TryToElementsIndex(JSTaggedValue key);
static inline JSTaggedValue LoadMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver,
JSTaggedValue key, uint32_t slotId, ICKind kind);
static inline JSTaggedValue StoreMiss(JSThread *thread, ProfileTypeInfo *profileTypeInfo, JSTaggedValue receiver,

View File

@ -143,6 +143,7 @@ std::pair<JSTaggedValue, bool> JSForInIterator::NextInternal(JSThread *thread, c
visited.Update(JSTaggedValue(newQueue));
it->SetVisitedObjs(thread, visited);
JSTaggedValue proto = JSTaggedValue::GetPrototype(thread, object);
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, std::make_pair(JSTaggedValue::Exception(), false));
it->SetObject(thread, proto);
it->SetWasVisited(false);
it->SetHasVisitObjs(true);

View File

@ -252,7 +252,7 @@ bool JSObject::AddElementInternal(JSThread *thread, const JSHandle<JSObject> &re
}
}
}
thread->NotifyStableArrayElementsGuardians(receiver);
thread->NotifyStableArrayElementsGuardians(receiver, StableArrayChangeKind::NOT_PROTO);
TaggedArray *elements = TaggedArray::Cast(receiver->GetElements().GetTaggedObject());
if (isDictionary) {
@ -1204,7 +1204,7 @@ bool JSObject::SetPrototype(JSThread *thread, const JSHandle<JSObject> &obj, con
JSHandle<JSHClass> newClass = JSHClass::TransitionProto(thread, hclass, proto);
JSHClass::NotifyHclassChanged(thread, hclass, newClass);
obj->SynchronizedSetClass(*newClass);
thread->NotifyStableArrayElementsGuardians(obj);
thread->NotifyStableArrayElementsGuardians(obj, StableArrayChangeKind::PROTO);
return true;
}

View File

@ -728,70 +728,122 @@ JSTaggedValue JSStableArray::At(JSHandle<JSArray> receiver, EcmaRuntimeCallInfo
return result.IsHole() ? JSTaggedValue::Undefined() : result;
}
JSTaggedValue JSStableArray::With(JSThread *thread, const JSHandle<JSObject> thisObjHandle,
JSHandle<JSObject> newArrayHandle, int64_t &len, int64_t &index,
JSHandle<JSTaggedValue> value)
JSTaggedValue JSStableArray::With(JSThread *thread, JSHandle<JSArray> receiver,
int64_t insertCount, int64_t index, JSHandle<JSTaggedValue> value)
{
JSMutableHandle<TaggedArray> array(thread, thisObjHandle->GetElements());
JSMutableHandle<TaggedArray> newArray(thread, newArrayHandle->GetElements());
int64_t k = 0;
while (k < len) {
if (k == index) {
newArray->Set(thread, k, value.GetTaggedValue());
} else {
newArray->Set(thread, k, array->Get(k));
}
++k;
JSHandle<JSObject> thisObjHandle(receiver);
JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle,
JSTaggedNumber(static_cast<uint32_t>(insertCount)));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newArray);
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
TaggedArray *srcElements = TaggedArray::Cast(thisObjHandle->GetElements().GetTaggedObject());
JSMutableHandle<TaggedArray> srcElementsHandle(thread, srcElements);
TaggedArray *destElements = TaggedArray::Cast(newArrayHandle->GetElements().GetTaggedObject());
if (insertCount > destElements->GetLength()) {
destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, insertCount);
}
for (uint32_t idx = 0; idx < insertCount; idx++) {
if (idx == index) {
destElements->Set(thread, idx, value.GetTaggedValue());
} else {
auto kValue = srcElementsHandle->Get(idx);
if (kValue.IsHole()) {
destElements->Set(thread, idx, JSTaggedValue::Undefined());
} else {
destElements->Set(thread, idx, kValue);
}
}
}
JSHandle<JSArray>::Cast(newArrayHandle)->SetArrayLength(thread, insertCount);
return newArrayHandle.GetTaggedValue();
}
JSTaggedValue JSStableArray::ToSpliced(JSThread *thread, JSHandle<JSObject> &thisObjHandle, EcmaRuntimeCallInfo *argv,
int64_t argc, int64_t actualStart, int64_t actualSkipCount, int64_t newLen)
JSTaggedValue JSStableArray::ToSpliced(JSHandle<JSArray> receiver, EcmaRuntimeCallInfo *argv,
int64_t argc, int64_t actualStart, int64_t actualSkipCount, int64_t insertCount)
{
JSMutableHandle<TaggedArray> thisArray(thread, thisObjHandle->GetElements());
// 1. Let A be ? ArrayCreate(newLen).
JSHandle<JSTaggedValue> newJsTaggedArray =
JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(newLen)));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newJsTaggedArray.GetTaggedValue());
JSMutableHandle<TaggedArray> newArray(thread, newArrayHandle->GetElements());
JSThread *thread = argv->GetThread();
int64_t i = 0;
int64_t r = actualStart + actualSkipCount;
while (i < actualStart) {
JSTaggedValue value = thisArray->Get(i);
newArray->Set(thread, i, value);
JSHandle<JSObject> thisObjHandle(receiver);
JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle,
JSTaggedNumber(static_cast<uint32_t>(insertCount)));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newArray);
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
TaggedArray *srcElements = TaggedArray::Cast(thisObjHandle->GetElements().GetTaggedObject());
JSMutableHandle<TaggedArray> srcElementsHandle(thread, srcElements);
TaggedArray *destElements = TaggedArray::Cast(newArrayHandle->GetElements().GetTaggedObject());
if (insertCount > destElements->GetLength()) {
destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, insertCount);
}
uint32_t i = 0, r = actualStart + actualSkipCount;
for (uint32_t idx = 0; idx < actualStart; idx++, i++) {
auto kValue = srcElementsHandle->Get(idx);
if (kValue.IsHole()) {
destElements->Set(thread, i, JSTaggedValue::Undefined());
} else {
destElements->Set(thread, i, kValue);
}
}
for (uint32_t pos = 2; pos < argc; ++pos) { // 2:2 means there two arguments before the insert items.
auto element = base::BuiltinsBase::GetCallArg(argv, pos);
destElements->Set(thread, i, element.GetTaggedValue());
++i;
}
for (int64_t pos = 2; pos < argc; ++pos) { // 2:2 means there two arguments before the insert items.
JSHandle<JSTaggedValue> element = base::BuiltinsBase::GetCallArg(argv, pos);
newArray->Set(thread, i, element.GetTaggedValue());
++i;
}
while (i < newLen) {
JSTaggedValue fromValue = thisArray->Get(r);
newArray->Set(thread, i, fromValue);
while (i < insertCount) {
auto kValue = srcElementsHandle->Get(r);
if (kValue.IsHole()) {
destElements->Set(thread, i, JSTaggedValue::Undefined());
} else {
destElements->Set(thread, i, kValue);
}
++i;
++r;
}
JSHandle<JSArray>::Cast(newArrayHandle)->SetArrayLength(thread, insertCount);
return newArrayHandle.GetTaggedValue();
}
JSTaggedValue JSStableArray::ToReversed(JSThread *thread, JSHandle<JSObject> thisObjHandle, uint32_t len)
JSTaggedValue JSStableArray::ToReversed(JSThread *thread, JSHandle<JSArray> receiver,
int64_t insertCount)
{
JSHandle<TaggedArray> srcArray(thread, thisObjHandle->GetElements());
JSTaggedValue newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(static_cast<double>(len))).GetTaggedValue();
JSHandle<JSObject> thisObjHandle(receiver);
JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle,
JSTaggedNumber(static_cast<uint32_t>(insertCount)));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newArray);
JSHandle<TaggedArray> dstArray(thread, newArrayHandle->GetElements());
uint32_t k = 0;
while (k < len) {
uint32_t start = len - k - 1;
JSTaggedValue value = srcArray->Get(start);
dstArray->Set(thread, k, value);
++k;
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
TaggedArray *srcElements = TaggedArray::Cast(thisObjHandle->GetElements().GetTaggedObject());
JSMutableHandle<TaggedArray> srcElementsHandle(thread, srcElements);
TaggedArray *destElements = TaggedArray::Cast(newArrayHandle->GetElements().GetTaggedObject());
if (insertCount > destElements->GetLength()) {
destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, insertCount);
}
for (uint32_t idx = 0; idx < insertCount; idx++) {
auto kValue = srcElementsHandle->Get(idx);
if (kValue.IsHole()) {
destElements->Set(thread, insertCount - idx - 1, JSTaggedValue::Undefined());
} else {
destElements->Set(thread, insertCount - idx - 1, kValue);
}
}
JSHandle<JSArray>::Cast(newArrayHandle)->SetArrayLength(thread, insertCount);
return newArrayHandle.GetTaggedValue();
}

View File

@ -57,12 +57,11 @@ public:
DataViewType targetType, uint32_t targetOffset,
uint32_t srcLength, JSHandle<TaggedArray> &elements);
static JSTaggedValue At(JSHandle<JSArray> receiver, EcmaRuntimeCallInfo *argv);
static JSTaggedValue ToReversed(JSThread *thread, JSHandle<JSObject> thisObjHandle, uint32_t len);
static JSTaggedValue With(JSThread *thread, const JSHandle<JSObject> thisObjHandle,
JSHandle<JSObject> newArrayHandle, int64_t &len, int64_t &index,
JSHandle<JSTaggedValue> value);
static JSTaggedValue ToSpliced(JSThread *thread, JSHandle<JSObject> &thisObjHandle, EcmaRuntimeCallInfo *argv,
int64_t argc, int64_t actualStart, int64_t actualSkipCount, int64_t newLen);
static JSTaggedValue With(JSThread *thread, JSHandle<JSArray> receiver,
int64_t insertCount, int64_t index, JSHandle<JSTaggedValue> value);
static JSTaggedValue ToSpliced(JSHandle<JSArray> receiver, EcmaRuntimeCallInfo *argv,
int64_t argc, int64_t actualStart, int64_t actualSkipCount, int64_t insertCount);
static JSTaggedValue ToReversed(JSThread *thread, JSHandle<JSArray> receiver, int64_t insertCount);
static JSTaggedValue Reduce(JSThread *thread, JSHandle<JSObject> thisObjHandle,
JSHandle<JSTaggedValue> callbackFnHandle,
JSMutableHandle<JSTaggedValue> accumulator, int64_t &k, int64_t &len);

View File

@ -812,6 +812,16 @@ bool JSTaggedValue::SetPrototype(JSThread *thread, const JSHandle<JSTaggedValue>
if (obj->IsSpecialContainer() || !obj->IsECMAObject()) {
THROW_TYPE_ERROR_AND_RETURN(thread, "Can not set Prototype on Container or non ECMA Object", false);
}
if (obj->IsJSFunction() && proto->IsJSFunction()) {
JSHandle<JSFunction> objFunc = JSHandle<JSFunction>::Cast(obj);
JSHandle<JSFunction> protoFunc = JSHandle<JSFunction>::Cast(proto);
JSTaggedValue objProtoOrHClass(objFunc->GetProtoOrHClass());
JSTaggedValue protoOrHClass(protoFunc->GetProtoOrHClass());
if (objProtoOrHClass.IsJSHClass() && protoOrHClass.IsJSHClass() && objProtoOrHClass != protoOrHClass) {
JSHandle<JSHClass> cachedJSHClass = JSHandle<JSHClass>(thread, objProtoOrHClass);
objFunc->SetProtoOrHClass(thread, cachedJSHClass->GetPrototype());
}
}
return JSObject::SetPrototype(thread, JSHandle<JSObject>(obj), proto);
}

View File

@ -361,18 +361,22 @@ void JSThread::ShrinkHandleStorage(int prevIndex)
GetCurrentEcmaContext()->ShrinkHandleStorage(prevIndex);
}
void JSThread::NotifyStableArrayElementsGuardians(JSHandle<JSObject> receiver)
void JSThread::NotifyStableArrayElementsGuardians(JSHandle<JSObject> receiver, StableArrayChangeKind changeKind)
{
if (!glueData_.stableArrayElementsGuardians_) {
return;
}
if (!receiver->GetJSHClass()->IsPrototype()) {
if (!receiver->GetJSHClass()->IsPrototype() && !receiver->IsJSArray()) {
return;
}
auto env = GetEcmaVM()->GetGlobalEnv();
if (receiver.GetTaggedValue() == env->GetObjectFunctionPrototype().GetTaggedValue() ||
receiver.GetTaggedValue() == env->GetArrayPrototype().GetTaggedValue()) {
glueData_.stableArrayElementsGuardians_ = false;
return;
}
if (changeKind == StableArrayChangeKind::PROTO && receiver->IsJSArray()) {
glueData_.stableArrayElementsGuardians_ = false;
}
}

View File

@ -59,6 +59,8 @@ enum class BCStubStatus: uint8_t {
PROFILE_BC_STUB,
};
enum class StableArrayChangeKind { PROTO, NOT_PROTO };
struct BCStubEntries {
static constexpr size_t EXISTING_BC_HANDLER_STUB_ENTRIES_COUNT =
kungfu::BytecodeStubCSigns::NUM_OF_ALL_NORMAL_STUBS;
@ -322,7 +324,7 @@ public:
return arrayHClassIndexMap_;
}
void NotifyStableArrayElementsGuardians(JSHandle<JSObject> receiver);
void NotifyStableArrayElementsGuardians(JSHandle<JSObject> receiver, StableArrayChangeKind changeKind);
bool IsStableArrayElementsGuardiansInvalid() const
{

View File

@ -230,9 +230,10 @@ JSTaggedValue ObjectFastOperator::GetPropertyByIndex(JSThread *thread, JSTaggedV
auto *hclass = holder.GetTaggedObject()->GetClass();
JSType jsType = hclass->GetObjectType();
if (IsSpecialIndexedObj(jsType)) {
if (jsType == JSType::JS_TYPED_ARRAY) {
return JSTaggedValue::Hole();
}
if (IsFastTypeArray(jsType)) {
holder = JSObject::Cast(holder)->GetJSHClass()->GetPrototype();
CHECK_IS_ON_PROTOTYPE_CHAIN(receiver, holder);
return JSTypedArray::FastGetPropertyByIndex(thread, receiver, index, jsType);
}
if (IsSpecialContainer(jsType)) {
@ -746,7 +747,7 @@ JSTaggedValue ObjectFastOperator::AddPropertyByIndex(JSThread *thread, JSTaggedV
return success ? JSTaggedValue::Undefined() : JSTaggedValue::Exception();
}
int32_t ObjectFastOperator::TryToElementsIndex(JSTaggedValue key)
int64_t ObjectFastOperator::TryToElementsIndex(JSTaggedValue key)
{
if (LIKELY(key.IsInt())) {
return key.GetInt();
@ -754,7 +755,7 @@ int32_t ObjectFastOperator::TryToElementsIndex(JSTaggedValue key)
if (key.IsString()) {
uint32_t index = 0;
if (JSTaggedValue::StringToElementIndex(key, &index)) {
return static_cast<int32_t>(index);
return static_cast<int64_t>(index);
}
} else if (key.IsDouble()) {
double number = key.GetDouble();

View File

@ -95,7 +95,7 @@ private:
static inline JSTaggedValue AddPropertyByIndex(JSThread *thread, JSTaggedValue receiver, uint32_t index,
JSTaggedValue value);
static inline int32_t TryToElementsIndex(JSTaggedValue key);
static inline int64_t TryToElementsIndex(JSTaggedValue key);
static inline bool GetNumFromString(const char *str, int len, int *index, int *num);

View File

@ -512,6 +512,7 @@ bool ObjectOperator::UpdateDataValue(const JSHandle<JSObject> &receiver, const J
bool res = accessor->CallInternalSet(thread_, JSHandle<JSObject>(receiver), value, mayThrow);
if (receiver->GetJSHClass()->IsDictionaryMode()) {
SetIsInlinedProps(false);
SetFastMode(false);
}
return res;
}

View File

@ -439,12 +439,10 @@ HWTEST_F_L0(JSStableArrayTest, With)
}
JSHandle<JSArray> handleArr(JSArray::CreateArrayFromList(thread, handleTagArr));
JSHandle<TaggedArray> newTagArr(objFactory->NewTaggedArray(lengthArr));
JSHandle<JSArray> newArr(JSArray::CreateArrayFromList(thread, newTagArr));
int64_t arrayLength = ARRAY_LENGTH_4;
int64_t index = static_cast<int64_t>(StableArrayIndex::STABLE_ARRAY_INDEX_2);
JSTaggedValue resultArr = JSStableArray::With(thread, JSHandle<JSObject>::Cast(handleArr),
JSHandle<JSObject>::Cast(newArr), arrayLength, index,
JSTaggedValue resultArr = JSStableArray::With(thread, handleArr,
arrayLength, index,
JSHandle<JSTaggedValue>(thread, JSTaggedValue(INT_VALUE_666)));
JSHandle<JSTaggedValue> destTaggedValue(thread, resultArr);
JSHandle<JSArray> destArr(destTaggedValue);
@ -484,7 +482,7 @@ HWTEST_F_L0(JSStableArrayTest, ToReversed)
}
JSHandle<JSArray> handleArr(JSArray::CreateArrayFromList(thread, handleTagArr));
JSTaggedValue resultArr =
JSStableArray::ToReversed(thread, JSHandle<JSObject>::Cast(handleArr), ARRAY_LENGTH_4);
JSStableArray::ToReversed(thread, handleArr, ARRAY_LENGTH_4);
JSHandle<JSTaggedValue> destTaggedValue(thread, resultArr);
JSHandle<JSArray> destArr(destTaggedValue);
JSHandle<TaggedArray> destTaggedArr(thread, TaggedArray::Cast(destArr->GetElements().GetTaggedObject()));

View File

@ -20,6 +20,10 @@ group("ark_js_moduletest") {
"arrayfindlast",
"arrayforeach",
"arrayjoin",
"arraytoreversed",
"arraytospliced",
"arraywith",
"arrayprotochange",
"assignproxy",
"async",
"asyncgenerator",
@ -87,6 +91,7 @@ group("ark_js_moduletest") {
"setobjectwithproto",
"spreadoperator",
"stackoverflow",
"storeicbyname",
"string",
"stubbuilder",
"throwdyn",
@ -94,6 +99,7 @@ group("ark_js_moduletest") {
"typearray",
"typedarrayat",
"typedarrayfindlast",
"typedarraynan",
"typedarraytosorted",
"typedarraywith",
"watch",
@ -140,6 +146,7 @@ group("ark_asm_test") {
"arrayfindlast",
"arrayforeach",
"arrayjoin",
"arrayprotochange",
"asmstackoverflow",
"assignproxy",
"async",
@ -198,6 +205,7 @@ group("ark_asm_test") {
"trycatch",
"typedarrayat",
"typedarrayfindlast",
"typedarraynan",
"typedarraytosorted",
"typedarraywith",
"watch",
@ -242,6 +250,7 @@ group("ark_asm_single_step_test") {
"arrayfindlast",
"arrayforeach",
"arrayjoin",
"arrayprotochange",
"asmstackoverflow",
"assignproxy",
"async",
@ -294,6 +303,7 @@ group("ark_asm_single_step_test") {
"trycatch",
"typedarrayat",
"typedarrayfindlast",
"typedarraynan",
"typedarraytosorted",
"typedarraywith",
"watch",

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_moduletest_action("arrayprotochange") {
deps = []
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @tc.name:arrayprotochange
* @tc.desc:test Array function when prototype changes
* @tc.type: FUNC
* @tc.require: issueI7O616
*/
var arr = [0, 1, 2, 3, 4];
var arr2 = [0, , , 3, 4];
arr2.__proto__ = arr;
print(arr2[1]);
print(arr2.at(1));

View File

@ -0,0 +1,15 @@
# Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
1
1

View File

@ -0,0 +1,18 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_moduletest_action("arraytoreversed") {
deps = []
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @tc.name:arraytoreversed
* @tc.desc:test Array.toReversed
* @tc.type: FUNC
* @tc.require: issueI5NO8G
*/
const arr0 = [0,undefined, , 1];
print(arr0.indexOf(undefined));
const arr1 = arr0.toReversed();
print(arr0.indexOf(undefined));
print(arr1.indexOf(undefined));
const arr2 = new Array(1025);
for(let i = 0; i < 1025; i = i + 1)
arr2[i] = i;
const arr3 = arr2.toReversed();

View File

@ -0,0 +1,16 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
1
1
1

View File

@ -0,0 +1,18 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_moduletest_action("arraytospliced") {
deps = []
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @tc.name:arraytospliced
* @tc.desc:test Array.toSpliced
* @tc.type: FUNC
* @tc.require: issueI5NO8G
*/
const arr0 = [1, , 3, 4, , 6, undefined];
print(arr0.indexOf(undefined));
const arr1 = arr0.toSpliced(1, 2);
print(arr0.indexOf(undefined));
print(arr1.indexOf(undefined));
const arr2 = new Array(1025);
for(let i = 0; i < 1025; i = i + 1)
arr2[i] = i;
const arr3 = arr2.toSpliced(0, 0);

View File

@ -0,0 +1,16 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
6
6
2

View File

@ -0,0 +1,18 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_moduletest_action("arraywith") {
deps = []
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @tc.name:arraywith
* @tc.desc:test Array.with
* @tc.type: FUNC
* @tc.require: issueI5NO8G
*/
const arr0 = [0, , undefined, 1];
print(arr0.indexOf(undefined));
const arr1 = arr0.with(0, 0);
print(arr0.indexOf(undefined));
print(arr1.indexOf(undefined));
const arr2 = new Array(1025);
for(let i = 0; i < 1025; i = i + 1)
arr2[i] = i;
const arr3 = arr2.with(0, 0);

View File

@ -0,0 +1,16 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2
2
1

View File

@ -27,3 +27,4 @@ hhh
1
2
true
true

View File

@ -112,3 +112,17 @@ try {
} catch (err) {
print(err instanceof TypeError);
}
// PoC testcase
try {
class C {
}
C.getPrototypeOf = 3014;
const proxy = new Proxy([7], C);
for (const v in proxy) {
}
} catch (err) {
print(err instanceof TypeError);
}

View File

@ -12,3 +12,9 @@
# limitations under the License.
icsuccess
test successful !!!
0 0
2147483647 1
2147483648 2
4294967295 3
4294967296 4

View File

@ -29,4 +29,30 @@ for (let j = 300; j > 0; j--)
{
func1(obj);
}
print(obj[i]);
print(obj[i]);
// PoC testcase
const arr = []
for (let i = 0; i < 20; i ++) {
const v0 = "p" + i;
const v1 = Symbol.iterator;
const v2 = {
[v1]() {},
};
arr[v0] = i;
}
const v3 = new Uint8Array(128);
v3[arr];
print("test successful !!!");
var obj1 = {
0: 0,
2147483647: 1,
2147483648: 2,
4294967295: 3,
4294967296: 4,
}
for (let item in obj1) {
print(item + " " + obj1[item]);
}

View File

@ -12,3 +12,7 @@
# limitations under the License.
null
true
true
true
true

View File

@ -22,5 +22,16 @@
var object = {
__proto__: null
};
print(Object.getPrototypeOf(object));
print(Object.getPrototypeOf(object));
class C32 extends String {
}
let obj1 = new C32();
print(obj1.__proto__ == C32.prototype);
print(C32.__proto__ == String);
C32.__proto__ = Array;
let obj2 = new C32();
print(obj2.__proto__ == C32.prototype);
print(C32.__proto__ == Array);

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_moduletest_action("storeicbyname") {
deps = []
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
test successful !!!

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @tc.name:storeicbyname
* @tc.desc:test storeicbyname
* @tc.type: FUNC
* @tc.require: issueI7UTOA
*/
const arr = [];
for (let i = 0; i < 200; i++) {
}
for (let i = 0; i < 100; i++) {
arr.length = 1025;
}
print("test successful !!!");

View File

@ -31,9 +31,6 @@ false
1,2,3
test successful !!!
test successful !!!
true
true
true
RangeError
0,0,0,0
not-equal

View File

@ -230,4 +230,4 @@ const v21 = new SharedArrayBuffer(32);
const v22 = new BigInt64Array(v21);
Atomics.or(v22, Int16Array, false);
print(v22);
print(Atomics.wait(v22, false, true));
print(Atomics.wait(v22, false, true));

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_moduletest_action("typedarraynan") {
deps = []
}

View File

@ -0,0 +1,23 @@
# Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
4294967291
4294967296
NaN
NaN
-1
1128267775
9007199254740991
0
2146959360
NaN

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @tc.name:typedarraynan
* @tc.desc:test TypedArray with NaN
* @tc.type: FUNC
* @tc.require: issueI7X3AY
*/
-4n ^-4n;
8>>8;
const o17 = {
"maxByteLength":8,
};
o17.b = 8;
o17.b = o17;
const v18 = new SharedArrayBuffer(8,o17);
const v19 = new Uint32Array(v18,4);
v19[0]=-5;
const v20 = new Float32Array(v18);
try {
v20.toReversed();
} catch(err) {
}
v20.set(v19);
print(v19[0]);
print(v20[0]);
print(v20[1]);
var buffer = new ArrayBuffer(8);
var array1 = new Int32Array(buffer);
array1[0] = -5;
array1[1] = -5;
var array2 = new Float64Array(buffer);
print(array2[0]);
array2[0] = 9007199254740991;
print(array1[0]);
print(array1[1]);
print(array2[0]);
array2[0] = NaN;
print(array1[0]);
print(array1[1]);
print(array2[0]);