Skip to content

Commit

Permalink
refactor: Reduce large structure moves
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Mar 14, 2024
1 parent 5f977e6 commit 6749e73
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 89 deletions.
113 changes: 58 additions & 55 deletions parser_library/src/processing/instruction_sets/asm_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ std::optional<int> try_get_number(std::string_view s)

} // namespace

void asm_processor::process_sect(const context::section_kind kind, rebuilt_statement stmt)
void asm_processor::process_sect(const context::section_kind kind, rebuilt_statement&& stmt)
{
auto sect_name = find_label_symbol(stmt);

Expand Down Expand Up @@ -115,7 +115,7 @@ void asm_processor::process_sect(const context::section_kind kind, rebuilt_state
lib_info);
}

void asm_processor::process_LOCTR(rebuilt_statement stmt)
void asm_processor::process_LOCTR(rebuilt_statement&& stmt)
{
auto loctr_name = find_label_symbol(stmt);

Expand Down Expand Up @@ -156,7 +156,7 @@ struct override_symbol_candidates final : public context::dependency_solver_redi
{}
};

void asm_processor::process_EQU(rebuilt_statement stmt)
void asm_processor::process_EQU(rebuilt_statement&& stmt)
{
auto loctr = hlasm_ctx.ord_ctx.align(context::no_align, lib_info);
context::ordinary_assembly_dependency_solver dep_solver(hlasm_ctx.ord_ctx, loctr, lib_info);
Expand Down Expand Up @@ -272,7 +272,7 @@ void asm_processor::process_EQU(rebuilt_statement stmt)
}

template<checking::data_instr_type instr_type>
void asm_processor::process_data_instruction(rebuilt_statement stmt)
void asm_processor::process_data_instruction(rebuilt_statement&& stmt)
{
if (const auto& ops = stmt.operands_ref().value; ops.empty()
|| std::any_of(
Expand Down Expand Up @@ -456,17 +456,17 @@ void asm_processor::process_data_instruction(rebuilt_statement stmt)
adder.finish();
}

void asm_processor::process_DC(rebuilt_statement stmt)
void asm_processor::process_DC(rebuilt_statement&& stmt)
{
process_data_instruction<checking::data_instr_type::DC>(std::move(stmt));
}

void asm_processor::process_DS(rebuilt_statement stmt)
void asm_processor::process_DS(rebuilt_statement&& stmt)
{
process_data_instruction<checking::data_instr_type::DS>(std::move(stmt));
}

void asm_processor::process_COPY(rebuilt_statement stmt)
void asm_processor::process_COPY(rebuilt_statement&& stmt)
{
find_sequence_symbol(stmt);

Expand Down Expand Up @@ -495,11 +495,14 @@ void asm_processor::process_COPY(rebuilt_statement stmt)
}
}

void asm_processor::process_EXTRN(rebuilt_statement stmt) { process_external(std::move(stmt), external_type::strong); }
void asm_processor::process_EXTRN(rebuilt_statement&& stmt)
{
process_external(std::move(stmt), external_type::strong);
}

void asm_processor::process_WXTRN(rebuilt_statement stmt) { process_external(std::move(stmt), external_type::weak); }
void asm_processor::process_WXTRN(rebuilt_statement&& stmt) { process_external(std::move(stmt), external_type::weak); }

void asm_processor::process_external(rebuilt_statement stmt, external_type t)
void asm_processor::process_external(rebuilt_statement&& stmt, external_type t)
{
if (auto label_type = stmt.label_ref().type; label_type != semantics::label_si_type::EMPTY)
{
Expand Down Expand Up @@ -549,7 +552,7 @@ void asm_processor::process_external(rebuilt_statement stmt, external_type t)
lib_info);
}

void asm_processor::process_ORG(rebuilt_statement stmt)
void asm_processor::process_ORG(rebuilt_statement&& stmt)
{
find_sequence_symbol(stmt);

Expand Down Expand Up @@ -683,7 +686,7 @@ void asm_processor::process_ORG(rebuilt_statement stmt)
}
}

