diff --git a/runtime/profiling/plugin_clear_profile.h b/runtime/profiling/plugin_clear_profile.h index 716880bd9e866371468acc4738a35cc214d45e51..60851a4e352da8ea03bb6204caabfa4358e754cb 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 7bfc660ad5047a911607e4dccc8be5052e479c6b..144a0ce9b31cce0086d2027dc9ce42db7db85d50 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 0000000000000000000000000000000000000000..3cea1b9df5d8629843ae6b7b021d225958a2cba7 --- /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