aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm
diff options
context:
space:
mode:
Diffstat (limited to 'libevmasm')
-rw-r--r--libevmasm/Assembly.cpp3
-rw-r--r--libevmasm/ControlFlowGraph.cpp4
-rw-r--r--libevmasm/ControlFlowGraph.h7
-rw-r--r--libevmasm/EVMSchedule.h62
4 files changed, 74 insertions, 2 deletions
diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp
index 7f7e1b9c..2024b1e9 100644
--- a/libevmasm/Assembly.cpp
+++ b/libevmasm/Assembly.cpp
@@ -322,7 +322,8 @@ Assembly& Assembly::optimise(bool _enable, bool _isCreation, size_t _runs)
count++;
{
- ControlFlowGraph cfg(m_items);
+ // Control flow graph that resets knowledge at path joins.
+ ControlFlowGraph cfg(m_items, false);
AssemblyItems optimisedItems;
for (BasicBlock const& block: cfg.optimisedBlocks())
{
diff --git a/libevmasm/ControlFlowGraph.cpp b/libevmasm/ControlFlowGraph.cpp
index fc2144c7..d4801562 100644
--- a/libevmasm/ControlFlowGraph.cpp
+++ b/libevmasm/ControlFlowGraph.cpp
@@ -250,6 +250,10 @@ void ControlFlowGraph::gatherKnowledge()
KnownStatePointer state = item.state;
if (block.startState)
{
+ // We call reduceToCommonKnowledge even in the non-join setting to get the correct
+ // sequence number
+ if (!m_joinKnowledge)
+ state->reset();
state->reduceToCommonKnowledge(*block.startState, !item.blocksSeen.count(item.blockId));
if (*state == *block.startState)
continue;
diff --git a/libevmasm/ControlFlowGraph.h b/libevmasm/ControlFlowGraph.h
index 4480ba49..03a1f717 100644
--- a/libevmasm/ControlFlowGraph.h
+++ b/libevmasm/ControlFlowGraph.h
@@ -94,7 +94,11 @@ class ControlFlowGraph
public:
/// Initializes the control flow graph.
/// @a _items has to persist across the usage of this class.
- ControlFlowGraph(AssemblyItems const& _items): m_items(_items) {}
+ /// @a _joinKnowledge if true, reduces state knowledge to common base at the join of two paths
+ explicit ControlFlowGraph(AssemblyItems const& _items, bool _joinKnowledge = true):
+ m_items(_items),
+ m_joinKnowledge(_joinKnowledge)
+ {}
/// @returns vector of basic blocks in the order they should be used in the final code.
/// Should be called only once.
BasicBlocks optimisedBlocks();
@@ -112,6 +116,7 @@ private:
unsigned m_lastUsedId = 0;
AssemblyItems const& m_items;
+ bool m_joinKnowledge = true;
std::map<BlockId, BasicBlock> m_blocks;
};
diff --git a/libevmasm/EVMSchedule.h b/libevmasm/EVMSchedule.h
new file mode 100644
index 00000000..02a34b16
--- /dev/null
+++ b/libevmasm/EVMSchedule.h
@@ -0,0 +1,62 @@
+/*
+ This file is part of cpp-ethereum.
+
+ cpp-ethereum is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ cpp-ethereum is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
+*/
+/** @file EVMSchedule.h
+ * @author Gav <i@gavwood.com>
+ * @author Christian <c@ethdev.com>
+ * @date 2015
+ */
+
+#pragma once
+
+namespace dev
+{
+namespace solidity
+{
+
+struct EVMSchedule
+{
+ unsigned stackLimit = 1024;
+ unsigned expGas = 10;
+ unsigned expByteGas = 10;
+ unsigned sha3Gas = 30;
+ unsigned sha3WordGas = 6;
+ unsigned sloadGas = 50;
+ unsigned sstoreSetGas = 20000;
+ unsigned sstoreResetGas = 5000;
+ unsigned sstoreRefundGas = 15000;
+ unsigned jumpdestGas = 1;
+ unsigned logGas = 375;
+ unsigned logDataGas = 8;
+ unsigned logTopicGas = 375;
+ unsigned createGas = 32000;
+ unsigned callGas = 40;
+ unsigned callStipend = 2300;
+ unsigned callValueTransferGas = 9000;
+ unsigned callNewAccountGas = 25000;
+ unsigned suicideRefundGas = 24000;
+ unsigned memoryGas = 3;
+ unsigned quadCoeffDiv = 512;
+ unsigned createDataGas = 200;
+ unsigned txGas = 21000;
+ unsigned txCreateGas = 53000;
+ unsigned txDataZeroGas = 4;
+ unsigned txDataNonZeroGas = 68;
+ unsigned copyGas = 3;
+};
+
+}
+}