Fabcoin Core  0.16.2
P2P Digital Currency
GasMeter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <evm.h>
4 #include "CompilerHelper.h"
5 #include "Instruction.h"
6 
7 namespace dev
8 {
9 namespace eth
10 {
11 namespace jit
12 {
13 class RuntimeManager;
14 using namespace evmjit;
15 
16 class GasMeter : public CompilerHelper // TODO: Use RuntimeHelper
17 {
18 public:
19  GasMeter(IRBuilder& _builder, RuntimeManager& _runtimeManager, evm_mode mode);
20 
22  void count(Instruction _inst);
23 
25  void count(llvm::Value* _cost, llvm::Value* _jmpBuf = nullptr, llvm::Value* _gasPtr = nullptr);
26 
28  void countSStore(class Ext& _ext, llvm::Value* _index, llvm::Value* _newValue);
29 
31  void countExp(llvm::Value* _exponent);
32 
34  void countLogData(llvm::Value* _dataLength);
35 
37  void countSha3Data(llvm::Value* _dataLength);
38 
40  void commitCostBlock();
41 
43  void giveBack(llvm::Value* _gas);
44 
46  void countMemory(llvm::Value* _additionalMemoryInWords, llvm::Value* _jmpBuf, llvm::Value* _gasPtr);
47 
49  void countCopy(llvm::Value* _copyWords);
50 
51 private:
52  int64_t getStepCost(Instruction inst) const;
53 
56  int64_t m_blockCost = 0;
57 
58  llvm::CallInst* m_checkCall = nullptr;
59  llvm::Function* m_gasCheckFunc = nullptr;
60 
62 
65 };
66 
67 }
68 }
69 }
70 
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
RuntimeManager & m_runtimeManager
Definition: GasMeter.h:61
evm_mode m_mode
EVM compatibility mode.
Definition: GasMeter.h:64
size_t count
Definition: ExecStats.cpp:37
evm_mode mode
Definition: SmartVM.cpp:47
Instruction
Virtual machine bytecode instruction.
Definition: Instruction.h:16
Base class for compiler helpers like Memory, GasMeter, etc.
Config::Value_type Value
evm_mode
EVM compatibility mode aka chain mode.
Definition: evm.h:359
llvm::IRBuilder<> IRBuilder