aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm/ConstantOptimiser.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-04-07 02:55:46 +0800
committerchriseth <c@ethdev.com>2016-04-07 02:56:00 +0800
commitf227050c203fd0da70fcefbbecc922fd16045aa6 (patch)
tree40ad7d2e00f051368349bdfc017a0d4b455d8313 /libevmasm/ConstantOptimiser.cpp
parent193b1c940ce3e21d52e2cbdd253c1d7cb820fa06 (diff)
downloaddexon-solidity-f227050c203fd0da70fcefbbecc922fd16045aa6.tar.gz
dexon-solidity-f227050c203fd0da70fcefbbecc922fd16045aa6.tar.zst
dexon-solidity-f227050c203fd0da70fcefbbecc922fd16045aa6.zip
Make solidity independent from ethcore.
Diffstat (limited to 'libevmasm/ConstantOptimiser.cpp')
-rw-r--r--libevmasm/ConstantOptimiser.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp
index 766371b0..27f630f5 100644
--- a/libevmasm/ConstantOptimiser.cpp
+++ b/libevmasm/ConstantOptimiser.cpp
@@ -69,13 +69,12 @@ unsigned ConstantOptimisationMethod::optimiseConstants(
bigint ConstantOptimisationMethod::simpleRunGas(AssemblyItems const& _items)
{
- EVMSchedule schedule; // TODO: make relevant to context.
bigint gas = 0;
for (AssemblyItem const& item: _items)
if (item.type() == Push)
- gas += GasMeter::runGas(Instruction::PUSH1, schedule);
+ gas += GasMeter::runGas(Instruction::PUSH1);
else if (item.type() == Operation)
- gas += GasMeter::runGas(item.instruction(), schedule);
+ gas += GasMeter::runGas(item.instruction());
return gas;
}
@@ -85,11 +84,11 @@ bigint ConstantOptimisationMethod::dataGas(bytes const& _data) const
{
bigint gas;
for (auto b: _data)
- gas += b ? m_schedule.txDataNonZeroGas : m_schedule.txDataZeroGas;
+ gas += b ? GasCosts::txDataNonZeroGas : GasCosts::txDataZeroGas;
return gas;
}
else
- return m_schedule.createDataGas * dataSize();
+ return GasCosts::createDataGas * dataSize();
}
size_t ConstantOptimisationMethod::bytesRequired(AssemblyItems const& _items)
@@ -121,7 +120,7 @@ bigint LiteralMethod::gasNeeded()
return combineGas(
simpleRunGas({Instruction::PUSH1}),
// PUSHX plus data
- (m_params.isCreation ? m_schedule.txDataNonZeroGas : m_schedule.createDataGas) + dataGas(),
+ (m_params.isCreation ? GasCosts::txDataNonZeroGas : GasCosts::createDataGas) + dataGas(),
0
);
}
@@ -148,9 +147,9 @@ bigint CodeCopyMethod::gasNeeded()
{
return combineGas(
// Run gas: we ignore memory increase costs
- simpleRunGas(m_copyRoutine) + m_schedule.copyGas,
+ simpleRunGas(m_copyRoutine) + GasCosts::copyGas,
// Data gas for copy routines: Some bytes are zero, but we ignore them.
- bytesRequired(m_copyRoutine) * (m_params.isCreation ? m_schedule.txDataNonZeroGas : m_schedule.createDataGas),
+ bytesRequired(m_copyRoutine) * (m_params.isCreation ? GasCosts::txDataNonZeroGas : GasCosts::createDataGas),
// Data gas for data itself
dataGas(toBigEndian(m_value))
);
@@ -217,9 +216,9 @@ bigint ComputeMethod::gasNeeded(AssemblyItems const& _routine)
{
size_t numExps = count(_routine.begin(), _routine.end(), Instruction::EXP);
return combineGas(
- simpleRunGas(_routine) + numExps * (m_schedule.expGas + m_schedule.expByteGas),
+ simpleRunGas(_routine) + numExps * (GasCosts::expGas + GasCosts::expByteGas),
// Data gas for routine: Some bytes are zero, but we ignore them.
- bytesRequired(_routine) * (m_params.isCreation ? m_schedule.txDataNonZeroGas : m_schedule.createDataGas),
+ bytesRequired(_routine) * (m_params.isCreation ? GasCosts::txDataNonZeroGas : GasCosts::createDataGas),
0
);
}