/* * Copyright (c) 2023 - 2024 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. */ #ifndef ES2PANDA_AOT_EMITFILES_H #define ES2PANDA_AOT_EMITFILES_H #include #include #include #include namespace panda::es2panda::aot { class EmitSingleAbcJob : public util::WorkerJob { public: explicit EmitSingleAbcJob(const std::string &outputFileName, panda::pandasm::Program *prog, std::map *statp, uint8_t targetApi, std::string targetSubApi) : outputFileName_(outputFileName), prog_(prog), statp_(statp), targetApiVersion_(targetApi), targetApiSubVersion_(targetSubApi) {}; NO_COPY_SEMANTIC(EmitSingleAbcJob); NO_MOVE_SEMANTIC(EmitSingleAbcJob); ~EmitSingleAbcJob() override = default; void Run() override; private: std::string outputFileName_; panda::pandasm::Program *prog_; std::map *statp_; uint8_t targetApiVersion_ = 0; std::string targetApiSubVersion_ { util::Helpers::DEFAULT_SUB_API_VERSION }; }; class EmitMergedAbcJob : public util::WorkerJob { public: explicit EmitMergedAbcJob(const std::string &outputFileName, const std::string &transformLib, const std::map &progsInfo, uint8_t targetApi, std::string targetSubApi) : outputFileName_(outputFileName), transformLib_(transformLib), progsInfo_(progsInfo), targetApiVersion_(targetApi), targetApiSubVersion_(targetSubApi) {}; NO_COPY_SEMANTIC(EmitMergedAbcJob); NO_MOVE_SEMANTIC(EmitMergedAbcJob); ~EmitMergedAbcJob() override = default; void Run() override; private: std::string outputFileName_; std::string transformLib_; const std::map &progsInfo_; uint8_t targetApiVersion_ = 0; std::string targetApiSubVersion_ { util::Helpers::DEFAULT_SUB_API_VERSION }; }; class EmitCacheJob : public util::WorkerJob { public: explicit EmitCacheJob(const std::string &outputProtoName, panda::es2panda::util::ProgramCache *progCache) : outputProtoName_(outputProtoName), progCache_(progCache) {}; NO_COPY_SEMANTIC(EmitCacheJob); NO_MOVE_SEMANTIC(EmitCacheJob); ~EmitCacheJob() override = default; void Run() override; private: std::string outputProtoName_; panda::es2panda::util::ProgramCache *progCache_; }; class EmitFileQueue : public util::WorkerQueue { public: explicit EmitFileQueue(const std::unique_ptr &options, std::map *statp, const std::map &progsInfo) : WorkerQueue(options->CompilerOptions().fileThreadCount), options_(options), statp_(statp), progsInfo_(progsInfo) { mergeAbc_ = options_->CompilerOptions().mergeAbc; } NO_COPY_SEMANTIC(EmitFileQueue); NO_MOVE_SEMANTIC(EmitFileQueue); ~EmitFileQueue() override = default; void Schedule() override; private: void ScheduleEmitCacheJobs(EmitMergedAbcJob *emitMergedAbcJob); const std::unique_ptr &options_; std::map *statp_; const std::map &progsInfo_; bool mergeAbc_ { false }; }; } // namespace panda::es2panda::aot #endif