Skip to content

Commit c097842

Browse files
committed
rebase
1 parent 0c0853e commit c097842

File tree

5 files changed

+25
-51
lines changed

5 files changed

+25
-51
lines changed

libevmasm/Assembly.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ bool Assembly::loadFromAssemblyJSON(Json::Value const& _json, bool _loadSources
602602
this->m_data[h256(fromHex(key))] = fromHex(code.asString());
603603
else
604604
{
605-
shared_ptr<Assembly> subassembly = make_shared<Assembly>();
605+
shared_ptr<Assembly> subassembly = make_shared<Assembly>(false, "");
606606
subassembly->setSources(this->sources());
607607
result &= subassembly->loadFromAssemblyJSON(code, false);
608608
this->m_subs.emplace_back(subassembly);
@@ -646,25 +646,6 @@ AssemblyItem Assembly::newImmutableAssignment(string const& _identifier)
646646
return AssemblyItem{AssignImmutable, h};
647647
}
648648

649-
Assembly& Assembly::optimise(bool _enable, EVMVersion _evmVersion, bool _isCreation, size_t _runs)
650-
{
651-
OptimiserSettings settings;
652-
settings.isCreation = _isCreation;
653-
settings.runInliner = true;
654-
settings.runJumpdestRemover = true;
655-
settings.runPeephole = true;
656-
if (_enable)
657-
{
658-
settings.runDeduplicate = true;
659-
settings.runCSE = true;
660-
settings.runConstantOptimiser = true;
661-
}
662-
settings.evmVersion = _evmVersion;
663-
settings.expectedExecutionsPerDeployment = _runs;
664-
optimise(settings);
665-
return *this;
666-
}
667-
668649
Assembly& Assembly::optimise(OptimiserSettings const& _settings)
669650
{
670651
optimiseInternal(_settings, {});

libevmasm/Assembly.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,6 @@ class Assembly
134134
/// is optimised according to the settings in @a _settings.
135135
Assembly& optimise(OptimiserSettings const& _settings);
136136

137-
/// Modify (if @a _enable is set) and return the current assembly such that creation and
138-
/// execution gas usage is optimised. @a _isCreation should be true for the top-level assembly.
139-
/// @a _runs specifes an estimate on how often each opcode in this assembly will be executed,
140-
/// i.e. use a small value to optimise for size and a large value to optimise for runtime.
141-
/// If @a _enable is not set, will perform some simple peephole optimizations.
142-
Assembly& optimise(bool _enable, langutil::EVMVersion _evmVersion, bool _isCreation, size_t _runs);
143-
144137
/// Create a text representation of the assembly.
145138
std::string assemblyString(
146139
langutil::DebugInfoSelection const& _debugInfoSelection = langutil::DebugInfoSelection::Default(),

libsolidity/interface/CompilerStack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,13 +692,13 @@ bool CompilerStack::compile(State _stopAfter)
692692
optimiserSettings.runJumpdestRemover = m_optimiserSettings.runJumpdestRemover;
693693
optimiserSettings.runPeephole = m_optimiserSettings.runPeephole;
694694

695-
m_contracts[evmSourceName].evmAssembly = make_shared<evmasm::Assembly>(evmSourceName);
695+
m_contracts[evmSourceName].evmAssembly = make_shared<evmasm::Assembly>(true, evmSourceName);
696696
m_contracts[evmSourceName].evmAssembly->loadFromAssemblyJSON(m_evmAssemblyJson[evmSourceName]);
697697
if (m_optimiserSettings.enabled)
698698
m_contracts[evmSourceName].evmAssembly->optimise(optimiserSettings);
699699
m_contracts[evmSourceName].object = m_contracts[evmSourceName].evmAssembly->assemble();
700700

701-
m_contracts[evmSourceName].evmRuntimeAssembly = make_shared<evmasm::Assembly>(evmSourceName);
701+
m_contracts[evmSourceName].evmRuntimeAssembly = make_shared<evmasm::Assembly>(false, evmSourceName);
702702
m_contracts[evmSourceName].evmRuntimeAssembly->setSources(m_contracts[evmSourceName].evmAssembly->sources());
703703
m_contracts[evmSourceName].evmRuntimeAssembly->loadFromAssemblyJSON(m_evmAssemblyJson[evmSourceName][".data"]["0"], false);
704704
if (m_optimiserSettings.enabled)

solc/CommandLineParser.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ ostream& operator<<(ostream& _out, CompilerOutputs const& _selection)
168168
if (_selection.*component)
169169
serializedSelection.push_back(CompilerOutputs::componentName(component));
170170

171-
return _out << joinHumanReadable(serializedSelection, ",");
171+
return _out << util::joinHumanReadable(serializedSelection, ",");
172172
}
173173

174174
string const& CompilerOutputs::componentName(bool CompilerOutputs::* _component)
@@ -199,7 +199,7 @@ ostream& operator<<(ostream& _out, CombinedJsonRequests const& _requests)
199199
if (_requests.*component)
200200
serializedRequests.push_back(CombinedJsonRequests::componentName(component));
201201

202-
return _out << joinHumanReadable(serializedRequests, ",");
202+
return _out << util::joinHumanReadable(serializedRequests, ",");
203203
}
204204

205205
string const& CombinedJsonRequests::componentName(bool CombinedJsonRequests::* _component)
@@ -347,17 +347,17 @@ void CommandLineParser::parseLibraryOption(string const& _input)
347347
try
348348
{
349349
if (fs::is_regular_file(_input))
350-
data = readFileAsString(_input);
350+
data = util::readFileAsString(_input);
351351
}
352352
catch (fs::filesystem_error const&)
353353
{
354354
// Thrown e.g. if path is too long.
355355
}
356-
catch (FileNotFound const&)
356+
catch (util::FileNotFound const&)
357357
{
358358
// Should not happen if `fs::is_regular_file` is correct.
359359
}
360-
catch (NotAFile const&)
360+
catch (util::NotAFile const&)
361361
{
362362
// Should not happen if `fs::is_regular_file` is correct.
363363
}
@@ -422,15 +422,15 @@ void CommandLineParser::parseLibraryOption(string const& _input)
422422
"Invalid length for address for library \"" + libName + "\": " +
423423
to_string(addrString.length()) + " instead of 40 characters."
424424
);
425-
if (!passesAddressChecksum(addrString, false))
425+
if (!util::passesAddressChecksum(addrString, false))
426426
solThrow(
427427
CommandLineValidationError,
428428
"Invalid checksum on address for library \"" + libName + "\": " + addrString + "\n"
429-
"The correct checksum is " + getChecksummedAddress(addrString)
429+
"The correct checksum is " + util::getChecksummedAddress(addrString)
430430
);
431-
bytes binAddr = fromHex(addrString);
432-
h160 address(binAddr, h160::AlignRight);
433-
if (binAddr.size() > 20 || address == h160())
431+
bytes binAddr = util::fromHex(addrString);
432+
util::h160 address(binAddr, util::h160::AlignRight);
433+
if (binAddr.size() > 20 || address == util::h160())
434434
solThrow(
435435
CommandLineValidationError,
436436
"Invalid address for library \"" + libName + "\": " + addrString
@@ -595,15 +595,15 @@ General Information)").c_str(),
595595
)
596596
(
597597
g_strRevertStrings.c_str(),
598-
po::value<string>()->value_name(joinHumanReadable(g_revertStringsArgs, ",")),
598+
po::value<string>()->value_name(util::joinHumanReadable(g_revertStringsArgs, ",")),
599599
"Strip revert (and require) reason strings or add additional debugging information."
600600
)
601601
(
602602
g_strDebugInfo.c_str(),
603-
po::value<string>()->default_value(toString(DebugInfoSelection::Default())),
603+
po::value<string>()->default_value(util::toString(DebugInfoSelection::Default())),
604604
("Debug info components to be included in the produced EVM assembly and Yul code. "
605605
"Value can be all, none or a comma-separated list containing one or more of the "
606-
"following components: " + joinHumanReadable(DebugInfoSelection::componentMap() | ranges::views::keys) + ".").c_str()
606+
"following components: " + util::joinHumanReadable(DebugInfoSelection::componentMap() | ranges::views::keys) + ".").c_str()
607607
)
608608
(
609609
g_strStopAfter.c_str(),
@@ -665,12 +665,12 @@ General Information)").c_str(),
665665
assemblyModeOptions.add_options()
666666
(
667667
g_strMachine.c_str(),
668-
po::value<string>()->value_name(joinHumanReadable(g_machineArgs, ",")),
668+
po::value<string>()->value_name(util::joinHumanReadable(g_machineArgs, ",")),
669669
"Target machine in assembly or Yul mode."
670670
)
671671
(
672672
g_strYulDialect.c_str(),
673-
po::value<string>()->value_name(joinHumanReadable(g_yulDialectArgs, ",")),
673+
po::value<string>()->value_name(util::joinHumanReadable(g_yulDialectArgs, ",")),
674674
"Input dialect to use in assembly or yul mode."
675675
)
676676
;
@@ -743,7 +743,7 @@ General Information)").c_str(),
743743
)
744744
(
745745
g_strCombinedJson.c_str(),
746-
po::value<string>()->value_name(joinHumanReadable(CombinedJsonRequests::componentMap() | ranges::views::keys, ",")),
746+
po::value<string>()->value_name(util::joinHumanReadable(CombinedJsonRequests::componentMap() | ranges::views::keys, ",")),
747747
"Output a single json document containing the specified information."
748748
)
749749
;
@@ -753,7 +753,7 @@ General Information)").c_str(),
753753
metadataOptions.add_options()
754754
(
755755
g_strMetadataHash.c_str(),
756-
po::value<string>()->value_name(joinHumanReadable(g_metadataHashArgs, ",")),
756+
po::value<string>()->value_name(util::joinHumanReadable(g_metadataHashArgs, ",")),
757757
"Choose hash method for the bytecode metadata or disable it."
758758
)
759759
(
@@ -1047,11 +1047,11 @@ void CommandLineParser::processArgs()
10471047

10481048
if (m_args.count(g_strPrettyJson) > 0)
10491049
{
1050-
m_options.formatting.json.format = JsonFormat::Pretty;
1050+
m_options.formatting.json.format = util::JsonFormat::Pretty;
10511051
}
10521052
if (!m_args[g_strJsonIndent].defaulted())
10531053
{
1054-
m_options.formatting.json.format = JsonFormat::Pretty;
1054+
m_options.formatting.json.format = util::JsonFormat::Pretty;
10551055
m_options.formatting.json.indent = m_args[g_strJsonIndent].as<uint32_t>();
10561056
}
10571057

@@ -1329,7 +1329,7 @@ size_t CommandLineParser::countEnabledOptions(vector<string> const& _optionNames
13291329

13301330
string CommandLineParser::joinOptionNames(vector<string> const& _optionNames, string _separator)
13311331
{
1332-
return joinHumanReadable(
1332+
return util::joinHumanReadable(
13331333
_optionNames | ranges::views::transform([](string const& _option){ return "--" + _option; }),
13341334
_separator
13351335
);

test/libevmasm/Assembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE(all_assembly_items)
6767
auto sub_asm = make_shared<string>("sub.asm");
6868
_subAsm.setSourceLocation({6, 8, sub_asm});
6969

70-
Assembly _verbatimAsm;
70+
Assembly _verbatimAsm(true, "");
7171
auto verbatim_asm = make_shared<string>("verbatim.asm");
7272
_verbatimAsm.setSourceLocation({8, 18, verbatim_asm});
7373

@@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(all_assembly_items)
202202
BOOST_CHECK(util::jsonParseStrict(json, jsonValue));
203203
BOOST_CHECK_EQUAL(util::jsonCompactPrint(_assembly.assemblyJSON(indices)), util::jsonCompactPrint(jsonValue));
204204

205-
Assembly _assemblyFromJson;
205+
Assembly _assemblyFromJson(true, "");
206206
_assemblyFromJson.loadFromAssemblyJSON(_assembly.assemblyJSON(indices));
207207
BOOST_CHECK_EQUAL(util::jsonCompactPrint(_assemblyFromJson.assemblyJSON(indices)), util::jsonCompactPrint(jsonValue));
208208
BOOST_CHECK_EQUAL(_assembly.assemble().toHex(), _assemblyFromJson.assemble().toHex());

0 commit comments

Comments
 (0)