From ea9366ae87de940a149224eb26d11846da0574f6 Mon Sep 17 00:00:00 2001 From: Tao Wu Date: Wed, 10 Sep 2025 17:41:45 +0800 Subject: [PATCH] add opt-try-catch-func option for es2panda Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICXDTE Signed-off-by: Tao Wu Change-Id: I2b5e8eb17f06c465289ec1bea10ac56a0178d3ed --- ets2panda/driver/build_system/src/build/base_mode.ts | 3 ++- ets2panda/driver/build_system/src/build/compile_worker.ts | 3 ++- ets2panda/util/generateBin.cpp | 1 + ets2panda/util/options.yaml | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ets2panda/driver/build_system/src/build/base_mode.ts b/ets2panda/driver/build_system/src/build/base_mode.ts index 231eaa7349..d2a5b6d816 100644 --- a/ets2panda/driver/build_system/src/build/base_mode.ts +++ b/ets2panda/driver/build_system/src/build/base_mode.ts @@ -360,7 +360,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 fbb0b497c0..47abc6440a 100644 --- a/ets2panda/driver/build_system/src/build/compile_worker.ts +++ b/ets2panda/driver/build_system/src/build/compile_worker.ts @@ -62,7 +62,8 @@ process.on('message', async (message: { let ets2pandaCmd = [ '_', '--extension', 'ets', '--arktsconfig', fileInfo.arktsConfigFile, - '--output', fileInfo.abcFilePath + '--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 a27bac139c..8fd646b5a5 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