Skip to content

Commit

Permalink
bintr: Make code shared, avoiding copy for background compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Jul 7, 2024
1 parent 5d5f8e1 commit 52d5d43
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/libriscv/tr_translate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,12 @@ if constexpr (SCAN_FOR_GP) {
// Code generation
std::vector<TransMapping<W>> dlmappings;
extern const std::string bintr_code;
std::string code = bintr_code;
std::shared_ptr<std::string> code = std::make_shared<std::string>(bintr_code);

for (auto& block : blocks)
{
block.blocks = &blocks;
auto result = emit(code, block);
auto result = emit(*code, block);

for (auto& mapping : result) {
dlmappings.push_back(std::move(mapping));
Expand Down Expand Up @@ -624,7 +624,7 @@ VISIBLE const struct Mapping mappings[] = {
void* dylib = nullptr;
auto* exec = shared_segment.get();
// Final shared library loadable code w/footer
const std::string shared_library_code = code + footer;
const std::string shared_library_code = *code + footer;

TIME_POINT(t9);
if constexpr (libtcc_enabled) {
Expand Down Expand Up @@ -697,7 +697,7 @@ VISIBLE const struct Mapping mappings[] = {
for (auto& def : defines) {
embed_file << "#define " << def.first << " " << def.second << "\n";
}
embed_file << code;
embed_file << *code;
// Construct a footer that self-registers the translation
const std::string reg_func = "libriscv_register_translation" + std::to_string(W);
embed_file << R"V0G0N(
Expand Down

0 comments on commit 52d5d43

Please sign in to comment.