!9062 Revert a part of 8662

Merge pull request !9062 from YuliCheng/RevertGrowOP
This commit is contained in:
openharmony_ci 2024-09-04 04:52:12 +00:00 committed by Gitee
commit f5c1614152
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 6 additions and 36 deletions

View File

@ -831,7 +831,7 @@ GateRef NewObjectStubBuilder::CopyArray(GateRef glue, GateRef elements, GateRef
BRANCH(Int32GreaterThan(newLen, oldLen), &extendArray, &notExtendArray);
Bind(&extendArray);
{
result = ExtendArrayCheck(glue, elements, newLen);
result = ExtendArrayCheck(glue, elements, newLen, spaceType);
Jump(&exit);
}
Bind(&notExtendArray);
@ -844,29 +844,13 @@ GateRef NewObjectStubBuilder::CopyArray(GateRef glue, GateRef elements, GateRef
BRANCH(checkIsMutantTaggedArray, &isMutantTaggedArray, &isNotMutantTaggedArray);
Bind(&isMutantTaggedArray);
{
size_ = ComputeTaggedArraySize(ZExtInt32ToPtr(newLen));
Label afterAllocate(env);
auto hclass = GetGlobalConstantValue(
VariableType::JS_POINTER(), glue_, ConstantIndex::MUTANT_TAGGED_ARRAY_CLASS_INDEX);
// Be careful. NO GC is allowed when initization is not complete.
HeapAlloc(&array, &afterAllocate, spaceType, hclass);
Bind(&afterAllocate);
StoreHClass(glue_, *array, hclass);
InitializeTaggedArrayWithSpeicalValue(&afterInitializeElements,
*array, SpecialHole(), Int32(0), newLen);
array = newBuilder.NewMutantTaggedArray(glue, newLen);
Jump(&afterInitializeElements);
}
Bind(&isNotMutantTaggedArray);
{
size_ = ComputeTaggedArraySize(ZExtInt32ToPtr(newLen));
// Be careful. NO GC is allowed when initization is not complete.
Label afterAllocate(env);
auto hclass = GetGlobalConstantValue(
VariableType::JS_POINTER(), glue_, ConstantIndex::ARRAY_CLASS_INDEX);
HeapAlloc(&array, &afterAllocate, spaceType, hclass);
Bind(&afterAllocate);
StoreBuiltinHClass(glue_, *array, hclass);
InitializeTaggedArrayWithSpeicalValue(&afterInitializeElements,
*array, Hole(), Int32(0), newLen);
array = newBuilder.NewTaggedArray(glue, newLen);
Jump(&afterInitializeElements);
}
Bind(&afterInitializeElements);
Store(VariableType::INT32(), glue, *array, IntPtr(TaggedArray::LENGTH_OFFSET), newLen);

View File

@ -3883,26 +3883,12 @@ GateRef StubBuilder::GrowElementsCapacity(GateRef glue, GateRef receiver, GateRe
{
auto env = GetEnvironment();
Label subEntry(env);
Label isShared(env);
Label notShared(env);
Label storeElements(env);
env->SubCfgEntry(&subEntry);
DEFVARIABLE(newElements, VariableType::JS_ANY(), Hole());
NewObjectStubBuilder newBuilder(this);
GateRef newCapacity = ComputeElementCapacity(capacity);
GateRef elements = GetElementsArray(receiver);
Branch(IsJSShared(elements), &isShared, &notShared);
Bind(&isShared);
{
newElements = newBuilder.CopyArray(glue, elements, capacity, newCapacity, RegionSpaceFlag::IN_SHARED_OLD_SPACE);
Jump(&storeElements);
}
Bind(&notShared);
{
newElements = newBuilder.CopyArray(glue, elements, capacity, newCapacity, RegionSpaceFlag::IN_YOUNG_SPACE);
Jump(&storeElements);
}
Bind(&storeElements);
newElements = newBuilder.CopyArray(glue, elements, capacity, newCapacity);
SetElementsArray(VariableType::JS_POINTER(), glue, receiver, *newElements);
auto ret = *newElements;
env->SubCfgExit();