aboutsummaryrefslogtreecommitdiffstats
path: root/Assembly.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-09 00:58:42 +0800
committerchriseth <c@ethdev.com>2015-05-09 00:58:42 +0800
commit6cc71a188f3c59b32ac1f131ee74c703f1f81a70 (patch)
treef5f228b61fd53b6072db548c705463d05e26e2be /Assembly.cpp
parent4d62c463d143c93f7938db5b8f7d01d33aa1a698 (diff)
parent1dfcb4735011dfaa143d6592713ec6b4bf097934 (diff)
downloaddexon-solidity-6cc71a188f3c59b32ac1f131ee74c703f1f81a70.tar
dexon-solidity-6cc71a188f3c59b32ac1f131ee74c703f1f81a70.tar.gz
dexon-solidity-6cc71a188f3c59b32ac1f131ee74c703f1f81a70.tar.bz2
dexon-solidity-6cc71a188f3c59b32ac1f131ee74c703f1f81a70.tar.lz
dexon-solidity-6cc71a188f3c59b32ac1f131ee74c703f1f81a70.tar.xz
dexon-solidity-6cc71a188f3c59b32ac1f131ee74c703f1f81a70.tar.zst
dexon-solidity-6cc71a188f3c59b32ac1f131ee74c703f1f81a70.zip
Merge pull request #1813 from chriseth/sol_knowledgeEngine
Static Analysis Engine.
Diffstat (limited to 'Assembly.cpp')
-rw-r--r--Assembly.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/Assembly.cpp b/Assembly.cpp
index 6cc09a4b..9530ded4 100644
--- a/Assembly.cpp
+++ b/Assembly.cpp
@@ -304,9 +304,6 @@ Assembly& Assembly::optimise(bool _enable)
{
if (!_enable)
return *this;
- std::vector<pair<AssemblyItems, function<AssemblyItems(AssemblyItemsConstRef)>>> rules;
- // jump to next instruction
- rules.push_back({ { PushTag, Instruction::JUMP, Tag }, [](AssemblyItemsConstRef m) -> AssemblyItems { if (m[0].data() == m[2].data()) return {m[2]}; else return m.toVector(); }});
unsigned total = 0;
for (unsigned count = 1; count > 0; total += count)
@@ -314,10 +311,17 @@ Assembly& Assembly::optimise(bool _enable)
copt << toString(*this);
count = 0;
+ //@todo CFG interface should be a generator, that returns an item and a pointer to a
+ // knownstate, which has to replace the current state if it is not null.
+ // Feed these items to the CSE, but also store them and replace the stored version
+ // if the items generated by the CSE are shorter. (or even use less gas?)
copt << "Performing control flow analysis...";
{
ControlFlowGraph cfg(m_items);
- AssemblyItems optItems = cfg.optimisedItems();
+ AssemblyItems optItems;
+ for (BasicBlock const& block: cfg.optimisedBlocks())
+ copy(m_items.begin() + block.begin, m_items.begin() + block.end,
+ back_inserter(optItems));
if (optItems.size() < m_items.size())
{
copt << "Old size: " << m_items.size() << ", new size: " << optItems.size();
@@ -329,7 +333,9 @@ Assembly& Assembly::optimise(bool _enable)
copt << "Performing common subexpression elimination...";
for (auto iter = m_items.begin(); iter != m_items.end();)
{
- CommonSubexpressionEliminator eliminator;
+ //@todo use only a single state / expression classes instance.
+ KnownState state(make_shared<ExpressionClasses>());
+ CommonSubexpressionEliminator eliminator(state);
auto orig = iter;
iter = eliminator.feedItems(iter, m_items.end());
AssemblyItems optItems;