diff options
author | chriseth <c@ethdev.com> | 2017-03-03 23:17:21 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-03-03 23:51:37 +0800 |
commit | ddc4918f3602744544b42da7507fc473e522b61c (patch) | |
tree | aff58fac5cb7a9c51c5d7419e91f3e66400682b5 /libevmasm/ConstantOptimiser.cpp | |
parent | 05dac999223220fdb54c0d28781b3ef1d621061d (diff) | |
download | dexon-solidity-ddc4918f3602744544b42da7507fc473e522b61c.tar.gz dexon-solidity-ddc4918f3602744544b42da7507fc473e522b61c.tar.zst dexon-solidity-ddc4918f3602744544b42da7507fc473e522b61c.zip |
Add upper bound for computing constants.
Diffstat (limited to 'libevmasm/ConstantOptimiser.cpp')
-rw-r--r-- | libevmasm/ConstantOptimiser.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index 86244e17..a1dfd21c 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -194,7 +194,7 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value) // Is not always better, try literal and decomposition method. AssemblyItems routine{u256(_value)}; bigint bestGas = gasNeeded(routine); - for (unsigned bits = 255; bits > 8; --bits) + for (unsigned bits = 255; bits > 8 && m_maxSteps > 0; --bits) { unsigned gapDetector = unsigned(_value >> (bits - 8)) & 0x1ff; if (gapDetector != 0xff && gapDetector != 0x100) @@ -219,6 +219,8 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value) else if (lowerPart < 0) newRoutine.push_back(Instruction::SUB); + if (m_maxSteps > 0) + m_maxSteps--; bigint newGas = gasNeeded(newRoutine); if (newGas < bestGas) { |