Array.sort 增加开关

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB5ZD1?from=project-issue
Signed-off-by: 刘智杰 <liuzhijie9@huawei.com>
Change-Id: I6b961a1fa6afe04ed02887b56f5d89115043bfe6
This commit is contained in:
刘智杰 2024-11-21 12:52:11 +08:00
parent 732cc7d079
commit a990cdf41d

View File

@ -2392,11 +2392,19 @@ JSTaggedValue BuiltinsArray::Sort(EcmaRuntimeCallInfo *argv)
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
// Array sort
#if ENABLE_NEXT_OPTIMIZATION
if (thisHandle->IsStableJSArray(thread)) {
JSStableArray::Sort(thread, thisHandle, callbackFnHandle);
} else {
JSArray::Sort(thread, JSHandle<JSTaggedValue>::Cast(thisObjHandle), callbackFnHandle);
}
#else
if (thisHandle->IsStableJSArray(thread) && callbackFnHandle->IsUndefined()) {
JSArray::SortElementsByObject(thread, thisObjHandle, callbackFnHandle);
} else {
JSArray::Sort(thread, JSHandle<JSTaggedValue>::Cast(thisObjHandle), callbackFnHandle);
}
#endif
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
return thisObjHandle.GetTaggedValue();
}