aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-05-01 04:22:59 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-05-01 04:22:59 +0800
commit059e232e69f431baa1d9218619d860fc9f4aac0b (patch)
treee31e560405594d4adbdc89c8c2aa2566574976ec /libsolidity
parent2968639406888d97bfae70e4adf41674ac60fd83 (diff)
downloaddexon-solidity-059e232e69f431baa1d9218619d860fc9f4aac0b.tar.gz
dexon-solidity-059e232e69f431baa1d9218619d860fc9f4aac0b.tar.zst
dexon-solidity-059e232e69f431baa1d9218619d860fc9f4aac0b.zip
Support shifts in gas estimator
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/interface/GasEstimator.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp
index a496cc21..a532f86e 100644
--- a/libsolidity/interface/GasEstimator.cpp
+++ b/libsolidity/interface/GasEstimator.cpp
@@ -136,13 +136,22 @@ GasEstimator::GasConsumption GasEstimator::functionalEstimation(
ExpressionClasses& classes = state->expressionClasses();
using Id = ExpressionClasses::Id;
using Ids = vector<Id>;
- // div(calldataload(0), 1 << 224) equals to hashValue
Id hashValue = classes.find(u256(FixedHash<4>::Arith(FixedHash<4>(dev::keccak256(_signature)))));
Id calldata = classes.find(Instruction::CALLDATALOAD, Ids{classes.find(u256(0))});
- classes.forceEqual(hashValue, Instruction::DIV, Ids{
- calldata,
- classes.find(u256(1) << 224)
- });
+ if (!m_evmVersion.hasBitwiseShifting())
+ // div(calldataload(0), 1 << 224) equals to hashValue
+ classes.forceEqual(
+ hashValue,
+ Instruction::DIV,
+ Ids{calldata, classes.find(u256(1) << 224)}
+ );
+ else
+ // shr(0xe0, calldataload(0)) equals to hashValue
+ classes.forceEqual(
+ hashValue,
+ Instruction::SHR,
+ Ids{classes.find(u256(0xe0)), calldata}
+ );
// lt(calldatasize(), 4) equals to 0 (ignore the shortcut for fallback functions)
classes.forceEqual(
classes.find(u256(0)),