Use EVM version in gas meter and optimizer.

This commit is contained in:
chriseth
2018-03-05 11:36:33 +01:00
parent 5a54cd5c70
commit 6ec4517929
28 changed files with 328 additions and 201 deletions
+1 -1
View File
@@ -209,7 +209,7 @@ public:
void appendAuxiliaryData(bytes const& _data) { m_asm->appendAuxiliaryDataToEnd(_data); }
/// Run optimisation step.
void optimise(bool _fullOptimsation, unsigned _runs = 200) { m_asm->optimise(_fullOptimsation, true, _runs); }
void optimise(bool _fullOptimsation, unsigned _runs = 200) { m_asm->optimise(_fullOptimsation, m_evmVersion, true, _runs); }
/// @returns the runtime context if in creation mode and runtime context is set, nullptr otherwise.
CompilerContext* runtimeContext() { return m_runtimeContext; }
+2 -2
View File
@@ -1059,7 +1059,7 @@ void ContractCompiler::compileExpression(Expression const& _expression, TypePoin
CompilerUtils(m_context).convertType(*_expression.annotation().type, *_targetType);
}
eth::AssemblyPointer ContractCompiler::cloneRuntime()
eth::AssemblyPointer ContractCompiler::cloneRuntime() const
{
eth::Assembly a;
a << Instruction::CALLDATASIZE;
@@ -1070,7 +1070,7 @@ eth::AssemblyPointer ContractCompiler::cloneRuntime()
// this is the address which has to be substituted by the linker.
//@todo implement as special "marker" AssemblyItem.
a << u256("0xcafecafecafecafecafecafecafecafecafecafe");
a << u256(eth::GasCosts::callGas + 10) << Instruction::GAS << Instruction::SUB;
a << u256(eth::GasCosts::callGas(m_context.evmVersion()) + 10) << Instruction::GAS << Instruction::SUB;
a << Instruction::DELEGATECALL;
//Propagate error condition (if DELEGATECALL pushes 0 on stack).
a << Instruction::ISZERO;
+1 -1
View File
@@ -125,7 +125,7 @@ private:
void compileExpression(Expression const& _expression, TypePointer const& _targetType = TypePointer());
/// @returns the runtime assembly for clone contracts.
static eth::AssemblyPointer cloneRuntime();
eth::AssemblyPointer cloneRuntime() const;
bool const m_optimise;
/// Pointer to the runtime compiler in case this is a creation compiler.
+1 -1
View File
@@ -1756,7 +1756,7 @@ void ExpressionCompiler::appendExternalFunctionCall(
{
// send all gas except the amount needed to execute "SUB" and "CALL"
// @todo this retains too much gas for now, needs to be fine-tuned.
u256 gasNeededByCaller = eth::GasCosts::callGas + 10;
u256 gasNeededByCaller = eth::GasCosts::callGas(m_context.evmVersion()) + 10;
if (_functionType.valueSet())
gasNeededByCaller += eth::GasCosts::callValueTransferGas;
if (!existenceChecked)