From f30fc4c62e718172ad99a95a297dd51218ee5dbf Mon Sep 17 00:00:00 2001 From: Martin Sajti Date: Tue, 3 Oct 2023 10:33:08 +0200 Subject: [PATCH] Fix deterministic output on single thread compile Issue: #9511 Change-Id: Id6f514270fde4a7f01d078749a85be1c60eaf11a Signed-off-by: Martin Sajti --- aot/options.cpp | 2 +- binder/ETSBinder.h | 9 ++++----- binder/recordTable.h | 12 ++++++------ compiler/core/emitter.cpp | 2 +- compiler/core/programElement.cpp | 2 +- compiler/core/programElement.h | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/aot/options.cpp b/aot/options.cpp index c5a15797f..35361a487 100644 --- a/aot/options.cpp +++ b/aot/options.cpp @@ -78,7 +78,7 @@ bool Options::Parse(int argc, const char **argv) panda::PandArg op_ets_module("ets-module", false, "Compile the input as ets-module"); panda::PandArg op_ts_decl_out("gen-ts-decl", "", "For given .ets file, generate .ts interop file"); - auto constexpr DEFAULT_THREAD_COUNT = 2; + auto constexpr DEFAULT_THREAD_COUNT = 0; panda::PandArg op_thread_count("thread", DEFAULT_THREAD_COUNT, "Number of worker threads"); panda::PandArg op_size_stat("dump-size-stat", false, "Dump size statistics"); panda::PandArg output_file("output", "", "Compiler binary output (.abc)"); diff --git a/binder/ETSBinder.h b/binder/ETSBinder.h index 5958839e7..481b23471 100644 --- a/binder/ETSBinder.h +++ b/binder/ETSBinder.h @@ -22,8 +22,7 @@ namespace panda::es2panda::binder { -using ComputedLambdaObjects = - ArenaUnorderedMap>; +using ComputedLambdaObjects = ArenaMap>; struct DynamicImportData { const ir::ETSImportDeclaration *import; @@ -83,12 +82,12 @@ public: return &global_record_table_; } - ArenaUnorderedMap &GetExternalRecordTable() + ArenaMap &GetExternalRecordTable() { return external_record_table_; } - const ArenaUnorderedMap &GetExternalRecordTable() const + const ArenaMap &GetExternalRecordTable() const { return external_record_table_; } @@ -194,7 +193,7 @@ private: RecordTable global_record_table_; RecordTable *record_table_; - ArenaUnorderedMap external_record_table_; + ArenaMap external_record_table_; ArenaVector default_imports_; ArenaVector dynamic_imports_; ComputedLambdaObjects lambda_objects_; diff --git a/binder/recordTable.h b/binder/recordTable.h index 59cf5ef16..2847f164f 100644 --- a/binder/recordTable.h +++ b/binder/recordTable.h @@ -67,22 +67,22 @@ public: return (flags_ & RecordTableFlags::EXTERNAL) != 0; } - ArenaUnorderedSet &ClassDefinitions() + ArenaSet &ClassDefinitions() { return class_definitions_; } - const ArenaUnorderedSet &ClassDefinitions() const + const ArenaSet &ClassDefinitions() const { return class_definitions_; } - ArenaUnorderedSet &InterfaceDeclarations() + ArenaSet &InterfaceDeclarations() { return interface_declarations_; } - const ArenaUnorderedSet &InterfaceDeclarations() const + const ArenaSet &InterfaceDeclarations() const { return interface_declarations_; } @@ -154,8 +154,8 @@ private: friend class BoundContext; using RecordHolder = std::variant; - ArenaUnorderedSet class_definitions_; - ArenaUnorderedSet interface_declarations_; + ArenaSet class_definitions_; + ArenaSet interface_declarations_; ArenaVector signatures_; RecordHolder record_ {nullptr}; parser::Program *program_ {}; diff --git a/compiler/core/emitter.cpp b/compiler/core/emitter.cpp index 0891cfe7d..2c5f4f094 100644 --- a/compiler/core/emitter.cpp +++ b/compiler/core/emitter.cpp @@ -384,7 +384,7 @@ static void UpdateLiteralBufferId([[maybe_unused]] panda::pandasm::Ins *ins, [[m void Emitter::AddProgramElement(ProgramElement *program_element) { - prog_->strings.merge(program_element->Strings()); + prog_->strings.insert(program_element->Strings().begin(), program_element->Strings().end()); uint32_t new_literal_buffer_index = literal_buffer_index_; for (const auto &buff : program_element->BuffStorage()) { diff --git a/compiler/core/programElement.cpp b/compiler/core/programElement.cpp index e603e0ac7..bbbdd130e 100644 --- a/compiler/core/programElement.cpp +++ b/compiler/core/programElement.cpp @@ -18,7 +18,7 @@ #include namespace panda::es2panda::compiler { -std::unordered_set &ProgramElement::Strings() +std::set &ProgramElement::Strings() { return strings_; } diff --git a/compiler/core/programElement.h b/compiler/core/programElement.h index 0fc4d3bb3..db5bd11d1 100644 --- a/compiler/core/programElement.h +++ b/compiler/core/programElement.h @@ -32,14 +32,14 @@ public: NO_COPY_SEMANTIC(ProgramElement); NO_MOVE_SEMANTIC(ProgramElement); - std::unordered_set &Strings(); + std::set &Strings(); std::vector &LiteralBufferIns(); std::vector &BuffStorage(); pandasm::Function *Function(); void SetFunction(pandasm::Function *func); private: - std::unordered_set strings_; + std::set strings_; std::vector literal_buffer_ins_; std::vector buff_storage_; pandasm::Function *func_ {}; -- Gitee