mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Support shifts in gas estimator
This commit is contained in:
parent
2968639406
commit
059e232e69
@ -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)),
|
||||
|
Loading…
Reference in New Issue
Block a user