Browse Source

Remove addtional cost param from commitCostBlock(). Count additional cost manually. [#81461534]

cl-refactor
Paweł Bylica 10 years ago
parent
commit
e3245e140b
  1. 3
      libevmjit/Compiler.cpp
  2. 7
      libevmjit/GasMeter.cpp
  3. 3
      libevmjit/GasMeter.h

3
libevmjit/Compiler.cpp

@ -773,7 +773,7 @@ void Compiler::compileBasicBlock(BasicBlock& _basicBlock, bytes const& _bytecode
auto outOff = stack.pop();
auto outSize = stack.pop();
_gasMeter.commitCostBlock(gas);
_gasMeter.commitCostBlock();
// Require memory for in and out buffers
_memory.require(outOff, outSize); // Out buffer first as we guess it will be after the in one
@ -783,6 +783,7 @@ void Compiler::compileBasicBlock(BasicBlock& _basicBlock, bytes const& _bytecode
if (inst == Instruction::CALLCODE)
receiveAddress = _runtimeManager.get(RuntimeData::Address);
_gasMeter.count(gas);
auto ret = _ext.call(gas, receiveAddress, value, inOff, inSize, outOff, outSize, codeAddress);
_gasMeter.giveBack(gas);
stack.push(ret);

7
libevmjit/GasMeter.cpp

@ -181,10 +181,8 @@ void GasMeter::giveBack(llvm::Value* _gas)
m_runtimeManager.setGas(m_builder.CreateAdd(m_runtimeManager.getGas(), _gas));
}
void GasMeter::commitCostBlock(llvm::Value* _additionalCost)
void GasMeter::commitCostBlock()
{
assert(!_additionalCost || m_checkCall); // _additionalCost => m_checkCall; Must be inside cost-block
// If any uncommited block
if (m_checkCall)
{
@ -198,9 +196,6 @@ void GasMeter::commitCostBlock(llvm::Value* _additionalCost)
m_checkCall->setArgOperand(0, Constant::get(m_blockCost)); // Update block cost in gas check call
m_checkCall = nullptr; // End cost-block
m_blockCost = 0;
if (_additionalCost)
count(_additionalCost);
}
assert(m_blockCost == 0);
}

3
libevmjit/GasMeter.h

@ -36,8 +36,7 @@ public:
void countSha3Data(llvm::Value* _dataLength);
/// Finalize cost-block by checking gas needed for the block before the block
/// @param _additionalCost adds additional cost to cost-block before commit
void commitCostBlock(llvm::Value* _additionalCost = nullptr);
void commitCostBlock();
/// Give back an amount of gas not used by a call
void giveBack(llvm::Value* _gas);

Loading…
Cancel
Save