void asm_processor::process_OPSYN(rebuilt_statement stmt)
void asm_processor::process_OPSYN(rebuilt_statement&& stmt)
{
const auto& operands = stmt.operands_ref().value;

Expand Down Expand Up @@ -822,39 +825,39 @@ asm_processor::process_table_t asm_processor::create_table()
{
process_table_t table;
table.emplace(context::id_index("CSECT"),
[this](rebuilt_statement stmt) { process_sect(context::section_kind::EXECUTABLE, std::move(stmt)); });
[this](rebuilt_statement&& stmt) { process_sect(context::section_kind::EXECUTABLE, std::move(stmt)); });
table.emplace(context::id_index("DSECT"),
[this](rebuilt_statement stmt) { process_sect(context::section_kind::DUMMY, std::move(stmt)); });
[this](rebuilt_statement&& stmt) { process_sect(context::section_kind::DUMMY, std::move(stmt)); });
table.emplace(context::id_index("RSECT"),
[this](rebuilt_statement stmt) { process_sect(context::section_kind::READONLY, std::move(stmt)); });
[this](rebuilt_statement&& stmt) { process_sect(context::section_kind::READONLY, std::move(stmt)); });
table.emplace(context::id_index("COM"),
[this](rebuilt_statement stmt) { process_sect(context::section_kind::COMMON, std::move(stmt)); });
table.emplace(context::id_index("LOCTR"), [this](rebuilt_statement stmt) { process_LOCTR(std::move(stmt)); });
table.emplace(context::id_index("EQU"), [this](rebuilt_statement stmt) { process_EQU(std::move(stmt)); });
table.emplace(context::id_index("DC"), [this](rebuilt_statement stmt) { process_DC(std::move(stmt)); });
table.emplace(context::id_index("DS"), [this](rebuilt_statement stmt) { process_DS(std::move(stmt)); });
[this](rebuilt_statement&& stmt) { process_sect(context::section_kind::COMMON, std::move(stmt)); });
table.emplace(context::id_index("LOCTR"), [this](rebuilt_statement&& stmt) { process_LOCTR(std::move(stmt)); });
table.emplace(context::id_index("EQU"), [this](rebuilt_statement&& stmt) { process_EQU(std::move(stmt)); });
table.emplace(context::id_index("DC"), [this](rebuilt_statement&& stmt) { process_DC(std::move(stmt)); });
table.emplace(context::id_index("DS"), [this](rebuilt_statement&& stmt) { process_DS(std::move(stmt)); });
table.emplace(
context::id_storage::well_known::COPY, [this](rebuilt_statement stmt) { process_COPY(std::move(stmt)); });
table.emplace(context::id_index("EXTRN"), [this](rebuilt_statement stmt) { process_EXTRN(std::move(stmt)); });
table.emplace(context::id_index("WXTRN"), [this](rebuilt_statement stmt) { process_WXTRN(std::move(stmt)); });
table.emplace(context::id_index("ORG"), [this](rebuilt_statement stmt) { process_ORG(std::move(stmt)); });
table.emplace(context::id_index("OPSYN"), [this](rebuilt_statement stmt) { process_OPSYN(std::move(stmt)); });
table.emplace(context::id_index("AINSERT"), [this](rebuilt_statement stmt) { process_AINSERT(std::move(stmt)); });
table.emplace(context::id_index("CCW"), [this](rebuilt_statement stmt) { process_CCW(std::move(stmt)); });
table.emplace(context::id_index("CCW0"), [this](rebuilt_statement stmt) { process_CCW(std::move(stmt)); });
table.emplace(context::id_index("CCW1"), [this](rebuilt_statement stmt) { process_CCW(std::move(stmt)); });
table.emplace(context::id_index("CNOP"), [this](rebuilt_statement stmt) { process_CNOP(std::move(stmt)); });
table.emplace(context::id_index("START"), [this](rebuilt_statement stmt) { process_START(std::move(stmt)); });
table.emplace(context::id_index("ALIAS"), [this](rebuilt_statement stmt) { process_ALIAS(std::move(stmt)); });
table.emplace(context::id_index("END"), [this](rebuilt_statement stmt) { process_END(std::move(stmt)); });
table.emplace(context::id_index("LTORG"), [this](rebuilt_statement stmt) { process_LTORG(std::move(stmt)); });
table.emplace(context::id_index("USING"), [this](rebuilt_statement stmt) { process_USING(std::move(stmt)); });
table.emplace(context::id_index("DROP"), [this](rebuilt_statement stmt) { process_DROP(std::move(stmt)); });
table.emplace(context::id_index("PUSH"), [this](rebuilt_statement stmt) { process_PUSH(std::move(stmt)); });
table.emplace(context::id_index("POP"), [this](rebuilt_statement stmt) { process_POP(std::move(stmt)); });
table.emplace(context::id_index("MNOTE"), [this](rebuilt_statement stmt) { process_MNOTE(std::move(stmt)); });
table.emplace(context::id_index("CXD"), [this](rebuilt_statement stmt) { process_CXD(std::move(stmt)); });
table.emplace(context::id_index("TITLE"), [this](rebuilt_statement stmt) { process_TITLE(std::move(stmt)); });
context::id_storage::well_known::COPY, [this](rebuilt_statement&& stmt) { process_COPY(std::move(stmt)); });
table.emplace(context::id_index("EXTRN"), [this](rebuilt_statement&& stmt) { process_EXTRN(std::move(stmt)); });
table.emplace(context::id_index("WXTRN"), [this](rebuilt_statement&& stmt) { process_WXTRN(std::move(stmt)); });
table.emplace(context::id_index("ORG"), [this](rebuilt_statement&& stmt) { process_ORG(std::move(stmt)); });
table.emplace(context::id_index("OPSYN"), [this](rebuilt_statement&& stmt) { process_OPSYN(std::move(stmt)); });
table.emplace(context::id_index("AINSERT"), [this](rebuilt_statement&& stmt) { process_AINSERT(std::move(stmt)); });
table.emplace(context::id_index("CCW"), [this](rebuilt_statement&& stmt) { process_CCW(std::move(stmt)); });
table.emplace(context::id_index("CCW0"), [this](rebuilt_statement&& stmt) { process_CCW(std::move(stmt)); });
table.emplace(context::id_index("CCW1"), [this](rebuilt_statement&& stmt) { process_CCW(std::move(stmt)); });
table.emplace(context::id_index("CNOP"), [this](rebuilt_statement&& stmt) { process_CNOP(std::move(stmt)); });
table.emplace(context::id_index("START"), [this](rebuilt_statement&& stmt) { process_START(std::move(stmt)); });
table.emplace(context::id_index("ALIAS"), [this](rebuilt_statement&& stmt) { process_ALIAS(std::move(stmt)); });
table.emplace(context::id_index("END"), [this](rebuilt_statement&& stmt) { process_END(std::move(stmt)); });
table.emplace(context::id_index("LTORG"), [this](rebuilt_statement&& stmt) { process_LTORG(std::move(stmt)); });
table.emplace(context::id_index("USING"), [this](rebuilt_statement&& stmt) { process_USING(std::move(stmt)); });
table.emplace(context::id_index("DROP"), [this](rebuilt_statement&& stmt) { process_DROP(std::move(stmt)); });
table.emplace(context::id_index("PUSH"), [this](rebuilt_statement&& stmt) { process_PUSH(std::move(stmt)); });
table.emplace(context::id_index("POP"), [this](rebuilt_statement&& stmt) { process_POP(std::move(stmt)); });
table.emplace(context::id_index("MNOTE"), [this](rebuilt_statement&& stmt) { process_MNOTE(std::move(stmt)); });
table.emplace(context::id_index("CXD"), [this](rebuilt_statement&& stmt) { process_CXD(std::move(stmt)); });
table.emplace(context::id_index("TITLE"), [this](rebuilt_statement&& stmt) { process_TITLE(std::move(stmt)); });

