!7939 [JIT] fix load string length from raw value

Merge pull request !7939 from xiaoweidong/fix_string_len
This commit is contained in:
openharmony_ci 2024-06-28 07:24:00 +00:00 committed by Gitee
commit 5eb11ec37f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 79 additions and 4 deletions

View File

@ -1414,6 +1414,16 @@ GateRef NumberSpeculativeRetype::VisitLoadStringLength(GateRef gate)
return SetOutputType(gate, GateType::IntType());
}
if (IsConvert()) {
GateRef input = acc_.GetValueIn(gate, 0);
TypeInfo typeInfo = GetOutputTypeInfo(input);
if (typeInfo == TypeInfo::CHAR) {
acc_.ReplaceValueIn(gate, ConvertToTagged(input), 0);
} else if (typeInfo != TypeInfo::TAGGED) {
LOG_COMPILER(FATAL) << "should be tagged type";
UNREACHABLE();
}
}
return Circuit::NullGate();
}

View File

@ -23,6 +23,7 @@ group("ark_jit_ts_test") {
"construct_with_normal_function",
"addition_assignment",
"catch_with_osr",
"string_length",
"ts_inline",
]

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# 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

View File

@ -14,9 +14,9 @@
*/
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
constructor(height, width) {
this.height = height;
this.width = width;
}
}

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_jit_test_action("string_length") {
deps = []
}

View File

@ -0,0 +1,15 @@
# 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.
true
97

View File

@ -0,0 +1,31 @@
/*
* 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.
*/
function f(arg) {
let v = arg[0];
let c = v.charCodeAt(0);
return v.length > 0 ? c : ".";
}
let ss = "abcdefg"
for (let i = 0; i < 20; i++) {
f(ss)
}
ArkTools.jitCompileAsync(f);
let res = ArkTools.waitJitCompileFinish(f);
print(res)
print(f(ss))