aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm/Assembly.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-27 20:06:36 +0800
committerGitHub <noreply@github.com>2017-07-27 20:06:36 +0800
commit1caa14b0717533dc415d76aa92061235c7aaebfd (patch)
tree572964fab76c6c5e8e67fbc998f0b142ff8c2c50 /libevmasm/Assembly.h
parentfd9d953919b7b89f0999f830241c7900a5d1f266 (diff)
parentf9d5f7e4973d68500adec10d29e13c0151d8fedb (diff)
downloaddexon-solidity-1caa14b0717533dc415d76aa92061235c7aaebfd.tar
dexon-solidity-1caa14b0717533dc415d76aa92061235c7aaebfd.tar.gz
dexon-solidity-1caa14b0717533dc415d76aa92061235c7aaebfd.tar.bz2
dexon-solidity-1caa14b0717533dc415d76aa92061235c7aaebfd.tar.lz
dexon-solidity-1caa14b0717533dc415d76aa92061235c7aaebfd.tar.xz
dexon-solidity-1caa14b0717533dc415d76aa92061235c7aaebfd.tar.zst
dexon-solidity-1caa14b0717533dc415d76aa92061235c7aaebfd.zip
Merge pull request #2651 from ethereum/asm-optimiser
Introduce fine-grained optimiser settings in libevmasm
Diffstat (limited to 'libevmasm/Assembly.h')
-rw-r--r--libevmasm/Assembly.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h
index 0d40abcf..451b4ea0 100644
--- a/libevmasm/Assembly.h
+++ b/libevmasm/Assembly.h
@@ -97,12 +97,28 @@ public:
LinkerObject const& assemble() const;
bytes const& data(h256 const& _i) const { return m_data.at(_i); }
+ struct OptimiserSettings
+ {
+ bool isCreation = false;
+ bool runPeephole = false;
+ bool runDeduplicate = false;
+ bool runCSE = false;
+ bool runConstantOptimiser = false;
+ /// This specifies an estimate on how often each opcode in this assembly will be executed,
+ /// i.e. use a small value to optimise for size and a large value to optimise for runtime gas usage.
+ size_t expectedExecutionsPerDeployment = 200;
+ };
+
+ /// Execute optimisation passes as defined by @a _settings and return the optimised assembly.
+ Assembly& optimise(OptimiserSettings _settings);
+
/// Modify (if @a _enable is set) and return the current assembly such that creation and
/// execution gas usage is optimised. @a _isCreation should be true for the top-level assembly.
/// @a _runs specifes an estimate on how often each opcode in this assembly will be executed,
/// i.e. use a small value to optimise for size and a large value to optimise for runtime.
/// If @a _enable is not set, will perform some simple peephole optimizations.
Assembly& optimise(bool _enable, bool _isCreation = true, size_t _runs = 200);
+
Json::Value stream(
std::ostream& _out,
std::string const& _prefix = "",
@@ -113,7 +129,7 @@ public:
protected:
/// Does the same operations as @a optimise, but should only be applied to a sub and
/// returns the replaced tags.
- std::map<u256, u256> optimiseInternal(bool _enable, bool _isCreation, size_t _runs);
+ std::map<u256, u256> optimiseInternal(OptimiserSettings _settings);
unsigned bytesRequired(unsigned subTagSize) const;