return table;
}
Expand Down Expand Up @@ -890,7 +893,7 @@ class AINSERT_operand_visitor final : public expressions::mach_expr_visitor
};
} // namespace

void asm_processor::process_AINSERT(rebuilt_statement stmt)
void asm_processor::process_AINSERT(rebuilt_statement&& stmt)
{
static constexpr std::string_view AINSERT = "AINSERT";
const auto& ops = stmt.operands_ref();
Expand Down Expand Up @@ -947,7 +950,7 @@ void asm_processor::process_AINSERT(rebuilt_statement stmt)
}
}

void asm_processor::process_CCW(rebuilt_statement stmt)
void asm_processor::process_CCW(rebuilt_statement&& stmt)
{
constexpr context::alignment ccw_align = context::doubleword;
constexpr size_t ccw_length = 8U;
Expand All @@ -972,7 +975,7 @@ void asm_processor::process_CCW(rebuilt_statement stmt)
lib_info);
}

void asm_processor::process_CNOP(rebuilt_statement stmt)
void asm_processor::process_CNOP(rebuilt_statement&& stmt)
{
auto loctr = hlasm_ctx.ord_ctx.align(context::halfword, lib_info);
context::ordinary_assembly_dependency_solver dep_solver(hlasm_ctx.ord_ctx, loctr, lib_info);
Expand Down Expand Up @@ -1006,7 +1009,7 @@ void asm_processor::process_CNOP(rebuilt_statement stmt)
}


