mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 04:00:37 +00:00
Reason:optimize CopyArray
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAXXBN?from=project-issue Test: Build & Boot devices Signed-off-by: wupengyong <wupengyong@huawei.com> Change-Id: I41d4a322cec55051d06f33f7fb821e4a5a2d8a1f
This commit is contained in:
parent
0798656e68
commit
d732a736fb
@ -3021,14 +3021,10 @@ JSHandle<TaggedArray> ObjectFactory::CopyArray(const JSHandle<TaggedArray> &old,
|
||||
JSHandle<TaggedArray> newArray(thread_, header);
|
||||
newArray->SetLength(newLength);
|
||||
newArray->SetExtraLength(old->GetExtraLength());
|
||||
|
||||
for (uint32_t i = 0; i < newLength; i++) {
|
||||
JSTaggedValue value = old->Get(i);
|
||||
if (old->GetClass()->IsMutantTaggedArray()) {
|
||||
newArray->Set<false>(thread_, i, value);
|
||||
} else {
|
||||
newArray->Set(thread_, i, value);
|
||||
}
|
||||
if (old->GetClass()->IsMutantTaggedArray()) {
|
||||
newArray->Copy<false>(thread_, 0, 0, *old, newLength);
|
||||
} else {
|
||||
newArray->Copy(thread_, 0, 0, *old, newLength);
|
||||
}
|
||||
|
||||
return newArray;
|
||||
|
@ -72,6 +72,7 @@ template <bool needBarrier>
|
||||
inline void TaggedArray::Copy(const JSThread* thread, uint32_t dstStart, uint32_t srcStart,
|
||||
const TaggedArray* srcArray, uint32_t count)
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
ASSERT((dstStart + count <= GetLength()) && "TaggedArray::Copy dst count is out of range");
|
||||
ASSERT((srcStart + count <= srcArray->GetLength()) && "TaggedArray::Copy src count is out of range");
|
||||
size_t taggedTypeSize = JSTaggedValue::TaggedTypeSize();
|
||||
|
@ -472,4 +472,50 @@ print(srcutf16.slice(0, 13)); // bytes > 16 && bytes % 16 > 8 && bytes % 8 > 0
|
||||
print(srcutf16.slice(0, 16)); // bytes == 2 * 16
|
||||
print(srcutf16.slice(0, 25)); // bytes > 16 && bytes % 16 != 0
|
||||
print(srcutf16.slice(0, 28)); // bytes == 7 * 8
|
||||
print(srcutf16.slice(0, 32)); // bytes == 4 * 16
|
||||
print(srcutf16.slice(0, 32)); // bytes == 4 * 16
|
||||
|
||||
var str11;
|
||||
var result11;
|
||||
var re11 = /[Cz]/;
|
||||
var re12 = /([Cz])/;
|
||||
|
||||
function createHaystack() {
|
||||
let s = "abCdefgz";
|
||||
for (let i = 0; i < 3; i++) s += s;
|
||||
return s;
|
||||
}
|
||||
|
||||
function SimpleSplit2() {
|
||||
result11 = str11.split(re11);
|
||||
if (result11.length != 17) {
|
||||
print("fail!");
|
||||
}
|
||||
}
|
||||
|
||||
function Function1Replace(re) {
|
||||
result11 = re[Symbol.replace](str11, String);
|
||||
if (result11 != "abCdefgzabCdefgzabCdefgzabCdefgzabCdefgzabCdefgzabCdefgzabCdefgz") {
|
||||
print("fail!");
|
||||
}
|
||||
}
|
||||
|
||||
str11 = createHaystack();
|
||||
|
||||
function SimpleMatch1() {
|
||||
result11 = str11.match(re11);
|
||||
if (result11[0] != 'C') {
|
||||
print("fail!");
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
SimpleMatch1();
|
||||
}
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
SimpleSplit2();
|
||||
}
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
Function1Replace(re12);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user