Fabcoin Core  0.16.2
P2P Digital Currency
RuntimeManager.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 
5 #include "CompilerHelper.h"
6 #include "Type.h"
7 #include "Instruction.h"
8 
9 namespace dev
10 {
11 namespace eth
12 {
13 namespace jit
14 {
15 using namespace evmjit;
16 
18 {
19 public:
20  RuntimeManager(IRBuilder& _builder, code_iterator _codeBegin, code_iterator _codeEnd);
21 
22  llvm::Value* getRuntimePtr();
23  llvm::Value* getDataPtr();
24  llvm::Value* getEnvPtr();
25 
26  llvm::Value* getValue();
27  llvm::Value* getGas();
28  llvm::Value* getGasPtr();
29  llvm::Value* getCallData();
30  llvm::Value* getCode();
31  llvm::Value* getCodeSize();
32  llvm::Value* getCallDataSize();
33  llvm::Value* getJmpBuf() { return m_jmpBuf; }
34  void setGas(llvm::Value* _gas);
35 
36  llvm::Value* getMem();
37 
38  void registerReturnData(llvm::Value* _index, llvm::Value* _size); // TODO: Move to Memory.
39 
40  void exit(ReturnCode _returnCode);
41 
42  void abort(llvm::Value* _jmpBuf);
43 
44  llvm::Value* getStackBase() const { return m_stackBase; }
45  llvm::Value* getStackSize() const { return m_stackSize; }
46 
47  void setJmpBuf(llvm::Value* _jmpBuf) { m_jmpBuf = _jmpBuf; }
48  void setExitBB(llvm::BasicBlock* _bb) { m_exitBB = _bb; }
49 
50  static llvm::StructType* getRuntimeType();
51  static llvm::StructType* getRuntimeDataType();
52 
53  //TODO Move to schedule
54  static const size_t stackSizeLimit = 1024;
55 
56 private:
57  llvm::Value* getPtr(RuntimeData::Index _index);
58  void set(RuntimeData::Index _index, llvm::Value* _value);
59 
60  llvm::Value* m_jmpBuf = nullptr;
61  llvm::Value* m_dataPtr = nullptr;
62  llvm::Value* m_gasPtr = nullptr;
63  llvm::Value* m_memPtr = nullptr;
64  llvm::Value* m_envPtr = nullptr;
65 
66  std::array<llvm::Value*, RuntimeData::numElements> m_dataElts;
67 
68  llvm::Value* m_stackBase = nullptr;
69  llvm::Value* m_stackSize = nullptr;
70 
71  llvm::BasicBlock* m_exitBB = nullptr;
72 
73  code_iterator m_codeBegin = {};
74  code_iterator m_codeEnd = {};
75  llvm::Value* m_codePtr = nullptr;
76 };
77 
78 }
79 }
80 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
llvm::Value * getStackSize() const
byte const * code_iterator
Definition: Common.h:11
Base class for compiler helpers like Memory, GasMeter, etc.
Config::Value_type Value
ReturnCode
Definition: JIT.h:86
void setJmpBuf(llvm::Value *_jmpBuf)
void setExitBB(llvm::BasicBlock *_bb)
std::array< llvm::Value *, RuntimeData::numElements > m_dataElts
llvm::IRBuilder<> IRBuilder
llvm::Value * getStackBase() const