void asm_processor::process_START(rebuilt_statement stmt)
void asm_processor::process_START(rebuilt_statement&& stmt)
{
auto sect_name = find_label_symbol(stmt);

Expand Down Expand Up @@ -1061,7 +1064,7 @@ void asm_processor::process_START(rebuilt_statement stmt)

section->current_location_counter().reserve_storage_area(offset, context::no_align);
}
void asm_processor::process_END(rebuilt_statement stmt)
void asm_processor::process_END(rebuilt_statement&& stmt)
{
const auto& label = stmt.label_ref();
context::ordinary_assembly_dependency_solver dep_solver(hlasm_ctx.ord_ctx, lib_info);
Expand Down Expand Up @@ -1093,7 +1096,7 @@ void asm_processor::process_END(rebuilt_statement stmt)

hlasm_ctx.end_reached();
}
void asm_processor::process_ALIAS(rebuilt_statement stmt)
void asm_processor::process_ALIAS(rebuilt_statement&& stmt)
{
auto symbol_name = find_label_symbol(stmt);
if (symbol_name.empty())
Expand All @@ -1108,7 +1111,7 @@ void asm_processor::process_ALIAS(rebuilt_statement stmt)
std::move(dep_solver).derive_current_dependency_evaluation_context(),
lib_info);
}
void asm_processor::process_LTORG(rebuilt_statement stmt)
void asm_processor::process_LTORG(rebuilt_statement&& stmt)
{
constexpr size_t sectalgn = 8;
auto loctr = hlasm_ctx.ord_ctx.align(context::alignment { 0, sectalgn }, lib_info);
Expand Down Expand Up @@ -1136,7 +1139,7 @@ void asm_processor::process_LTORG(rebuilt_statement stmt)
lib_info);
}

void asm_processor::process_USING(rebuilt_statement stmt)
void asm_processor::process_USING(rebuilt_statement&& stmt)
{
using namespace expressions;

Expand Down Expand Up @@ -1217,7 +1220,7 @@ void asm_processor::process_USING(rebuilt_statement stmt)
hlasm_ctx.processing_stack());
}

void asm_processor::process_DROP(rebuilt_statement stmt)
void asm_processor::process_DROP(rebuilt_statement&& stmt)
{
using namespace expressions;

Expand Down Expand Up @@ -1272,7 +1275,7 @@ bool asm_expr_quals(const semantics::operand_ptr& op, std::string_view value)
}
} // namespace

void asm_processor::process_PUSH(rebuilt_statement stmt)
void asm_processor::process_PUSH(rebuilt_statement&& stmt)
{
const auto& ops = stmt.operands_ref().value;

Expand All @@ -1286,7 +1289,7 @@ void asm_processor::process_PUSH(rebuilt_statement stmt)
lib_info);
}

void asm_processor::process_POP(rebuilt_statement stmt)
void asm_processor::process_POP(rebuilt_statement&& stmt)
{
const auto& ops = stmt.operands_ref().value;

Expand All @@ -1301,7 +1304,7 @@ void asm_processor::process_POP(rebuilt_statement stmt)
lib_info);
}

void asm_processor::process_MNOTE(rebuilt_statement stmt)
void asm_processor::process_MNOTE(rebuilt_statement&& stmt)
{
static constexpr std::string_view MNOTE = "MNOTE";
const auto& ops = stmt.operands_ref().value;
Expand Down Expand Up @@ -1397,7 +1400,7 @@ void asm_processor::process_MNOTE(rebuilt_statement stmt)
hlasm_ctx.update_mnote_max((unsigned)level.value());
}

void asm_processor::process_CXD(rebuilt_statement stmt)
void asm_processor::process_CXD(rebuilt_statement&& stmt)
{
context::address loctr = hlasm_ctx.ord_ctx.align(context::fullword, lib_info);
constexpr uint32_t cxd_length = 4;
Expand Down Expand Up @@ -1428,7 +1431,7 @@ struct title_label_visitor
std::string operator()(const semantics::vs_ptr&) const { return {}; }
};

