From a50b2b5778b9d8d9611c5f4d1315b8cbb6247ddc Mon Sep 17 00:00:00 2001 From: schernykh Date: Wed, 21 Dec 2022 12:00:38 +0300 Subject: [PATCH] Fix call profile clear Signed-off-by: schernykh --- runtime/profiling/plugin_clear_profile.h | 23 ++++---------- tests/checked/CMakeLists.txt | 3 +- tests/checked/ecma_call_profile_clear.js | 38 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 tests/checked/ecma_call_profile_clear.js diff --git a/runtime/profiling/plugin_clear_profile.h b/runtime/profiling/plugin_clear_profile.h index 716880bd9..60851a4e3 100644 --- a/runtime/profiling/plugin_clear_profile.h +++ b/runtime/profiling/plugin_clear_profile.h @@ -24,22 +24,9 @@ case panda_file::SourceLang::ECMASCRIPT: { } ASSERT(static_cast(prof_id) < js_method->GetProfileSize()); auto prof_data = js_method->GetProfilingVector() + prof_id; - switch (profiling::GetProfileKind(inst.GetOpcode())) { - // No need to clean profiling for this profiling kinds - case profiling::ProfilingKind::UNARY_ARITH: - case profiling::ProfilingKind::BINARY_ARITH: - case profiling::ProfilingKind::OBJ_BY_INDEX: - break; - case profiling::ProfilingKind::CALL: { - auto profile = ecmascript::CallProfile::FromBuffer(prof_data); - ASSERT(profile != nullptr); - auto *profile_table = static_cast(vm)->GetEcmaCallProfileTable(); - profile->Clear(profile_table); - break; - } - default: { - UNREACHABLE(); - break; - } - } + ASSERT(profiling::GetProfileKind(inst.GetOpcode()) == profiling::ProfilingKind::CALL); + auto profile = ecmascript::CallProfile::FromBuffer(prof_data); + ASSERT(profile != nullptr); + auto *profile_table = static_cast(vm)->GetEcmaCallProfileTable(); + profile->Clear(profile_table); } \ No newline at end of file diff --git a/tests/checked/CMakeLists.txt b/tests/checked/CMakeLists.txt index 7bfc660ad..144a0ce9b 100644 --- a/tests/checked/CMakeLists.txt +++ b/tests/checked/CMakeLists.txt @@ -103,7 +103,8 @@ if (NOT PANDA_TARGET_ARM32) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/obj_by_index.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inlining.js SUPPORT_RELEASE true) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inlining_megamorphic.js SUPPORT_RELEASE true) - panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inlining_deoptimize.js SUPPORT_RELEASE true) + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_inlining_deoptimize.js SUPPORT_RELEASE true) + panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ecma_call_profile_clear.js SUPPORT_RELEASE true) # there is flaky bug when turning on TSAN if (NOT PANDA_ENABLE_THREAD_SANITIZER) panda_add_checked_test_ecma(FILE ${CMAKE_CURRENT_SOURCE_DIR}/acc_after_deopt.js SUPPORT_RELEASE true) diff --git a/tests/checked/ecma_call_profile_clear.js b/tests/checked/ecma_call_profile_clear.js new file mode 100644 index 000000000..3cea1b9df --- /dev/null +++ b/tests/checked/ecma_call_profile_clear.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021-2022 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. + */ + + +//! CHECKER Clear call profile after deoptimize. Deoptimize happend with PC for DynamicCall. +//! RUN_PAOC options: "" +//! RUN options: "--compiler-enable-jit=false", entry: "_GLOBAL::func_main_0" +//! EVENT /DeoptimizationReason,_GLOBAL::.*test.*,NOT_SMALL_INT/ +//! EVENT /Deoptimization,_GLOBAL::.*test.*,.*,CFRAME/ + +function construct(len) { + return new Array(len); +} + +function test(len) { + var blockSize = 16; + var blockCount = Math.ceil(len/blockSize); + var ciphertext = construct(blockCount); + var sum = 0; + for (var b = 0;b < blockCount; b++) { + sum += (sum * b * len); + } + return sum; +} + +test(17); \ No newline at end of file -- Gitee