From 1a4bdeb6c5063659e9ad919f37a17a6f6da55cbd Mon Sep 17 00:00:00 2001 From: qiuyu Date: Tue, 12 Jul 2022 16:59:40 +0800 Subject: [PATCH] Bytecode optimizer adaption and test adaption Disable bytecode optimizer by defalut. use --opt-level to enable it Remove deprecated code (class2panda log mask) Adapt function name change for type adapter unit test Signed-off-by: qiuyu Change-Id: I2bec65bff38913a41554b7ef415d5a5130872a6a --- ts2panda/src/cmdOptions.ts | 2 +- .../ts2abc/tests/type_adapter_test/type_adapter_test.cpp | 2 +- ts2panda/ts2abc/ts2abc.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ts2panda/src/cmdOptions.ts b/ts2panda/src/cmdOptions.ts index 4e108670db..d4049f6c37 100644 --- a/ts2panda/src/cmdOptions.ts +++ b/ts2panda/src/cmdOptions.ts @@ -34,7 +34,7 @@ const ts2pandaOptions = [ { name: 'timeout', alias: 't', type: Number, defaultValue: 0, description: "js to abc timeout threshold(unit: seconds)." }, { name: 'opt-log-level', type: String, defaultValue: "error", description: "specifie optimizer log level. Possible values: ['debug', 'info', 'error', 'fatal']" }, { - name: 'opt-level', type: Number, defaultValue: 1, description: "Optimization level. Possible values: [0, 1, 2]. Default: 0\n 0: no optimizations\n \ + name: 'opt-level', type: Number, defaultValue: 0, description: "Optimization level. Possible values: [0, 1, 2]. Default: 0\n 0: no optimizations\n \ 1: basic bytecode optimizations, including valueNumber, lowering, constantResolver, regAccAllocator\n \ 2: other bytecode optimizations, unimplemented yet"}, { name: 'help', alias: 'h', type: Boolean, description: "Show usage guide." }, diff --git a/ts2panda/ts2abc/tests/type_adapter_test/type_adapter_test.cpp b/ts2panda/ts2abc/tests/type_adapter_test/type_adapter_test.cpp index 4e8bf2f9a2..9f989d125d 100644 --- a/ts2panda/ts2abc/tests/type_adapter_test/type_adapter_test.cpp +++ b/ts2panda/ts2abc/tests/type_adapter_test/type_adapter_test.cpp @@ -100,7 +100,7 @@ void TypeAdapterTest::TestVariablesArgsType() const panda::pandasm::Parser p; auto res = p.Parse(source); auto &program = res.Value(); - auto it = program.function_table.find("foo"); + auto it = program.function_table.find("foo:(any,any)"); TestAssertNotEqual(it, program.function_table.end()); auto &foo = it->second; diff --git a/ts2panda/ts2abc/ts2abc.cpp b/ts2panda/ts2abc/ts2abc.cpp index f66e50ce9f..fafa7ae825 100644 --- a/ts2panda/ts2abc/ts2abc.cpp +++ b/ts2panda/ts2abc/ts2abc.cpp @@ -1327,9 +1327,11 @@ bool GenerateProgram([[maybe_unused]] const std::string &data, const std::string if (g_optLevel != static_cast(OptLevel::O_LEVEL0) || optLevel != static_cast(OptLevel::O_LEVEL0)) { optLogLevel = (optLogLevel != "error") ? optLogLevel : g_optLogLevel; - const uint32_t componentMask = panda::Logger::Component::CLASS2PANDA | panda::Logger::Component::ASSEMBLER | - panda::Logger::Component::BYTECODE_OPTIMIZER | panda::Logger::Component::COMPILER; - panda::Logger::InitializeStdLogging(panda::Logger::LevelFromString(optLogLevel), componentMask); + panda::Logger::ComponentMask mask; + mask.set(panda::Logger::Component::ASSEMBLER); + mask.set(panda::Logger::Component::BYTECODE_OPTIMIZER); + mask.set(panda::Logger::Component::COMPILER); + panda::Logger::InitializeStdLogging(panda::Logger::LevelFromString(optLogLevel), mask); bool emitDebugInfo = true; std::map stat; -- Gitee