void asm_processor::process_TITLE(rebuilt_statement stmt)
void asm_processor::process_TITLE(rebuilt_statement&& stmt)
{
const auto& label = stmt.label_ref();

Expand Down
54 changes: 27 additions & 27 deletions parser_library/src/processing/instruction_sets/asm_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace hlasm_plugin::parser_library::processing {
// processor of assembler instructions
class asm_processor : public low_language_processor
{
using process_table_t = std::unordered_map<context::id_index, std::function<void(rebuilt_statement)>>;
using process_table_t = std::unordered_map<context::id_index, std::function<void(rebuilt_statement&&)>>;

const process_table_t table_;

Expand Down Expand Up @@ -85,41 +85,41 @@ class asm_processor : public low_language_processor

context::id_index find_sequence_symbol(const rebuilt_statement& stmt);

void process_sect(const context::section_kind kind, rebuilt_statement stmt);
void process_LOCTR(rebuilt_statement stmt);
void process_EQU(rebuilt_statement stmt);
void process_DC(rebuilt_statement stmt);
void process_DS(rebuilt_statement stmt);
void process_COPY(rebuilt_statement stmt);
void process_EXTRN(rebuilt_statement stmt);
void process_WXTRN(rebuilt_statement stmt);
void process_ORG(rebuilt_statement stmt);
void process_OPSYN(rebuilt_statement stmt);
void process_AINSERT(rebuilt_statement stmt);
void process_CCW(rebuilt_statement stmt);
void process_CNOP(rebuilt_statement stmt);
void process_START(rebuilt_statement stmt);
void process_ALIAS(rebuilt_statement stmt);
void process_END(rebuilt_statement stmt);
void process_LTORG(rebuilt_statement stmt);
void process_USING(rebuilt_statement stmt);
void process_DROP(rebuilt_statement stmt);
void process_PUSH(rebuilt_statement stmt);
void process_POP(rebuilt_statement stmt);
void process_MNOTE(rebuilt_statement stmt);
void process_CXD(rebuilt_statement stmt);
void process_TITLE(rebuilt_statement stmt);
void process_sect(const context::section_kind kind, rebuilt_statement&& stmt);
void process_LOCTR(rebuilt_statement&& stmt);
void process_EQU(rebuilt_statement&& stmt);
void process_DC(rebuilt_statement&& stmt);
void process_DS(rebuilt_statement&& stmt);
void process_COPY(rebuilt_statement&& stmt);
void process_EXTRN(rebuilt_statement&& stmt);
void process_WXTRN(rebuilt_statement&& stmt);
void process_ORG(rebuilt_statement&& stmt);
void process_OPSYN(rebuilt_statement&& stmt);
void process_AINSERT(rebuilt_statement&& stmt);
void process_CCW(rebuilt_statement&& stmt);
void process_CNOP(rebuilt_statement&& stmt);
void process_START(rebuilt_statement&& stmt);
void process_ALIAS(rebuilt_statement&& stmt);
void process_END(rebuilt_statement&& stmt);
void process_LTORG(rebuilt_statement&& stmt);
void process_USING(rebuilt_statement&& stmt);
void process_DROP(rebuilt_statement&& stmt);
void process_PUSH(rebuilt_statement&& stmt);
void process_POP(rebuilt_statement&& stmt);
void process_MNOTE(rebuilt_statement&& stmt);
void process_CXD(rebuilt_statement&& stmt);
void process_TITLE(rebuilt_statement&& stmt);

template<checking::data_instr_type instr_type>
void process_data_instruction(rebuilt_statement stmt);
void process_data_instruction(rebuilt_statement&& stmt);

enum class external_type
{
strong,
weak,
};

void process_external(rebuilt_statement stmt, external_type t);
void process_external(rebuilt_statement&& stmt, external_type t);
};

} // namespace hlasm_plugin::parser_library::processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace hlasm_plugin::parser_library::processing {

template<checking::data_instr_type instr_type>
data_def_postponed_statement<instr_type>::data_def_postponed_statement(rebuilt_statement stmt,
data_def_postponed_statement<instr_type>::data_def_postponed_statement(rebuilt_statement&& stmt,
context::processing_stack_t stmt_location_stack,
std::vector<data_def_dependency<instr_type>> dependencies)
: postponed_statement_impl(std::move(stmt), std::move(stmt_location_stack))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class data_def_postponed_statement final : public postponed_statement_impl
std::vector<data_def_dependency<instr_type>> m_dependencies;

public:
data_def_postponed_statement(rebuilt_statement stmt,
data_def_postponed_statement(rebuilt_statement&& stmt,
context::processing_stack_t stmt_location_stack,
std::vector<data_def_dependency<instr_type>> dependencies);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace hlasm_plugin::parser_library::processing {
// implementation of postponed_statement interface
struct postponed_statement_impl : public context::postponed_statement, public resolved_statement
{
postponed_statement_impl(rebuilt_statement stmt, context::processing_stack_t stmt_location_stack)
postponed_statement_impl(rebuilt_statement&& stmt, context::processing_stack_t stmt_location_stack)
: stmt(std::move(stmt))
, stmt_location_stack(std::move(stmt_location_stack))
{}
Expand Down
Loading

0 comments on commit 6749e73

Please sign in to comment.