Fix aot codes crash when involving builtin methods in Map/Set/Date

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

Signed-off-by: c00513733 <chenqiuyao@huawei.com>
Change-Id: If86c5f25f4ce14eac5fb56b87b6b3cf55bd4b1a1
This commit is contained in:
c00513733 2024-07-27 10:53:58 +08:00
parent 1acae53762
commit c9ddd7213a
6 changed files with 116 additions and 3 deletions

View File

@ -352,9 +352,26 @@ GateRef BuiltinLowering::LowerCallTargetCheckWithObjectType(GateRef gate, Builti
}
}
GateRef obj = acc_.GetValueIn(gate, 2); // 2: receiver obj
GateRef check1 = builder_.IsSpecificObjectType(obj, expectType);
GateRef check2 = LowerCallTargetCheckDefault(gate, id);
return builder_.BoolAnd(check1, check2);
auto env = builder_.GetCurrentEnvironment();
Label entry(&builder_);
env->SubCfgEntry(&entry);
DEFVALUE(result, (&builder_), VariableType::BOOL(), builder_.False());
Label heapObject(&builder_);
Label exit(&builder_);
BRANCH_CIR(builder_.TaggedIsHeapObjectOp(obj), &heapObject, &exit);
builder_.Bind(&heapObject);
{
GateRef check1 = builder_.IsSpecificObjectType(obj, expectType);
GateRef check2 = LowerCallTargetCheckDefault(gate, id);
result = builder_.BoolAnd(check1, check2);
builder_.Jump(&exit);
}
builder_.Bind(&exit);
auto res = *result;
env->SubCfgExit();
return res;
}
GateRef BuiltinLowering::CheckPara(GateRef gate, GateRef funcCheck)

View File

@ -75,6 +75,7 @@ group("ark_aot_ts_test") {
"binaryop_special_value",
"builtinmath",
"builtins_string",
"call_builtin_objects",
"call_same_bytecode_func",
"callithisrange",
"calls",

View File

@ -0,0 +1,19 @@
# 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_aot_test_action("call_builtin_objects") {
deps = []
is_enable_pgo = true
}

View File

@ -0,0 +1,48 @@
/*
* 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.
*/
declare interface ArkTools {
isAOTCompiled(args: any): boolean;
}
declare function print(arg:any):string;
let v1 = new Map();
let v2 = new Set();
let v3 = new Date();
class C {
constructor(a4, a5, a6) {
let v11 = v1;
let v22 = v2;
let v33 = v3;
v1 ^= a4;
v2 ^= a5;
v3 ^= a6;
v11["has"](1);
v22["has"](2);
v33["getTime"]();
}
}
function testCallSpecificObjects(): void {
const c1 = new C(Map, Set, Date);
try {
const c2 = new C(1, 1, 1);
} catch (e) { }
}
testCallSpecificObjects();
print("testCallSpecificObjects success, isAotCompiled: " + ArkTools.isAOTCompiled(testCallSpecificObjects));

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.
testCallSpecificObjects success, isAotCompiled: true

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.
testCallSpecificObjects success, isAotCompiled: false