!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); BRANCH(Int32GreaterThan(newLen, oldLen), &extendArray, &notExtendArray);
Bind(&extendArray); Bind(&extendArray);
{ {
result = ExtendArrayCheck(glue, elements, newLen); result = ExtendArrayCheck(glue, elements, newLen, spaceType);
Jump(&exit); Jump(&exit);
} }
Bind(&notExtendArray); Bind(&notExtendArray);
@ -844,29 +844,13 @@ GateRef NewObjectStubBuilder::CopyArray(GateRef glue, GateRef elements, GateRef
BRANCH(checkIsMutantTaggedArray, &isMutantTaggedArray, &isNotMutantTaggedArray); BRANCH(checkIsMutantTaggedArray, &isMutantTaggedArray, &isNotMutantTaggedArray);
Bind(&isMutantTaggedArray); Bind(&isMutantTaggedArray);
{ {
size_ = ComputeTaggedArraySize(ZExtInt32ToPtr(newLen)); array = newBuilder.NewMutantTaggedArray(glue, newLen);
Label afterAllocate(env); Jump(&afterInitializeElements);
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);
} }
Bind(&isNotMutantTaggedArray); Bind(&isNotMutantTaggedArray);
{ {
size_ = ComputeTaggedArraySize(ZExtInt32ToPtr(newLen)); array = newBuilder.NewTaggedArray(glue, newLen);
// Be careful. NO GC is allowed when initization is not complete. Jump(&afterInitializeElements);
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);
} }
Bind(&afterInitializeElements); Bind(&afterInitializeElements);
Store(VariableType::INT32(), glue, *array, IntPtr(TaggedArray::LENGTH_OFFSET), newLen); 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(); auto env = GetEnvironment();
Label subEntry(env); Label subEntry(env);
Label isShared(env);
Label notShared(env);
Label storeElements(env);
env->SubCfgEntry(&subEntry); env->SubCfgEntry(&subEntry);
DEFVARIABLE(newElements, VariableType::JS_ANY(), Hole()); DEFVARIABLE(newElements, VariableType::JS_ANY(), Hole());
NewObjectStubBuilder newBuilder(this); NewObjectStubBuilder newBuilder(this);
GateRef newCapacity = ComputeElementCapacity(capacity); GateRef newCapacity = ComputeElementCapacity(capacity);
GateRef elements = GetElementsArray(receiver); GateRef elements = GetElementsArray(receiver);
Branch(IsJSShared(elements), &isShared, &notShared); newElements = newBuilder.CopyArray(glue, elements, capacity, newCapacity);
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);
SetElementsArray(VariableType::JS_POINTER(), glue, receiver, *newElements); SetElementsArray(VariableType::JS_POINTER(), glue, receiver, *newElements);
auto ret = *newElements; auto ret = *newElements;
env->SubCfgExit(); env->SubCfgExit();