From d0d126fc69b6e689ae03e888be80990e7b9bbbbe Mon Sep 17 00:00:00 2001 From: Tao Wu Date: Wed, 10 Sep 2025 17:49:46 +0800 Subject: [PATCH] cherry-pick pr 8309 to branch 0728 Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICXDUG?from=project-issue Signed-off-by: Tao Wu Change-Id: Ia0dfdf353a7792572cd2e40fdb50980c3ccd06b4 --- ets2panda/driver/build_system/src/build/base_mode.ts | 3 ++- ets2panda/driver/build_system/src/build/compile_worker.ts | 1 + ets2panda/util/generateBin.cpp | 1 + ets2panda/util/options.yaml | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ets2panda/driver/build_system/src/build/base_mode.ts b/ets2panda/driver/build_system/src/build/base_mode.ts index 0117bdc06b..43c25cd27e 100644 --- a/ets2panda/driver/build_system/src/build/base_mode.ts +++ b/ets2panda/driver/build_system/src/build/base_mode.ts @@ -348,7 +348,8 @@ export abstract class BaseMode { moduleInfo.arktsConfigFile, '--output', intermediateFilePath, - '--simultaneous' + '--simultaneous', + '--opt-try-catch-func=false' ]; ensurePathExists(intermediateFilePath); if (this.isDebug) { diff --git a/ets2panda/driver/build_system/src/build/compile_worker.ts b/ets2panda/driver/build_system/src/build/compile_worker.ts index a93ea46d22..252c963381 100644 --- a/ets2panda/driver/build_system/src/build/compile_worker.ts +++ b/ets2panda/driver/build_system/src/build/compile_worker.ts @@ -59,6 +59,7 @@ process.on('message', (message: { '_', '--extension', 'ets', '--arktsconfig', fileInfo.arktsConfigFile, '--output', fileInfo.abcFilePath, + '--opt-try-catch-func=false' ]; if (isDebug) { ets2pandaCmd.push('--debug-info'); diff --git a/ets2panda/util/generateBin.cpp b/ets2panda/util/generateBin.cpp index 134b2c9511..46fa686579 100644 --- a/ets2panda/util/generateBin.cpp +++ b/ets2panda/util/generateBin.cpp @@ -50,6 +50,7 @@ static int OptimizeBytecode(ark::pandasm::Program *prog, const util::Options &op } ark::bytecodeopt::g_options.SetOptLevel(options.GetOptLevel()); + ark::bytecodeopt::g_options.SetSkipMethodsWithEh(!options.IsOptTryCatchFunc()); // Set default value instead of maximum set in ark::bytecodeopt::SetCompilerOptions() ark::compiler::CompilerLogger::Init({"all"}); ark::compiler::g_options.SetCompilerMaxBytecodeSize(ark::compiler::g_options.GetCompilerMaxBytecodeSize()); diff --git a/ets2panda/util/options.yaml b/ets2panda/util/options.yaml index 0e3f72acae..32274e6c7d 100644 --- a/ets2panda/util/options.yaml +++ b/ets2panda/util/options.yaml @@ -101,6 +101,11 @@ options: description: Compiler optimization level range: 0-2 +- name: opt-try-catch-func + type: bool + default: true + description: Enable optimizations for functions with try-catch blocks + - name: ets-module type: bool default: false -- Gitee