mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-03-01 16:59:12 +00:00
[jit] fix load string len from raw value
Change-Id: Ieec2fde8cf6c666f0312540b14a3a42c81961bbb Signed-off-by: xiaoweidong <xiaoweidong@huawei.com>
This commit is contained in:
parent
2d8f70fa32
commit
eb43351d57
@ -1413,6 +1413,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();
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ group("ark_jit_ts_test") {
|
||||
"construct_with_normal_function",
|
||||
"addition_assignment",
|
||||
"catch_with_osr",
|
||||
"string_length",
|
||||
"ts_inline",
|
||||
]
|
||||
|
||||
|
@ -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
|
||||
|
@ -14,9 +14,9 @@
|
||||
*/
|
||||
|
||||
class Rectangle {
|
||||
constructor(height, width) {
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
constructor(height, width) {
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
|
||||
|
18
test/jittest/string_length/BUILD.gn
Normal file
18
test/jittest/string_length/BUILD.gn
Normal 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 = []
|
||||
}
|
15
test/jittest/string_length/expect_output.txt
Normal file
15
test/jittest/string_length/expect_output.txt
Normal 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
|
31
test/jittest/string_length/string_length.ts
Normal file
31
test/jittest/string_length/string_length.ts
Normal 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))
|
Loading…
x
Reference in New Issue
Block a user