From fba7e055d9fb20b3053362f0099d2fbaacfb7432 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 4 May 2018 17:18:02 +0200 Subject: Follow highest gas usage only for gas estimation. --- libevmasm/PathGasMeter.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libevmasm/PathGasMeter.h') diff --git a/libevmasm/PathGasMeter.h b/libevmasm/PathGasMeter.h index 2527d7fb..9537b176 100644 --- a/libevmasm/PathGasMeter.h +++ b/libevmasm/PathGasMeter.h @@ -58,9 +58,17 @@ public: GasMeter::GasConsumption estimateMax(size_t _startIndex, std::shared_ptr const& _state); private: + /// Adds a new path item to the queue, but only if we do not already have + /// a higher gas usage at that point. + /// This is not exact as different state might influence higher gas costs at a later + /// point in time, but it greatly reduces computational overhead. + void queue(std::unique_ptr&& _newPath); GasMeter::GasConsumption handleQueueItem(); - std::vector> m_queue; + /// Map of jumpdest -> gas path, so not really a queue. We only have one queued up + /// item per jumpdest, because of the behaviour of `queue` above. + std::map> m_queue; + std::map m_highestGasUsagePerJumpdest; std::map m_tagPositions; AssemblyItems const& m_items; solidity::EVMVersion m_evmVersion; -- cgit