Bug in TypedArray Fill

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAM2S5

Signed-off-by: hecunmao <hecunmao@huawei.com>
Change-Id: I68ee4425f33f1834a654666dd116036a409e2bd0
This commit is contained in:
hecunmao 2024-08-23 16:30:27 +08:00
parent 473c6e7ec6
commit 71711e6fc7
5 changed files with 62 additions and 1 deletions

View File

@ -842,7 +842,7 @@ bool JSTypedArray::FastTypedArrayFill(JSThread *thread, const JSHandle<JSTaggedV
DataViewType elementType = TypedArrayHelper::GetType(jsType);
uint64_t byteBeginOffset = start * elementSize + offset;
uint64_t byteEndOffset = std::min(end, arrLen) * elementSize + offset;
if (byteBeginOffset <= byteEndOffset) {
if (byteBeginOffset < byteEndOffset) {
BuiltinsArrayBuffer::TryFastSetValueInBuffer(thread, buffer,
byteBeginOffset, byteEndOffset, elementType, numValue.GetNumber(), true);
}

View File

@ -155,6 +155,7 @@ group("ark_js_moduletest") {
"trycatch",
"typearray",
"typedarrayat",
"typedarrayfill",
"typedarrayfindlast",
"typedarrayfrom",
"typedarraynan",
@ -357,6 +358,7 @@ group("ark_asm_test") {
"throwerror",
"trycatch",
"typedarrayat",
"typedarrayfill",
"typedarrayfindlast",
"typedarrayfrom",
"typedarraynan",
@ -535,6 +537,7 @@ group("ark_asm_single_step_test") {
"throwerror",
"trycatch",
"typedarrayat",
"typedarrayfill",
"typedarrayfindlast",
"typedarrayfrom",
"typedarraynan",

View File

@ -0,0 +1,18 @@
# Copyright (c) 2024 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("typedarrayfill") {
deps = []
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2024 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 typedarrayfill success!

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 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:typedarrayfill
* @tc.desc:test TypedArray.fill
* @tc.type: FUNC
* @tc.require: issueI7F8N1
*/
let buff = new ArrayBuffer(0);
let arr = new Int32Array(buff);
arr.fill(0);
print("test typedarrayfill success!")